CMSC 435/634: Introduction to Computer Graphics

Assignment 2

Modeled Scene

Due March 4, 2004

The Assignment

For this assignment, you will be creating a simple procedurally generated roller coaster based on a 3D spline curve. The roller coaster will be created by selecting a handful of random spline control points in space for the roller coaster track to pass through. You will then find points along the spline curve, and connect these points with a tube of triangles to represent the track.

The track should float above a flat plane, representing the ground (you need not show the track supports). The coaster should be lit by one OpenGL distant light (simulating the sun or moon) and one ambient light (simulating light from atmospheric scattering). Compute all of the geometry in advance, when your program starts up. You should only be rendering and processing user interaction in the rendering loop.

For lighting to work, you will need to compute surface normals for each vertex of each triangle you draw. One way to get these normals is to use the vector from the center of the tube to the vertex. However you compute your surface normals, be sure to choose an outward orientation all of them.

I have provided some OpenGL code to get you started. This code, in ~olano/public/cs435/assn2. It uses OpenGL for rendering and GLUT for handling the windowing and interaction. Versions of these libraries based on the Mesa software-only OpenGL library are provided (and the Makefile given will use them). See below for (sketchy) information on working from home for this assignment.

Strategy

I would recommend something like the following sequence: get the general path working first using GL_LINES instead of GL_TRIANGLES; add the ground plane and lighting; switch to the tube geometry, and finally adjust the lighting for best appearance.

634 required / 435 extra credit

Add three new keypress events (similar to Escape-key handling in the sample code). When space is pressed, you should generate new roller-coaster geometry with a new set of points. When 's' is pressed, save a set of favorite point locations to a file. When 'l' is pressed (that's a lower-case L), read point locations back from the file.

What to turn in

Turn in this assignment electronically as 'cs435 Proj2' using the submit mechanism:
    submit cs435 Proj2 [files...]
Be sure to submit all files that you created or modified. We should be able to copy the submitted files into a clean copy of assn2 and be able to build and run your project. The only way we'll be able to grade this time is to build and run your project. Please make sure it will run on linux.gl.umbc.edu or irix.gl.umbc.edu (and let us know which to use). Be sure to leave time to port if you develop on a system other than one of these!

As always, we will be looking at your source code, so please try to make it understandable and comment anything you want to make sure we notice. 'This is what I'm doing' comments are more useful for my understanding than comments like 'add x to y'. Additional comments may help your grade in cases where your program does not operate entirely correctly (since they can give me insight into what you were trying to do). In any case, your programs are expected to be robust and easy to understand.

References

For anyone looking for more information on OpenGL, the irix machines include all of the OpenGL man pages (you don't have to be sitting at one, you can just 'ssh irix.gl.umbc.edu'). Just try 'man glVertex2f', 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. This a good introduction to writing OpenGL programs.

Working at home

Once again, if possible, I urge you to use the university computers for your work. I test things out on the gl systems and may or may not be able to help you if things don't work right for you at home. If you do work at home, your final submitted version must be able to run on the gl machines and must be electronically submitted there.

If you have a X server on your home machine (i.e. if you are running linux, mac with X11, or one of the windows X11 packages), it is possible to run remotely, though interacting with the application is much harder when displaying remotely.

If you absolutely must work at home, you will need:

All of these libraries are cross-platform and run on both unix and windows. However, if there are no pre-built binaries for your platform, you may end up having to build them from the source downloads. Which brings me back to: if you don't have to work at home, don't.