CS 5600 - Spring 2008

Homework Assignment 7

OpenGL Lighting and Texturing (100 points)

Handed out: March 24, 2008
Due: 11:30am, April 4, 2008

You will write an OpenGL program which lights your robot.  The light should follow the viewer and should be slightly offset from the eye-point.  Think of your hand holding a flashlight and hold your right arm above your head (holding the flashlight).  Now move your arm slightly to the right but still above your head.  That makes a  reasonable lighting position.

1. You will write a program that lights a human-like robot.  The normals at each vertex should be interpolated from the shared faces.  To have this, you will have to draw your own cube.  Using glutSolidCube will give you the wrong normals.  Another way to think about the normals is they should be from the centroid through the vertex.  Think about where to compute the normals (before or after scaling).

2. The robot will be composed of a torso, upper-arms, lower-arms, hands (just  boxes), upper-legs, lower-legs, feet (just boxes).  You should draw cubes where each face is a different color.  Then use scaling and transformations to position those cubes to form the robot.  A non-uniform scaling will give you elongated boxes that look like an arm/leg.  Just like the last assignment except that you have to deal with normals.

3. The lighting should be a white light at full intensity. 

4. Provide a 'reset' which returns the robot to the initial position by typing the 'r' key.

5. After typing the 'q' key, the lighting should be flat-shading.

6. After typing the 'w' key, the lighting should be smooth shading.

7. Make the robot an interesting material with 'glowing' hands and feet.

8. You should texture map the torso with the provided texture and you should texture map a photo of you to the head (use your digital camera or phone to get the photo and gimp to convert it into a suitable format).

9. You should draw the result into a 512x512 window.

10. You must turn in documentation in the form of a webpage as in the other assignments.

11. You must use perspective projection for this assignment (like the last assignment).

12. To read/write ppm files, use the glm.h and the glm.c header/code (thanks to Nate Robins again!).

Output

The program should draw its output to an OpenGL window of size 512x512 as in the example program.

Submission

use the handin routine in the CADE Lab. You can with zip or tar your solution. You should comment your code appropriately and hand in a web-page that will serve as complete documentation. Please include a paragraph of difficulties and a paragraph of what you learned in this assignment.

The handin name for this lab is "lab7".

Windows users should use the Zip utility and handin a single zipped file. Unix users should use the tar program to do the same. We will recompile the programs to grade them. Make sure your workspace/program will compile for us. That is, be careful about your user-specific pathname variables! If you do this on a home machine, please allow sufficient time for porting to the CADE machines. We will grade based on compiling and running on the CADE machines.

Due to a bug in the handin program, do not include spaces in the names of the files that you submit, otherwise we will not receive them. For instance, "no spaces.txt" is not a valid filename and would not be received, while "no_spaces.txt" is valid. Please keep this in mind while handing in your assignment.