ofxAssimpModelLoader single mesh position!

Hello everyone,

I have a question about ofxAssimpModelLoader and placement of each mesh
contained in the model!

When I import a model taken from .dae (https://www.mixamo.com/)

if you use the structure Assimp for design, the template is located and rendered
correctly.

while if I fill a vector mesh and design individually lose their initial position and some bones act more on the rig the model.

This is the code does anyone know tell me why?

 ofEasyCam cam;
 vector<ofMesh> mesh;
 ofxAssimpModelLoader assimp;

 void setup(){
       assimp.loadModel("dae/u/samba_dancing.dae",true);
       assimp.setPosition( 0, -8, -5 );
       assimp.setScale(0.9,0.9,0.9);
       assimp.setRotation(1,180,1,0,0);
       assimp.setLoopStateForAllAnimations(OF_LOOP_NORMAL);
       assimp.playAllAnimations();
       for(int i = 0; i < assimp.getNumMeshes(); i++){
              mesh.push_back( assimp.getMesh(i) );
       }
 }

 void update(){
       assimp.update();
 }

 void draw(){
      ofBackgroundGradient(ofColor(155),ofColor(0));
      ofEnableDepthTest();
      cam.begin();
      ofPushMatrix();
      for(int i = 0; i < assimp.getNumMeshes(); i++){
             mesh[i].drawFaces();
      }
      ofPopMatrix();
      ofTranslate(200,0,0);
      assimp.drawFaces();
      ofDisableDepthTest();
      cam.end();
 }

image sample:

Thanks and Good day

Dario

Dario, that happens because the getMesh() method returns the mesh in the object coordinate system, instead of the world or camera coordinate system, so you will have to apply a transformation matrix to it to get the correct placement. At first glance I didn’t found a method to retreive that info, but at least is a start :wink:

1 Like

thanks for this!