For updates see Addendum at the bottom of the page.
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.
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:
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.
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.
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.