CS184 AS7: Designing and Riding a Rollercoaster

DUE DATE: Satuday March 12, 11:00pm
Groups of two are allowed!


Your raytracer should, by now, be able to leap tall buildings and fight crime. However, for this assignment we will not be using it. Instead, you'll be designing and riding a virtual rollercoaster. In doing so, you'll learn about splines, sweeps, moving cameras, and using OpenGL for 3D rendering.

Minimum Specifications

We will provide you with a rollercoaster generator/renderer that reads a configuration file, builds a B-rep of the rollercoaster and renders that construction from a bird's eye camera position. You'll be modifying the example track, and the provided framework code, to acomplish the following:

  1. Creating an interesting track: Create a track that is more compelling than the basic sample loop. Experiment with the twist and azimuth parameters to tweak your track and make something that closes nicely on itself, and which takes turns plausibly (tilting inward with the turns). Add at least one vertical loop to the track. Edit the B-spline control points and possibly also the track cross section. Note that the framework was designed assuming that you will use a "nice" track with C2 and G2 continuity and non-vanishing velocity.
  2. A cart that rides the track: You should make a cart that rides continuously along your track, staying consistently oriented relative to it. We provide a drawCart function to render a "cart" to get you started, but you must replace that with something more cart-like (with a body and wheels). How you create the cart is up to you.
  3. A first person view mode: The user should be able to toggle to a first person view by pressing 'V'. This should switch the view to a camera that rides along with the cart. The camera could be placed in the front face of the cart, or it could be placed slightly behind and above the cart, so that the view always shows the (fixed) front end of the cart, and, of course, the track beyond that.
  4. Dynamic velocity control: The cart (with or without the camera) should move at a velocity that varies dynamically in a sensible way according to track geometry. The simplest model is to rely on constant energy, which is the sum of potential energy (= Height of the track) plus kinetic energy (= Velocity squared). For each frame, subtract potential energy from a chosen total energy to determine the velocity of the cart, and then move the cart a small distance proportional to that velocity. Note, that in principle, the speed of the car should be measured along the actual arc-length of the spline. Since it is a pain to do this extra integration, you could optionally define "velocity" in parametric space. This is not too bad an approximation, if your control points for the spline are spaced at roughly uniform distances. Alternatively, you could simply take small steps along the track until at least the appropriate distance has been travelled each frame.

Extra Credit ideas:

Track File Format

We provide a simple custom file format to specify a track, an example of which is provided with the framework. The format provides the following commands:
  1. x y:  Define a vertex of the cross section.
  2. x y z [az]:  Define a control point of the b-spline. [az] is a last optional parameter, which specifies a local azimuth value on the spline. Note that these azimuth values are smoothed by the b-spline function just like the x, y, z.
  3. twist  tw:  Specify a global twist for the track
  4. azimuth  az:  Specify a global azimuth for the track
  5. #  comment:  Lines beginning with '#' are comments

Example Track File

# basic roller coaster track

# global azimuth of 45 degrees everywhere - as a starting base for further modifications.
azimuth 45
# global twist 20 degrees - i.e., a linearly increasing azimuth, starting at 0 degrees and ending at 20 degrees.
twist 20

# a rectangular cross section
p -2 1
p 2 1
p 2 -1
p -2 -1

# a short wavy loop.
# local azimuths of 80 degrees are specified at the three low points of the track, where the speed is highest.
v    10.0    20.0  0.0
v     5.0    -5.0   8.6   -80.0
v    -5.0   20.0   8.6
v   -10.0   -5.0  0.0   -80.0
v    -5.0  20.0  -8.6
v     5.0   -5.0  -8.6   -80.0


To submit this project, all of the following needs to be done by the deadline: Windows Users: The grader should ONLY have to open your .sln file and press F5 to build and run your solution.
*Nix Users: The grader should ONLY have to run make with the appropriate makefile to build your project. Thus, for Mac and Linux make and for solaris gmake.

Note: The submit program retains the directory structure of what you send it. Thus, we recommend making a new directory for your assignment on the server, cd'ing into that directory, copying the whole framework with your code into this directory, and running submit as7 to easily submit the whole project to us.

Group submissions

For this project, groups of two are allowed. If you're working in a group, only one of you should submit the full project results; the other should only submit the README.txt file. Both of you should include your partner's name in the README.txt file.


See the Framework page here. Version 5 of the framework provides code to load and display roller coasters.

Implementation Tips