3D Playground

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

3D Playground

Post by paul doe »

This is sitting in my repo for a while now, it might be useful to someone:

fb-3d-playground

It's nothing fancy, just the (little) revised code found in another thread, written in a tutorial-like manner. The controls for the demo are detailed in the readme.md file. The complete discussion can be found here: 3D without OpenGL.

It is little more than a playground, and serves mainly to illustrate different coordinate systems and how they relate to each other. It can also be used as a sort of debug-mode for computational geometry algorithms and stuff like that. Perhaps I'll refactor it someday, to really make it usable for anybody as a base for a 3D engine.

Mighty impressive screenshot:
Image

=D
BasicCoder2
Posts: 3906
Joined: Jan 01, 2009 7:03
Location: Australia

Re: 3D Playground

Post by BasicCoder2 »

Failed to compile,

Command executed:
"C:\FreeBasic\fbc.exe" "E:\fb-3d-playground-master\fb-3d-playground.bas"

Compiler output:
C:\FreeBasic\bin\win32\ld.exe: reopening E:\fb-3d-playground-master\fb-3d-playground.exe: Permission denied
C:\FreeBasic\bin\win32\ld.exe: final link failed: Permission denied

Results:
Compilation failed

System:
FBIde: 0.4.6
fbc: FreeBASIC Compiler - Version 1.05.0 (01-31-2016), built for win32 (32bit)
OS: Windows NT 6.2 (build 9200)
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: 3D Playground

Post by lizard »

Works here on Mint with ~440 fps.
Haubitze
Posts: 44
Joined: May 20, 2016 8:42

Re: 3D Playground

Post by Haubitze »

nice work paul doe,

i used it for an galaxy generator with MST building, the building of the MST takes a while.

http://users.freebasic-portal.de/haubitze/3DGame.7z
Image
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: 3D Playground

Post by lizard »

Haubitze wrote:nice work paul doe,
i used it for an galaxy generator with MST building, the building of the MST takes a while.
Works here on Mint 32 bit, too.

Only very little changes needed:

Code: Select all

#include Once "Inc\sGUI\sGUI.bas"
#include once "Inc\sGUI\ScrollBar.bas"
The "I" in "inc" must be uppercase for linux. :-)
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: 3D Playground

Post by paul doe »

BasicCoder2 wrote:Failed to compile, <snip>
BC2, that seems like an error generated by your IDE. I get similar results when FbEdit can't delete the temporary instance from a previous QuickRun. Works fine here, tested it before publishing the link ;)
lizard wrote:Works here on Mint with ~440 fps.
Cool! I need to get a new box. I get 80 fps here =D
Haubitze wrote:nice work paul doe,

i used it for an galaxy generator with MST building, the building of the MST takes a while.
Thanks. Wow, that was a fast response =D

May I suggest that you remove the paper plane, the floor and the axes? They just get in the way of an otherwise beautiful demo =D

Code: Select all

#Include once "fbgfx.bi"
#include Once "Inc\sGUI\sGUI.bas"
#include once "Inc\sGUI\ScrollBar.bas"
Using FB
using sGUI
#Include Once "3dsloader.bas"
#Include once "platform.bi" '' platform specific definitions
#include once "core.bi" '' core functions and defines
#include once "math.bi" '' math functions and constants
#include once "vec4.bi" '' vec4 type and operations
#include once "mat4.bi" '' mat4 type and operations
#include once "arrayList.bi" '' convenience

#include once "camera.bas" '' the camera class definition
#include once "object.bas" '' the object definition
#include once "utility.bi" '' to draw lines an' stuff directly in 3D space
#Include Once "3DGame.bi"
/'
   3D playground

   intended as a simple tutorial/framework to do 3D stuff without too much complication
   it is a bare-bones implementation, actually. Mostly to test all the math/conventions
   behind the representation of a 3D scene (using the term 'scene' veeeery loosely here)

   conventions used
      RIGHT HANDED coordinate system
      positive rotations are COUNTER-CLOCKWISE
      facets are defined in COUNTER-CLOCKWISE order
      angles are in RADIANS - use radians( angle_in_degrees ) for convenience
