# Create mesh

hello,

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 ?

Thank you…

I guess the TriMesh-Tutorial should clear things up

Hello,

thank you for the answer.

I'm reading the tutorial and it's most difficult to draw a mesh with jME than JOGL.

FiReTiTi, seems like You want to create lots of cubes ?

If so, jme has a primitive for that.

And maybe You can use shared meshes and culling as well if You try to do a voxel engine as i think You intend.

Thank you for the answer, but :

• jME have a primitive "Box", but I have LOT CUBES (> 100 000). I don't give all the cubes, one by one to rootNode.
• There is not tutorial about ShardeMesh on the web site : http://www.jmonkeyengine.com/wiki/doku.php?id=user_s_guide What is the advantage to use SharedMesh vs TriMesh ?

And yes, I intend to buid a voxel engine, because I do research on numerical imaging for 3D discret space.

I have a voxel engine for JOGL and I hope to improve display and speed with jME.
FiReTiTi said:

- There is not tutorial about ShardeMesh on the web site : http://www.jmonkeyengine.com/wiki/doku.php?id=user_s_guide :(

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.

thank you…

I will look the jmetest and I'll try the SharedMesh.

just a random thought… but is a scenegraph really a good foundation for a voxel engine?

renanse said:

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.

What is the advantages of 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.

Maybe I don't know build right a SharedMesh.

I have read specifications of shaders, utilisations and examples.

It seem to be difficult and long to learn. I need an voxel engine quickly and I will work with shaders later.