EECS 487 Winter 2007

Project 1: Scan Conversion

wireframe cow colored cow
Fig. 1. A scan converted cow. Left: wireframe (no colors). Right: filled triangles (using vertex colors).


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
  1. plan to use the jot library provided for you on CAEN space, or else install jot on your machine;
  2. copy the project support code and edit the Makefile to indicate jot installation information; and
  3. 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 Linux, Windows, and Mac OS X, and has been used in a number of research projects. Your first step will be to get the jot source code and compile it, unless you plan to use the compiled version of jot provided on CAEN space. For instructions on getting and compiling jot, click here.

For this and subsequent projects, you will need to become familiar with some jot classes. Reading relevant header files is a good way to do this. Some jot documentation is also available via web pages created automatically by doxygen. In this project, you will primarily be concerned with the PIXEL and VEXEL classes in jot's math library (called mlib). These classes represent points and vectors, respectively, in 2D "pixel coordinates". Useful information about using jot code in this project is contained in the source file jot-tops.C inside the proj1 directory (see below).

Support Code

Next, copy the project support code to your local machine.  (On windows, you can execute the following commands using cygwin, which we recommend):
  % scp -r red.engin.umich.edu:/afs/engin.umich.edu/class/perm/eecs487/proj1 .
(Note the 'dot' at the end of line.) The above command overwrites all proj1 files, including any files that you may have made changes to. To copy 'old' versions of files while leaving the new untouched (sync-ing operation):
  % rsync -avz red.engin.umich.edu:/afs/engin.umich.edu/class/perm/eecs487/proj1 .
(Do this from the parent directory containing the proj1 subdirectory.)

The C++ source code file p1.C contains this support code. It defines a jot application that loads a 3D model from the command line, then renders the model either using OpenGL (that part is already implemented) or else using scan conversion code that you will write. The application understands several commands entered by pressing keys: 'g' to toggle between OpenGL rendering and your code, 'w' to toggle between wrireframe and filled triangles (in your code), and 't' to toggle between semi-transparent and opaque mode (in your code). The handling of the key commands is already implemented. You just need to write the scan conversion code, including support for lines, filled triangles (with or without colors assigned to the vertices), and support for both opaque and transparent rendering. Read through this file to get familiar with it, then implement the following missing functionality:

Lines:
Triangles:
Transparency:
Code quality:
  1. Comment your code reasonably, particularly your design decisions and choice of approach.
  2. Modularize your code: use a suitable number of helper functions with descriptive names.
  3. 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 later 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:

The support code comes with a README file that explains how to compile and run the project on Windows, Linux, or Mac OS X.

Once you compile, you can run the executable, named p1, which takes a model file as a command-line argument. For example:

  % p1 models/house.sm

On Windows you can use a DOS or cygwin shell to execute the above command.

Several models are provided for you. Model files are located in the proj1/models directory and have .sm extensions.

When you run p1, if you place the cursor in the rendering window and press key 'g', you can 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 not seeing the model and seeing it rendered in OpenGL. Press the 'H' key to see other key commands available in project 1.

Handing in

Turn in two files: your version of p1.C, and a brief write-up in text format that discusses:
  1. anything about your implementation that is noteworthy (e.g., your method for clipping lines, or for interpolating colors along line segments), and
  2. feedback on this assignment, including suggestions for how it should be changed next time.
  3. name your file writeup-<uniqname>.txt . Example: I'd name my writeup file writeup-rmanoj.txt
  • Copy your code, write-up and any other supporting files (Makefiles or Visual Studio project files etc) to the following directory on IFS:
            /afs/umich.edu/class/eecs487/w07/submit/<uniqname>/p1/

This path is accessible from any machine you've logged into using your ITCS (umich.edu) password. Report problems to ITCS.
  • The timestamp on your key files (p1.C and your writeup) will indicate the time of submission and if this is past the deadline your submission will be considered late. Therefore, you are allowed multiple 'submissions' as long as you respect the deadline.
  • Test the compilation: Your submission must compile without errors and warnings (except those from external libraries like OpenGL, JOT etc.) on CAEN Linux or Windows machines. Mention the platform in your writeup. Code that doesn't compile will be heavily penalized.
Due date

The project is due on January 25, 2007, 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: January 10, 2007