Assignment #4 -- Parametric Surfaces
Due Date
This assignment is due at 11:59pm on Friday, April 21st. 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 actuall 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. 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.
- Write the resulting polygons out as an Obj or Inventor file.
Your Program
Your program will take three command line arguments with a fourth
option parameter. These are: the input file name, the output tile
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 outputfile.obj 0.1 -a
The inputfile 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.
You must implement the ability to write out Obj files. (Recall that
Obj is the format you have already worked with.) If you also
implement Inventor output then the format for the output file should
be determined automatically based on the filename extension.
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
this or this.
You can see the shape of the example files by looking at this or this
Inventor files. (See below for information on Inventor.)
The point files are this or this
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".
Obj output is required regardless of Inventor support. I recommend
that you implement Obj output and verify that your code works well
before spending time on Inventor.
The inventor files have been placed in the class home directory under the file
Inventor. This file contains four subdirectories: Mac, Win, Samples, and
inventor. Mac contains precompiled libraries and ivview for the Macs, Win
contains precompiled libraries and ivview for Windows, Samples contains sample
inventor files, and inventor contains the source distribution. Furthermore, a
Windows source distribution can be downloaded from Coin3d.
The inventor files can be accessed
For windows:
by mounting:
mamba/cs184/Inventor
(right click on "My Network Places" under the start menu, then select "Map Network Drive")
For Macs:
by cd'ing to ~cs184/Inventor.
Sample inventor files:
You will also find several sample inventor files to help illustrate the inventor format the simplest of which is probably tetSmall.iv
to run simply type:
ivview someFile.iv
at the prompt.
For Windows and Mac make sure the .dll's are in the same file as the ivview
executable.
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.
Test Files
Here are additional test files: test2.iv or
teapot2.iv.
Questions should be posted to the news group