3D Begginner Help?

Blitz3D Forums/Blitz3D Beginners Area/3D Begginner Help?

ChaseHatesEggs(Posted 2015) [#1]
Trying to make these cubes move in random directions but I can't get it to work.
What am I doing wrong?
Any 3D tips?



Floyd(Posted 2015) [#2]
There are many issues, but the most important one is
For a=0 To 999
 ; generate some random values
 CUBE=CreateCube() 
 ; update position and color
Next
This creates 1000 cubes, remembers the last one and forgets the other 999.

You need an array to hold the CreateCube values so you can use them later.

It is far more efficient to create one cube and use CopyEntity to make the others.

Position and movement values should probably be float rather than integer unless you are deliberately restricting to grid points.

Finally, those two dimensional arrays are pointless albeit harmless. Since you are always using them as array( something, 1 ) they could just as easily be one dimensional: array( something ).


ChaseHatesEggs(Posted 2015) [#3]
@Floyd How would I make the Array store the CreateCube Values? I tried but keep having trouble.


Floyd(Posted 2015) [#4]
originalCube = CreateCube()
HideEntity originalCube

Dim CUBE(999)
For n = 0 To 999
	; do stuff
	CUBE(n) = CopyEntity( originalCube )
	; do more stuff
Next

You could create CUBE(0) as the original and make 999 copies. But typically you use the style I have shown, so all 1000 entities CUBE(0) to CUBE(999) get handled the same way.


RemiD(Posted 2015) [#5]
to make it less confusing you can also do :
;create a cube of 1x1x1unit
cubexmesh = createcube()
scalemesh(cubexmesh,1.0/2,1.0/2,1.0/2)
hideentity(cubexmesh)

;an array of 1001 slots but we will only use the slots from 1 to 1000
dim cube(1000)

for i% = 1 to 1000 step 1
 cube(i) = copyentity(cubexmesh)
 positionentity(cube(i),-0.5+i,0,0)
next