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.


You can use ofMesh::getVertices()

i.e - not tested -

ofxAssimpModelLoader model;
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++){

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


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.