CS184 AS7: Designing and Riding a Rollercoaster

DUE DATE: Wednesday April 1st, 11:00pm

Aim

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). Edit the B-spline control points and possibly also the track cross section.
  2. A cart that rides the track: You should make a cart that rides continuously along your track, staying consistently oriented relative to it. You can use the drawCart function to render a cart, but we encourage you to modify this function to get a more interesting and/or plausible vehicle.
  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 changing scenery 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. But since it is a pain to do this extra integration, we let you 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. To maintain accuracy in realizing the desired velocity, take small steps along the track until the appropriate distance has been travelled.

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

Submission

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.

Framework

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

Implementation Tips