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:
- 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.
- 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.
- 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.
- 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:
- 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).
- Experiment with torsion control: Try editing the track-generating code to
use a Frenet frame or a Torsion-minimizing frame, and compare the
results. (Note that this will require digging in to the framework code and understanding the details of how the sweep is generated!)
- 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.
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:
- 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.
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
- 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.
- Note that camera positioning is the first thing that happens after glLoadIdentity(). When you want to place the camera on the track, you want to make sure your code to do so happens instead of the two lines currently between glLoadIdentity and coaster->Render.