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.
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:
- 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.
- 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.
- 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
- 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:
- Tie track layout to the polygon editor of As#2
Rather than typing in coordinate triplets for the control points,
modify the polygon editor of As#2 to modify the control vertex
positions until you have a rollercoaster that you like. Perhaps you
display two parallel projections of the control polygon for the track as follows:
-- first a top down view that shows the basic layout in which you move vertices only with respect to their (x,y) values;
-- then a side view in which you can adjust the height of the various control points.
- Texture the track: To make the track more interesting to
move along, and to get a better sense of the momentary speed of the
car, it would be nice to have some tick marks along the track. A
natural way to provide such tick marks are the ties that carry the
rails of the track. A simple way to provide such a pattern on top of
the track is by texture mapping, in which this pattern is placed repeatedly along the track surface. Texture map of track. (More on texture mapping in the next asignment).
- Decorate the scene: Add a skybox, or some texture-mapped
surrounding polygons that give some "background."
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:
- p x y: Define a vertex of the cross section.
- v 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.
- twist tw: Specify a global twist for the track
- azimuth az: Specify a global azimuth for the track
- # 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.
# global twist 20 degrees - i.e., a linearly increasing azimuth, starting at 0 degrees and ending at 20 degrees.
# 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:
- Submit using the submit as7 command on the INST machines:
- A copy of your code, including the whole framework, the compiles on the platform you developed on.
- A README.txt containing: Your name, SID, Login and a description of the platform your code compiles on.
- An image of the rollercoaster you have designed from a view which allows the whole thing to be seen.
- TWO animated GIFs of your coaster ride -- one of the cart riding, and another from the first-person view.
- The trk file for your custom coaster
- Put on your class instructional website:
- A separate page for this assignment.
- On this page, the images you are turning in, as well as the coaster track files for them.
The grader should ONLY have to open your .sln file and press F5 to build and run your solution.
The grader should ONLY have to run make with the appropriate makefile to build your project. Thus, for Mac and Linux
and for solaris
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
to easily submit the whole project to us.
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
See the Framework
page here. Version 5 of the framework provides code to load and display roller coasters.
- Most of your code can go in the display() function in main.cpp.
- For finding a position and orientation on the track, use the sample, sampleForward, and sampleUp functions in the SplineCoaster class.
- The parameter t used by the sampling functions goes once around the track per unit increase. So for example at t=.5, you will be halfway around the track, and at t=1 you'll be back at the start.