CS475 Assignment: SmallE, Part 3
Pararth Shah 09005009
Phew! Its Done Finally!!
For heirarchical model and code structure, click here
For details of texturing and camera placement, click here
Compile and Execute:
- Two SmallEs!!
- For the purpose of animation, modelled one more smalle robot in the scene.
- Due to the modular nature of the code, this was fairly straightforward: required instantiating one more object of SmallE class. Also added 'id' parameter to SmallE class, which decides the textures to be drawn onto the bot.
- config.h now divided into: a set of structural parameters common to all smalle bots, and then parameters relating to the colour/texturing of the bot, divided into two sets, for smalle_0 (male) and smalle_1 (female).
- SmallE::init_texture() uses either of the two sets of textures depending upon value of the 'id' member of the SmallE class.
- Use '0' key to toggle between controlling DOFs of each smalle.
- Keyframe Recording
- Now it is possible to save the scene into a file (keyframes.txt) using '8' key. The keyframe consists of the current camera, and states of each of the smalle bot (DOFs + speech bubble state).
- Also, a file intervals.txt is saved, which stores a default value of number of frames a particular keyframe should be run at. This can be later edited before playback to give more control on the speed of the animation. For example, an interval value of 0 between two keyframes indicates that it is a scene change and the player does not interpolate between the two keyframes.
- Keyframe Playback
- To run the recorded keyframes from 'keyframes.txt' using interval data from 'intervals.txt' press '9' key.
- It calls a function renderKeyframe() which reads the files into memory, initializing the parameters for animation, and initiates another function processKeyframe() which processes each keyframe.
- processKeyframe() interpolates between two successive keyframes for every frame within an interval. It uses SmallE::setDOF function to set the parameters of each SmallE bot according to the interpolated keyframe, and then calls glutPostRedisplay() to redraw the scene. Subsequently, it registers a glutTimerFunc callback to call itself with updated frame no as parameter, after default milliseconds.
- Default time interval between successive callbacks = 10 ms. This multiplied by the number of interpolated frames in an interval (obtained from intervals.txt) gives the amount of time in milliseconds that a keyframe will be played for.
- Speech Bubbles
- For each bot, a speech bubble can be shown using '*' key, to assist in the story of the animation.
- The bubbles are implemented using technique of billboarding, which allows the bubbles to constantly face the plane perpendicular to the viewing direction of the camera.
- The bubbles are textured using images which must be specified in config.h for each smalle bot. To toggle between bubble images of a bot, use '(' and ')' keys.
- Recorded Animation
- A sample animation is available. To play, do:
- $ cp intervals.txt.backup intervals.txt
- $ cp keyframes.txt.backup keyframes.txt
- $ make
- $ ./simple
- -> Press '9' key in GLUT window.
(use capitals (shift+key) to rotate in opposite direction)
- z: rotate smalle about z axis
- x: rotate smalle about x axis
- c: rotate smalle about y axis
- q,w,e: lower neck x,y,z rotations
- a,s,d: upper neck x,y,z rotations
- t,y: rotate right arm
- u,i: rotate left arm
- f,g,h: rotate right wrist
- j,k,l: rotate left wrist
- v,b: rotate upper fingers of right wrist
- n,m: rotate upper fingers of left wrist
- o: rotate right wheel
- p: rotate left wheel
- 5,6,7: rotate head about x,y,z axis (use shift+number for opposite direction)
- UP_ARROW_KEY: translate smalle forward
- DOWN_ARROW_KEY: translate smalle backward
- LEFT_ARROW_KEY: rotate smalle left about vertical axis
- RIGHT_ARROW_KEY: rotate smalle right about vertical axis
- r: reset all degrees of freedom to default orientation
- 1: Camera follows SmallE
- 2: Camera centered on Table
- 3: Camera centered on Chair
- 4: SmallE's View of the World
Additions: Keyframes, Speech Bubbles!
- 8: record keyframe
- 9: play recorded animation
- 0: toggle between smalle_0 and smalle_1
- *: toggle show/hide speech bubble
- (: previous speech bubble
- ): next speech bubble