Overview
In this project you will implement the midpoint line drawing algorithm
to rasterize line segments, and also a simple method for scan
converting triangles and using barycentric coordinates to interpolate
colors. Both algorithms are described in our textbook,
Fundamentals of
Computer Graphics.
You are given support code for this project and will need to
- install the jot library
(see below),
- copy the project support code and edit the makefile to indicate jot
installation information, and
- implement the missing functionality.
Jot
The support code is based on
jot, a
collection of C++ libraries that
support 3D graphics applications.
jot was
developed at Brown
University, Princeton University, and the University of Michigan, runs
on Mac OS X, Windows and Linux, and
has been used in a number of research projects, including
WYSIWYG NPR.
Your first step will be to get the
jot source
code and compile it. For
instructions,
click here.
Support Code
Next, copy the project support
code to your local machine:
% scp -r red.engin.umich.edu:/afs/engin.umich.edu/class/perm/eecs487/proj1 .
The C++ source code file
p1.C
contains this support code. Read through this file to get
familiar with it, then implement the following missing functionality:
Lines:
- Render mesh edges as 1-pixel wide white lines using the midpoint
line
drawing algorithm described in the textbook (Fundamentals of Computer
Graphics, 2nd Edition, Section 3.5: Line Drawing). The image of the cow
on the left above is an example of this type of rendering (known as
"wireframe"). 20 points.
- Extend the algorithm to handle the case that colors are stored at
mesh vertices. In that case, interpolate colors smoothly along the line
segment. We suggest you use an incremental method. (See Section 3.5). 10 points.
- Add functionality for clipping the lines before scan converting
them. The goal is to discard any line segment that lies entirely
outside the window, and trim line segments that lie partially outside
the window, leaving only the parts that are inside the window. This can
greatly speed rendering for some viewpoints. 10 points.
Triangles:
- Implement the algorithm described in the text (section 3.5) for
scan converting triangles and using barycentric coordinates to
interpolate colors assigned to mesh vertices. 25 points.
- If the mesh does not have colors assigned to its vertices,
compute a single color for the whole triangle using a simple
shading calculation: construct a greyscale color value from the dot
product of the triangle normal and
the vector from the camera to the triangle centroid (both unit
vectors). 15 points.
Transparency:
- Add the ability to toggle between opaque and semi-transparent
lines and
triangles. When semi-transparent mode is on, blend the computed color
with the color already stored at that pixel in the image, using a blend
factor of 0.5. 10 points.
Code quality:
- Comment your code reasonably, particularly your design decisions
and choice of approach.
- Modularize your code: use a suitable number helper functions with
descriptive names.
- Use descriptive variable and function names: apply a suitable
tradeoff between symbol-length and descriptiveness.
Bottom line: Make your code readable!
10 points
Modifying the code:
Implementation of the missing functionality must
begin within bodies of
two functions with the following prototypes:
void
scan_convert_faces(CGELlist& gels, RefImage& img, double
opacity);
void
scan_convert_edges(CGELlist& gels, RefImage& img, double
opacity);
You will find these prototypes at the top of
p1.C and skeletal
definitions somewhere within
p1.C.
You starting points are marked with
the comment:
//
YOUR CODE HERE
Declare and define helper functions as you see fit.
Building and running the
code:
Edit the provided Makefile to define the path to your jot directory.
Then you should be able to compile the program, as follows:
% cd proj1
% make
This results in an executable named
p1 which takes a model file as
a
command-line argument, for example:
% p1 models/house.sm
A number of models are provided for you
to run your code on. Model files are located in the
proj1/models directory and have
.sm extensions. When you
run your code, with the cursor in the rendering window,
press key 'g' to toggle between OpenGL rendering (built into the
support code) and your scan
conversion code. Since your code is not yet written, you will
initially toggle between seeing the model (rendered in OpenGL), and
not seeing it.
Handing in
Turn in two files: your version of
p1.C, and a brief write-up in
text
format that discusses:
- anything about your
implementation that is noteworthy (e.g., your method for clipping
lines, or for interpolating
colors along line segments), and
- feedback on
this assignment, including suggestions for how it should be changed
next time.
Specific instructions for how to turn
in your work:
Use the
submit487
script to submit your files as follows from any CAEN linux machine:
%
/afs/engin.umich.edu/class/f05/eecs487/submit487 1 p1.C writeup.txt
- The first argument is the project number and must be 1 for this
project.
- The other two arguments are the names of the files you are
submitting:
- in any order,
- the writeup need not be named writeup.txt
- the writeup must be a text file (i.e. should be readable using
notepad, vi, emacs etc)
- You will receive a confirmation later. (not necessarily
immediately)
- The script depends on a few utilities like shar, basename
and mail.
These are definitely present on red.engin.umich.edu. Try this host if a
bunch of other hosts fail.
Important: Do not
attempt to copy this script to your directory and/or modify it in any
way. Violations are easily detectable and
will be dealt with severely.
Contact the GSI should anything come up.
Multiple
submissions:
- You are allowed to make a maximum of two submissions.
- In case you submit two or more times, only the second (never the
first) will be considered.
- Penalties apply depending on the number of submissions exceeding
two.
- The submission script does not
count your submissions!
Due date
The project is due on September 26, 2005, by 11:59pm. Turning it in 48
hours earlier is worth a 4% bonus; turning it in 24 hours early is
worth a 2% bonus.
Last updated: 23 Sep 2005