Basic usage of multiple similar objects

Started by menion, May 20, 2015, 09:38:58 AM

Previous topic - Next topic

menion

Hello guys,

Question (example): imagine Earth (sphere) and 20-50 satellites around. Every second, number (I define which sats are visible at the moment), position (they are moving) and color (color define strength of signal) of satellites change.

May you forward me to any sample application or existing topic (I was searching a lot and I'm unable to find it), where I may read some similar technique how to handle this task.

Because I do not know if I should pre-create all sats at begin (there should be up to 100 objects, maybe more) and before every draw remove or add sats to world, define it's parameters and then call "draw", or if I may use just one satellite (I'm unable to find method to do this) and then just in cycle change it's parameters and call "draw" on it. Etc etc. Too much options.

Also because lib is closed source, it is not clear for me, if I may change color of Object3D "setAdditionalColor" even after "build" was called.

Thank you for you time!

EgonOlsen

You can set an additional color at any time. build() basically locks the mesh, but not colors, transformations or texturing information. What you can't do it to render one object multiple times unless you are rendering the scene itself multiple times in the same buffer with modified transformations...that would be possible, but I've never actually seen that somebody did it that way.
If your satellites are based on one or a limited set of models, the best way would be load them as a kind of blue prints and for each actual object on screen do something like at application startup like so:


Object3D clone=new Object3D(bluePrint, true);
clone.shareCompiledMesh(bluePrint);
clone.build();

menion

Thank you Egon, you gave me very nice answer on most of questions!!

One last if I can.

I can imagine this, like creating required objects (satellites) on-the-fly as copy of a single object (shared mesh). Isn't a big performance problem to add or remove a lot of them from the "world" instance before a draw? Or is there a faster method how to temporary disable rendering of certain object, like object3D.setVisible(true/false)?


menion

Ah, I completely missed this.

Thank you Egon, really appreciate your help!