Motive Animation System
An open source project by FPL.
 All Classes Functions Variables Typedefs Friends Pages


A Motivator is an animated variable. You can use,

  • Motivator1fs to animate floats,
  • Motivator2fs, Motivator3fs, and Motivator4fs to animate 2, 3, and 4 dimensional vectors,
  • MatrixMotivator4fs to animate 4x4 matrices, and
  • RigMotivators to animate entire skeletons.

Simple example

Suppose you have a duck that follows screen touches. You could use a Motivator2f to represent the duck's position on screen. Whenever a touch occurs, the duck's Motivator2f is updated with a new target position, and the duck smoothly animates to it.

The code would look something like this:

// Initialize the Motivator to use the `Spline` animation algorithm.
Motivator2f duck_position;
duck_position.InitializeWithTarget(SplineInit(), &motive_engine,
// Smoothly transition the duck to wherever a touch occurs.
while (FollowDuck()) {
vec2 touch_position;
if (ScreenTouch(&touch_position)) {
// Set the duck's target position, velocity, and time.
duck_position.SetTarget(Tar2f::Target(touch_position, kZeros2f,
// Once per frame, motive_engine.AdvanceFrame() is called to animate *all*
// Motivators at once. In this case, we only have one Motivator,
// but in many applications there will be thousands.
// Draw the duck at its current position.
// Use the velocity to draw motion lines behind the duck, too.
DrawDuck(duck_position.Value(), duck_position.Velocity());

Please see src/samples/duck2f/duck2f.cpp for the complete source of this example.

Behind-the-scenes example

The next example illustrates how to animate the face-angle of a character. The comments describe, in brief, what is going on internally.

This program generates the output below. Notice that the face angle is animated smoothly from 120 degrees to -120 degrees.

Notice also that we take the shortest path by passing through 180 degrees, instead of 0. We get this behavior by setting modular_arithmetic to true in SmoothInit.

y = 178.020294
|                                        ***
|                                    ****
|                                ****
|                          ******
|              ************
|                                                                     **********
|                                                            **********
|                                                      ******
|                                                  *****
|                                             *****
|                                          ***
y = -179.489014

If you'd like to experiment with this program, it is compiled for you in src/samples/smooth1f/smooth1f.cpp.

Motivators driving other Motivators

A MatrixMotivator4f is driven by a series of Motivator1fs that represent rotation, translation, and scale operations. These operations are composed to produce the final 4x4 matrix.

A RigMotivator is driven by an array of MatrixMotivator4fs. Each 4x4 matrix represents the transform of a bone in the skeleton.

In general, more complicated Motivators are driven by simpler Motivators.

Animation algorithms

Internally, a Motivator is a handle into a MotiveProcessor. The MotiveProcessor holds all the data and does all the animating. Each MotiveProcessor follows its own animation algorithm. See [Motive Processors] for more details.

At any time, a Motivator can be reinitialized to use a different animation algorithm from a different MotiveProcessor.

The external API remains the same, no matter what MotiveProcessor is backing a Motivator. This means you can always call Value() and Velocity() on a Motivator1f that's been initialized.