'/
'' set a screen mode

function getCpuTick() as double
	dim as double ticks
	asm
		lea edi,[ticks]
		rdtsc
		mov [edi],eax
		mov [edi+4],edx
		fild qword ptr [edi]
		fstp qword ptr [edi]
	end asm
	return ticks
end Function
const as integer scrW = 1024, scrH = 600
screenRes( scrW, scrH, 32,2 , GFX_ALPHA_PRIMITIVES )

windowTitle( fbVersion & " - 3D Playground" )
InitGFX


/'
   define a projection plane (in this case the screen itself)

   the projection plane is where the image gets projected (duh)
   in the pinhole camera model, the projection plane is actually the
   so called 'near' plane. The near parameter of the camera is really
   the distance of this plane to the origin of coordinates (in the
   case of the camera, its position in the world coordinate system
'/
dim as rectangle projectionPlane = ( 0.0, 0.0, scrW, scrH )

/'
   instantiate a camera class
   remember the parameters for the constructor:

   position, in WORLD space
   X axis of the camera's coordinate system
   Y axis of the camera's coordinate system
   Z axis of the camera's coordinate system. If you flip it, you will end with a
      left-handed coordinate system. Not that it matters much, save for the fact that
      all other methods treat the matrix as a right-handed one. If you use lookAt()
      and suddenly the axes get flipped, this is the most probable reason
   near clipping plane Z distance
   far clipping plane Z distance
   projection plane

   a word of advice: the axes of the camera have to be of a certain length, for the
   projection matrix depends on it. See the code below, where the U and V vectors
   get scaled to match the relation of the projection plane. If you fool around with
   them and suddenly the image looks like crap, this is the most probable reason.

   to remember:
      the U vector (the X one) controls the horizontal field of view
      the V vector (the Y one) controls the vertical field of view
      and the Z vector controls the zoom

      of course, they must be perfectly perpendicular to each other, if not the resulting
      image is sheared. Anyway, you don't have to mess with the constructor if you don't
      like and/or understand what it does for the camera to do its job.

   having said all that, play around! See how each function transforms the camera, and
   the effect it has on the image. Look at the implementation to see how it's done, but
   most important of all, have fun!
'/
dim as cameras cam = cameras( _
vec4( 0.0, 0.0, 3.0 ), _
vec4( 1.0, 0.0, 0.0 ), _
vec4( 0.0, 1.0, 0.0 ), _
vec4( 0.0, 0.0, -1.0 ), _
0.1, 10000.0, projectionPlane )

/'
   scene manager (yeah right)

   here, it's just a list that contains the objects to be rendered, but in real code it
   is an instance of the scene manager.
'/
dim as arrayList objects

/'
   let's create some objects, shall we? One, actually (yeah I'm cheap)

   these are the vertices and edges to define a small paper plane that
   you can manipulate (see the code in the main loop)
   the objects ideally should be loaded from a file, but that will
   complicate the implementation. If there's some interest, I will show
   how you can load an obj file (or invent your own format if you wish)
'/
dim as object3d ptr obj = new object3d() '' it will be at the origin, at the start

obj->vertices->add( new vec4( -0.1, 0.0, 0.0 ) )
obj->vertices->add( new vec4(  0.1, 0.0, 0.0 ) )
obj->vertices->add( new vec4(  0.0, 0.0, 0.3 ) )

obj->vertices->add( new vec4(  0.0,  0.0, 0.0 ) )
obj->vertices->add( new vec4(  0.0, -0.1, 0.0 ) )
obj->vertices->add( new vec4(  0.0,  0.0, 0.3 ) )

