I have a Mesh instance and need to get a list/set of all the vertices that compose it (so I can run inspection/analysis on each of their (x,y,z) coordinates).
I don’t see a getVertex(...) method but was thinking that I might be able to do something like:
Mesh mesh = getSomehow();
Vector3f v1, v2, v3;
List<Vector3f> allVertices = new ArrayList<Vector3f>();
for(int i = 0; i < mesh.getVertexCount(); i++) {
// I *believe* this will populate all vectors with unique vertex info
mesh.getTriangle(i, v1, v2, v3);
allVertices.add(v1);
allVertices.add(v2);
allVertices.add(v3);
}
But this feels messy and possibly will generate duplicate indices (vertices) in the list. Either way, if there is a more straight-forward way to do this (ideally an API method or util class somewhere) I would rather use that approac.
Thanks @rickard - I see that method now and am looking at the VertexBuffer class.
Once I get that VertexBuffer instance, any idea as to how I can iterate through all the vertices and get their individual (x,y,z) components? I see a getComponentSize() as well as a getData(), but no obvious way of iterating the buffer no converting the buffered data into, say, a Vertex instance, etc. Thoughts? Thanks again!
Thanks @The_Leo, I did a search for the FloatBuffer class but don’t see it on GitHub, any idea where its hiding out? Once I can look at its source I should be able to figure out the best way to iterate its internal data.
Also, just to confirm, the FloatBuffer pos variable will contain all vertices for the mesh, right? I’m only asking because the variable name “pos” is throwing me off (position)? Thanks again!
If you already rendered that object, OpenGL would have complained before that I suppose You don’t check for every text file if each byte has 8 bits do you?