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).
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.
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);
Rasterizer3D
class so you should probably make a copy in a new directory/folder.
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.
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.
teapot.txt
and fighter.txt
data files
from programming assignment 7. The resulting
images should look something like the following:
.pdf
files containing the images generated
by your implementation using Canvas.
Copyright 2020