Thursday, September 18, 2008

FBX and XNA Part 5 - Animation Interpolation

One thing I glossed over was how you arrive at the 'current animation rotation' or translation.

The Key: entries represent instants in time that the LimbNode is at a particular translation and rotation. (And scale and color and transparency, but we ignore theses.) What we do is have a ModelTracker class that keeps track of the current values for the animation for every LimbNode.
We simply interpolate between the instants in time. But remember, the first entry is the beginning of the time line, and the last entry is the end so it is a tricky interpolation.

If there is only one entry in the Key: section we just use that value. If there are no Key: entries at all we use the default. If there is not even a take: section for that LimbNode in the given Take, we create a new key frame and initialize it's default values to the LimbNode Lcl Rotation and Translation.

This all happens in the Games Update section. Many ModelTrackers can share the same Model.

We also detect when the animation hits the end and provide a callback so the game can take action when the animation ends.

Not yet implemented bu soon to come, tracking where a given LimbNode is in world coordinates so we can detect when a blade strikes an enemy. Update: This is done. Turns out that on a LimbNode in Maya you can set arbitrary attributes, that then show up in the Properties60 section of the LimbNode entry. We just set a property "Attack" and look for those and track them during attack moves. Same for "Step" for tracking foot prints and putting prints in the snow.

Also, KeyFrame sequences can be specified on any property, so we can put an animation on the value of a Attack Attribute and vary the attack deadliness through the attack swing.

I have not yet accounted for the Initial Velocity Tangent and Final Velocity Tangent. This allows for smoother blending between key frame segments.

TF

No comments: