Evaluating With Animation Turned Off

Evaluating With Animation Turned Off

Anonymous
Not applicable
1,090 Views
5 Replies
Message 1 of 6

Evaluating With Animation Turned Off

Anonymous
Not applicable

Hello,
I'm importing a FBX file with some animation, however I want to evaluate its nodes as if it has no animation.

Calling lpScene->SetCurrentAnimationStack(NULL); does nothing to remove the current animation from evaluation.

I'm using the function GetGlobalPosition() to return a matrix at time 0, but it's still evaluating the
current animation.  I can solve this by deleting all animations, but I obviously want to keep them.

So, how can I evaluate a node's world position as if it has no animation, but without deleting all animations?

0 Likes
Accepted solutions (1)
1,091 Views
5 Replies
Replies (5)
Message 2 of 6

regalir
Autodesk
Autodesk

You can try to "disable" the animation stack:

 

FbxAnimStack* currentAnimStack = lScene->GetCurrentAnimationStack();

lScene->SetCurrentAnimationStack(NULL);

 

// call the Evaluate functions ...

lGlobalPosition = pNode->EvaluateGlobalTransform(pTime);

 

// restore the animation stack

lScene->SetCurrentAnimationStack(currentAnimStack);

0 Likes
Message 3 of 6

Anonymous
Not applicable

That's my problem.  Passing NULL doesn't disable the stack.  I think this is how it always behaved.

This is what the SDK docs say:


"When no context is specified, the FBX SDK will try to automatically pick the first animation stack available in the scene and set it as the current context."

So, even if you try to NULL it out, it still evaluates the first (or last) animation in the stack.

0 Likes
Message 4 of 6

Anonymous
Not applicable

As a test, I can delete all animations, and compare the results.  Passing NULL doesn't seem to disable animation.

 

void
Delete_Animations(FbxScene* pScene) {

 if(NULL == pScene) return;

 // Keep looping until all animations are deleted.
 while(1) {

    INT first_index=0;
    FbxAnimStack* pAnimStack = FbxCast<FbxAnimStack>(pScene->GetSrcObject<FbxAnimStack>( first_index ));
    if(!pAnimStack) {
       break;
    }

    char name[MAX_PATH]="";
    strcpy( name, pAnimStack->GetName() );

    pScene->RemoveAnimStack( name );
 }
}
0 Likes
Message 5 of 6

regalir
Autodesk
Autodesk
Accepted solution

It will be easier if you disconnect all the animation stacks and re-connect them afteward.

 

// Get the current animation stack
FbxAnimStack* stack = lScene->GetCurrentAnimationStack();

// disconnect all the animation stacks from the scene (and remember
// their order so we can re-connect them identically)
FbxArray<FbxAnimStack*> stacks;
while (lScene->GetSrcObjectCount<FbxAnimStack>())
{
	FbxAnimStack* s = lScene->GetSrcObject<FbxAnimStack>(0);
	stacks.Add(s);
	lScene->DisconnectSrcObject(s);
}

// turn off the CurrentAnimationStack
lScene->SetCurrentAnimationStack(NULL);

// =========================
FbxAMatrix m1 = node->EvaluateGlobalTransform(pTime);
// =========================

// Re-connect all the animation stacks
for (int i = 0; i < stacks.GetCount(); i++)
	lScene->ConnectSrcObject(stacks[i]);

// and set back the current one
lScene->SetCurrentAnimationStack(stack);
Message 6 of 6

Anonymous
Not applicable

Thanks for the help, that works great.

I also came up with another solution.  I can add a dummy animation to the stack, set that as current, read my nodes, then delete the dummy animation from the stack.  But I like your way much better.  Thanks.

0 Likes