Is it possible to find vertices location of imported blender model? I found getVertices() on java doc. Please somebody give me an example how to do it?
FloatBuffer positions = (FloatBuffer)(myMesh.getBuffer(VertexBuffer.Type.Position).getData());
positions.rewind();
while(positions.hasRemaining())
{
float x1 = positions.get();
float y1 = positions.get();
float z1 = positions.get();
float x2 = positions.get();
float y2 = positions.get();
float z2 = positions.get();
}
I think…
edit: or check out the last post here: Get vertices and indices from meshes - #2 by shirkit
What are you actually trying to do?
I want to import blender model and possible to edit in jme as custom mesh.
I think this is what you want, but you’re being a little vague. Anyway, here’s wonderwall.
Vector3f[] vertices = BufferUtils.getVector3Array(geom.getMesh().getFloatBuffer(VertexBuffer.Type.Position));
Okay. Thanks. Let me try that first .
BTw. What I mean is blenderContext. For getVertices() method, explanation is like this:
getVertices
public java.util.List<com.jme3.math.Vector3f> getVertices()
Returns:
the vertices of the mesh
BlenderContext is an internal of the jme3-blender which is the Blender Importer Module which is not appropriate for a jme application directly and also sucks because it doesn’t work for other sources of models.
What you might be interested in the most is Mesh#getTriangle
which is what I use, the only downside is, that you don’t have Mesh#setTriangle
and thus need to set the Indices and Vertex Buffers (which is something you might need to know for CSG/Custom Meshes anyway):
List<Triangle> tris = new ArrayList<>(surface.getTriangleCount());
for (int i = 0; i < surface.getTriangleCount(); i++) {
Triangle tri = new Triangle();
surface.getMesh().getTriangle(i, tri);
tris.add(tri);
}