CS838 - Project 2

Motion Capture Viewing System

This program allows you to view motion capture data stored in the BVH file format. The motion can be played back in realtime or frame-by-frame. The paths of selected joints, end affectors, and markers can be displayed. The paths of markers can be saved to a file. Euler, quaternion, and exponential map interpolations are supported.

User Interface

Most of the window is occupied by the viewing pane. The viewing pane shows the actual motion described by the motion capture file. The viewing perspective can be adjusted by the mouse. Holding the left mouse button and dragginb across the pane will rotate the scene about its origin (not about the camera). Horizontal movements rotate about the Y-axis and vertical movements rotate about the X-axis. The X-axis rotation is constrained to +/-90 degrees. Dragging the middle mouse button translates the camera horizontally and vertically with respect to the scene. Dragging the right mouse button scales the scene.

Below the viewing pane are the playback controls. The play button starts and stops playback of the motion when pressed. The slider shows the current frame and can be dragged to change the current frame. The prev and next buttons advance the current frame by one in either direction. The text boxes below the prev and next buttons control what part of the motion should be shown. You must hit 'Enter' in the box for any change to take effect. The realtime button constrains the playback to realtime, delaying or dropping frames as necessary. Without this turned on, playback procedes as fast as frames can be drawn.

At the bottom of the screen are the load and save buttons. The left-most button is used to load a BVH motion file. The button next to it loads a marker file. The next button removes the current markers. The last button writes a file containing the positions of the markers throughout the motion.

To the right of the viewing pane are the viewing options. At top is a list of all joints, end affectors, and markers in the scene. By clicking on the list, you can display the paths followed by the selected points. Multiple entries can be select by using the 'Shift' key. Paths will be displayed only for the subrange of frames indicated by the text boxes below the frame slider.

Below the selection list are the interpolation display buttons. The system can interpolate joint angles of the skeleton between the first and last frames of the currently selected subrange. Interpolation can be done using euler angles, quaternions, or exponential maps. Each form of interpolation is displayed using a different color. Any combination of interpolations and keyed frames can be displayed with the buttons. Each button controls displaying of both joint paths and the skeleton.


Implementation

Skeleton

The data structure specifying the skeleton is fully generalized. It is built up as a tree with joints as interior nodes and end affectors as leaves. All data pertaining to a joint is stored in its node in the tree. This includes all motion data. Any operations involving data in the tree traverse it recursively.

Forward Kinematics

All calculations needed to draw the skeleton are redone for each redraw starting from the euler angles draw in from the motion file. Representations that use quaternions or exponential maps are first converted to the appropriate format, then used. The converted formats are not save. Since the skeleton is drawn for only one frame at a time, this isn't a huge performance penalty.

On the other hand, all calculations for displaying the paths of the joints and end affectors are precomputed and saved. This is done because information from all frames is used on every redraw. Recalculating all this each time would be enormously expensive for longer motions.

Markers

When markers are read in, they are inserted into the skeleton tree, becoming part of the skeleton. This makes many operations, like path tracing, automatic (since they're performed on all nodes in the tree). A special flag marks marker nodes so that bones aren't drawn for them. The same flag allows us to find the markers for unload and save operations. Markers become children of the joints they are associated with. Currently, loading a set of markers leaves any existing markers in place, allowing allowing multiple sets to be loaded at once. The unload command removes all markers. The save command saves path tracing of all markers.

Interpolation

Each type of interpolation is distinguished by drawing the resulting skeleton and path traces in a different color. The program implements euler angle, quaternion, and exponential map interpolations. Interpolation is done between the first and last frame currently marked for playback. As for the fully-keyed motion, calculations for drawing the skeleton are redone for every redraw, while path-trace data is precomputed. The path-trace interpolations are recomputed whenever the playback frame range is changed.

The data structures store the rotation keys as euler angles only. Whenever quaternions or exponential maps are used, the euler angles are first converted to the appropriate form. The algorithms for converting from euler angles to quaternions and for slerp interpolation were taken from Animating Rotation with Quaternion Curves, by Ken Shoemake. Algorithms for exponential map conversion and interpolation were based on Practical Parameterization of Rotations Using the Exponential Map, by F. Sebastian Grassia. For exponential map conversion, the euler angles were first converted to quaternions.

BVH files

The skeleton tree structure is built up as the heirarchy section of the file is read. Then, all the motion data is read into a giant 2-D array. Once all the data is in, the 2-D array is distributed among the skeleton nodes (pointers to 1-D arrays are copied, not the arrays themselves). The code assumes all files will use the standard BVH rotation order and that all joints other than the root will only have rotation channels. The code works with all the BVH example files.


Files