Qt 5.9 | Qt 3D | C++ Classes | QBlendedClipAnimator

Qt 5.9.3 Reference Documentation

# QBlendedClipAnimator Class

(Qt3DAnimation::QBlendedClipAnimator)

QBlendedClipAnimator is a component providing animation playback capabilities of a tree of blend nodes. More...

Header: | #include <QBlendedClipAnimator>
qmake: | QT += 3danimation
Since: | Qt 5.9
Instantiated By: | BlendedClipAnimator
Inherits: | Qt3DAnimation::QAbstractClipAnimator

- List of all members, including inherited members

## Properties

- blendTree : Qt3DAnimation::QAbstractClipBlendNode *

- 3 properties inherited from Qt3DAnimation::QAbstractClipAnimator
- 1 property inherited from Qt3DCore::QComponent
- 3 properties inherited from Qt3DCore::QNode

## Public Functions

| QBlendedClipAnimator(Qt3DCore::QNode *parent = nullptr)
| ~QBlendedClipAnimator()
QAbstractClipBlendNode * | blendTree() const

- 3 public functions inherited from Qt3DAnimation::QAbstractClipAnimator
- 2 public functions inherited from Qt3DCore::QComponent
- 11 public functions inherited from Qt3DCore::QNode

## Public Slots

void | setBlendTree(QAbstractClipBlendNode *blendTree)

- 5 public slots inherited from Qt3DAnimation::QAbstractClipAnimator
- 1 public slot inherited from Qt3DCore::QComponent
- 3 public slots inherited from Qt3DCore::QNode

## Signals

void | blendTreeChanged(QAbstractClipBlendNode *blendTree)

- 3 signals inherited from Qt3DAnimation::QAbstractClipAnimator
- 3 signals inherited from Qt3DCore::QComponent
- 4 signals inherited from Qt3DCore::QNode

### Additional Inherited Members

- 2 protected functions inherited from Qt3DCore::QNode

## Detailed Description

QBlendedClipAnimator is a component providing animation playback capabilities of a tree of blend nodes.

An instance of QBlendedClipAnimator can be aggregated by a QEntity to add the ability to play back animation clips and to apply the calculated animation values to properties of QObjects.

Whereas a QClipAnimator gets its animation data from a single animation clip, QBlendedClipAnimator can blend together multiple clips. The animation data is obtained by evaluating a so called blend tree. A blend tree is a hierarchical tree structure where the leaf nodes are value nodes that encapsulate an animation clip (QAbstractAnimationClip); and the internal nodes represent blending operations that operate on the nodes pointed to by their operand properties.

To associate a blend tree with a QBlendedClipAnimator, set the animator's blendTree property to point at the root node of your blend tree:

      auto blendTreeRoot = new QAdditiveClipBlend();
      ...
      auto animator = new QBlendedClipAnimator();
      animator->setBlendTree(blendTreeRoot);

A blend tree can be constructed from the following node types:

Note: The blend node tree should only be edited when the animator is not running.

- Qt3DAnimation::QClipBlendValue
- Qt3DAnimation::QLerpClipBlend
- Qt3DAnimation::QAdditiveClipBlend

Additional node types will be added over time.

As an example consider the following blend tree:

      Clip0----
              |
              Lerp Node----
              |           |
      Clip1----           Additive Node
                          |
                  Clip2----

This can be created and used as follows:

      // Create leaf nodes of blend tree
      auto clip0 = new QClipBlendValue(
          new QAnimationClipLoader(QUrl::fromLocalFile("walk.json")));
      auto clip1 = new QClipBlendValue(
          new QAnimationClipLoader(QUrl::fromLocalFile("run.json")));
      auto clip2 = new QClipBlendValue(
          new QAnimationClipLoader(QUrl::fromLocalFile("wave-arm.json")));

      // Create blend tree inner nodes
      auto lerpNode = new QLerpClipBlend();
      lerpNode->setStartClip(clip0);
      lerpNode->setEndClip(clip1);
      lerpNode->setBlendFactor(0.5f); // Half-walk, half-run

      auto additiveNode = new QAdditiveClipBlend();
      additiveNode->setBaseClip(lerpNode); // Comes from lerp sub-tree
      additiveNode->setAdditiveClip(clip2);
      additiveNode->setAdditiveFactor(1.0f); // Wave arm fully

      // Run the animator
      auto animator = new QBlendedClipAnimator();
      animator->setBlendTree(additiveNode);
      animator->setChannelMapper(...);
      animator->setRunning(true);

By authoring a set of animation clips and blending between them dynamically at runtime with a blend tree, we open up a huge set of possible resulting animations. As some simple examples of the above blend tree, where alpha is the additive factor and beta is the lerp blend factor we can get a 2D continuum of possible animations:

      (alpha = 0, beta = 1) Running, No arm waving --- (alpha = 1, beta = 1) Running, Arm waving
              |                                               |
              |                                               |
              |                                               |
      (alpha = 0, beta = 0) Walking, No arm waving --- (alpha = 0, beta = 1) Running, No arm waving

More complex blend trees offer even more flexibility for combining your animation clips. Note that the values used to control the blend tree (alpha and beta above) are simple properties on the blend nodes. This means, that these properties themselves can also be controlled by the animation framework.

## Property Documentation

### blendTree : Qt3DAnimation::QAbstractClipBlendNode *

This property holds the root of the animation blend tree that will be evaluated before being interpolated by the animator.

Access functions:

QAbstractClipBlendNode * | blendTree() const
void | setBlendTree(QAbstractClipBlendNode *blendTree)

Notifier signal:

void | blendTreeChanged(QAbstractClipBlendNode *blendTree)

## Member Function Documentation

### QBlendedClipAnimator::QBlendedClipAnimator(Qt3DCore::QNode *parent = nullptr)

Default constructs an instance of QBlendedClipAnimator.

### QBlendedClipAnimator::~QBlendedClipAnimator()

Destroys the instance of QBlendedClipAnimator.