Assignment 3: Wire Frame Rendering - Due October 21.

For updates see Addendum at the bottom of the page.

Overview

For this assignment, you will extend the object modeling and transformation system you wrote for Assignment #2 so that it renders wire-­‐frame projections of models as viewed from a given camera position. The Input/Output is almost the same as Assignment #2. There are two input files. The first file is an .obj file, in exactly the same format (and with the same semantics) as in Assignment #2. It contains the model. The second file is once again a command file containing geometric transformations. This time, however, there are two additional commands. One command declares a camera. The other tells the system to generate a wire-­‐ frame rendering of the model. In other words, it tells the system to generate an image in which the lines of the model are drawn as projected by the camera. The output of your program is an image in PPM format. Also, unlike in Assignment #2 you must now verify that all polygons are convex, and throw an error if they are not.

Input File Formats

The first input file is the model file, and is exactly the same as in Assignment #2. Its description is still available in Assignment #2 on the class web site; it will not be repeated here. The second input file is the command file. It contains rotate, translate, scale and arbitrary (transformation) commands, exactly as in Assignment #2. This time, however, there are two additional commands:

Camera: c name d vrpx vrpy vrpz vpnx vpny vpnz vupx vupy vupz
Here name is the name of the camera (there could be more than one) and d is the focal length of the camera. vrpx vrpy vrpz specify the 3D coordinates of the view reference point (VRP) of the camera in world coordinates. vpnx vpny vpnz specifies the view plane normal of the camera. You should not assume the vpn is normalized; rescale it to make it a unit vector. Similarly, vupx vupy vupz specifies the view up vector. You should not assume that it is either unit length or perpendicular to the vpn.
Wire-frame: w name minx miny maxx maxy
Here name is the name of a previously declared camera, and minx miny maxx and maxy specify the size and location of the visible part of the image plane. For example w foo -­‐256 -­‐ 256 256 256 would specify a 513x513 image with the optical center in the middle.

Output Format

Last time, the output was an .obj file. This time (and for the remaining assignments), the output is an image in ppm format . PPM is an easy format to write: everything is in ASCII, and many image display programs (including xv and gimp, both of which are available on the department machines) read it. It is not as compact as compressed binary formats, but it is convenient for our purposes.

Here is an example ppm format image:

P3 2 2 256
0 0 0 255 255 255
255 255 255 0 0 0

Every ppm image begins with P3. This tells any reading application to expect an ASCII color image. The next two values (2 and 2 in this example) are the width and height of the image, measured in pixels. The next value (256) tells the system to expect 8-­‐bit pixel values. This value should always be 256 for the purposes of this class.

What remains it to give three values for every pixel. In the example, a 2x2 image has only 4 pixels, which means the system is expecting 4x3 = 12 values. The three values are the red, green and blue color values for a pixel. In this assignment, these values will always be the same, and will always be either 0 (off, i.e. not on a line) or 255 (on a line). However, starting in Assignment #3 you will be providing three distinct values per pixel.

Note that in ppm, the first three values will be displayed as the pixel in the upper left of the image. If the image is w pixels wide, the first w pixels form the top most row of the image, running left to right.

Submission

As with the previous assignment, your work will be turned in as a tar file submitted through RamCT.

The procedure for running your assignments, on a CS Department Linux Machine, will be automated and additional details will be supplied here.

Addendum

As discussed in lecture, it is not necessary to perform 3D clipping in this assignment. It is required that you perform 2D clipping as discussed in lecture.

The use of some simple form of antialiasing is strongly encouraged for this assignment. You will like much better your images if you do this. However, since it was not made a part of the initial assignment requirements, antialiasing is not required.