obj->edges->add( new edge( obj->vertices->get( 0 ), obj->vertices->get( 1 ) ) )
obj->edges->add( new edge( obj->vertices->get( 1 ), obj->vertices->get( 2 ) ) )
obj->edges->add( new edge( obj->vertices->get( 2 ), obj->vertices->get( 0 ) ) )

obj->edges->add( new edge( obj->vertices->get( 3 ), obj->vertices->get( 4 ) ) )
obj->edges->add( new edge( obj->vertices->get( 4 ), obj->vertices->get( 5 ) ) )
obj->edges->add( new edge( obj->vertices->get( 5 ), obj->vertices->get( 3 ) ) )

'' add the defined object to the scene
objects.add( obj )

'' move it a little so it doesn't lie exactly in the center of the world
obj->move( vec4( 1.0, 0.0, -1.0 ) )

'' some variables used for interaction
dim as integer mouseX, mouseY, mouseButton
dim as integer oldMouseX, oldMouseY

'' to make movement (somewhat) constant
dim as double frameTime

'' background color (change it if you don't like it)
dim as uint32 backgroundColor = rgba( 8, 8, 32, 255 )
color( , backgroundColor )





/'----------------------------------------------------------------------------'/
/'                      Test Main for the 3ds-bin lib                         '/
/'----------------------------------------------------------------------------'/

Dim As String filen="test.3ds"
bin3ds=FreeFile

If Open(filen For Binary Access Read As bin3ds) Then End

#Ifdef __DEBUG__
print"Loading 3ds binary file : ";filen
#EndIf
While (ReadPrimaryChunk()=0)
	Print current_chunk,temp_name
Wend
Close #bin3ds
/'----------------------------------------------------------------------------'/


Dim line_pattern(0 To 15) As UShort={&b0000000011111111,&b0000000111111110,&b0000001111111100,&b0000011111111000,&b0000111111110000,&b0001111111100000,&b0011111111000000,&b0111111110000000,&b1111111100000000,&b1111111000000001,&b1111110000000011,&b1111100000000111,&b1111000000001111,&b1110000000011111,&b1100000000111111,&b1000000001111111}

generate_galaxy(GetScrollBarVal(ScrollSpiralArms), GetScrollBarVal(ScrollSpiralK)/10.0, GetScrollBarVal(ScrollSpiralP)/10.0)
Dim target As vec4 Ptr=galaxy->vertices->Get(0)
'' (extremely crappy) main loop
do




	'' grab an object to have fun
	'dim as object3d ptr o = objects.get( 0 )

	'' update interaction
	oldMouseX = mouseX
	oldMouseY = mouseY

	getMouse( mouseX, mouseY, , mouseButton )

	/'
      camera controls

      click and draw the mouse to free look
      w: forward
      s: backward
      a: strafe left
      d: strafe right
      q: up
      e: down
      space: look at the paper plane (hold to keep looking at it)

      you see, they are very similar to that of a FPS
   '/
	if( multikey( fb.sc_e ) ) then
		'' down
		cam.move( -vec4( 0.0, 1.0, 0.0 ) * 10.0 * frameTime )
	end if

	if( multikey( fb.sc_q ) ) then
		'' up
		cam.move( vec4( 0.0, 1.0, 0.0 ) * 10.0 * frameTime )
	end if

	if( multikey( fb.sc_w ) ) then
		'' forward
		cam.move( normalize( cam.getDir() ) * 10.0 * frameTime )
	end if

	if( multikey( fb.sc_s ) ) then
		'' backwards
		cam.move( normalize( -cam.getDir() ) * 10.0 * frameTime )
	end if

	if( multikey( fb.sc_a ) ) then
		'' left
		cam.move( normalize( cam.getU() ) * 10.0 * frameTime )
	end if

	if( multikey( fb.sc_d ) ) then
		'' right
		cam.move( normalize( -cam.getU() ) * 10.0 * frameTime )
	end if

	if( multikey( fb.sc_space ) ) then
		'' look at the object (in case we lost it)
		cam.lookAt( vec4( 0.0, 0.0, 0.0 ) )
	end if
	'/'
  '    paper plane controls

  '       i: forward
  '       k: backwards
  '       j: turn left
  '       l: turn right
  '       u: turn up
  '       o: turn down
  ' '/
	'if( multikey( fb.sc_u ) ) then
	'	o->rotate( normalize( o->getU() ), radians( 0.5 ) )
	'end if

	'if( multikey( fb.sc_o ) ) then
	'	o->rotate( normalize( o->getU() ), radians( -0.5 ) )
	'end if

	'if( multikey( fb.sc_i ) ) then
	'	o->move( normalize( o->getDir() ) * 10.0 * frameTime )
	'end if

	'if( multikey( fb.sc_k ) ) then
	'	o->move( normalize( -( o->getDir() ) ) * 10.0 * frameTime )
	'end if

	'if( multikey( fb.sc_j ) ) then
	'	o->rotate( normalize( o->getV() ), radians( 0.5 ) )
	'end if

	'if( multikey( fb.sc_l ) ) then
	'	o->rotate( normalize( o->getV() ), radians( -0.5 ) )
	'end if

	'' if the left mouse button is pressed, activate free look mode
	'If( mouseButton = 1 ) then
	'	cam.rotate( vec4( 0.0, 1.0, 0.0 ), 5.0 * ( oldMouseX - mouseX ) / cam.projectionPlane.width )
	'	cam.rotate( cam.getU, -5.0 * ( oldMouseY - mouseY ) / cam.projectionPlane.height )
	'End if


	cam.lookAt(vec4(target->x,target->y,target->z),vec4(0,1,0))
	Dim cpos As vec4=cam.getPos()
	Dim cdist As double=distance3d(target->x,target->y,target->z,cpos.x,cpos.y,cpos.z)
	If (cdist>0.1) Then
		cam.move(normalize( cam.getDir() ) * 1.0 * frameTime)
	Else
		target=galaxy->vertices->Get(Int(Rnd*galaxy->vertices->count))
	EndIf

	'' render the screen
	frameTime = timer()*1
	screenLock()

	'cls()
	Line(0,0)-(1024,800),backgroundColor,BF
	'' draw the floor to have a frame of reference
	'for zz as integer = -10 to 10 step 1
	'	drawLine3d(   cam, vec4( -10, 0, zz ), vec4( 10, 0, zz ), rgba( 32, 32, 32, 64 ) )
	'next

	'for xx as integer = -10 to 10 step 1
	'	drawLine3d( cam, vec4( xx, 0, -10 ), vec4( xx, 0, 10 ), rgba( 32, 32, 32, 64 ) )
	'next

	/'
         draw the absolute axes of the world

         x = red
         y = green
         z = blue
      '/
	'drawLine3d( cam, vec4( 0.0, 0.0, 0.0 ), vec4( 3.0, 0.0, 0.0 ), rgba( 128, 0, 0, 255 ) )
	'drawLine3d( cam, vec4( 0.0, 0.0, 0.0 ), vec4( 0.0, 3.0, 0.0 ), rgba( 0, 128, 0, 255 ) )
	'drawLine3d( cam, vec4( 0.0, 0.0, 0.0 ), vec4( 0.0, 0.0, 3.0 ), rgba( 0, 0, 128, 255 ) )
	'' renders the objects
	'for i as integer = 0 to objects.count - 1
	'	dim as object3d ptr o

	'	o = objects.get( i )
	'	'' render the edges
	'	for j as integer = 0 to o->edges->count - 1
	'		dim as edge ptr e = o->edges->get( j )

	'		drawLine3d( cam, o->objectSpaceToWorldSpace( *e->vertex1 ), o->objectSpaceToWorldSpace( *e->vertex2 ), rgba( 255, 255, 0, 255 ) )
	'	next
	'next


	' render the edges
	Dim As UInteger cols(0 To 1)={&h336666ff,&h33ff6666}
	dim as edge ptr e = galaxy->edges->get( 0 )
	for j as integer = 0 to galaxy->edges->count - 1
		e = galaxy->edges->Get( j )
		Dim dist1 As Double=distance3d(0,0,0,e->vertex1->x,e->vertex1->y,e->vertex1->z)
		Dim dist2 As Double=distance3d(0,0,0,e->vertex2->x,e->vertex2->y,e->vertex2->z)
		Dim As UInteger col_s1=cols(Int(density(map(dist1,0,50,-4,4))+0.75))
		Dim As UInteger col_s2=cols(Int(density(map(dist2,0,50,-4,4))+0.75))
		'Print col_s2,Int(density(map(dist2,0,50,-4,4))+0.5),density(map(dist2,0,50,-4,4))+0.5
		'			drawPoint3d(cam,galaxy->objectSpaceToWorldSpace( *e->vertex1 ),10,&h336666ff)

		If e->vertex1->x=0 And e->vertex1->y=0 And e->vertex1->z=0 then
			drawPoint3d(cam,galaxy->objectSpaceToWorldSpace( *e->vertex1 ),10,&hffff0000)
			drawPoint3d(cam,galaxy->objectSpaceToWorldSpace( *e->vertex2 ),10,col_s2)
			drawLine3d( cam, galaxy->objectSpaceToWorldSpace( *e->vertex1 ), galaxy->objectSpaceToWorldSpace( *e->vertex2 ), rgba( 255, 00, 00, 255 ),line_pattern(Int((Timer*10.0))Mod 16) )
		Else
			drawPoint3d(cam,galaxy->objectSpaceToWorldSpace( *e->vertex1 ),10,col_s1)
			drawPoint3d(cam,galaxy->objectSpaceToWorldSpace( *e->vertex2 ),10,col_s2)
			drawLine3d( cam, galaxy->objectSpaceToWorldSpace( *e->vertex1 ), galaxy->objectSpaceToWorldSpace( *e->vertex2 ), rgba( 64, 64, 255, 64 ) ,line_pattern(Int((Timer*10.0))Mod 16))
		endif
	next
	'	drawPoint3d(cam,galaxy->objectSpaceToWorldSpace( *e->vertex2 ),10,&h336666ff)

	'GadgetOn(ScrollBulgeSize)
	'GadgetOn(ScrollBulgeOffset)
	'GadgetOn(ScrollSpiralK)
	'GadgetOn(ScrollSpiralP)
	'GadgetOn(ScrollSpiralArms)
	'Draw String (220,104),Str(GetScrollBarVal(ScrollBulgeSize)),&hffffffff
	'Draw String (220,124),Str(GetScrollBarVal(ScrollBulgeOffset)),&hffffffff
	'Draw String (220,144),Str(GetScrollBarVal(ScrollSpiralK)),&hffffffff
	'Draw String (220,164),Str(GetScrollBarVal(ScrollSpiralP)),&hffffffff
	'Draw String (220,184),Str(GetScrollBarVal(ScrollSpiralArms)),&hffffffff
	event->xSleep(0)
	if event->GADGETMESSAGE then
		'    select case event->GADGETMESSAGE
		'      case Scroll
		'        print "Scrollbereich:" & minimum & "-" & maximum & " @ Pagesize " & pagesize & ": " & GetScrollBarVal(Scroll)
		'    end select
	end if

	screenUnlock()
	ScreenSync
	/'
      it's important not to let this var to be negative, as it gets multiplied with
      the camera vectors and could screw some calculations (movement, for example)
      told you, the loop implementation is very crappy, but it seems like this is
      esier for most people to grasp
   '/
	frameTime = abs( timer() - frameTime )
	sleep( 16 )
loop until multikey( fb.sc_escape ) '' loop until esc is pressed

'' finally, if there's objects in the list, free them
if( objects.count > 0 ) then
	dim as object3d ptr o

	for i as integer = 0 to objects.count - 1
		o = objects.get( i )
		delete( o )
	next
end if
Well done!
lizard
Posts: 440
Joined: Oct 17, 2017 11:35
Location: Germany

Re: 3D Playground

Post by lizard »

paul doe wrote:Cool! I need to get a new box. I get 80 fps here =D[
This box is a 3 GHz double core with 4 GB Ram and onboard graphics, not the newest. :-)
Haubitze
Posts: 44
Joined: May 20, 2016 8:42

Re: 3D Playground

Post by Haubitze »

Hello Paul Doe,

i have a question about camera position. i need to turn a camera around a point. so i can "orbit" him.
in BlitzBasic3D i think i use lookat and move. but i cant build it in your engine.

can you explain how i can orbit an point with a given distance with an camera?

thanks for this nice work :)

