an easier way to create a large group of spheres?

Blitz3D Forums/Blitz3D Programming/an easier way to create a large group of spheres?

Captain Wicker (crazy hillbilly)(Posted 2012) [#1]
Hello,

Is there any other possible way to create a group of spheres besides creating a million spheres?? Anything besides a For/Next statement? I can't think of any, Can a get some assistance over here?



Thanks in Advance. :)


Yasha(Posted 2012) [#2]
any other possible way to create a group of spheres besides creating a million spheres?


By creating a billion spheres! MUAHAHAHAHAHAAAA!

...can you rephrase the question? It's not really obvious what you mean.


Kryzon(Posted 2012) [#3]
I think he meant if is there's a way to create a group of spheres without linearly going through a For/Next loop creating each one individually.

Answer: No.

Computers work in a linear fashion. Each action needs a preceding instruction. The amount of actions (1 mil spheres) dictates how many instructions you'll need.


Matty(Posted 2012) [#4]
Yes - you could create them in your modelling program and then simply load them in in a single command....

Ie create model with 1 million spheres in your favourite 3d package...export as a b3d...and use "loadanimmesh"

Last edited 2012


Blitzplotter(Posted 2012) [#5]
Ie create model with 1 million spheres in your favourite 3d package...export as a b3d...and use "loadanimmesh"


Nice solution - the loadanimmesh cmd - I need to play with this a little more....


Kryzon(Posted 2012) [#6]
It's not really a solution. You're just hiding the low-level work. EDIT: It is one step closer to the goal, but it's still far away.

Besides, it'll take much, much longer because of the added HD i/o.

The B3D file loader will still go through a loop processing each entity in the file (i.e the 1 mi spheres), loading 1 sphere at a time.

Last edited 2012


MusicianKool(Posted 2012) [#7]
multi threading?


Yasha(Posted 2012) [#8]
multi threading?


Graphics engines really don't like multi-threading, in general.

You can load data from files and process it in your own code beforehand using as many threads as you want, but it has to all be loaded into DirectX in the main thread.

Don't know why, and don't know if this is still true for newer DirectX versions.


Matty(Posted 2012) [#9]
If you don't want to use a for-next statement as mentioned above you can also do it this way:

type mysphere

field ent

end type

function createsphererecursive(numbertocreate)
numbertocreate = numbertocreate - 1
if numbertocreate <= 0 then return 

sphere.mysphere = new mysphere
sphere\ent = createsphere(8)
createsphererecursive(numbertocreate-1)
	
end function 



Axel Wheeler(Posted 2012) [#10]
Sorry to bump, but the OP may really be looking for a way to make shallow copies of the sphere without all the overhead of a separate identical mesh for each.

If so, the CopyEntity command is your answer. It creates a "shallow copy" of the mesh and the resulting copies are vastly more efficient (on cpu) to work with. In general you can run Entity commands on them separately (each one can have it's own position, color, scale, etc.)

Just don't run a Mesh command on one or it will affect all of them.


Rob the Great(Posted 2012) [#11]
I laugh every time I see Yasha's post at the top. Not related to the problem, I just figured I would share that.


Ching(Posted 2012) [#12]
I laugh when I see Matty's solution, a recursive solution to a simple linear problem. Matty take a break from Uni! lol.