The Rubberman

 

by Andrex DeMayo

CSC471 Final Project

Prof. Wood

 

Download the executable here

 

Description & Notes

 

This project is a simple example how to create a recursive hierarchical model with a few animations. The model is made up of cylinders with a sphere at the end, so there won't be a gap in between cylinders when they are rotated. Only the head, feet, and hands are single spheres. The "Waving" and "Dancing" animations are done with just recursive rotations. There is also a spotlight that you can control.

 

One of the largest advantages is that initialization can be recursive, so you can add a bunch of objects with a single function call. Each object could also be translated with a set amount, so that they can be drawn side-by-side-by-side... One of the tricks you can do is call a recursive rotate, and that will bend the body parts in a curve. Of course, you could also only bend a single part and the rest will follow. The main disadvantage of hierarchical modeling is that a transformation you do to a part will affect the rest of its children. You might have to "undo" the transformation for the children you don't want transformed. In the "Arm Wave" animation, this was a little difficult.

 

One of the things you need to watch out for with recursive modeling is the maximum stack size. The specifications from OpenGL say that the ModelView Matrix stack should have a maximum size of at least 32. You'll see strange results if you start pushing more than that on the stack, so you should limit your recursive depth to that.

 

 

Usage

 

Keyboard Commands
'H' key: displays this (H)elp screen
'R' key: resets the camera & spotlight
'V' key: switches the (V)iewing mode between orthogonal and perspective
'Q' key: (Q)uits the program

Spotlight Controls (based on the keypad):
'8' key: UP
'2' key: DOWN
'4' key: LEFT
'6' key: RIGHT
'9' key: BACK
'3' key: FORWARD
'+' key: Increase Light Intensity
'-' key: Decrease Light Intensity

Left-click: starts doing the transformation
Right-click: shows the context menu

Transformations
Camera Scale:
Left-click and hold while dragging to uniformly scale the cube.
The positive direction for scaling is up-right and negative is down-left.
You can only see the effect in Perspective Viewing Mode.

Camera Rotate:
Left-click and hold while dragging to rotate the cube like using a trackball.
Note: Camera scaling will be reset.

Spotlight Position/Direction:
Select this from the context menu and then use the spotlight control keys.

Animations
Animations will repeat until "None" is selected. The next animation will start once the previous has finished.

Waving: The rubberman waves his arms up and down.
Dancing: The rubberman moves his body.
Arm Wave: The rubberman does the wave with his arms.
None: Turn off animations.

 

 

Diagrams & Pictures

 

Below are diagrams of how I structured the class and model hierarchy:

Figure 1 - The HierQuadric Class

 

 

Figure 2 - The Model Hierarchy

 

And finally, some screenshots:

 

 

 

Resources

NeHe Productions - http://nehe.gamedev.net/    Contains OpenGL Tutorials (48 when I visited there).
Good-Tutorials.com - http://www.good-tutorials.com/    Tutorials for Photoshop, such as creating your own textures. Really only helpful if you have access to Photoshop.