You may submit on either Unix, OS X, or Windows. The platform you submit on will be the one used to grade assignments.
As with the last assignment, we will be using Prof. Hilfinger's submit software for submission of this assignment.
You should include a README file that at the minimum contains the following data:
Windows: The grader should be able to recompile your program by simply opening the project and rebuilding it from scratch.
Unix and OS X: The grader should be able to recompile your program simply by typing "make".
You are provided sample code for you to start with. If you chose to use that code, you are responsible for figuring out how to use properly. If you have questions, post them to the news group or ask the Professor/TAs during their office hours. Link to code.
You do not have long to do this assigment. Do not wait until the last minute to start!
Check the news group regularly for updates on the assignment or
other clarification. We will assume that anything posted there is
henceforth known to all.
The assignment is to create a simple walkthrough program. Your program will read a scene description from a file (described below) and allow a user to interactively explore the environment by pressing the arrow keys. Pressing the "up" arrow key should move the camera in the direction its looking by 0.1 units. Pressing the "down" arrow key should move in the direction the camera is looking by -0.1 units. Pressing the "left" arrow key should rotate the camera 5 degrees to the left and pressing the "right" arrow key should rotate 5 degrees to the right. Holding the "shift" key and pressing the "left" or "right" arrow keys should translate the camera 0.1 units in the appropriate direction (this is known as "strafing").
You will need to setup the correct projections for the camera and render all the objects in the scene. Additionally, you must put an analog clock with hour, minute, and second hands in the lower left hand corner of your viewport. This clock should display the current time of day and be updated every second.
The objects will be read from files using a simplified .obj format. You will need to compute normals for the objects, and hitting the 's' key should toggle between flat and smooth shading.
Your program should accept a single command line argument which is the name of a file containing the scene description.
Pressing the "o" key should return the camera to its original
position and pressing "q" should quit the program.
The file begins by specifying the initial camera setup. The first numbers are the field of view, near and far clipping planes. The aspect ratio should be determined from the window size (resize events). The next 3 specify the x, y, and z coordinates of the eye (center of projection), the next three specify a point that the eye is looking at (often called center) and the last three specify an up direction. These are exactly the parameters to the gluLookAt function.
The camera description is followed by an integer which specifies the number of objects in the scene. Each object entry first contains the color (3 floats). This is followed by ka, kd, and ks (3 more floats), which are the various reflectances of the object (ka multiplies the ambient term, etc). Then an arbitrary number of transformations may be specified. These are specified either as "translate", "rotate", or "scale." "translate" is folowed by three floats which give the translation. "scale" is followed by 3 floats which give the scale in each coordinate direction. "rotate" is followed by 4 floats, the angle (in degrees) and the axis. The transformations are given in the order they should be added to the stack. That is, the reverse order in which they are applied to points. After the transformations an obj file which contains the actual triangles describing the object is given.
After all the object descriptions, we describe the lights. First, there is an integer which specifies the number of lights. Each light is then specified by ambient, diffuse, and specular colors (each given as four floats (RGBA)) and the position (also 4 floats).
An example scene file is available here.
We will be using a simplified OBJ file format. Lines begin with a "v", for vertex, or "f", for face. The vertices are all listed before the faces. A "v" is followed by 3 floats which specify the position of the vertex. An "f" is followed by the ints which map into the vertex array. That is "f 1 2 3" specifies a triangle made of the first, second and third vertices specified. The indices used to specify the faces start at one (not zero).
An example OBJ file is available here.