Jump to content
  • Advertisement
Sign in to follow this  
tmason

OpenGL Importing Models from ASSIMP - Rotation Problem

This topic is 1559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
 

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:
 

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.

Share this post


Link to post
Share on other sites
Advertisement

Is this a model you have created in 3DS Max or Blender? if so there should be an option in the export to choose which axis you want to set as the Up direction. 

 

If it isn't a model you have created, I would suggest downloading the viewer supplied by assimp ( I think it is called "open3Mod" ). Try loading the model in that, and seeing if it displays properly in that. 

 

If it does then it should hopefully just be a case of getting the import flags for assimp correct in your Importer. 

 

If it doesn't then it could be that the model will need tweaking in a Modelling application like Blender or 3DS Max and Exporting again. 

 

As an added note, in Open3Mod you can check the details of each Node in the model so you will be able to see exactly which nodes have the incorrect rotation applied to

them.

 

Also make sure that the handedness of your matrices is not the factor that is causing this issue, i.e. possibly try setting the MakeLeftHanded Flag for assimp.

 

Hope this helps

Edited by JordanBonser

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!