15-462 Programming Lab 2: Roller Coaster via Splines

Due Tuesday, October 9th, 11:59 PM

An Overview

For this assignment you'll be deriving a spline function from geometric constraints, and using the function along with several different features of OpenGL to create a roller coaster simulation with a first-person view, allowing the user to "ride" the coaster in an immersive environment. As with the previous assignment, you will create an interesting animation after finishing the program itself. This time, the objective of your animation is to show off both your coaster and the features of your program.


In the first assignment you used some basic OpenGL functionality but didn't get into anything really interesting (unless you went nuts with extra credit).

This assignment asks you to utilize some more interesting features of the OpenGL library in the design of a more significant and entertaining application. In addition, this project gives you a great deal more freedom to be creative in the actual design of your program and the features that go into it; you are asked to create your own solutions to issues involved in the making of your simulation, and to render your coaster as you wish in a world of your design.

After completing this assignment, you should have a solid understanding of:

This assignment should be challenging, and will likely take a significant amount of time. However, this should also be a lot of fun!

Background Information

In order to create the track for your roller coaster, you'll need to render a spline sequence which represents the entire length of your track. Rather than using provided functions, you will be implementing a spline function yourself. This function should take four control points (p0 through p3) and a floating point value (u) from 0 to 1 to trace along the length of the line defined by these four control points. Drawing a single spline from four control points isn't that exciting—you'll need to use several control points in sequence and draw spline segments along them, starting from the first four points and proceeding until you draw the final spline for the last four points. This will allow you to represent a long, elaborate curve for your coaster.

We'll be using Catmull-Rom splines for the representation of your coaster. These will be defined in lecture but you can also look at notes here.

Your Implementation

Make sure you understand Catmull-Rom splines pretty well, then on to the coding itself. You can download the Starter Code here (Updated 10/02/07).

In Windows: The Visual Studio 2005 solution file is also included in the zip file. The starter code has been set up to be able to build in both Windows and with the Makefile in Linux.

Before doing anything else, you'll probably want to visually check your function by drawing some splines to the screen. We provide a set of "track" files containing control points to define some simple spline shapes, and starter code to read in a sequence of these files and convert them to sequences of control points that you can use. It's definitely a good idea to write the code to draw a simple spline sequence and test this before moving on to later parts of the assignment.

Next, try setting up the world in which you will actually place your coaster. You can use a plane for the ground—this should be texture-mapped for realism with an image of your choice. There are plenty of free texture sites on the Web, so find one that appeals to you. After this, create your sky as you wish—this should also be texture-mapped, and the method of modelling it is up to you. There are issues with many obvious representations, so think about this carefully. Make sure that you can still draw splines as before once you have this set up. Note that the "sky" includes the horizon as well, so simply having a single plane above and a single one below does not constitute an entire sky.

Now, implement the ability to ride the coaster. It's easiest to start with your camera moving at constant speed (in u) along the spline before worrying about realism. Properly orienting your camera is a challenging problem! You'll want to have your camera facing "forward" (along the tangent to your spline) as it moves. Also, you need to make the "up" vector of your camera follow some continuous path of normals to the spline. A cheap method to decide your up vector is to always set it equal to the normal of your ground plane—however, this is totally unrealistic for many splines (think about what happens with loops). Another method is here. Both of these have their limitations, so you are encouraged to come up with another solution to this problem. This document may also be useful.

Modify the appearance of the coaster itself—instead of just a line, make your track look like a track! Draw some sort of cross-section, and add whatever details you like. Add lighting to make your coaster look more realistic!

Finally, modify the velocity with which your camera moves to make it physically realistic in terms of arc length and gravity.

After that's all done, add some fun extras!

Grading Criteria

Your program must:

Animation Requirement

As in the previous assignment, you are required to submit an animation, represented by a series of JPEG images which are screenshots from your program. We allow for more frames this time as your coaster may take more time to demonstrate—please name your JPEG frames 000.jpg, 001.jpg, and so on. Do not exceed 1000 frames. The frame rate for the animation, again, is 15fps. Be warned that the animate program installed in the cluster may have problems with excessively large numbers of images—it may be wise to use it to test subsequences of 100 frames or so.

The animation represents a smaller portion of your grade than in the previous assignment, as the implementation of the program itself is much more important and involves much more thinking. You will still receive points, however, for showing off your coaster in a creative manner.

A note for those of you who have had trouble dealing with storage for all your images: It is wise not to try to store your frames on your Andrew account, as this will likely fill your quota very quickly. If you have your program write its frames to ./movie, then you can submit it to the correct handin directory for the assignment, run your program, and write your frames directly into the movie handin directory. This avoids worries about intermediate storage. Just make sure your handed in version doesn't output frames by default. When we go to grade your program it shouldn't start outputing frames when we run it.


Please submit your project to /afs/andrew/scs/cs/15-462/turnin/your_andrew_id/. Copy your modified src directory into that directory. When we run "make" in the src directory it should compile your program successfully. Also within asst2, make a sub-directory called movie, and place the frames for your animation within, numbered as described below.

What to submit

Make sure that all files for asst2 go into the asst2 folder. When you submit, also include the following:

Any failure to comply to the above submission rules might result in misgrading your lab.



This assignment is much more open-ended as to what you may choose to implement for extra credit. You may be awarded credit for any creative or interesting solution to an issue in your implementation, as long as it is well-documented in your readme file. Below are some ideas you might want to think about if you have the time:

Please note that the amount of extra credit awarded will not exceed 10% of this assignment's total value.