Assignment #4 -- Parametric Surfaces
Due Date
This assignment is due at 11:59pm on Friday, November 10th.
Projects turned in late will lose points as described in the policies
handout. This assignment should be done alone or in pairs. You may
share ideas with other groups, but you may not share code.
SUBMISSION DETAILS
You may develop on Unix, OS X, or Windows. The platform you
use will be the one used to grade assignments. Keep in mind that
there are slight variations due to OS versions, different libraries,
and other factors, so you should verify that your code runs on the
instructional machines appropriate for you plat form choice.
As with the last assignment, we will be using Prof. Hilfinger's
submit software for submission of this assignment.
You should include a README file that at the
minimum contains the following data:
-
Your (and your partner's) name,
-
The platform your code runs on,
-
The location of your source code (i.e. indicate who in your group has
done the submission, and on what platform). So only one of you in your
group needs to submit the actual code.
- Any example input files you have created. These files should be
mentioned in the README file.
All files needed to compile your code should appear in the
submitted directory. It is your
responsibility to make sure that they will compile and run properly.
You will also need to set the permissions properly.
Windows: The grader should be able to recompile your program by
simply opening the project and rebuilding it from scratch.
Unix and OS X: The grader should be able to recompile
your program simply by typing "make".
Check the news group regularly for updates on the assignment or
other clarification. We will assume that anything posted there is
henceforth known to all.
Overview
For this assignment you will write a program that will convert input
from a Bezier surface representation to a polygonal representation and
then display it with OpenGL. To do this, your program should:
- Read in a list of patch data from a file.
- Subdivide the patch using either a uniform or adaptive subdivision technique.
- Open a window and use OpenGL to Render the object.
- When "s" is pressed the program will toggle between flat and smooth shading.
- When the arrow keys are pressed the object will be rotated
-
- When launched the initial zoom will show the entire object. Pressing the +/- keys will zoom in/out.
Your Program
Your program will take two command line arguments with a third option
parameter. These are: the input file name, the subdivision parameter,
and a flag which determines if subdivision should be adaptive or
uniform. An example command would look like:
% myprogram3 inputfile.bez 0.1 -a
The input file contains a list of patches. The subdivision parameter
should be interpreted as the step size in U and V for uniform
subdivision, or as an error measure for adaptive subdivision. If the
-a is present, then adaptive subdivision should be used, otherwise
uniform.
The Input File
The input file contains the control points for the patches and an
output file name. Keep in mind that the control points are vectors,
not scalars! An example file would look like
arch or teapot.
You can see the shape of the example files by looking at arch or teapot
Inventor files. (See below for information on Inventor.)
Conversion and Subdivision
For uniform subdivision, quadrilateral polygons should be formed by
taking subdivision parameter sized steps in the U and V
direction.
For adaptive subdivision, the error between the actual surface and the
quadrilateral polygon should be less than subdivision
parameter. The error should be distance evaluated at the midpoints
of the quadrilateral edges and the center of each
quadrilateral1. Techniques to avoid cracking should be used in the
adaptive subdivision code. You may prefer to use a subdivision
technique that yields triangles. If you do then the error should be
checked at the center of each triangle edge.
Inventor
The use of Inventor for this assignment is optional and will be worth
some small amount of bonus points. The TAs have compiled a viewer
program, ivview, that can be used to view inventor files. (See news
group posting for information.) You may write Inventor files by
either using the Inventor API or simply writing your own output
routines. Inventor is not supported on instructional machines, so
compiling and linking against Inventor libraries should be "fun".
There is a free version of inventor from Coin3D that you can install
on your own machines.
If you implement optional Inventor output then your program should
accept an optional command line argument that comes after the required
ones. This is -o and a file name. If the -o option is given then no
OpenGL window should be opened and instead the model should be written
to the specified output file name.
More Optional
If you like, you may use Maya (or some other program) to create
additional input files. Maya can be used to create B-Spline surfaces
that can be exported to files. Figure out how to get data out of Maya
and converted to the format expected by your program.
Questions should be posted to the news group