15-462 Graphics Project 2: Simulating a Roller Coaster

Written work due by September 26th lecture or earlier
Program and animation due Friday October 4th midnight

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.


Now that the first programming assignment has familiarized you with working in OpenGL, this assignment asks you to utilize some more interesting features of the library in the design of a more significant and more 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 significantly more time than the first programming assignment. 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 deriving 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 were defined along with their geometric constraints in lecture, so please see the slides on splines and on physics for this information.

Your Derivation

As mentioned above, you need to use the background information on Catmull-Rom splines to derive the function which interpolates your control points. This derivation involves only the most basic use of calculus--your problem is to phrase the constraints given as a set of equations, and to then solve this system to obtain the constants for your function. You may either leave the parameter s unspecified until you actually wish to use the function (highly recommended), or assume a value of 1/2.

We require that you submit your written derivation to make sure that you understand how this process works--this is how splines in general are formulated and put to practical use. The final matrix form of the Catmull-Rom spline function (which should be the final result of your derivation) is present in the lecture notes--your job is to perform a logical derivation of the basis matrix to determine this function yourself. You must show your work and your reasoning at each step, from initial verbal constraints to the final function as specified in the lecture notes.

Please submit your derivation by lecture on September 26.

Your Implementation

Now that you've done some math and understand Catmull-Rom splines pretty well, on to the coding itself. You can find the starter code and supplementary files here.

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.

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. Another method is here. Both of these have their limitations, so you are encouraged to come up with another solution to this problem.

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-- so please see the slides on splines and on physics for this information.

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

Grading Criteria

Your Catmull-Rom spline derivation must be submitted by September 26th's lecture.

Your program must:

Animation Requirement

As last time, 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.


Please submit your code along with your makefile and readme to /afs/andrew/scs/cs/15-462/students/your_andrew_id/, in a sub-directory called asst2. Running "make" in this directory should compile your program successfully--if not, you've left out a necessary file. Within this directory, make a sub-directory called movie, and place the frames for your animation within, numbered as described above.



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.