Homework 7 is due on Tuesday Nov. 23 at 11:59 pm
You will write a program that generates an animation given a script containing keyframes. Your program should take in a script containing the total number of frames to be generated, followed by the keyframes of the animation. The script files will therefore have the form:
Total-number-of-frames <Keyframe1> . . . <KeyframeN>
where each keyframe will look like:
Frame x [translation tx ty tz] [rotation nx ny nz angle] [scale sx sy sz]
Note that any of the three transformation fields can be omitted (however, at least one of the three should be specified in order for the keyframe to be useful). These are global transformations for the object (therefore, they do not combine).
Some example scripts are available in the hw7 data folder.
Once your program has read in the script file, it should use interpolating cubic splines (Catmull-Rom work really well for this) (handout) to determine the position, orientation and scale of the object at every frame x, x in [0, numFrames - 1]. For a more technical explanation of Catmull-Rom splines, see this paper. (Note: Keyframes may set only some of the transformation fields leaving the others free). When interpolating the rotations, you will use the quaternion (handout) form of the rotation. This article on quaternion rotations may also be useful.
After interpolation, your program should display the animation sequence. The easiest object to test your program on (also the one that we.ll be grading) is a colored I-bar, as shown below. You should make each of the cylindrical sections different colors and give them all unit length, except the middle piece which should have length two. (Use GLU quad / cylinder to draw these. It's really easy.)
The I-bar is a good object for testing your animation since you can easily see the effects of translation, rotation and scaling of the object. Each segment is made of a different colored cylinder in order to see more easily the effects of rotations.
Your program should be called keyframe have the following syntax:
keyframe <script-file-name>
where scriptfile is the keyframe script defined above. Your program should read the scriptfile, create the animation, and play the sequence as described above. During playback, your program should respond to the following keypress events:
P Play
S Stop
F Forward one frame
R Reverse one frame
L Toggle Loop mode on/off.
Loop mode means that the animation will restart at the
beginning upon reaching the end
J Jump to frame. After pressing this key, the program should
ask the user to input the frame number to jump to.
0 Zero. Reset to the first frame.
Your program should also respond to the arrow keys to move the camera:
Up Move the camera toward the origin
Down Move the camera away from the origin
Left Rotate the camera to the left around the origin
(always looking at the origin).
Right Rotate the camera to the right around the origin
(always looking at the origin).
Note that your camera should always look at the origin. The initial field of view of the camera should be set such that the entire animation can be viewed without moving the camera. Your program should be written in OpenGL. (Note: If you wish, you may use your previous mouse navigation system as long it seems sufficiently intuitive to use-- the camera should move, not the I-bar; the camera should always look at the origin; don't let the transformations get all messed up and confusing/ don't make it roll the camera.)
Test files are available in the data directory. You should also develop your own test cases.
Include a README file with your code, saying what you did, how to compile it, and anything else you think we need to know.