bw logo

Chapter 11. Animation System

The animation system in the BigWorld engine combines many sophisticated techniques that are accessed via an easy-to-use interface. This system allows game developers to quickly create lifelike characters and environments. The problem this system solves is taking the raw content that is created by artists and integrating it into a believable dynamic game world.

Artists working on design tools such as 3ds Max or Maya can create models and animations, then use the BigWorld Exporter plug-in to export them into data files of a format understandable by the graphics engine.

The Model Editor tool can be used to view these models and play back animations. It is then used to create a list of actions from these animations that are the Python-accessible interfaces within the game engine.

11.1. Basic keyframed animations

The motions of an object over time can be stored as an array of keyframes that describe the position, rotation, and scale of an object (or part of one) at different points in time. These keyframes are then used as reference values and intermediate positions and rotations are calculated by interpolating between keyframe data.

More realistic intricate objects are described as nodal trees representing a bone hierarchy. An example is a simple biped character that would have a typical hierarchy shown below:

Typical biped hierarchy

Each node represents the spatial state of a part of an object. These can map to rendered geometry either directly for rigid objects such as a hydraulic machine or as bone transforms that are used to update a skinned mesh (each geometry vertex having a set of weights that define how each bone influences its movement).

11.2. Animation layering and blending

A simple animation such as a man waving may consists of keyframe arrays from a subset of the whole bone tree, e.g., only for Torso, UpperArmRight and LowerArmRight.

A different animation of the man walking may include only the Torso and Pelvis sub-tree. These two animations can be seen as different layers of the total movement. Within the BigWorld framework, this layering is achieved via setting nodal alpha values with the Model Editor tool, as illustrated below:

Model Editor 'Blending' fields

Within the engine, different layers can be seen to be played on different animation tracks, which control the stopping and starting of animations for particular parts of the body (the usual separation into upper and lower body allows motion and action to be dealt with smoothly yet independently within a game).

It is possible to play an arbitrary number of animations at once and have the resulting motion be a blended interpolation of all the animations. This is essentially the same procedure as keyframed interpolation, as we are interpolating position, rotation, and scale data. When the different animation layers need to be combined into a single motion, the nodes that overlap in the different tracks need to be blended together.

Transitions between animations could be achieved by creating all possible animation transitions and allowing all animations to complete their cycle before starting a new animation.

A much more adaptable and robust method is to blend out ending animations and blend in starting animations over a period of time. As long as the animation list is large enough to account for possible jarring transitions. For example, instead of having only stand and run animations, include also walk and jog ones, then this system combined with good animations creates smooth lifelike behaviour in game characters.

11.3. Animation data files

The BigWorld exporter outputs the following data files (all file types exported to the resource tree <res>):

  • .visual files

    Define an object's bone structure and material data.

  • .primitive files

    Define the vertex data such as offset and weighting values for a skinned object, and contain BSP data where appropriate.

  • .animation files

    Define the keyframe data of an animation.

11.4. Animation data streaming

Animation data is stored as a series of blocks that are asynchronously streamed into memory on demand.

The sum of all these blocks is referred to as the streamed block cache, which size is constrained to prevent excessive memory usage. To specify the size of the cache, set the animation/streamChacheSizeKB tag in <engine_config>.xml (for details, see File <engine_config>.xml)

The watchers Memory/StreamedBlocks_CacheSize and Memory/StreamedBlocks_CacheMaxSize display the current size and the limit of the cache in bytes, respectively.

11.5. Actions

An action is a wrapper object that links an animation to in-game behaviour and events. Action objects differ from animation ones in the information they hold, as described below:

  • Animation object

    • Raw keyframe data.

    • Information on frame rate.

    • Functionality on how to play itself on a model.

  • Action object

    • Blending time information.

    • Information on whether action is loop.

    • Information on whether an animation is movement.

    • Animation-matching data specifying particular object state values for when a particular action should be played.

The raw data describing an action is defined in a .model file in XML format (located in any of the various sub-folders under the resource tree <res>, such as for example, <res>/environments, <res>/flora, <res>/sets/vehicles, etc...).. This data is produced from the Model Editor tool.

For details, see Action Matcher.