Get global vertices position of an instance of ofxAssimpModelLoader

Hello, I’ve loaded a model and I’ve changed the position and the rotation of it inside my scene.

Now I need to find the global position of the vertices of the meshes contained in the model. Is there a way to have the global transofrmation matrix? like getGlobalTransformMatrix im 3DPrimitive ?

it looks like ofxAssimpModelLoader stores the position in an ofPoint, and the rotation with:

vector<float> rotAngle;
vector<ofPoint> rotAxis;

where each ofPoint in rotAxis represent one of the 3 rotation axis and each float is the angle on each axis. I think, although it is not that clear to me from this code. What does indicates the which parameter?

Does it make sense to have a method that returns the globalTransformationMatrix out of these values?

I could use the position stored in ofPoint to create a translation matrix, I could use the ofPoint that save the scale to create the scale matrix, and then I could get the quaternion out of rotAngle and rotAxis (once that i figure out how the rotation is stored) and then:

glm::mat4 globalPosMatrix = translationMatrix * rotationMatrix * scaleMatrix;

does this makes sense?

does anyone have a suggestion about how to proceed here?

Ok, this looks like an old topic.

@bilderbuchi @Jordi , is this the way to go right now?

This is what I came up to:


#pragma once
#include "ofMain.h"
#include "ofxAssimpModelLoader.h"

class MeshHelper{
    //get an of3dPrimitive from a mesh
    static of3dPrimitive toPrimitive(const ofMesh& mesh);
    // it fullfills an empty vector of of3dPrimitive
    // with the primitive obtained from an ofxAssimpModelLoader
    // and set as parent node for each primitive, the parentNode
    static void readModelAndGetPrimitives(ofxAssimpModelLoader& model,
                                                vector<of3dPrimitive>& primitives,
                                                ofNode& parentNode);


#include "MeshHelper.h"

of3dPrimitive MeshHelper::toPrimitive(const ofMesh& mesh) {
    of3dPrimitive primitive;
    return primitive;

void MeshHelper::readModelAndGetPrimitives(ofxAssimpModelLoader& model,
                                               vector<of3dPrimitive>& primitives,
                                               ofNode& parentNode){
    for (int i = 0; i< model.getMeshCount(); i++) {
        auto primitive = MeshHelper::toPrimitive(model.getMesh(i));

usage example:

vector<of3dPrimitive> primitives;
centerOfTheScene.setPosition(0, 0, 0);
model.loadModel("teapot/teapot.obj", 20);
MeshHelper::readModelAndGetPrimitives(model, primitives, centerOfTheScene);

I can then move the model around moving the node, example:

centerOfTheScene.move(0, 0, -132);

And then query each primitive in the vector and for each primitive I can get the Global Transformation Matrix using primitive.getGlobalTransformMatrix()