Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® FBX® / FBX SDK / How to get Global Transform Matrix
  RSS 2.0 ATOM  

How to get Global Transform Matrix
Rate this thread
 
62681
 
Permlink of this thread  
avatar
  • orangekid
  • Posted: 08 December 2011 11:51 PM
  • Total Posts: 1
  • Joined: 08 December 2011 10:38 PM

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.



Replies: 1
/userdata/avatar/vx3501hqr_small.jpg

Hello orangekid, you declare mytime but did not explicitly initiate it, so it is 0 by default.
As a result, mytime*0, mytime*10 and mytime*20 are all 0, so the three matrices actually all ask for matrices at time 0.
KFbxTime::SetSecondDouble can be used to set a double value as time in seconds.

Author: Jiayang Xu

Replied: 11 December 2011 01:58 PM