I have a 3D matrix which represent a 3D discret object : 0 to 255, 0 = no material, 1 to 255 the color of the voxel.
I wish draw my object with triangles, two triangles by faces on the border of my objet.
With Jogl, I use one of this two solutions for drawing my object :
I represent every visible voxel with au GlutSolidCube and I give it the color of the voxel. I put the family of cube in a display list and I display the list.
I draw only the exterior faces of the voxel. Every face is represent by two triangles that I put this mesh of triangles in a display list. The color of the triangle is the value of the voxel (1 to 255).
Questions :
How can I create this mesh of triangle with JME ?
Someone could give me an example for create a simple cube (with face of differents colors) with JME and display it ?
In jME, most of the "tutorials" really consists of the test classes in the source packages under jmetest. You'll find TestSharedMesh there.
FiReTiTi said:
What is the advantage to use SharedMesh vs TriMesh ?
It draws multiple instances of the same geometry data in one single draw call, eliminating render pass switching between drawing of the instances. So it can be faster to draw. It also requires less memory than multiple distinct TriMeshes. For more details, look at the SharedMesh javadoc.
just a random thought... but is a scenegraph really a good foundation for a voxel engine?
I think it will be better than my JOGL voxel engine.
I must build two display lists for my biggest 3D objects :
- the first for the scene moves (translation and rotaion), qui display every voxel like a GL_POINTS (no 3D display => fast display)
- the second when the mousse button is not pressed which display the object with triangles for 3D display.
I guess I would just recommend either locking as much as possible or combining cubes into larger meshes. Updating bounds, world vectors and so forth on a ton of small objects every frame will be hard on the cpu… (not to mention the costs of individually shuttling hundreds of thousands of small data chunks to the card.)
You might consider doing most of the work of creating and managing your voxel cubes in a shader.
Actualy in my voxel engine, I did three tests of display for a same discret object
Display with a TriMesh who contain every visibles faces of my object => FPS ~= 150
Display with a SharedMesh who contain every visibles voxels draw with a Box => FPS ~= 25 FPS
Display with a SharedMesh who contain every visibles faces of my object. I did six face with triangles in a TriMesh and I call these TriMesh when I build the SharedMesh ~= 2 FPS.