CS 5600 - Spring 2012
Homework Assignment 3
OpenGL Lighting (100 points)
Handed out:
February 20, 2013
Due: 11:59pm, March 20, 2013
This is a
bigger assignment than the previous ones.
Do NOT wait until after Spring Break to start on it!
Read
everything, I tried to be clear in the specification.
You will
write an OpenGL program which renders a lit, animated, dog figure. Try to
make your dog as cute as possible. You should approximate the body, head,
tail, legs, ears, nose, and eyes with spheres (gluSphere). Make a nice looking dog through
transformations. The legs need two
parts: upper and lower leg. You should use hierarchical modeling to
achieve the desired animation effect.
You must use z-buffering to make the eyes, nose, body parts look
correct and connected (hint: think about intersecting spheres.
1. You will write a program that
animates a dog modeled by calls to gluSphere.
quadratic
= gluNewQuadric(); // Create A Pointer To The Quadric Object
gluQuadricNormals(quadratic,
GLU_SMOOTH); // Create Smooth Normals
gluSphere(quadratic,
100.0, 20, 20); // or whatever parameters you want
2. A
non-uniform scaling will give you elongated spheres (dog-body parts).
3. The dog
will walk along the ground from the left side to the right side of the
screen. Draw a colored ground plane for the dog to walk upon.
You will not be graded on the style of the walk; it should just walk as
similar to a dog as you can make it. Hint: use a sin function to
cycle through the walk by rotating joints and translating the dog.
4. Provide a
'reset' which returns the dog to the initial position by typing the 'r'
key.
5. Make the
dog walk faster by repeatedly typing the 'f' key. The reset should not
reset the speed.
6. Make the
dog walk slower by repeatedly typing the 's' key. The reset should not
reset the speed.
7. You should
allow the dog to rotate about its center by typing the 'l' (the L key in
lowercase) to rotate right and 'k' to rotate left. The reset key should not
reset the rotation, just the position of the dog. When the dog rotates, it
should walk in the direction it is rotated. That is, if the dog is rotated
90 degrees to the right, it should walk in the direction of the near-plane.
If the dog rotates 90-degress to the left, it should talk in the direction
of the far plane (away from the viewer)
8. The
lighting should be a white light at full intensity. The ‘c’ key
should toggle between the light following the camera and the light being
fixed in the scene. Initially, and
if you reset, the light should follow the camera. It should be offset slightly from the
camera position though so that you can see shading better. 90 degrees from the camera is too much,
something like 20-25 degrees should be sufficient. Humans are used to light being above the
viewer. I suggest placing the light
above and to the right of the viewer.
9. After
typing the 'q' key, the lighting should be flat-shading.
10. After
typing the 'w' key, the lighting should be smooth shading.
11. Make the
dog an interesting material with 'glowing'
eyes, nose and ears. The main body
should be a chrome material (see the previous link) which is highly specular and use a low
tessellation for the sphere which is the body so that you can see the problems
with fixed function pipeline rendering (Gouraud). You can make the legs
whatever color you’d like. Document
your choices.
12. You must
use perspective projection for this assignment.
13. You must
turn in documentation as in the other assignments.
14. You must
include a virtual trackball to move the camera.
This will provide mouse control to
move the camera around the scene.
Output
The program
should draw its output to an OpenGL window of size 512x512 as in the
example program. You should use a perspective projection in this
assignment. hint: use gluPerspective to set the PROJECTION matrix stack
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 "lab3".
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.