Hi all,
I’m using jME for academic purposes, for visualiation of a mobile robot simulation based on the nVidia PhysX physics engine (I know jME comes with JBullet now but not at the time I created the simulation, plus I was working on top of existing code). I’d like to create a more complex terrain than the ones I’ve been using so far so my idea is to create the terrain in jME and then extract the triangle mesh to duplicate it in PhysX. I need to do all this programmatically since I need to randomly generate terrains on the fly.
So it seems I should do something like:
- Generate a height map
- Create a TerrainQuad based on the height map
- Extract all TerrainPatches using TerrainQuad.getAllTerrainPatches(java.util.List holder)
- For each TerrainPatch tp in holder:
[java]Mesh m = tp.getMesh();
java.nio.FloatBuffer vb = (FloatBuffer) m.getVertexBuffer( VertexBuffer.Type.Position ).getData();
java.nio.IntBuffer ib = (IntBuffer) m.getIndexBuffer();
float[] vertices = vb.array();
int[] indices = ib.array();[/java]
- Concatenate the arrays of vertices and the arrays of indices and pass them to PhysX, together with the triangle count.
Does that look about right? Thing I’m worried about is jME’s adaptive (based on camera position) LOD implementation; I just want to create the mesh in PhysX once, with uniform LOD. Is it correct that if I don’t add a TerrainLodControl when I generate the terrain, the LOD will be uniform? Is there a way to specify how detailed the uniform LOD should be?
The other thing I’m worried about is whether PhysX will interpret the indices “counter-clockwisely”, but I guess I’ll just have to find out.
Thanks
Matt
Edit: Third thing I’m worried about: does the order in which I loop through the TerrainPatches matter?