Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Importing Models from ASSIMP - Rotation Problem

  1. #1
    Junior Member Regular Contributor
    Join Date
    Apr 2014
    Posts
    109

    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?

    Thank you for your time.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Posts
    894
    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. #3
    Junior Member Regular Contributor
    Join Date
    Apr 2014
    Posts
    109
    Quote Originally Posted by carsten neumann View Post
    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.

    Thanks for your fast reply.

Tags for this Thread

Posting Permissions

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