CMSC 435/634: Introduction to Computer Graphics

Assignment 3
Viewing Pipeline
Due March 11, 2004

Last Update
Wed Mar 3 18:32:28 EST 2004

The Assignment

For this assignment, you will be modifying your last assignment to fly through the "roller coaster" tube (when creating assignments 2 and 3, I was actually thinking about the magic carpet/cave scene in Aladin). You will replace the former parallel projection with a perspective projection from the point of view of a person sitting on the carpet. You will replace the mouse motion handler with a new one that maps horizontal mouse motion to looking left and right and vertical mouse motion to speeding up and slowing down your flying speed along the track. The view should tip to align with track as you travel, following the motion of the "carpet", with looking left and right added as if you were turning your head while sitting on the carpet.

Perspective projection should be applied in the OpenGL projection matrix stack (glMatrixMode(GL_PROJECTION)), while viewing transformations should be applied in the OpenGL model-view matrix stack (glMatrixMode(GL_MODELVIEW)). It is probably easiest to move the view matrix setup into your draw function.

You animate motion by making changes each frame then redrawing. Normally, GLUT only calls your draw function if something it knows about 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 (the mouse motion handler does this). This method is perfectly acceptable for the assignment. For a more consistent speed across different graphics systems, you can use glutTimerFunc to have GLUT call your view-changing function after a specified time interval. In this latter case, your TimerFunc would set the view, call glutPostRedisplay so the new view will be drawn, and call glutTimerFunc again to change the view after the next interval.

634 required

Do all of the matrix manipulations yourself, using only glLoadMatrix to set the final result. I would recommend getting the base project working using the OpenGL matrix functions, then replace them incrementally. You will get more credit for a working program that makes partial use of glLoadMatrix or glMultMatrix than a completely non-working program that uses only glLoadMatrix. This should not be too difficult if you use the man pages for the OpenGL transformation functions as reference.

Extra credit (for everyone)

Add some fun additional animated vehicle motion. Some possibilities are tipping with the momentum as you curve around the track or bobbing up and down slightly like a "typical" magic carpet. You're welcome to come up with other ideas too — be creative.


Plan ahead first. Know how you're going to find the position and view vector. Once you have a plan, implement in stages. For example, you might get perspective viewing working first, then add the motion along the track, then make the view direction follow the track direction, and finally add the ability to turn left and right.

If your assignment 2 did not work, you can get a working sample version from me after you have turned in your final version of assignment 2. However, I would encourage you to start from your own assignment 2 code if at all possible. Problems with your assignment 2 will not count against your assignment 3 grade, but you should at least have a tube track that connects back to itself.

You may find the following OpenGL calls helpful to complete the assignment:

What to turn in

Turn in this assignment electronically as 'cs435 Proj3' using the submit mechanism:

    submit cs435 Proj3 [files...]

The usual assignment boilerplate still applies -- submit all files you've created or modified; we must be able to build and run on the GL systems to grade! If you develop elsewhere leave sufficient time to port back. Comments are your friend and ours, they're a good idea and they can improve your grade.


As a reminder, gl machines include all of the OpenGL man pages (you don't have to be sitting at one, you can just 'ssh'). Just try 'man glFrustum', etc. to find out more about any function used in the assignment that sparks your curiosity. Also, the OpenGL 1.1 Programmers Guide (the "OpenGL red book") is available online, and is a good reference