Linker problems
If you get linker errors (e.g. related to ClassId when using the GetSrcObject or FindMember functions) make sure you link to "libfbxsdk-md.lib" instead of "libfbxsdk.lib".
Node Transformations
Regarding computation of node transformation matrices you need to realize that there are two different formulas used depending on whether the current file is a Maya scene or comes from 3dsmax.
Make sure you read the relevant section in the FBX SDK Programmer's Guide -> Nodes and the Scene Graph -> FBX Nodes -> "Computing Transformation Matrices" (http://docs.autodesk.com/FBX/2014/ENU/FBX-SDK-Documentation/).
The first step is to get the local node transformation. There are several ways to do this:
Option 1:
FbxMatrix matTransform = pNode->GetScene()->GetEvaluator()->GetNodeLocalTransform(pNode);
Option 2:
FbxVector4 translation = pNode->EvaluateLocalTranslation();
FbxVector4 rotation = pNode->EvaluateLocalRotation();
FbxVector4 scale = pNode->EvaluateLocalScaling();
FbxMatrix matTransform( translation, rotation, scale );
Option 3:
FbxVector4 translation = pNode->LclTranslation.Get();
FbxVector4 rotation = pNode->LclRotation.Get();
FbxVector4 scale = pNode->LclScaling.Get();
FbxMatrix matTransform( translation, rotation, scale );
The next step is to get the geometric transform (assuming 3dsmax is used):
FbxVector4 T = pNode->GetGeometricTranslation (FbxNode::eSourcePivot);
FbxVector4 R = pNode->GetGeometricRotation(FbxNode::eSourcePivot);
FbxVector4 S = pNode->GetGeometricScaling(FbxNode::eSourcePivot);
FbxMatrix matGeometricOffset(T, R, S);
Then we apply the mentioned formula for 3dsmax:
FbxMatrix nodeMatrix = parentMatrix * matTransform;
FbxMatrix worldMatrix = nodeMatrix * matGeometricOffset;
The resulting matrix should then be converted to the conventions of the 3D API you are using (GL/D3D/etc.)
Getting all AnimStacks of the current Scene
The FBX SDK in many cases provides several different ways to retrieve the same information, which can be a bit confusing at times.
To iterate over all AnimStacks in the scene you can use
for(int i=0; i < m_pImporter->GetAnimStackCount(); i++)
{
FbxAnimStack* pAnimStack = m_pScene->GetSrcObject
// ...
}
Or alternatively:
for(int i=0; i < m_pImporter->GetAnimStackCount(); i++)
{
FbxTakeInfo* takeInfo = m_pImporter->GetTakeInfo(i);
FbxString takeName = takeInfo->mName;
FbxAnimStack* pAnimStack = m_pScene->FindMember
// ...
}
But as said, there are even more ways of doing the same thing...
No comments:
Post a Comment