3

I load FBX models using Autodesk FBX SDK2013.The models get rotated 90 degrees on X-Axis by default.

The SDK supplies this method :

FbxAxisSystem::OpenGL.ConvertScene(scene);

to perform axis conversion.But it doesn't work.Calling it changes nothing.Moreover,it seems that the FBX exporter uses OpenGL right hand sytem by default,at least that is what it says on import:

     FbxAxisSystem fbxAxis = scene->GetGlobalSettings().GetAxisSystem();

            if (fbxAxis != FbxAxisSystem::OpenGL)
            {
                      //....
            }

returns false. So I don't understand;if it is OpenGL (right handed system,why the models have Z axis as up? Is it the SDK bug?

Michael IV
  • 11,016
  • 12
  • 92
  • 223
  • Handed-ness has nothing to do with the direction of the up axis. Also, what is "up" depends also on how you are viewing the scene. – Nicol Bolas Aug 10 '13 at 00:20
  • In my scene Y is up while -Z is forward.The imported model's Y(which is Z in the 3dsMax) is aligned with my Z while I expect it being aligned with my Y... – Michael IV Aug 10 '13 at 09:59
  • "*The imported model's Y(which is Z in the 3dsMax) is aligned with my Z*" So in Max you say "Z". And it comes out after going through your FBX file into your application as "Z". And this is... wrong? It seems more likely that the model was oriented incorrectly in Max. – Nicol Bolas Aug 10 '13 at 10:08

1 Answers1

4

I finally found the solution.Someone here actually said that the ConvertScene() doesn't affect the vertices array but sets node global/local matrices.With these we can then transform the node geometry or the vertices.

So here how it is done:

    FbxMatrix globalTransform = mesh->GetNode()->GetScene()->GetEvaluator()->GetNodeGlobalTransform( mesh->GetNode());
dvec4 c0 =  glm::make_vec4((double*)  globalTransform.GetColumn(0).Buffer());
dvec4 c1 =  glm::make_vec4((double*) globalTransform.GetColumn(1).Buffer());
dvec4 c2 =  glm::make_vec4((double*) globalTransform.GetColumn(2).Buffer());
dvec4 c3 =  glm::make_vec4((double*) globalTransform.GetColumn(3).Buffer());
glm::mat4 convertMatr =mat4(c0,c1,c2,c3);
convertMatr = inverse(convertMatr); //need to inverse otherwise the model is upside down

Then use convertMatr to transform mesh's vertices.Hope it will be helpful to anyone as Autodesk forum is not too much responsive.

Michael IV
  • 11,016
  • 12
  • 92
  • 223