Project 5: Subdivision Surfaces
Due: May 1,
11:59pm, 2006
Objective
This project is about smooth surface creation using the Loop
subdivision technique. You will write a program that reads in a polyhedral model
and subdivides it a specified number of times. Your program will then rotate two
models on the screen: the original flat-shaded model and the subdivided
smooth-shaded surface.
Program Specifics
Your program should accept two command-line arguments:
- Filename The name of the file (with suffix .ply) that contains the
polyhedral model's description.
- Subdivide Number This specifies how many times the model should be
subdivided using Loop's scheme.
After your program has read in the
model, it should first pop up an OpenGL window and show a slowly rotating
version of the original model. This original model should be flat-shaded so that
the polygons can be seen individually. Then the subdivided model should be
slowly rotated around, and it should be smooth-shaded, which requires per-vertex
normal calculations. Each of these two models should be put through 360 degrees
of rotation so that all sides can be seen.
Polyhedral File Format
The file format we will use for this project is a
simple text format. The first two lines specify the number of vertices and faces
of the model, respectively. Then all of the vertex (x,y,z) values are listed,
one per line. This is followed by the list of faces, one face per line. The
first number that describes a face is simply the number of sides of that face,
and for this project, that number will always be 3. Following this, indices into
the vertex list are given. The vertices are indexed starting from the value
zero.
We have provided several models here model.zip.
Look at these files to see the exact file specification.
Suggested Approach
First, write a program to read in the .ply file
format into your own polyhedral model data structure. Next, use calls to OpenGL
and GLUT to display this model. You can then write the code needed to calculate
surface normals at the vertices of a model. Finally, write a routine that takes
a given model and subdivides it using Loop subdivision. The key to this program
is deciding on a polyhedral representation that will allow the subdivision and
the surface normal calculations to be done with relative ease. The "corners"
representation and the "vertices, faces, and pointers" representation are two
good possible choices.
Authorship Rules
The code that you turn in must be entirely your own.
You are allowed to talk to other members of the class and to the instructor and
the TA about high-level questions about the assignment. It is also fine to seek
the help of others for general C programming questions. You may not, however,
use code that anyone other than yourself has written. Code that is explicitly
not allowed includes code taken from the Web, from books, or
from any source other than yourself. You should not show your code to other
students. If you need help with the assignment, seek the help of the instructor
or the TA.