CS 312: Computer Graphics -- Assignment 3

Viewing

Due October 22, 2010 by 11:59pm
Due October 24, 2010 by 11:59pm



For this assignment, you will be modifying your Assignment 2 project to drive an amphibious vehicle on and around your island.   You will replace the former parallel projection with a perspective projection from the point of view of a person sitting in the vehicle at a fixed distance above the island. You will replace the mouse motion handler with a new one that maps horizontal mouse motion to turning left and right and vertical mouse motion to speeding up and slowing down your motion in the direction it is currently pointing. The view should tip to align with the landscape as you move.  To figure out the vertical position for your vehicle and the up-vector for the view, you will first need to locate the current position in x/y coordinates, figure out which triangle you are in, and finally interpolate between adjacent triangles to find the height and components of the up vector within the triangle.  Your view should tilt to align with the surface at that point. All aspects of the vehicle's view should be done on the OpenGL projection matrix stack (glMatrixMode(GL_PROJECTION)). This could be done in the mouse motion handler, but the assignment may be easier if you set view parameters in the mouse motion handler and create the projection matrix in your draw function.

You may find the following OpenGL calls helpful to complete the assignment:
Where the previous version enabled the user to interactively specify the amount of triangulation, you should choose a fixed amount of triangulation (at least 7 levels deep) that gives a sufficiently good looking island from your vehicle's perspective.  Your vehicle should start in a random location on the island (i.e., NOT on the water).

When any of '1' to '5' are pressed, you should transport the vehicle to a nice location on a pre-chosen island (i.e., pre-set the random seed to create the island and a starting location for the vehicle that you think looks particularly nice).

As always, there will be points for creativity, effort and realism.


Strategy

Plan ahead first. Know how you're going to find the position, height, and orientation of the view. Don't forget to account for cases when the vehicle is outside of the x/y region covered by the island or when the island surface dips below sea level (in both cases, you should float above the water surface). Once you have a plan, implement in stages. For example, you might get perspective viewing working first, then add the steering, then movement, then find the right height for your position, and finally tip the view to align with the island slope.


Submitting the Assignment

Submit your C or C++ program, all source code, the Makefile, and any other files necessary to run your project.  I must be able to type make on the CS systems and have it produce an executable for grading.  Name your executable "assn3".

In your comments, include information about the computer platform (hardware and OS) you used to develop your program, and be sure to include additional comments as needed to describe your code.  A good rule of thumb is that someone should be able to remove all code from the file and recreate a rough semblance of the result from your comments.

If you developed on somewhere other than the cs systems, be certain that your program runs correctly on the cs systems where it will be graded.  Leave time for this step!

Place all submitted files into a directory named LastnameFirstname-Assn3. For example, my directory would be EatonEric-Assn3. Then create a tar archive of that directory, such that the tar file expands to the directory (not a bunch of files). Copy that tar archive into ~eeaton/submit/cs312/username/ (where "username" is your cs system username) to complete the submission.

Be certain to use the names specified above for the directory and tar archive!!


Extra Credit Opportunities

The following are some ideas for extra credit for this project, but you may also explore others of your own choosing.  The maximum amount of extra-credit is noted next to each item.  Completing the extra credit will not be accepted in lieu of completing the main assignment.

Be sure to include a README file in your submission describing your extra credit additions and how to use them.

  1. (up to +10%)  Visualize the vehicle.  At a minimum, you could simulate the hood of the vehicle as a box, but displaying a windshield frame wouldn't be too difficult. Perhaps, set the 'v' key to toggle the viewpoint from the driver to behind the vehicle (showing the entire vehicle) and back again.  Remember, your vehicle itself should tilt based on the terrain.
  2. (up to +6%) Add a 2D navigation map of the island in a corner of the screen with an indicator showing the location and direction of the vehicle.
  3. (up to +10%)  Add some fun additional animated vehicle motion. Some possibilities are bobbing up and down when on water, smoothly changing view orientation over several frames as you move from triangle to triangle rather than abruptly snapping from one orientation to another, or making the vehichle slide down in the direction of steepest descent if it drives onto an area with slope steeper than (say) 30 degrees. You're welcome to come up with other ideas too -- be creative.  You animate motion by making changes incrementally over several frames. Normally, GLUT only calls your draw function if something changes. However, if you call glutPostRedisplay inside your draw function, it will cause GLUT to call your draw function again for a new frame as soon as the current frame is complete. For example, to smoothly change view orientation, you might have a current orientation and target orientation. If these don't match, make a change limited to (say) no more than 10 degrees per frame. Draw with the changed value, but if the current and target orientations are still not the same, call glutPostRedisplay to take another step next frame.
  4. (up to +5%)  Do all of the matrix manipulations yourself, using only one glLoadMatrix to set the final result. I would recommend getting the base project working using the OpenGL matrix functions, then replace them incrementally.
  5. (up to +15%)  Add scenery to the island.  This could include fractal trees (generated procedurally!), houses, rocks, a flock of birds in the background, etc.  You should either prevent driving through the scenery, or ensure that something cute happens when the vehicle does drive into the scenery (e.g., it plows down the trees, or it bounces off, or something).  Maybe your vehicle can launch red spheres that eliminate the scenery.  Maybe it can launch green spheres that randomly generate new scenery.  Be creative!!


Based on an assignment by Marc Olano.