Program 5

Program 5: Rollercoaster Baron

Due: Thursday, September 30th, 2010 (before lab session starts)

Utilize your base code from the previous lab and homework assignments, bezier and tvehicle. The goal of this program is to integrate your vehicle into the bezier curve builder such that your vehicle will travel along the curve specified using the bezier program. This, in effect, is like building a rollercoaster where the curve is the track and your vehicle is the ride car.

Save/Restore

To make building the track easier, you should allow the user to read in a set of control points from a file. That means you should able to run your program as follows:

$ ./rollercoaster <datafile>

The points should just be a tuple of x y z, where each point is on one line:

Controls
0.0 1.0 1.0
0.0 2.0 3.0
...

Note that the program starts with the sentinel Controls to mark that the following coordinates correspond to control points.

Once the rollercoaster track is loaded the user should be able to manipulate the curve as normal. To allow the user to save the modified track or restore the original one, you provide a key binding to allow for saving the current track and or to reload the original datafile. For instance, if the user presses F1, it should save the current track and if the user presses F2 it will restore it.

Decor et Milieu

The secret to Disneyland's success is not the quality of the rides, but in the magical atmosphere it provides (that's what it's a theme park and not just an amusement park). To augment the drab scene, you should allow the user to place additional objects into the scene. These can be anything from basic primitives such as cubes and spheres, to more sophisticated objects such as trees and buildings.

To allow for switching between items, you should replace the the middle-click mouse binding. Currently, it is used to delete an control point. Instead, you should simply add a key binding such as d or DELETE that deletes the currently selected control point. With the middle-click mouse binding free, you can then bind a menu that allows the user to select what type of objection to place: a control point, a cube, a cone, etc. This means middle clicking will bring up a menu or palette of objects to place. You should allow the user to switch between a control point and at least two other objects.

The other binding you will need to modify is the wheel up and wheel down controls. Currently, if a control point is selected, the wheel controls will adjust the height of the object. You should modify it so if you have selected a non-control object then scrolling the wheel will adjust the scale of the object. If you wish, you may want to add key bindings to allow the user to modify the orientation of your objects (ex. [, ]).

The data file format should then be:

Controls
x, y, z
Cubes
x, y, z, scale, orientation
Spheres
x, y, z, scale, orientation

Of course, you can replace Cubes and Spheres with whatever objects you wish and you only have to include scale and orientation if you allow the user to modify those properties.

Riding the Rollercoaster

Once a track is in place and the scene is set, the user should be able to press a key to start the vehicle in motion (ex. F3). The vehicle should precisely follow the trajectory of the curve and have the appropriate orientation (tilt up when going up hill, tilt down when going downhill, etc). To animate the vehicle, you will probably want to update its location using a timer callback.

Note

When your vehicle reaches the end of the track, you can either have it turn around and come back the opposite direction, or simply jump to the beginning of the track.

Cameras

During the animation of your rollercoaster, you should divide the window into 4 viewports with the following displays:

  1. Display the normal orbital camera control.
  2. Display a mini-map that provides a overhead view of where along the track your vehicle is.
  3. Display a viewport that shows the point of view of a rider in your vehicle as it goes along the track.
  4. Display a viewport that shows the view of the side of the vehicle as it moves along the track (camera is pointed at the vehicle, and is to the left or right of the vehicle).

Usage

Your program should have the following command line interface:

usage: rollercoaster [options] <datafile>
Options:
    -h         Show this help message

An example invocation would be:

$ ./rollercoaster datafile

Feel free to add additional flags and options to modify your programs behavior at runtime.

Note

Your program must read in the input file from command line arguments.

Grading Rubric

Grading for this assignment is out of 45 points:

Points Requirements
10

Rollercoaster track designer:

  • User can build track using bezier curves using mouse and keyboard:
    • Controls points can be modified in x, y, z directions.
    • User may select control points using mouse and drag them around in orthographic mode.
  • Tracks can be saved and restored:
    • Track points can be specified in a file and passed to the program from the commandline.
    • Track can be saved to datafile using a key binding.
    • Track can be restore to original point using a key binding.
Optional:
  • Use a stack to allow for multiple undo and redo operations in addition to save and restore.
10

Decor et milieu:

  • User should be able to place non-control objects onto the grid.
  • User switches between objects and control points by selecting from a menu that is activated using a middle-click.
  • User should be able to delete objects and control points using a key binding.
  • Objects can be modified using mouse and key board just like control points.
  • Objects can be saved and restored from data file similar to track control points.
Optional:
  • Allow user to scale and orient non-control objects.
  • Have scene objects be animated.
10

Rollercoaster vehicle animation:

  • Key binding toggles vehicle animation mode.
  • Vehicle follows the user designed track and has the appropriate orientation.
  • Vehicle shows animation while moving.
  • Vehicle does something once it reaches end of track (turns around or jumps to beginning).
10

Camera views:

During rollercoaster animation the window is split into four viewports:

  1. The normal orbital control that follows vehicle.
  2. Orthographic bird's eye view of the track and vehicle as it moves.
  3. Point of view of rider as vehicle moves along the track.
  4. Side view of the vehicle as it moves along the track.
5

Submission builds and runs properly and includes the appropriate files:

  • Submission includes Makefile, source code, and README, and builds and runs on RHEL5 machine.
  • README should specify how to run the program and the key bindings if they deviate from the ones mentioned above.
  • Source code is well-structured and well-formatted.

Submission

Submit your source code, Makefile, and README to your course dropbox:

/afs/nd.edu/coursefa.10/cse/cse40166.01/dropbox/<afsid>/pgm5