Get vertices and indices from meshes

Looking at the Navigation Mesh library in the jME plugins there is a solution:



[java] FloatBuffer pb = mesh.getFloatBuffer(Type.Position);

IndexBuffer ib = mesh.getIndexBuffer();



// copy positions to float array

float[] positions = new float[pb.capacity()];

pb.clear();

pb.get(positions);



// generate int array of indices

int[] indices = new int[ib.size()];

for (int i = 0; i < indices.length; i++) {

indices = ib.get(i);

}[/java]



I had already seen this like 1-2 months ago, but I totally forgot, when I was looking into NavMesh generation and the NMGen