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 the source code and Motion files into your working directory
The OpenGL library in the new cluster machines have not been updated. So,
do the following to get the code running
setenv PATH .:/usr/openwin/bin:/usr/X11R6/bin:/usr/bin:/usr/bin/X11:/bin:/usr/sbin:/sbin:/usr/ucb:/usr/ccs/bin:/usr/local/bin
setenv LD_LIBRARY_PATH /afs/cs/user/kiranb/www/animation/GL:/usr/local/bin
make clean; and then make
run the executable: ./player.i386_rh71 (This should bring up an FLTK window)
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:
//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 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)
The following picture illustrates these fields for lfemur (left upper
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.
"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
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
Steps to display the animation:
You first need to load the skeleton (.ASF) file.
Then load the motion (.AMC) file.
You can now view the motion using the player buttons.
You can save the current frame as an image by pressing Save button.
To record a sequence of images (if you want to make a movie), first press
record (R) button to specify the prefix for the name of all images then
play the animation.
All the frames played while record button is ON will be recorded.
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.
(First sample in sampled motion corresponds to frame 1 in the original
(Second sample in sampled motion corresponds to frame 17 in the original
(Third sample in sampled motion corresponds to frame 22 in the original
(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.
Skeleton class (skeleton .h): read an ASF file and build the skeleton
hierarchy. See the description of member function and member variable in
"skeleton.h" file. When the skeleton is read the following hierarchy of
bones is constructed: Each node in the hierarchy represents a bone segment
as shown in picture 1b. Each bone has exactly one child. If in skeleton
file (.ASF) a particular bone has more than one child (like root for example)
the second child is set as a sibling of the first child, the next child
as a sibling of a previous child and so on.
Motion class (motion.h): read/write an AMC file and store joint
angles for each frame in the m_pPostures aray. Each posture defines the
root position and orientations for all bones at a particular frame. For
more details see "motion.h" file.
Display class: draw the actor at a given posture.
Player.cxx: player function handling (user interface functions),
render setting (OpenGL initialization, light and camera settings)
Tansform.cxx: some math functions for transformation
Vector class: 3d vector representation and operations (addition,
subtraction, ....). See "vector.h" file for the full description.
Interpolator class: currently supports linear interpolation using
euler angle representation. You first need to initialize the interpolator
by providing the sampled motion and setting the interpolation type (LINEAR
for example) and angle representation (EULER or QUATERNION). Then Interpolate()
function can be called to create interpolated motion. See "interpolate.h"
file for more information. You will need to add functions to this class
to do the kinds of interpolation you were asked in the assignment.