Hello guys!
So, I'm currently working on our senior game-dev project and I'm currently tasked with implementing animations in DirectX.
It's been a few weeks of debugging and I've gotten pretty far, only a few quirks left to fix but I can't figure this one out.
So, what happens is when a rotation becomes too big on a particular joint, it completely flips around.
This seems to be an issue in the FBX data extraction and I've isolated it to the key animation data.
First off, here's what the animation looks like with a small rotation:
Small rotation in Maya
Small rotation in Engine
Looks as expected! (Other than the flipped direction, which I'm not too concerned about at this point; however, if you think this is part of the issue please let me know!)
Now, here's an animation with a big rotation (+360 around Y then back to 0):
Big rotation in Maya
Big rotation in Engine
As you can see the animation completely flips here and there.
Here's how the local animation data for each joint is retrieved:
while (currentTime < endTime)
{
FbxTime takeTime;
takeTime.SetSecondDouble(currentTime);
// #calculateLocalTransform
FbxAMatrix matAbsoluteTransform = GetAbsoluteTransformFromCurrentTake(skeleton->GetNode(), takeTime);
FbxAMatrix matParentAbsoluteTransform = GetAbsoluteTransformFromCurrentTake(skeleton->GetNode()->GetParent(), takeTime);
FbxAMatrix matInvParentAbsoluteTransform = matParentAbsoluteTransform.Inverse();
FbxAMatrix matTransform = matInvParentAbsoluteTransform * matAbsoluteTransform;
// do stuff with matTransform
}
// GetAbsoluteTransformFromCurrentTake() returns:
// pNode->GetScene()->GetAnimationEvaluator()->GetNodeGlobalTransform(pNode, time);
This seems to work well, but on the keys when the flip happens it returns a matrix where the non-animated rotations (Y and Z in this case) have a value of 180, rather than 0.
The Y value also starts "moving" in the opposite direction.
From the Converter we save out the matrix components as T, R, S (R in Euler) and during import in engine the rotation is converted to a quaternion for interpolation.
I'm not sure what else I can share that might help give a clue as to what the issue is, but if you need anything to help me just let me know!
Any help/ideas are very much appreciated! ❤️
E. Finoli