salute

PS: i refactor my demo, the MST is build one or two bits faster. also i have an preview of the generated galaxy in realtime
(sGUI is used to get the parameters). but i will make it look nice this is why i ask about the orbiting thing.
also i plan an a* pathfinder so you travel from one point to another between the connections shown on the sceen.
Haubitze
Posts: 44
Joined: May 20, 2016 8:42

Re: 3D Playground

Post by Haubitze »

Here a little update on my Demo, i think the MST is build a bit faster. i also have adjust the colors a bit.
but my A* algo do not the work i sugested :(

eventualy anyone can tell me what i make wrong. but i have to say the code isnt commented an its not clean to this time.
my first thinking was that my heuristic function was the error but now i think it is how i build the node-graph.

anywai, pls take a look and send me an report how it runs.

the link is the sam as above but here is it again. http://users.freebasic-portal.de/haubitze/3DGame.7z
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: 3D Playground

Post by badidea »

Haubitze wrote:... anywai, pls take a look and send me an report how it runs ...
Compiles on linux when I replace inc with Inc on line 2 and 3.
But with -w all -exx compile option i get:
Aborting due to runtime error 1 (illegal function call) at line 124 of /home/badidea/Downloads/FreeBASIC/3DGame/Inc/sGUI/ScrollBar_Basis.bas::DRAWSB()
With a normal compile, it seems to run smooth, but I don't see any FPS.
Also, the keys (e,q,w,a,d,s) don't seem to do much,
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: 3D Playground

Post by paul doe »

Haubitze wrote:Hello Paul Doe,

i have a question about camera position. i need to turn a camera around a point. so i can "orbit" him.
in BlitzBasic3D i think i use lookat and move. but i cant build it in your engine.

can you explain how i can orbit an point with a given distance with an camera?

thanks for this nice work :)
Owww sorry mate! Didn't see this post before (I wasn't really looking, though =D)

