Unlike previous assignments where you were writing low level graphics routines, in this assignment you get to use the existing OpenGL graphics routines. All of the OpenGL commands are legal including the GLU routines. You can use any of them you want.
This program does not have a ready-made shell. The code you wrote for hw#3 is a pretty good starting point for this assignment (though you will want to gut almost all of the code for hw3 out.)
Your program should be run as:
assignment4 polygon-file-name car-polygon-file-name
You can find a sample polygon-file-name datafile for the program here
where polygon-file-name is a file in the same format as the file for assignment 3. Note however that this is not the same data file. Since HW#3 only diplayed wireframe images that datafile was rather sloppy.
Again, these polygons will generate a small town (the same small town) sitting on a plane stretching from -200, -200 to 200, 200 in world-space. The town will remain static.
Again you will be controlling a vehicle driving (flying) through the town. The second file name will be a file whose contents YOU create. It will be the set of at least 10 polygons which define what your car will look like. Be creative (ie you will lose points if your car is a cube), and keep the car in scale with the rest of the scene.
The vehicle should start out at (0,4,0) on the plane looking in the negative Z direction with a 60 degree field of view, in what will be described as 'view 1' below.
The viewer can control the location of the vehicle:
The mouse can also be used to move and turn the vehicle in this assignment:
The user will also have several commands to change the look of the image:
w: view everything as a wireframe image
f: view everything as a flat shaded image
v: draw back-facing polygons
b: do not draw back-facing polygons
g: turn the depth buffer on
h: turn the depth buffer off
k: turn on the car's single headlight - a white spotlight
at the center of the car matching the car's orientation
m: turn off the car's single headlight (objects should be their assigned colours)
The car that you create should only be drawn in views 2, and 3.
The screen should also display several textual items of interest using the font routines from the tk library. These items should be readble but not obscure too much of the scene - come up with an appropriate layout.
As in assignment #3, you should restrict the user's camera to move only within the 400 by 400 unit area, and not allow the camera to drop beneath the y=0 plane.
As with assignment 3, your program should be well commented and be a good example of literate programming; again it will be submitted electronically; and again be sure it can be compiled and executed with acc and Mesa on the EECS suns.
Since this assignment is on a much higher level than the previous assignments, it is basically a question of calling the corect functions in the correct order.
This would be a very good assignment to try and use OpenGL on the INDYs that are available in the EECS lab as they should be significantly faster than the suns. You will probably also want to use the colour monitors if possible (and since this assignment 'requires' colour you can use the colour sun monitors on this assignment.)
A good way to test whether back-face culling is on is to allow the camera to drop below the plane and see what is visible.
One thing to be careful of is to be sure that you draw all the polygons of your 'car' in counterclockwise order so they will backface cull correctly. Remember you will only be seeing the car from the outside.
Another thing to be careful of is that you want the font screen overlays to appear the same no matter what the view is. Hint: you do NOT need 3 different sets of coordinates for the fonts ... the same font code should work no matter what view is currently selected ... if you write the routines correctly.
When lighting is enabled the colour defined in the data file should be used as the diffuse material component. You will need to compute the normals for each vertex when lighting is on. You can assume that each polygon has the same normal. There should be no global ambient light in the scene.
You will also need to make use of the auxIdleFunc() to tell the program what to do when it is idle.
As this program is essentially an extension of the previous assignment I would suggest first implementing the code to draw the town and drive around it as in the 3rd assignment. Then add in the code to drive the car with the mouse. Then draw your car and add in the code for turning back facing polygons and the depth buffer on and off (these are very simple.) Then add in the other views. Then add in the font code. Then add in the lighting code.