Exporting Animation with the IGame Exporter

January 1st, 2008

Exporting Animation with the IGame Exporter

Download Example Skin Exporter Using IGame with 3dsmax 7 [Requires Visual Studio .NET 2003]

Code Demonstrated: AffineParts, GetFullSampledKeys, IGameNode, IGameObject, IGameControl

Notes:

  • You might be able to use the latest tech demo as a testbed to import GSA Animations. However, I can’t guarantee that the latest version will support obsolete versions of the GSA format.

This paper discusses using the IGame Exporter for 3ds max to export animation authored by the Character Studio Physique/Biped plugins. First, I’d like to give background about skeletal animation and how it works. Skeletal Animation is based on human anatomy- each bone in a mesh influences the vertices around it. In the authoring program, such as 3ds max, the animator binds a ’skeleton’ to a character. All the major components of a human skeleton- such as an arm, head, Right leg, and left leg are all represented by skeletal systems. In reality, the ‘bone’ is simply a matrix whose position and rotation information is relative to it’s parent bone. The root bone, Bip01, is a child of the scene- resulting in an identity matrix for it’s offset matrix. What my exporter does is export the Scene as the Root. Bip01 is the child of the Scene bone. This process is recursive, all child bones are exported. The engine can cull this info out or keep it.

In 3d studio max, you can get many different matrices from the animation controller- the offset, world, and local matrices. They also provide an affine matrix decomposition function that allows developers to get rotation, position, etc directly. The most important matrix is the relative, offset matrix (world TM * inverse parent TM). Using the local/offset matrix, we can smoothly transistion between different animation sequences. When exporting data from the authoring software, our main concern is getting the local matrix exported along with the model data. The information I export from 3ds max:

  • Model positioned in the original reference pose. The model should be positioned with arms outstretched and legs outstretched. This way when you generate the bound to cover the entire character, you’ll get a bound that covers the entire model. Additionally, this allows the game engine to smoothly transisition to other animation sequences. This way we already have the base vertex position. We can take the vertex and compute the inverse position/rotation to get it’s local relative to the bone. Then all we have to do is multiply by the bone’s new world location to deform the vertex (I elaborate on this in my Software Skinning  tutorial). The key is the mesh is exported in it’s reference pose. Using the offset  matrices for the bones, we transform the vertices into the animation sequences.  


 

  • Export the transformation matrix (bone) for each key frame for every animation sequence. I’ve noticed some exporters take the animation data and interpolate within the time range and pick a matrix for the time step (like 30 fps,etc). What I simply do is just grab all the keys and let the game engine interpolate the data in real time. Most animation sequences only consist of like 6-7 key frames anyway. Keep in mind each animation for the character is relative to the reference pose.
  • Split apart the TM data into position, rotation, and scale using an affine comp. 3d studio max includes this function in their API ( decomp_affine() from “decomp.h”).
    We need to split the matrix so we can interpolate the position/rotation data for the current time in the animation (0.0f - 1.0f). When you export the rotation as a Quaternion, make sure to be careful and invert the w component (otherwise all of your animations may look totally off). Of course, this may differ between authoring software programs, etc.

I have included the entire source for my exporter in the top link. It exports the motion/mesh data into a .gsa file. A .gsa file only holds one animation sequence. In order to process the complete animation data for a character importers will have to import each individual .gsa file and merge the data together. First, export the reference pose as a .gsa. Load the mesh from this file. All the other gsa files also contain mesh information, in which you must ignore. Simply import the animation data only. The meshes come with a lot of triangles. The importer should search for duplicate vertices and use the index buffer to reuse duplicate indicies. Visit Software Skinning for more info about duplicate vertices.

  1. No comments yet.
  1. No trackbacks yet.