You can do the same here, but you get 'drifting' due to the crappy precision of the singles and the fact that the code uses in-place array modification and does not perform any kind of orthonormalization every once and then, so distances tend to drift and axes tend to become skewed. A better approach is simply to load the identity vectors and construct the matrices again from scratch (like the old OpenGL fixed-function pipeline did, if you programmed it back in the days).

Or, you can compute and apply the transformation matrix yourself. Remember it was:
  • Translate the object you want to rotate to the position you want to orbit around.
  • Perform the rotation around the axis you want.
  • And then translate back in that direction.
I think I have a better version of this crap lying around, but couldn't find it for the life of me. If there's some interest, I shall rework this little demo (it was coded in a real hurry, and it shows) into something a little more manageable and useful, with a scene manager too (complete with frustum culling) so it can really be used as a base for some more advanced. I don't know, I've been pretty busy with other things recently, sorry =D
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: 3D Playground

Post by paul doe »

Haubitze wrote:Here a little update on my Demo, i think the MST is build a bit faster. i also have adjust the colors a bit.
but my A* algo do not the work i sugested :(

eventualy anyone can tell me what i make wrong. but i have to say the code isnt commented an its not clean to this time.
my first thinking was that my heuristic function was the error but now i think it is how i build the node-graph.

anywai, pls take a look and send me an report how it runs.
I have something on that that you can use. Hang on, I'll prepare a little code you can study. Do you prefer plain A*, or something more like a Vector Field Pathfinding? Which one could be more useful to you? There are some implementations of A* here in the forum, but I hadn't seen one for Vector Fields, so I suppose it would be this one =D

About how it runs: runs nice... for a while, then crashed. Badidea above provided a nice debug info about where to look first.
badidea wrote:Also, the keys (e,q,w,a,d,s) don't seem to do much,
They don't. They're a hangover from old code =D
Haubitze
Posts: 44
Joined: May 20, 2016 8:42

Re: 3D Playground

Post by Haubitze »

hey badidea and Paul Doe, thanks for testing. in the next demo i will show an FPS counter.

for the A* i think an Plain A* where enoug for me. if i create hundreds of ships and they are all searching for an path to another target
then i think Vector Field Pathfinding is a bit to much.

the rotation problem is solved and i think i implement it how you say Paul.

the sGUI problem i will look at it if i cant solve it i have to speak to Muttonhead.
i also will take a look why it crash after a time.

so far so good ;)

