CMSC 435/634: Introduction to Computer Graphics

Assignment 3
Modeling (opt/grad)
Due October 4, 2002


This assignment is required for students taking 634. Students taking 435 who choose to do the assignment can earn a maximum of 30 points extra credit.


Spline patches are a common modeling tool. Many modeling packages provide a flexible means to design objects out of a collection of patches, producing patch control points which must be used by a renderer to render. For this assignment, we will be that renderer.

Once again, I have provided some OpenGL code to get you started. This code, in ~olano/public/cs435/assn3, may look familiar as it is based on the polygons.c file I provided for Assignment 2. The sample code for this assignment adds the following features:

The Assignment

You will read patch control points for a set of bicubic patches from a file. You will subdivide into some number of smaller patches, with the degree of subdivision under keyboard control (Use '+' or '=' to increase the subdivision and '-' or '_' to decrease the subdivision). You'll then draw the subdivide patch mesh using four triangles per patch, with each triangle connecting two corner control points to a common center point. You should draw each triangle in a random color.

Patch file

The patch file will has the following format: Blank lines or lines starting with '#' should be ignored. Each remaining line will have four 3D control point coordinate (12 numbers). A full bicubic patch will have sixteen control point lines in the following order
 0  1  2  3
 4  5  6  7
 8  9 10 11
12 13 14 15
The sample patch file is for the Utah or Newell teapot, a classic test model in computer graphics.


Two examples of
how a patch might be split into triangles We could use two triangles to connect the four corners of each patch for final drawing (and it is often done this way). However, since we are not basing our level of subdivision on either size or flatness, we will sometimes get strange folds on saddle shaped patches. By adding a vertex at patch coordinates (.5,.5) (which happens to be one corner from the next level of subdivision), we'll have a slightly better appearance for these patches.

Random colors

Completely random colors may include black or dark colors that will be difficult to see against the black window background. Avoid colors where red+green+blue < 0.25. Any method you use to limit the color selection is fine. Here are three suggestions:

What to turn in

Turn in this assignment electronically as 'cs435 Proj3' using the submit mechanism:
    submit cs435 Proj3 [files...]
If submitting after the due date, submit as Proj3late. In either case, you should all files that you created or modified. We should be able to copy the submitted files into a clean copy of assn3 and be able to build and run your project. The only way we'll be able to grade this time is to build and run your project. Please make sure it will run on or (and let us know which to use).

We will be looking at your source code, so please try to make it understandable and comment anything you want to make sure we notice. 'This is what I'm doing' comments are more useful for my understanding than comments like 'add x to y'As always, additional comments may help your grade in cases where your program does not operate entirely correctly (since they can give me insight into what you were trying to do). In any case, your programs are expected to be robust and easy to understand.


For anyone looking for more information on OpenGL, the irix machines include all of the OpenGL man pages (you don't have to be sitting at one, you can just 'ssh'). Just try 'man glVertex2f', etc. to find out more about any function used in the assignment that sparks your curiosity. Also, the OpenGL 1.1 Programmers Guide (the "OpenGL red book") is available online. This a good introduction to writing OpenGL programs.

Working at home

If you managed to work from home last time, you're in luck since this project uses the same set of libraries. If not, the usual caveats apply: If it comes down to a choice between the two, remember that your grade is based on a working project, not a successfully installed GLUT library. In the end, the project MUST run over ssh to either or Be sure to test it before you submit.