This project is to develop a simple Z-buffer renderer to view 3D models. This will be accomplished by importing a file for a 3D model derived of triangle polygons in a specified file format (below). Sample model files are provided but the progam will work on general files of the specified type.
The program will use Lab 3 as a starter and generalize it to view the model in the file as well as allow basic manipulation as specified below. Use the Z-buffer render algorithm as detailed in class (Lecture 6) to render only the nearest polygon on the scene by storing the depth value in a custom depth data structure. The color of each triangle can be specified at random to allow a visual separation between neighboring triangles.
To be clear, your program cannot use GL functions for polygons or lines (e.g. GL_line) but instead, must draw the image one pixel at a time as was done in lab.
Note, projection can be done simply by dropping the third dimension for each vertex and drawing only the values for the x,y. (FYI, this is a simple orthographic projection.)
Next, the viewer must be able to rotate the model by spinning it about a vertical axis at the center of the model. You will determine this axis from the model file (e.g. average all vertices) To accomplish the rotation, the original 3D vertices must be rotated and then the Z-buffer renderng should be applied to the transformed points.
Finally, to receive full credit you will also need to have your code organized and well-documented, including describing carefully how to control the interaction (e.g. rotation control).
For extra credit, there are two additions to be added. First, you can receive some easy extra credit points by allowing the user to also draw a wireframe of the model by switching modes (wireframe and filled-in) Next, you can also get points for adding the ability to pan (equivalent to translating the model left-right and up-down) and zoom (equivalent in this case to performing a uniform scale on the model so that is grows larger and smaller.) The latter (pan/zoom) is all or nothing. And you should consider what is a good choice for inputs for each part of the functionality (rotate, change mode, etc.) and communicated that clearly in the program.
Point Breakdown:
Load model 20
Render 35
Rotate 35
Code comments/organization 10
Extra credit:
Zoom/pan 10
Wireframe 5
You will turn in the assignment using the standard "turn-in" before midnight on the due date. Late assignments are accepted up to one week late with penalties of 5 pts off per day, and counting the weekend as a single day.
Model file specs and samples
test.txt
4 2
200 200 200
800 200 200
200 500 200
800 500 800
0 1 2
0 3 1
sampletri.txt
4 4
200 200 200
800 200 200
500 500 800
500 200 800
0 1 2
1 3 2
2 3 0
3 1 0
samplehouse.txt
9 16
200 200 200
200 500 200
800 200 200
800 500 200
800 200 800
800 500 800
200 200 800
200 500 800
500 800 500
0 1 2
1 3 2
2 3 0
3 1 0
2 3 4
3 5 4
5 4 6
6 7 5
7 6 0
0 1 7
0 2 4
0 4 6
1 3 8
3 5 8
5 7 8
7 1 8