Animation in Ogre
Animation definition
- Animation:
- The variation of the value of one or more parameters defining an entity, during a given period of time
- Examples of such parameters:
- Position
- Orientation
- Size
- Color
Animation modes
- Variation can be expressed as:
- A set of consecutive values (frames)
- A function of elapsed or absolute time
- Both - Keyframing
Keyframing
- Parameter values defined for specific time instants - Key Frames (e.g. position translated one unit every one second)
- Animation system interpolates values for intermediate positions
- Different interpolation functions (also knows as tweening functions) can be used, e.g. linear, spline-based, spring-based, etc.
Ogre Animation Basics
- Ogre has an animation engine to ease the setup and updating of animations
- Main components:
- Animation
- Tracks
- Keyframes
- Animation State
Animation definition classes
- Animation
- Defines a compound animation, containing a set of AnimationTrack's, each controlling a type of parameter of a given object (e.g. a track for animating the position and another for animating the color)
- AnimationTrack
- A sequence of keyframes that affects one parameter of a given animable object.
- There are different types (e.g. NodeAnimationTrack)
- KeyFrame
- A set of parameter values corresponding to a given time in an animation. (e.g. an object position at 3 seconds of the sequence).
- There are different types of KeyFrame's (e.g. TransformKeyFrame's)
Animation Execution
- The actual execution of an animation is controlled by an animation state
- The animation state changes the animable object's parameters to the values defined in the Animation, according to a given time instant.
Animation Execution Classes
- AnimationState
- An instance of an Animation, that represents a state associated to a given time.
- Time instants between keyframes are interpolated.
- The type of interpolation can be configured (linear, spline, …)
Animation State Notes
- The same animation can be used in similar objects, each with its AnimationState.
- The programmer has to request the update of the animation states providing the desired animation time instant.
- See example in the lecture notes
Character / Mesh Animation
- Ogre provides mechanisms for complex animation of meshes and characters
- Basic animation concepts apply, main differences are:
- Meshes are associated (rigged) with a set of control points (skeleton)
- What is animated are the control points that deform the meshes
- Animation's and AnimationTrack's are created by the artists modelling the characters with specific tools
- Programmer's task:
- Load the animations and control the corresponding AnimationState's
Character Rigging
- Characters are first created as meshes
- Meshes are rigged with a bone or skeleton.
- The skeleton consists of a set of segments (the bones) and joints
- The rigging consists of mapping different parts of the mesh to different bones (e.g. the arm polygons are linked to the arm bone).
Creating skeletal animations
- The modeler animates the character by manipulating the skeleton's bones
- The mesh parts will deform to follow the corresponding bones.
- By creating a sequence of bone positions and storing each position as a keyframe, an animation is created.
Exporting skeletal animations
- For the same character, multiple animations can be created (e.g. “walking”, “running”, “falling”).
- When exporting a rigged character to Ogre format, you will get the associated:
- mesh,
- materials,
- textures,
- and a .skeleton file that holds the information on the skeleton and all the animations associated to it.
Skeleton loading and animation playing
- When a mesh is loaded in Ogre:
- The associated skeleton is also made available,
- The corresponding Animation objects are created.
- You may create one or more entities based on that mesh
- For each of them, you can obtain the corresponding animation state
- You can animate them independently
- Example in the lecture notes