|
Hi.
I am trying to get the GlobalTransform matrix at specified Skeleton Node and specified time by using the function “EvaluateGlobalTransform”. FBX SDK Programmer’s Guide 2012 shows us how to use this function as follows:
**** FBX SDK Programmer’s Guide 2012 (FBX’s Node) ***************
Global and Local Transformation Matrices
A node’s global and local tranformation matrices can be respectively obtained by calling KFbxNode::EvaluateGlobalTransform() and KFbxNode::EvaluateLocalTransform():
// Get the node’s default global transformation matrix. KFbxXMatrix& lGlobalTransform = lNode->EvaluateGlobalTransform(); // Get the node’s default local transformation matrix. KFbxXMatrix& lLocalTransform = lNode->EvaluateLocalTransform();These member functions are equivalent to using the KFbxScene’s animation evaluator KFbxAnimEvaluator::GetNodeGlobalTransform() and KFbxAnimEvaluator::GetNodeLocalTransform() functions:
// Get the scene’s animation evaluator. KFbxAnimEvaluator* lEvaluator = lScene->getEvaluator(); // Get the node’s default global transformation matrix. KFbxXMatrix& lGlobalTransform = lEvaluator->GetNodeGlobalTransform(lNode); // Get the node’s default local transformation matrix. KFbxXMatrix& lLocalTransform = lEvaluator->GetNodeLocalTransform(lNode);An animated node’s transformation matrix can be obtained for a specific point in time by passing a KTime object.
KTime lTime; // Set the time at two seconds. lTime.SetSecondDouble((float) 2); // Get the node’s global transformation matrix at 2 seconds. KFbxXMatrix& lGlobalTransform = lNode->EvaluateGlobalTransform(lTime);
*****************************
According to this instruction, I try to get global transformation matrices at different times. However, EvaluateGlobalTransform function always returns the same matrix(at time 0).
My code is as follows:( It is a little modified for explanation )
KFbxNode *pRootNode;
KFbxMatrix mat[100], mat1[100], mat2[100];
KFbxSkeleton *pSkeleton;
int i, counter = 0;
KTime mytime; //*** time of one frame
int ChildNodeNum = pRootNode->GetChildCount();
for( i=0; i<ChildNodeNum; i++ )
{
KFbxNode *pChild = pRootNode->GetChild(i);
KFbxNodeAttribute *pAttrib = pChild->GetNodeAttribute();
if( pAttrib )
{
KFbxNodeAttribute::EAttributeType type = pAttrib->GetAttributeType();
if( type == KFbxNodeAttribute::eSkeleton )
{
pSkeleton = (KFbxSkeleton *)pAttrib;
mat[counter] = pSkeleton->GetNode()->EvaluateGlobalTransform( mytime * 0 );
mat1[counter] = pSkeleton->GetNode()->EvaluateGlobalTransform( mytime * 10 );
mat2[counter] = pSkeleton->GetNode()->EvaluateGlobalTransform( mytime * 20 );
counter ++;
}
}
}
When this code is carried out, three matrices( mat, mat1, mat2 ) become same.(mat) So, I can’t get matrices at the times besides 0.
Would you like to point out what is wrong ? Your help will be greatly appreciated.
regards.
|