Source Code:
The source code for the AMC viewer is at /afs/cs.cmu.edu/academic/class/15464-f05/asst1/src_viewer/
the code for linear interpolation for euler angles is at /afs/cs.cmu.edu/academic/class/15464-f05/asst1/src_interpolate/
and the motion data files are at /afs/cs.cmu.edu/academic/class/15464-f05/asst1/data/

You may have to do the following to get the code running:
setenv LD_LIBRARY_PATH /afs/cs/academic/class/15464-f05/lib/



Description of Motion Capture file format:
You do not have to deal with the ASF file in your code. But it is useful to understand how it works anyways. The code in the "src_viewer" directory 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 Picture 1). 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
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 parent/child relationship among all bones in the skeleton hierarchy is defined in the ":hierarchy " section of the .ASF file. Each line lists 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 1. Shows the skeleton hierarchy, in particular name and id for each bone as defined in .ASF file.

The next figure shows rotation axes and names of some bones. In the user interface for the program (the joint box) you can view the local coordinate system for each bone by entering its bone index, which is defined in .ASF file.


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 1.

Steps to display the animation:



Interpolation:
The code in the "src_interpolate" directory currently performs linear interpolation using euler angle representation. An AMC file and a corresponding _offset.txt file is needed as input. 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 are provided to you together with the 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)

The current "interpolate" executable writes the results in a file called "interp.AMC". The file "walk_turn.AMC_samp20_interp.AMC" in the "src_interpolate" directory is the result of doing linear interpolation using euler angles on "walk_turn.AMC_samp20.AMC". The interpolated motion can then be viewed by the amc_viewer.



Source code structure and description:
The code in the "src_viewer" directory consists of the following classes. 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.
The code in the "src_interpolate" uses the motion and skeleton class to read and write the AMC files.