Full Source
Solaris Binary only
For this assignment we implemented a robot in OpenGL. Well, I like
polygons, lots and lots of polygons. In total the scene in the
glRobot.sgm file contains almost 7000 triangles. This would have
been impossible to do by hand,
so my robot is constructed in Maya
(A 3D Modeler/Animation package) and exported. The file format and
plug-in are of my own design. While the code is included in the
submission the exporter will only currently compile on Mac OS X due
to some wackiness in Maya's API.
The structure of the file format and rendering back-end allows a large
amount of Maya's structure to be apparent in the robot executable.
So everything in this world, including the robot is a group.
Called a DAG (Directed association graph) node in Maya. Each
group has transformation attributes like scaling, rotation,
and translation.
The mouse is the primary control used to manipulate the active group.
Initially the active group is the camera. Called "defaultCamera" in
the group hierarchy and camera menu. The current active group is
changed by either selecting a new group to control in the
"Manipulate Arm" menu, the "Manipulate Group" menu, or the
"Select Camera" menu.
Initially clicking and dragging horizontally manipulates
the rotation about the y axis of the currently active group. Dragging
vertically manipulates the rotation about the x axis of the group.
This is the default mode for mouse manipulation and can be returned to
at any time by pressing the 'c' key.
By pressing the 'x' key clicking and dragging horizontally manipulates
the translation along the x axis of the currently active group. Dragging
vertically manipulates the translation along the y axis of the group.
By pressing the 'z' key clicking and dragging horizontally manipulates
the rotation about the z axis of the currently active group. Dragging
vertically manipulates the translation along the z axis of the group.
The robot does have some specific keyboard control using the arrow
keys. The forward key moves it forward, back move it back, and left
and right rotate it counterclockwise and clockwise respectively.
If you would like to see from the robots "eyes" select
"cameraOnRobotsHead" from the "Camera" menu.
The animation menu provides direct access to the key-frame animations
defined in the .anim file. Except one which is accessible from "Do a
trick". All animations are played for 2 seconds when executed from the
animation menu.
While the light can be manipulated from the group menu they can
also be manipulated along with the intensity and cutoff from the menu.
This, and all other light menu options, require input from stdin
however.
There are several fancy opengl effects implemented in the robot
program. For instance there is a large crystalline tree which is
blended into the scene. There is also a mirror initially to the robots
left. This mirror can be freely manipulated by the mouse when selected
from the group menu.
The floor is also texture mapped with a marble texture and properly lit.
The 'm' key toggles toon shading which is performed using
sphere mapping. I chose this implementation since the computational
cost is generally independent of model complexity.
There are also shadows. These are projected shadows so there is no
self shadowing yet they still look pretty cool.
The model is displayed using both display lists and vertex arrays
to achieve maximum speed.