CMSC 435/634: Introduction to Computer Graphics

Assignment 3
A Simple Walkthrough
Due October 21, 2015 @ 1:00 AM

The Assignment

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.

Scene File Format

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 three numbers 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 gluPerspective() and gluLookAt() functions.

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).


Simplified OBJ File Format

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 three 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).


Getting Started

I have pushed some stub code to your proj3 directories as well as a default scene and some models. You can run the program from the command by typing
make && ./walk default.scene
Also an executable of my program is at ~adamb/public/walk.

As with the other projects feel free to develop on a platform of your choosing, but the resulting program must compile and run on the gl machines to receive full credit. To test your program on the gl machines, enable X tunneling (ssh -X) when logging in remotely.

Dave Mount from UMCP has created a nice basic OpenGL Quick Reference Guide that will covers pretty much all of the command's you need for this assignment. His lecture notes may also be helpful.

634 only

Display lists: If you simply draw the objects each frame, things will be slow. OpenGL can cache objects and then redisplay then efficiently. Display lists are the mechanism for doing this. How will you know if it is working?... large objects like this one don't take forever to display.

Extra Credit

For up to 15 points of extra credit, implement these additional features (5 pts each):

What to turn in

Turn in this assignment electronically by pushing your source code to your proj3 GIT directory by 1:00 AM on the day of the deadline. We will be looking for multiple checkins documenting your development process.

As always, double check that you have submitted everything we need to build and run your submission, but no generated files (.o's, executables, or images). Be sure to include a Makefile that will build your project when we run 'make', and a readme.txt file telling us about your assignment. Do not forget to tell us what (if any) help did you receive from books, web sites or people other than the instructor and TA.