Assignment 5: Spline-based Path Generation

 CS 445/645 Introduction to Computer Graphics

Spring 2004

Due: 5:00 p.m. April 27th

Note: This assignment is optional.  If you choose to do it, it will be graded like all the other assignments, each of which will have a weighting of 0.2.  If you do not complete this assignment, the weights of your remaining four assignments will be 0.25.

Goal: To build a program uses splines to generate an animated character in a texture mapped room.
Details:

This assignment can be completed using OpenGL and glut.  Your program will accept one command line argument, the name of the data file.  The data contained in this file is a list of control points for a spline that will be generated according to the Bezier, B-spline, and Hermite standards.  This spline will be rendered as a curve on the floor of a simple cubic room you will construct using OpenGL primitives.  The walls, floor, and ceiling of this room will be texture mapped.  A character of your creation will "walk" along the spline from beginning to end and the user will be able to view the animation either through a camera that he or she controls or an automated camera that follows the character.

There are five key portions:

  • Parse the input file

  • Generate the spline

  • Generate the texture mapped room

  • Animate a character

  • Create the camera controller

Input File

The first line of the input file will consist of a character equal to 'h', 'b', or 'z' followed by a space and then an integer corresponding to the number of control points that will follow.  The list of control points begins on the next line with one control point per line.  The control point is represented as a pair (or triple if you want to extend your system to a character that "flies" instead of "walks") of comma-separated values.  The h-b-z indicate whether the spline to be generated is Hermitian, B-spline, or Bezier.

Generate the spline

We presented in class a recursive algorithm that renders Bezier splines.  You should implement this algorithm and convert the control points of the input file to the Bezier basis for rendering by this one recursive algorithm.

Generate the texture mapped room

OpenGL makes it relatively easy to load images as texture maps that you can apply to squares and triangles.  Fortunately, the geometry you create to represent the walls of the room will be simple (12 triangles) and assigning texture coordinates should go quickly. 

Animate the character

To keep production time down, the character you animate can be anything of your choosing.  It should have a distinct shape that permits one to judge which way it is facing because when the character slides along the spline, it should also rotate so it is facing the tangent to the curve.

Create the camera controller

You have two choices for the camera controller.  One choice is to implement a simulated "trackball" interface where the user can rotate the world and zoom in.  An example for how to create the trackball interface can be found at the end of the lecture on Bezier splines.

A second candidate for a camera is to create an automatic camera that tracks the character over its shoulder.  The camera should be a small amount  behind the character and it should rotate in unison with the character.

Extra Credit:

There are lots of fun things you can add to this assignment

  • Make the memory allocation dynamic so the input file no longer needs to specify the exact number of control points.

  • Make the room more realistic than a simple box.  You've got a poly loader from assignment one that you could use to insert other objects in the room.

  • Apply more advanced texture techniques

  • Create a more realistic character (I've got motion capture data of a walking person if you want it)

Turnin: Create a subdirectory named Assignment5{yourID}.

Copy all source code to this file.

Create a README that details 

  • Any extra credit you performed 
  • The compiler you used
  • Instructions for using your program
Hints, Code, Setup:

The glut.h file and glut libraries: http://www.opengl.org/developers/documentation/glut.html

OpenGL (normally included with OS):
http://www.opengl.org/users/downloads

Collaboration and Use of Web Materials:

You can use any materials you find on the web for this assignment.

The Red Book on OpenGL will be useful with texture information.

The textbook also has OpenGL tutorials.

You can talk with one another about your program, but do not look at anyone’s code and do not show your code to anyone.

Late Days: You have a total of five late days to use during the semester.  Each late day you use will provide you with a 24 hour extension.