Classes¶
Animation/Controller
Brief descriptions¶
Classes |
|
Manages multiple animation instances animating one target. |
|
Detailed information¶
animation::AnimationController¶
engine/core/modules/animation/include/nau/animation/controller/animation_controller.h
-
class AnimationController : public virtual IRefCounted¶
Manages multiple animation instances animating one target.
Note
No blending is performed. For a blending controller see BlendAnimationController.
Subclassed by nau::animation::BlendAnimationController, nau::animation::DirectAnimationController
Public Functions
-
AnimationController()¶
Default constructor.
-
~AnimationController()¶
Destructor.
-
async::Task load()¶
Loads managed animations from assets.
-
virtual void update(float dt, const IAnimatable::Ptr &target)¶
Advances each managed animation.
- Parameters:
dt – [in] Time in seconds elapsed since the last update.
target – [in] Target object to apply animations to.
-
virtual void addAnimation(nau::Ptr<AnimationInstance> animation)¶
Binds the animation to the controller.
- Parameters:
animation – [in] Animation to manage.
-
float getFrameRate() const¶
Retrieves the animation frame rate.
- Returns:
Animation frame rate (frames per second).
-
int getCurrentFrame() const¶
Retrieves the total number of frames accumulated from the controller updates.
Note
This count is not nullified upon any animation reaches its end. In order to retrieve the current frame of a concrete animation instance, address to the corresponding AnimationInstance methods.
- Returns:
Total number of frames.
-
virtual float getWeight(TAnimDescrParam animationId) const¶
Retrieves the weight of a managed animation.
- Parameters:
animationId – [in] A handle to the animation instance to retrieve the weight of.
- Returns:
Animation instance weight.
-
int getAnimationInstancesCount() const¶
Retrieves the number of animation instances managed by the controller.
- Returns:
Number of managed animation instances.
-
AnimationInstance *getAnimationInstanceAt(int index)¶
Retrieves managed animation instance.
- Parameters:
index – [in] Index of the animation instance to retrieve.
- Returns:
A pointer to the managed animation instance object.
-
AnimationInstance *getAnimInstance(TAnimDescrParam animationId)¶
Retrieves managed animation instance.
- Parameters:
animationId – [in] A handle to the animation instance to retrieve.
- Returns:
A pointer to the managed animation instance object.
-
virtual const eastl::string_view getControllerTypeName() const = 0¶
Public Static Attributes
-
static constexpr float NEGLIGIBLE_WEIGHT = 5.e-3f¶
Protected Functions
-
inline virtual void onLoaded()¶
Private Types
-
using Ptr = nau::Ptr<AnimationController>¶
Private Members
-
std::vector<nau::Ptr<AnimationInstance>> m_animations¶
A collection of managed animation instances.
-
int m_frame = 0¶
-
float m_frameTime = .0f¶
-
struct AnimInstanceDescriptor¶
Encapsulates a handle to an animation instance.
Public Functions
-
AnimInstanceDescriptor() = default¶
-
AnimInstanceDescriptor(const AnimationInstance &animInstance)¶
-
AnimInstanceDescriptor(nau::string animName)¶
-
AnimInstanceDescriptor(const eastl::string &animName)¶
Public Members
-
eastl::string name¶
Friends
-
friend bool operator==(const AnimInstanceDescriptor&, const AnimInstanceDescriptor&) = default¶
-
AnimInstanceDescriptor() = default¶
-
AnimationController()¶
animation::BlendAnimationController¶
engine/core/modules/animation/include/nau/animation/controller/animation_controller_blend.h
-
class BlendAnimationController : public nau::animation::AnimationController¶
Public Functions
-
BlendAnimationController() = delete¶
Default constructor (deleted).
-
inline BlendAnimationController(nau::Ptr<AnimationMixer> aMixer)¶
Initialization constructor.
- Parameters:
aMixer – [in] Mixer object that is used to blend the managed animations.
-
virtual void update(float dt, const IAnimatable::Ptr &target) override¶
Advances each managed animation instance, blends them and animates the target.
- Parameters:
dt – [in] Time in seconds elapsed since the last update.
target – [in] Target object to apply animations to.
-
virtual void addAnimation(nau::Ptr<AnimationInstance> animation) override¶
Binds the animation to the controller.
- Parameters:
animation – [in] Animation to manage.
-
virtual float getWeight(TAnimDescrParam animationId) const override¶
Retrieves the weight of a managed animation.
- Parameters:
animationId – [in] A handle to the animation instance to retrieve the weight of.
- Returns:
Animation instance weight.
-
void setWeight(TAnimDescrParam animationId, float weight)¶
Sets the weight of the managed animation.
- Parameters:
animationId – [in] A handle to the animation instance to set the weight of.
weight – [in] Value to assign.
-
virtual const eastl::string_view getControllerTypeName() const override¶
Private Members
-
eastl::vector<AnimationPlaybackData> m_playbackTable¶
Stores weights of managed animations.
-
nau::Ptr<AnimationMixer> m_animationMixer¶
Mixer object that is responsible for blending animation instances.
-
struct AnimationPlaybackData¶
-
BlendAnimationController() = delete¶
animation::DirectAnimationController¶
engine/core/modules/animation/include/nau/animation/controller/animation_controller_direct.h
-
class DirectAnimationController : public nau::animation::AnimationController¶
Public Functions
-
virtual void update(float dt, const IAnimatable::Ptr &target) override¶
Advances each managed animation.
- Parameters:
dt – [in] Time in seconds elapsed since the last update.
target – [in] Target object to apply animations to.
-
virtual void addAnimation(nau::Ptr<AnimationInstance> animation) override¶
Binds the animation to the controller.
- Parameters:
animation – [in] Animation to manage.
-
virtual float getWeight(TAnimDescrParam animationId) const override¶
Retrieves the weight of a managed animation.
- Parameters:
animationId – [in] A handle to the animation instance to retrieve the weight of.
- Returns:
Animation instance weight.
-
void setWeight(TAnimDescrParam animationId, float weight)¶
-
virtual const eastl::string_view getControllerTypeName() const override¶
Protected Functions
-
void updateWeights()¶
Private Members
-
eastl::vector<AnimationPlaybackData> m_playbackTable¶
-
struct AnimationPlaybackData¶
-
virtual void update(float dt, const IAnimatable::Ptr &target) override¶