JMU CS488 - Computer Graphics Applications
Help Policies Solutions Study-Aids Syllabus Tools
Programming Assignment 8


1 Overview

For this assignment you must improve your 3-D rasterizer from programming assignment 7. Specifically, you must add the ability to fill triangles (accounting for hidden lines/surfaces). This will require you to write ZBuffer class.

This assignment is about 3-D computer graphics. The only new aspects of C++ that you will use are virtual methods and pure virtual methods (and you will only use them in classes that have been provided to you).

2 Existing Classes

In the next assignment, we will use a Colorizer to determine the color of a pixel given information about the colors of the vertices. For this assignment, we will use one color for all of the pixels in the face. However, so that we won't have to modify the code in the future, we will use a Colorizer in this assignment. To that end, an abstract Colorizer class and a concrete DefaultColorizer class have already been written. They should be self-explanatory.

The default colorizer will be used to calculate the color used in any call to the Rasterizer2D object's drawPoint() method.

3 Detailed Specification

The specifications for the classes in this assignment are available in "documentation format". That is, you are being provided with the documentation for the classes, and your implementation must conform to the documentation.

In addition, your Rasterizer3D class must now have the following constructor:

   /**
    * Explicit Value Constructor
    *
    * @param fb        The FrameBuffer containing the pixels
    * @param colorizer The Colorizer to use to calculate the Color of a pixel
    */
    Rasterizer3D(FrameBuffer* fb, Colorizer* colorizer);    
  

the following new private method:

   /**
    * Fill a single triangle (i.e., face of a triangular mesh)
    *
    * Note: The vertices are 3D in homogeneous coordinates so have four
    * components. They have not been projected so the z-values are available.
    * 
    * @param triangle   A pointer to the Triangle to fill
    */
   void fillTriangle(Triangle* triangle);
  

and the following new public method:

    /**
     * Fill the given "triangular mesh"
     *
     * @param triangles   The "triangular mesh"
     */
    void fill(list<Triangle*> triangles);
  

4 A Development Strategy

You will have to make changes to your Rasterizer3D class so you should probably make a copy in a new directory/folder.

5 Hints

The following hints may help you complete this assignment.
  1. Though it wasn't required, you may have implemented the scanlineFillTriangle() method in the Rasterizer2D class for PA6. If so, you should copy that code into the fillTriangle() method in the Rasterizer3D and make the necessary changes there. It's too difficult to have the fillTriangle() method in the Rasterizer3D call the scanlineFillTriangle() method in the Rasterizer2D. Don't worry about having duplicate code.
  2. If, after struggling for a significant amount of time, you are unable to correctly implement the fillTriangle() method, let me know and I will send you an implementation without \(z\)-buffering.

Of course, you should feel free to ask any other questions you may have.

6 Integration Testing

You must perform integration testing using the teapot.txt and fighter.txt data files from programming assignment 7. The resulting images should look something like the following:
teapot.png
fighter.png

7 Submission

You must submit .pdf files containing the images generated by your implementation using Canvas.

8 Grading

Points will be awarded based on the correctness of the images generated by your implementation.

Copyright 2020