Get a mesh vertices location

Question? What is the best way to get all the vertices in a mesh as in their location?
I dont know how o accomplish that. I’m using assimpmodelloader but i dont think it offers such functionality.

Hi,

You can use ofMesh::getVertices() http://openframeworks.cc/documentation/3d/ofMesh/#show_getVertices

i.e - not tested -

ofxAssimpModelLoader model;
model.loadModel(...);
ofMesh mesh = model.getMesh(0) // im assuming there is only one
vector<ofVec3f> vertices = mesh.getVertices();
// do stuff with vertices

I think it mostly depends on what you need, but if you only want to get the 3d position of a vertex in a ofMesh, you can do this:

ofVec3f pos = mesh.getVertex(vertexId);

so if you want to store all positions in a vector you can do:

vector vtx;
for(int i=0; i < mesh.getNumVertices();i++){
vtx.push_back(mesh.getVertex(i));
}

If you’re using ofxAssimpModelLoader, you model is made up of one or more ofMesh which you can get using:

model.getMesh(meshIndex);

This approach is perfectly ok if you just need to store positions once, but may not be the best solution if you’re planning to get a huge amount of vertices every frame. Again: it really depends on what you need to do.