سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top