CSE 167 - Introduction
to Computer Graphics - Fall 2003
Instructor: Sam Buss, Univ. of California, San Diego
Project #2 - Modify a program that draws two cubes to use triangle fans and quad strips.
Due Date: Thursday, October 30, midnight.
CORRECTED ASSIGNMENT: You should use triangle fans, not triangle strips. The first posted version of the assignment erroneously said "triangle strips", but should have said "triangle fans". (My apologies! If you already coded it with triangle strips, please come talk to me about it.)
Goals: Gain some basic familiarity with triangle fans and quad-strips. Learn how to make a quadrilateral solid color and how to shade colors smoothly. This is a "mini" assignment that will count towards your course grade somewhat less than the rest of the assignments. Most of you should be able to complete it in one to three hours total time.
What to hand in: Make a directory called
TwoCubes in your CSE 167 home directory. (The CSE 167 home directory on
ieng9, under Class Resources, not your "My Documents"
file modification dates will serve as a time stamp so we will know files have
been turned in on time. Please in that directory, all your source
files and project files (including .dsp and .dsw files).
Grading will be personalized and one-on-one with a TA or with Sam Buss. Your program must run on the PC lab, you must come into the PC lab and meet one of us. You will have to show your source code, run the program, possibly make changes on the spot to your program and recompile as requested by the grader, and be able to explain how your program works and why it renders what it does. Your files should be complete and project must recompile in the ieng9 directory. You will then come see a TA to get your work graded. This grading MUST be done by Thursday, November 6, and we prefer that it be done earlier. If too many people procrastinate on getting graded, not everyone will have time to be graded!
FOR THIS PROJECT #2, DO THE FOLLOWING STEPS #1 - #7.
1. Downloading files for Project #1. Download the TwoCubes program from the zip file Fall03TwoCubesProjectTwo.zip. Extract these into a directory named TwoCubes in your home directory. If you have problems downloading this zip file, you may instead copy the TwoCubes folder from the CSE 167 public directory on ieng9.
2. Experiment with how the program works.
The arrow keys (left, right, up down) control the view position. The "w" key toggles wire-frame mode. Examine the code and understand how these work. (Optional: if the rate of movement is too slow, press "R" to make them faster. If it is too slow, press "r" to make the rate slower.
The cube on the left is smooth shaded, (GL_SMOOTH option). The cube on the right is flat-shaded (GL_FLAT option). Both cubes are drawn as six quadrilaterals. Examine the code to understand the commands that control the shading (flat or smooth) and understand how the cubes are specified.
Find every place in the code where glutPostRedisplay is called. Understand why is it called in these places.
3. Re-write the code for the cube on the right. In place of the code given for the cube on the right, write a new version of the code that generates exactly the same image but uses triangle fans (GL_TRIANGLE_FAN) instead of quadrilaterals. Your new cube should look identical (in non-wire-frame mode) to the cube shown in the original version of TwoCubes. You may use either four triangle fans or two triangle fans to generate the whole cube (you should not use six or eight, however).
4. Re-write the code for the cube on the left. In place of the code given for the cube on the right, write a new version of the code that generates exactly the same image but uses quad strips (GL_QUAD_STRIP) instead of quadrilaterals. Your new cube should look identical (in non-wire-frame mode) to the cube shown in the original version of TwoCubes.
5. Be sure that all faces of the cube are facing the correct direction. It is recommended that you be careful about specifying vertices in the right order. You may *not* disable the back face culling that is used in the supplied code! There should not be any holes in your cubes.
6. Understand the difference between flat and smooth shading. Be able to discuss the differences with the TA grading your program, and to explain how the shading is caused by the source code.
7. Examine carefully the way the program works in wire frame mode. Do you notice anything unusual as the cubes are rotated in wire frame mode? Are there any artifacts due to aliasing? Can you see any z-fighting? If you have trouble seeing aliasing problems, try slowing down the motion by pressing "r" a few times, then hold down arrow in key and watch the edges of the cubes. Try this in both wire-frame mode and non-wire-frame mode. Be ready to discuss what you see with your TA when you are being graded. (These phenomena may be different on different machines! There is a tendency for OpenGL implementations of lines and of wire-frame mode to have small bugs.)
Grading: On a scale of 1-8 again.