Crystal Space 2.0.0: 4.15.1.1 General concepts and examples

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

#### 4.15.1.1 General concepts and examples

In an animation blending tree, the combination of animations is made by creating a tree of animation nodes that will blend the position and orientation of each bone of the skeleton of the Animesh, hence the name of the method. The structure of the tree, i.e. the choice of animation nodes and the way they are combined, will affect the behavior of the animation.

Each leaf of the blending tree is either a raw animation sequence (user-defined by an artist or acquired by technologies such as motion capture), or a procedural node, i.e. a node dynamically generating an animation. The other nodes in the tree are used for the combination of sub-trees in order to achieve complex animations and behaviors.

#### First example: a windmill

A windmill is extremely simple since it has a priori only a single animation: the wheel turning. This animation will be defined in a very simple animation sequence (a `CS::Animation::iSkeletonAnimation`), with e.g. two key frames.

In order to animate the mesh of your windmill, you would create a blending tree containing a single animation node, a `CS::Animation::iSkeletonAnimationNodeFactory`, that would simply play the wheel animation. Before that, you need to configure the `CS::Animation::iSkeletonAnimationNodeFactory` in order to play cyclically, otherwise the animation will be stopped after it has been played once.

The blending tree has a single node and looks like this:

       CS::Animation::iSkeletonAnimationNode

Now, say that there is more wind, and that you want to change the speed of the rotation of the wheel. For that, you would access the `CS::Animation::iSkeletonAnimationNode` in the blending tree (using e.g. `CS::Animation::iSkeletonAnimNode::FindNode()`), and change the animation speed with `CS::Animation::iSkeletonAnimNode::SetPlaybackSpeed()`.

#### Second example: debugging your windmill

Event if the first windmill example is very simple, it might just not work and your wheel just don't do what you want. A way to analyze a bit further what is going on is to use a `CS::Animation::iSkeletonDebugNode`. With this node, you would be able to display the structure of the skeleton of your mesh, and hopefully to understand your problem.

In order to use the `‘Debug’` node, you would just add it at the top of your blending tree, i.e. the root, with the the `CS::Animation::iSkeletonAnimationNode` as a child node. Now, when the animation is played, both nodes are activated, and you can either animate your windmill and visualize the skeleton.

The structure of the blending tree now looks like this:

         CS::Animation::iSkeletonDebugNode
                          |
                          |
       CS::Animation::iSkeletonAnimationNode

#### Third example: dynamic behavior

Now, say that you have several different animations of your wheel turning at various speed, e.g. with the wheel starting to roll out when the speed is high. You may use a `CS::Animation::iSkeletonSpeedNode` that will take all these animations as input child nodes, and combine them in order to generate a new animation, whatever the rotation speed asked by the user.

Say also, that you want to attach some pieces of tissue to the wheel, and that you want those pieces to ba animated through soft body physical simulation. For that, you would use a `CS::Animation::iSkeletonRagdollNode` in order to create the physical rigid bodies that will represent the wheel (you would need to provide the collision model of your animesh for that). Then you would create a Genmesh animated by the soft body controller, and attach it to the rigid bodies of your wheel.

Now, the structure of the blending tree looks like this:

                                        CS::Animation::iSkeletonDebugNode
                                                         |
                                                         |
                                       CS::Animation::iSkeletonRagdollNode
                                                         |
                                                         |
                                        CS::Animation::iSkeletonSpeedNode
                                                         |
                              ----------------------------------------------------------
                              |                                                        |
           CS::Animation::iSkeletonAnimationNode                    CS::Animation::iSkeletonAnimationNode
                 ('normal speed' animation)                                 ('high speed' animation)

#### Other examples

Other examples of setup of animations trees and general Animesh usage can be found in the `avatartest` application. The `csbias` demo is also another interesting example.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated using texi2html 1.76.