Matrix and Vector classes/templates
  from programming assignment 2 
  and your 2-D rasterizer from 
  programming assignment 3
  in a rudimentary 3-D rasterizer. Specifically, you must write 
  some utility functions for working with triangular meshes
  and a Rasterizer3D class that can render wireframes.
  
  This assignment is about 3-D computer graphics. The only new 
  aspect of C++ that you need to use is a list.
  
#include them
  from the appropriate directory/folder.
  struct that encapsulates a triangle
  has already been created for you. It should be self-explanatory.
    Triangle ( Header )
meshUtilities and 
  Rasterizer3D class are available on-line:
    meshUtilities ( Header , Implementation )
Rasterizer3D ( Header )
Rasterizer3D object will need to construct and
          use (and then destruct) a Rasterizer2D object.
          drawTriangle method in the Rasterizer2D
          class must be passed a 2x3 matrix. The triangular mesh contains
          4x3 triangles. So, they will need to be pre-multiplied by a
          2x4 matrix before being passed. (You should be able to figure
          out what the 2x4 matrix must look like.)
          The output from these tests should look like the following (when not rotated):
Your driver should be something like the following:
#define PI 3.14159265358979323846
Color             GRAY  = {102,102,102};
Color             WHITE = {255,255,255};
Color             YELLOW = {255,255,0};   
int               view;
list<Triangle*>   triangles;
Rasterizer3D*     rasterizer;   
int main(int argc, char* argv[])
{
   FrameBuffer*      frameBuffer;
   GraphicsWindow*   window;
   int               depth, height, width;   
   view = 0;
   
   width  = 801;   
   height = 801;
   depth  = 801;   
   
   window      = new GraphicsWindow(width, height);
   frameBuffer = window->getFrameBuffer();
   rasterizer = new Rasterizer3D(frameBuffer);
   // Read and scale the triangular mesh
   // (In an IDE you may need to hard-code the path to the file)
   if (argc == 1) read("teapot.txt", triangles);
   else           read(argv[1],      triangles);
   scaleAndTranslate(triangles, width, height, depth);
   // Setup the rasterizer
   rasterizer->useTrimetricView(-view*(PI/4.0),0.0);
   rasterizer->clear(GRAY);   
   // Draw the triangles
   rasterizer->draw(triangles);
   frameBuffer->show();
   
   
   // Delete the triangles pointed to by the elements of the list
   for (list<Triangle*>::iterator i=triangles.begin(); i!=triangles.end(); i++)
   {
      delete (*i);      
   }
   
   delete rasterizer;   
   delete window; // The window will delete the FrameBuffer
}
  
Remember to test different projections and different rotations.
Copyright 2014