The goal of this homework is to work with matrices. You are going to replace the MODELVIEW_MATRIX and PROJECTION_MATRIX stack with matrix stacks of your own. You will then transform each point on each triangle by the top matrix in each stack. The projection matrix will be applied followed by the viewport conversion. The easiest way to accomplish this is to project the vertices in the mglVertex method, and store the projected vertex on the vertex stack. Nothing else associated with drawing triangles should have to be changed.
The end result will be a set of 2D points projected from the original 3D object vertices. These points will then be drawn onto the screen using the provided image class. Draw the vertices as single pixels: they should show up as dots in the right places (seeing the ball bounce will allow you to see if the points are in the right place). Make sure the rotations and translations have the correct effect on the points.
You will need to augment the provided matrix class to construct arbitrary scale, rotate and translate matrices (the translate is provided as an example). It is advisable for you to use the STL wherever possible (the stack, perhaps).
Use the provided image class to store the colors. The draw method in the image class can be used to place the image on the screen. Please make sure you call the routine for drawing the image as appropriate.
Requirements:
HINT: You will need to record and check which matrix mode you are in for each operation (except VIEWPORT)!
HINT: You can determine if your matrices are correct by using the glGet routines to get matrix values constructed by openGL. The values should be approximately the same as yours. Once you have check make sure you remove the openGL calls.
HINT: You can determine if your matrices are correct by using the glGet routines to get matrix values constructed by openGL. The values should be approximately the same as yours.
HINT: You can use gluProject to project triangle vertices to the image point. The results should be similar to what you get using your projection code.
HINT: Make sure you clear the image when glClearBuffer is called. For some reason the real openGL glClearBuffer must be called. If this is not called, the program will core dump (I do not understand this bug, but it is annoying).
The homework is due at the start of class on Friday.
Use the code from the previous assignment. Develop supplementary classes to help with the current task. Make sure to use the Matrix class.
You will submit a tar file containing all of the source code, a Makefile and a README file. The source code must compile (and run) on a CCC machine. Feel free to develop on any platform you like, just make sure things run on CCC before submitting. The program should compile when make is invoked on the command line in the directory with your code. Submissions which do not compile when make is typed, or do not run successfully, will not be graded and given 0 points.
The README file should contain an extensive description of what you are handing in, the layout of your code (what you have changed, what files you are submitting, and a discussion of the overall algorithm). This README file will count towards your grade. Submissions without a README or submissions with a worthless README will not be graded and given 0 points.
Submittal will be made using the turnin program. Here are the commands (on ccc) you will use for a submittal:
Each homework assignment is graded on a 10 point scale (this is 10 points towards your final grade). 6 points will be graded for functionality: the program does what the assignment requests. 2 points will be based on documentation in the README, and 2 points will be based on the quality of your design and coding style (use STL to assist you in this).
You will loose 1.5 points for handing the assignment in late. The late period for each hw is always until the start of class on the following Monday. Any assignment not handed in by Monday is a zero.
Since a grade of 0 will be given if the code does not compile and run, it is in your best interest not to submit anything until you have completely tested and evaluated what you have written.