Source Code:
Link to the Source Code
Link to the Motion Files
Note that the source file is at /afs/cs/user/kiranb/www/animation/src
and the motion file is at /afs/cs/user/kiranb/www/animation/ASF_AMC


Download Procedure:

Description of Motion Capture file format:
This code reads and displays the data from the optical motion capture system (.ASF and .AMC). The world coordinate system is Y up. The skeleton file (.ASF) describes how the bones in the skeleton are connected, and their degrees of freedom (see Pictures 1a and 1b). All bones are described in the ":bonedata" section of this file. Each bone has the following fields:

begin
id bone_id                  //Unique id for each bone
name bone_name        //Unique name for each bone
direction dX dY dZ    //Vector describing direction of the bone in world coordinate system
length 7.01722           //Length of the bone
axis 0 0 20 XYZ         //Rotation of local coordinate system for
                                   //this bone relative to the world coordinate
                                   //system. In .AMC file the rotation angles
                                    //for this bone for each time frame will be
                                   //defined relative to this local coordinate
                                    //system (see Pictures 2a and 3)
dof rx ry rz                //Degrees of freedom for this bone.
limits (-160.0 20.0)
            (-70.0 70.0)
            (-60.0 70.0)
end

The following picture illustrates these fields for lfemur (left upper leg) bone:


Picture 1a: Example of .ASF fields for lfemur bone

The parent/child relationship among all bones in skeleton hierarchy is defined in the ":hierarchy " section of the .ASF file. Each line list the parent first, then its children.
For example:
"root lhipjoint rhipjoint lowerback"
Root is a parent and lhipjoint, rhipjoint, lowerback are root's children.

The following picture shows the skeleton hierarchy as defined in ASF file (length of the bones is not up to scale).

Picture 1b. Shows the skeleton hierarchy, in particular name and id for each bone as defined in .ASF file.

Next figure shows rotation axes and names of some bones. In the program you can view the local coordinate system for each bone by entering its bone index, which is defined in .ASF file and shown in picture 1b.


Picture 2. Shows local coordinate system for some of the bones.

For a brief introduction on mocap file format, you can look at http://www.cs.wisc.edu/graphics/Courses/cs-838-1999/Jeff/ASF-AMC.html

The motion file (.AMC) records each bone's rotation angles (Euler angles) relative to the bone's local coordinate system at each time step, where the local coordinate system for each bone is defined in the skeleton (.ASF) file.



Running the code:
Make sure there is a "Skeleton.ASF" file in the working directory since it is the default skeleton file used in the program. A simple camera control is provided. You can drag the left mouse button to rotate about the character, middle mouse button to zoom in/out, and the right mouse button to move around. You can view the rotation axes of each bone by entering its bone index, which is defined in skeleton (.ASF) file and shown in picture 1b.

Below is the picture of GUI for the program (designed and created by Steve Lin).



Steps to display the animation:
You first need to load the skeleton (.ASF) file.

Interpolation:
You can also generate and view interpolated version of a given sampled motion. Currently only linear interpolation using euler angle representation is supported. If the loaded motion file was created by sampling the original motion file, you can create interpolated version of the motion by pressing "Interpolate" button. You will be asked for an offset file. The offset file defines how many frames were skipped when the sampled motion file was created, so that it is known how many frames to fill in.

The offset files will be provided to you together with sampled motion files. Each offset file will have the same name as the corresponding motion file, with suffix "_offset.txt" at the end.

Offset file format:
One integer per line. Each integer represents the time frame in the original motion for each sample in the sampled motion.
Example:
1                         (First sample in sampled motion corresponds to frame 1 in the original motion)
17                       (Second sample in sampled motion corresponds to frame 17 in the original motion)
22                       (Third sample in sampled motion corresponds to frame 22 in the original motion)
....                       (And so on. Number of lines in the file is equal to the number of frames in sampled file)

Either the interpolated or the sampled motion can be viewed now.



Source code structure and description:
The code consists of the following classes. We only provide a brief description here. For more detailed description of each class se the corresponding .h files. This code can play back the original, sampled or interpolated motion. When the "Load Actor" button is pressed the .ASF file is read and a new actor is created. The description of the actor is saved into an instance of the skeleton class. When the "Load Motion" button is pressed the .AMC file is read and saved into an instance of the motion class.