I am completely new to Panda3d. I want to make a cube-voxel game where you can add new/remove cubes to the existing scene. a la minecraft.
i have managed to proceed with the procedual cube example, but then a thought hit me. maybe it will be much better to use a model of a cube, instead of generating a procedural one for my purposes.
when i first started out, i thought maybe it will be better to use procedural approach. maybe merging vertices and joining blocks will be easier.
now I am not so sure.
Can you tell me which approach is better?
can i take say, 6 egg models of a cube and merge them to make a larger cuboid which has only 4 vertices/6 faces?
my code is here, if anyone wants to take a look at it;
rishav-sharan.blogspot.com/2011/ … y-map.html
If you don’t want to modify your cube geometry wise then a model will do just fine and you just create multi instances of it (see http://www.panda3d.org/manual/index.php/Instancing)
else you could of course take the procedural approach but it has a steeper learning curve.
It’s up to you and what you actually want to do with those cubes.
You can also modify existing geometry from a model but I don’t think that would fair well with the instancing approach.
so, I have done both. weirdly, i am getting lower framerate on using the egg model for the same number of cubes.
Mainly, I want to ask if merginng cubes, culling faces, setting cube colors is easier in either appraoch. any ideas?
I find it easier to use a loaded model than constantly generating geometry.
In order to merge vertices successfully with many loaded models you have to parent all of the models to a common root and then do:
If you are using only generated geometry the first call is not needed, flattenStrong() alone is sufficient.
That should account for any difference in performance between the two approaches.
Hi drwr, can you elaborate a bit more?
what gains will I have on using the model over using a procedural cube?
Also, can i put on textures, normal mapping etc on a procedural cube?
There aren’t any performance gains. It’s just a question of which interface you prefer. If you’re really only talking about cubes, it probably doesn’t matter much at all. But using loaded models allows you more freedom to use an artist tool like Maya or Blender to construct more elaborate shapes in place of cubes, should you eventually go that route. Also, I personally find it easier to call loader.loadModel() than to make the dozen calls required to construct a cube by hand.
You can do anything with either approach. Of course the low-level egg loader is built on top of the procedural functions to construct geometry.
from what i tried, i was getting a tiny bit better performance from the procedural cube approach.
but the using the model is much easier.
Be sure to make the clearModelNodes() and flattenStrong() calls I showed above. These are very important for performance when you are assembling many small models together.
i have done that.
my fps have gone up from 45 to 350+.