Configuring and Loading an Animation
Candera Animation Concept
The following key concepts are required to run animations in a Candera application:
In SceneComposer, animations can be configured in the AnimationDesign view:
It is also possible to import an animation to SceneComposer from a content generation tool via FBX format - Import FBX in SceneComposer User Manual
Animation Player Example
As an example, refer to
Configuring Animation Player
In the Player or in an application, the animation can be retrieved from the generated asset by specifying its Candera name (e.g. MyModule#Animations#Animation).
AssetProvider* assetProvider = GetAssetProvider();
m_animPlayer = assetProvider->GetAnimation(m_animName);
In SceneComposer the animation can be retrieved from AssetProvider only if it was previously loaded in the scene. A better way to access it directly is to define it as a widget property.
// Define Animation property
CdaProperty(Animation,Candera::Animation::AnimationPlayer::SharedPointer, GetAnimation, SetAnimation)
CdaDescription("Animation")
CdaPropertyEnd()
// End Define Animation property
Next, as already explained in Initializing AssetLoader and Animations, an instance of Candera::Animation::AnimationTimeDispatcher is needed to provide current world time to animations.
For this, the new animation player must be added to the Candera::Animation::AnimationTimeDispatcher instance maintained by the application.
// Add player to time dispatcher
Animation::AnimationTimeDispatcher::SharedPointer timeDispatcher = GetAnimationTimeDispatcher();
if (timeDispatcher == 0) {
return;
}
static_cast<void>(timeDispatcher->AddPlayer(m_animPlayer));
// End Add player to time dispatcher
Now the animation player is ready to be used.