The Running Man - Halloween Edition

Last time, we saw how to load a 3d skeletal model, skin a mesh on top of that model, and animate it using forward kinematics. However, we used the built-in java.awt.Graphics class to perform rasterization of transformed triangles. This limits our control over the rasterization process - it allows us to draw plain triangles with one color, period.

Proper looking 3d graphics requires several additional features. We would like to have smooth shading, where the colors at each vertex are blended together at the internal points of a triangle - this is especially useful to perform smooth lighting. We would also like to apply a 2d texture to each triangle, in order to approximate surface detail using bitmaps, rather than additional geometry, and have this modulated with the (smoothly blended) base color. Finally, we would also like to store and compute depth values, in order to perform proper hidden surface removal. To introduce these features, we are forced to throw out the basic rasterization support, and implement our own.

To rotate the object, we use a "virtual trackball" metaphor. Imagine that the object was suspended in a large sphere; when you click on the screen with the left button, the mouse grabs the appropriate location on the sphere. Moving the mouse will rotate the sphere accordingly, and the object will rotate with it. This allows for arbitrary rotations around two axes. To rotate around the vector perpindicular to the screen, hold shift + left button.

Left Mouse Button
Rotates the object around two axes using a "virtual trackball" interface
Shift + Left Mouse Button
Rotates the object around the vector perpindicular to the screen
Center Mouse Button
Translates the object in the x-y plane
Right Mouse Button
Scales the object in the current view plane
Space Bar
Switches through the different animations
"b" Key
Toggles back face culling
"x" Key
Toggles drawing the axis lines
"s" Key
Switches between skeleton-only and skinned mode
"w" Key
Switches between wired-only and filled mode
Escape Key
Resets movement parameters

The source is in the files:

Copyright © 2003 Christopher DeCoro