CS4451: Assignment 3

"Blobby Man"

Due: 10am, Friday October 15th


Purpose

To understand and implement a program using hierarchical transformations.

Secondary: to implement simple object selection and interactive manipulation, and to use a perpective transformation.


Task

Write a C program using GLUT and OpenGL calls to create a "blobby man". This fellow should have the following parts, with their hierarchical nesting indicated by the indentation:
  1. Torso
    1. head
    1. left upper arm
      1. left lower arm
        1. left hand
    2. right upper arm
      1. right lower arm
        1. right hand
    3. lower body (below the waist)
      1. left thigh (upper leg)
        1. left calf (low leg)
          1. left foot
      2. right thigh (upper leg)
        1. right calf (low leg)
          1. right foot

For example, the right foot is a child of the right calf, etc. This hierarchy should correspond to the transformations you store internally and issue when drawing the man -- each piece should be positioned relative to its parent, and the transformations you store internally should reflect this. The origins of each parts should correspond to the joint around which you rotate it. (ie. the upper arms should be defined with their origin at the shoulder, the lower arms should have their origin at the elbow, the hands at the wrist, and so on. The origin of the body should be in the center of the torso sphere). You may assume that each part can only rotate around one axis (even though some joins support multiple axis of rotation, in reality).

Each piece of the man should be created with an appropriately scaled sphere. You should color the spheres in some "reasonable" way (ie. use a few different colors, perhaps to indicate a shirt, shoes, pants and skin).When the program starts, the man should be in a standing pose: upright, arms and legs straight and hanging down.

You should be able to manipulate the man using a click-and-drag interaction technique (as described below) to rotate all the parts.

You should implement a "debug mode" (described below), which is toggled on and off when the user presses the "d" key. We suggest implementing this early on, to help you debug your code.


Turn in

Your program should consist of a set of files which should be commented with your name and a description of the contents of that file, as well as the usual comments throughout the file. Your submission MUST include a makefile, and MUST be mailed to the class account as a single, uuencoded tar file (as described on the web page). (Using MIME attachments to turn in files will make the grader crabby and result in much tougher program grading!)

The time the mail is received will be used to determine whether or not the program is late, so be sure to allow a couple of minutes for the mail system to transmit your file if you are working right up to the deadline.

IMPORTANT: If the TA has to edit your files, including your Makefile, you will lose points.


Due date

This program is due before class on Friday, October 15th. This means it must be received by 9:59am EDT on Friday to not be considered late.

Additional Instructions

Interaction

To manipulate the man, you should use the following interaction technique (make sure the colors you choose for the parts are different from the two colors used for the interaction):

  1. As the user moves the mouse over the man, the piece under the mouse changes to a color (such as yellow) indicating which piece would be selected
  2. Clicking on a piece and holding down the mouse button selects it.
    • The color of the part should be changed to another colors (such as green) indicating that it is selected
    • A line should be drawn out of the origin of the part, showing the axis that is being rotated about. Make sure it is big enough to see.
  3. Moving the mouse left and right with the button held down rotates the object. Be careful to rotate the object an amount proportional to the distance of the mouse (in the x direction) from the place where the user clicked. The relationship between the distance in x and the amount of rotation should be chosen to allow the piece to rotate at a "reasonable" rate.
  4. Releasing the mouse leaves the part in the last rotation position.

Transformations per object

You will need to store three sets of transformations for each part:

  • The scale and translation needed to change the sphere from it's default position and size to the shape and and position appropriate for that body part
  • The position and orientation relative to its parents coordinate system
  • The current angle of rotation of the join (this will be changed by the interaction described above).

Debug Mode

The debug mode in this assignment is simple. When it is turned on or off, you should print to standard output a description of the transformations you would issue (each of the three kinds above, per object) to redraw the screen. When the user is rotating a part in debug mode, you should print the mouse starting location (where the user clicked), the current location of the mouse, the difference in the x direction, the computed angle of rotation.

Basic Submission

At a minimum, your program should create a window and create a blobby man in a standing position (50% of the grade). The interaction with the mouse is required for the remaining 50%.


EXTRA CREDIT

Extra credit will be give for doing the following things. You may implement one or both of the following options, each of which may be worth an additional 10% (depending on how well they are implemented).

All extra credit programs should be contained in separate source files, and your makefile should create additional executable programs for each. (ie. your submission must still contain an implementation of the basic program that perfoms as described above.)

  1. Better joint angle rotation. As defined above, you can rotate the parts freely through 360 degrees, and only have one degree of rotation. In reality, the parts should be able to rotate a limited amount. Furthermore, most joints can rotate around more than one axis (actually, all of them except the knee and elbow).
    Therefore, you should select rotational limits and ensure the user does not exceed them, and use the y position of the mouse to rotate around a second axis of rotation.

  2. Make your man a little more coordinated. Ok, not really. But, he must now balance a long rod with a ball on the top end in each hand (model them as long thin red cylinders with a ball on the top, and make them big enough that the ball is just above the height of the mans head when he is standing upright). You should not be able to select or rotate these objects. The rods should always be upright in world coordinates, no matter how the rest of the arm holding it is oriented, and the bottom of them should always be in the middle of the appropriate hand.
    • Left rod. This rod should have a green ball on the top. This one must be modelled as a child of the hand in the hierarchy.
    • Right rod. This rod should have a blue ball on the top. This one must be modelled in world coordinates, not as a child of any part of the man.