# Thread: Importing Models from ASSIMP - Rotation Problem

1. ## Importing Models from ASSIMP - Rotation Problem

Hello,

So I have a rather interesting problem that I just can't figure out; I am importing models using ASSIMP and so far I can get the entire model to import fine but the entire scene is rotated such that +Y from the imported scene is oriented towards the +Z axis of the OpenGL environment.

On the ASSIMP forums the suggested solution was to multiply the root node's matrix by a -90 degree X-axis rotation matrix and since all of the child matrices are multiplied by the root/parent then all would be well.

The problem then is that some of the nodes are oriented correctly but other geometry is off.

Here is my code to rotate the root node:

Code auto:0:
`RootNodeMatrix = glm::rotate(glm::mat4(1.0f), -90.0f, glm::vec3(1.0f, 0.0f, 0.0f)) * RootNodeMatrix;`

Then, in the recursive function that processes each node I supply the root/parent node and multiply like so:

Code auto:0:
`CurrentNodeModelMatrix *= (*ParentNodeModelMatrix);`

With this, as mentioned I get some of the geometry oriented correctly but a lot of it is still off.

With JUST multiplying the Child Node Matrix by the Parent Node's matrix everything is OK relative to each other but I have the wrong "up" direction.

Is there something simple I am missing here?

2. Code :
`CurrentNodeModelMatrix *= (*ParentNodeModelMatrix);`

This multiplies the matrices in the wrong order, it produces C = C * P, but you want C = P * C, so that vertices are transformed first by the current matrix and then by the parent. That is assuming you use the convention of placing the vector after the matrix, i.e. v' = M * v.

3. Originally Posted by carsten neumann
Code :
`CurrentNodeModelMatrix *= (*ParentNodeModelMatrix);`

This multiplies the matrices in the wrong order, it produces C = C * P, but you want C = P * C, so that vertices are transformed first by the current matrix and then by the parent. That is assuming you use the convention of placing the vector after the matrix, i.e. v' = M * v.
Feel like an idiot; that was the problem. Made the change and everything works now!

And yes, I used the convention of placing the vector after the matrix.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•