Edit: so now i think the crash is gone, it was my fault i updated the targets for the flying but dont generate it.
i also delete all the old stuff in the file so you dont get confused.
the sGUI error badidea becomes with "-w all -exx" i cant reproduce. im on win10 with fbc 1.05.0 32bit.
the project are also updated, see link above.
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: 3D Playground

Post by paul doe »

Haubitze wrote:for the A* i think an Plain A* where enoug for me. if i create hundreds of ships and they are all searching for an path to another target
then i think Vector Field Pathfinding is a bit to much.
Quite on the contrary. It was developed precisely to allow hundreds of units to do pathing all at once. It's simple to implement, and extremely efficient. I'll see if I can show you an implementation soon.
Haubitze wrote:the rotation problem is solved and i think i implement it how you say Paul.
Glad to hear it. Or, it dawned on me that you can also implement it as a positional and rotational constraint (been doing some physics code =D).
Haubitze wrote:Edit: so now i think the crash is gone, it was my fault i updated the targets for the flying but dont generate it.
i also delete all the old stuff in the file so you dont get confused.
the sGUI error badidea becomes with "-w all -exx" i cant reproduce. im on win10 with fbc 1.05.0 32bit.
the project are also updated, see link above.
Very well, I shall test it and report back.
Haubitze
Posts: 44
Joined: May 20, 2016 8:42

Re: 3D Playground

Post by Haubitze »

He everyone,

now i generate solarsystems using this resource http://sol.trisen.com/downloads/wg.pdf.
if i get in to an sector i try to render the system. but all is to far away (so it is to small to see it).
it uses for Stars this measurements

Code: Select all

star size = x*SOLSIZE
star seperation = x*AU
for the planets it measures

Code: Select all

planet size = x*KM
planet orbit = x*AU
for moons it is

Code: Select all

moon size = x*KM
moon orbit = x*parrent planet size
i have scale down the SOLSIZE and AU by a factor of 1000 so it becomes

Code: Select all

SOLSIZE = 696 ' mean is 696000 KM
AU = 149600 ' mean is 149600000 KM
but it dos not help to get a good result.
if anyone have an idea how to scale it down to get a good result i will be happy.
or if anyone have an idea how to render it to see the details of the system without destroy the informations behind it i also will be happy.

the project lays always here: http://users.freebasic-portal.de/haubitze/3DGame.7z

salute

PS.: also the pathfinding has spartialy gone and the source is unclean again.
the systemgenerator is from another project form me. so it will not use the paul doe's arrayList.
PPS.: an request to paul doe, for an object i think an z sorted drawing where an nice feature ;)
Post Reply