COMP 557 - Fall 2010 - Assignment 1
Transform Hierarchy for Character Posing

Due 12:00 noon Monday 27 September

Getting Started

Download the provided code from WebCT and dump it into a new java project. Follow the instructions in assignment zero for setting up your environment. Note that the provided code contains a jar called mintools. We will be using more of these helper classes in subsequent assignments, but for now, we are only using the TrackBallCamera class. The provided code attaches an instance of this class to the glCanvas so that mouse events can be used to alter the 3D view. Using the left mouse button you can rotate the object, using the middle button you can pan the object in the viewing plane, and using the right mouse button you can move the camera further or closer.

Start early! This assignment is not supposed to be hard, or time consuming, yet it is possible to get caught up on various details.


The purpose of this assignment is to use a hierarchy of transformations to draw and animate a character. You can use a variety of objects to build your character. Using glut to draw spheres, cubes, cones, cylinders, and the occasional teapot will be easiest. If you also want to draw triangles and quadrilaterals, you will need to specify their surface normal for lighting to work.

The file contains the necessary source code to create an OpenGL renderer in a windowed frame. A reasonable camera position and projection matrix is set up for you (see the use of the TrackBallCamera instance in the display method). The code also contains TODO comments in the places where you will need to add code to complete the assignment objectives that are given below.

Each objective is worth one mark, unless otherwise noted.

  1. Create Scene Graph Nodes

    Finish writing the scene graph node class called BodyNode. The node should have a display method to draw the contents of the node and all its children (which are also BodyNodes). In each node, you may want to store:

    • position with respect to its parent;
    • rotation axis for the joint connecting this node to its parent;
    • current rotation angle;
    • a list of children (possibly the empty list);
    • colour, i.e., material properties of the geometry of this node;
    • position, scale, orientation, and geometry information for this node.

    Note that as described in the list above, the rotation axis for the joint, and the position of the node with respect to its parent, describe a rigid transformation. The transformation describes the local coordinate frame in which the geometry of this node and its children are drawn. In the last bullet item, you can consider the position, scale, and orientation as additional modeling transforms to help you to place your desired canonical glut primitives (sphere, torus, cube, etc.).

  2. This is similar to how we saw the scene graph organized in class, except that we are mixing many transforms, material properties, and geometry in each node. The idea here is to simplify things slightly, but feel free to modify this as you see fit (be careful that your modifications work nicely with the rest of the objectives of the assignment). For instance, you may find it conceptually cleaner to keep the geometry in a separate type of node (i.e., create another class, such as a GeometryNode, to store the bottom two bullet items in the above list).

  3. Create and Animate a Chain (two marks)

    Write code such that when the 'C' key is pressed, a chain is created. The chain should be a reasonable length (e.g., 5 to 10 links), where each link is a torus. Choose your glutSolidTorus parameters so that you get something that resembles a chain link, and such that your chain is an appropriate size to be seen on the screen (i.e., without need of using the mouse to moving the camera from the default position). Each link should be rotated 90 degrees from its parent, and placed such that it appears to be hanging from its parent (see the screen shot at right).

    Each link should rotate as if it is sliding at the point of contact of its parent. You have two options, and can do either (or both, though doing both is obviously hardest). The easier option is to use the axis of rotation that goes through the center of the torus; this will produce a rotation which is only visible via the motion of its children (i.e., the torus will be rotating in place). The other option is to apply a rotation with an rotation axis on, and tangent to, the medial axis of the torus (i.e., at the point at center of the tube above the point of contact, and tangent to the circle at the center of the tube); this rotation will be visible both at the children and the torus itself. Note that the third axis (the overall direction of the chain) is not a good choice for rotations in the chain because twists along the chain direction quickly result in interpenetration.

    Use the space bar to toggle the animation mode. The provided code has an animation mode that sets all the angles to a sinusoid based on the current time to test your chain. It should appear to be swinging.

  4. Create a Character (two marks)

    link goes to source... no need to read the manual! link goes to source... no need to read the manual! Create an articulated character when the user presses the 'D' key. You can choose to make anything you like (e.g., animal, human, robot), but it should have at least two legs, two arms, and a head. In all you should have about 20 degrees of freedom in your character.

    You will likely find it useful to first make a sketch of your character to figure out how each of its body parts are connected to one another and where. Note that you will also need to choose a reasonable root node for the character, such as the torso. Write code to create the various body parts, and link them together by adding each child to the appropriate parent. Be sure to also add all your nodes to the nodeList! Note that you will want to avoid making a DAG so that all limbs of your character can be animated separately.

    Some joints should have a single degree of freedom (as shown in the picture above left), such as knees and elbows, while you should also have other joints which have multiple degrees of freedom (e.g., hips, shoulders, neck). You can create your multi-DOF joints any way you like, but it should work with the posing and animation controls in subsequent steps. One easy way to achieve a spherical joint would be to create three nodes all at the same location with different rotation axes. Two of the three nodes need not have any geometry associated with them, i.e., you would have two "invisible" nodes at the anchor position of the ball in socket joint show in the picture above right.

  5. Posing Controls and Setting Key Frames

    The provided code contains a primitive means of changing the pose of your character. The provided code uses the left and right arrow keys to walk through the nodeList, and then use up down arrows to adjust the angle by small increments (perhaps a few degrees).

    You may find it useful to try to find a way to modify the code so that the currently selected node is drawn in a different style or colour.

    Add code to save the current pose when you press 'K'. Save the pose into the existing list of "key poses". Code already exists to erase, load and save your key poses using keys 'E', 'L', and 'S'. Any code you add should work with the provided code, or you should fix it so that it works with your implementation.

    Note that using OpenGL picking to select which body part you want to pose would be a great way to simplify the task of character posing. This is beyond the scope of this assignment, but can be implemented for a 5% bonus!

  6. Key Frame Animation

    Create a simple key-frame animation. Plan ahead! The key pose editing functions are very limited (i.e., there is no undo, redo, insert, replace, delete, etc.). Try to make a reasonable walk cycle using at least four key poses. Save the animation and submit the resulting keyposes.javabin file with your code. Consider adding additional keyboard controls to increase or decrease the speed of the keyframe animation (currently the time between keyframes is half a second).

  7. Readme File (two marks)

    Create a readme.txt or readme.pdf file to submit with your assignment. The readme should include any comments you have with respect to the assignment, and describes anything you deem to be noteworthy. Try to be brief! Your readme should also contain written answers to the following questions:

    1. Is setting the joint angles individually always a good interface for setting key poses? What do you think would be a useful alternative? Try to think of at least one alternative, but list several if you can.

    2. For the following pairs of transformation types, do they commute always, sometimes, or never? Always means always, while never means only if one or both are the identity transformation. Sometimes means that the transforms do not commute in general, however, there are situations where two transforms will commute. If your answer is sometimes, then describe, as concisely and as generally as possible the situation where commutability will occur.

      • Rotation and Scale in 2D
      • Rotation and Scale in 3D
      • Rotation and Rotation in 2D
      • Rotation and Rotation in 3D
      • Translation and Rotation in 3D
      • Translation and Scale in 3D


Great! Be sure your name and student number is in the window title, in your readme, and in the top comments section of each of your source files.

Submit your source code and written answers in the readme file as a zip archive via WebCT. DOUBLE CHECK your submitted files by downloading them from WebCT. You cannot receive any marks for assignments with missing or corrupt files!!

Note that you are encouraged to discuss assignments with your classmates, but not to the point of sharing code and answers. All code and written answers must be your own.