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:
#pragma once
#include "ofMain.h"
#include "ofxAssimpModelLoader.h"
class MeshHelper{
public:
//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);
};
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()