Table of Contents

Ogre Tutorial 4: Animation in Ogre

Ogre Animation Basics

Animation Definition

An animation defines the variation of a series of parameters for a set of objects during a specified time span (e.g. an object performing a circular movement in 10 seconds). An animation is described by a set of tracks (each controlling specific parameters) and for each a set of keyframes associated at pre-defined time instants within the animation duration.

Animation Execution

The actual execution of an animation is controlled by an animation state, which transforms the animable object's parameters for the values defined in the Animation, according to a given time instant.

The same animation can be used in similar objects, each with its AnimationState. The programmer has to update the animations (typically in an update or frame listener), but to do so he/she only needs to update the AnimationState with the corresponding time instant.

Example: a circling light

Let's create a rotating light using the animation facilities provided by Ogre (this example has been loosely based on this Xadeck tutorial).

That's it. With these basic concepts you can already elaborate on a series of animations and effects, such as pulsing objects, magic flares around a character, moving an object along a path, etc.

Character / Mesh Animation

The same concepts described above apply to the animation of characters. The main difference is that you do not create the Animation's and animation tracks in code, but these are created interactively by the artists modelling the characters in a 3D modelling tool such as Blender or 3DS Max, and then exported to Ogre.

Character Rigging

Characters are first created as meshes in such modelling tools, and then rigged with a bone or skeleton. The skeleton consists of a set of segments (the bones) and joints, and 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 animation and exporting

The modeler can then animate the character by manipulating the skeleton's bones, and 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.

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 and 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, and the corresponding Animation objects are created. You may then create one or more entities based on that mesh, and for each of them obtain the corresponding animation state, so that you can animate them independently (AnimationState updates are again performed in a frame listener).

Skeletal animation example

Ogre provides a series of sample characters that you may use. Below is an example on how to add a “Jaiqua” to your scene: