Introduction to Computer Graphics - Spring 2005
Instructor: Sam Buss, Univ. of California, San Diego
Project #1 - Create two octahedra.
Due Date: Wednesday, April 13 midnight.
Goals: Gain some basic familiarity with triangle fan. Learn how to make a triangles of solid color as well as how to shade colors smoothly.
What to hand in: Make a directory called Octahedra in your
Math 155A home directory (also called the Math 155A
"storage" directory) to hold your turned-in programming
assignment. This folder is under Class
Resources, not your "My Documents" folder. The file modification dates
will serve as a time stamp so we will know files have been turned in on
time. Place all your source files and project
files (including .vcproj and .sln files) inside your
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 home (storage) directory. You will then come see a TA to get your work graded. This grading MUST be done by Wednesday, April 27, 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 #1, DO THE FOLLOWING STEPS #1 - #10. Your main task is to rewrite the program Oct.cpp so that it generates the same images as OctahedraDemo.exe.
1. Downloading files.. Download the Octahedra program from the zip file Spring05OctahedraProject.zip. Extract these into a directory named Octahedra.
2. There is an executable "Octahedra.exe" that shows how your program should end up. Experiment with with this program. Try out the following keyboard commands..
There are two octahedra shown.
The arrow keys (left, right, up down) control the view position. (Optional: if the rate of movement is too slow, press "R" to make it faster. If it is too fast, press "r" to make the rate slower.
The "w" key toggles wire-frame mode.
The shape on the left is smooth shaded, (GL_SMOOTH option). The shape on the right is flat-shaded (GL_FLAT option).
The colors on the top half of the flat shaded octahedron are fully saturated, for example, the red is <1,0,0>, the yellow is <1,1,0>, etc. The colors on the bottom half are at one third intensity, e.g., the red is <0.33,0,0> the yellow is <0.33,0.33,0>, etc.
Similar numeric values are used for colors on the smooth shaded shape. The top vertex is colored white and the bottom vertex black --- on the smooth shaded shape.
3. Find the solution "Octahedra.sln" and open in the C++ compiler. Examine the source code and run this program. This program looks somewhat like the OctahedraDemo.exe. However, it draws cubes instead of the octahedra. When you examine the source, do the following:
Examine the code and understand how the cubes are specified (usings GL_QUADS and as GL_QUAD_STRIP.)
Examine the code to understand the OpenGL commands that control the shading (flat or smooth).
Examine the code to understand the OpenGL commands that turn wire frame mode off and on.
Find every place in the code where glutPostRedisplay is called. Understand why is it called in these places.
Your job is to rewrite Octahedra.cpp so that it is functionally the same as OctahedraDemo.exe.
4. Re-write the code for the shape on the right. In place of the code given for the cube on the right, write code that draws the shape shown in OctahedraDemo. Use two triangle fans to build the shape.
5. Re-write the code for the shape on the left. In place of the code given for the cube on the left, write code that draws the shape shown in OctahedraDemo. Again, you must use two triangle fans.
6. Be sure that all faces of the shapes are facing in the correct outward 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 octahedra. It is OK to use glFrontFace(...) if you want to.
7. 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.
8. Examine carefully the way the program works in wire frame mode. Do you notice anything unusual as the octahedra are rotated in wire frame mode? Are there any artifacts due to aliasing? Can you see any z-fighting? These effects may be very subtle. 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 octahedra. 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.)
9. Turn in the project as described above.
10. Do the written homework on octahedra, due in class on Wednesday, April 13.
Program grading: On a scale of 1-8. Personal grading session with a TA or the professor.