Classes

Animation/Animation Instance

Brief descriptions

Structures

nau::animation::AnimationInstanceCreationData

Classes

nau::animation::AnimationInstance

Allows to modify animation playback and blending parameters which are individual for each animated object.

Detailed information

animation::AnimationInstanceCreationData

engine/core/modules/animation/include/nau/animation/playback/animation_instance.h

struct AnimationInstanceCreationData

Public Members

bool isStopped = false
AnimationAssetRef sourceRef

animation::AnimationInstance

engine/core/modules/animation/include/nau/animation/playback/animation_instance.h

class AnimationInstance : public virtual IRefCounted

Allows to modify animation playback and blending parameters which are individual for each animated object.

To modify keyframe data use animation editor. See Animation and IAnimationEditor.

Public Functions

AnimationInstance(const eastl::string &name, nau::Ptr<Animation> animation, const AnimationInstanceCreationData *creationData = nullptr)

Initialization constructor.

Parameters:
  • name[in] Name of the animation.

  • animation[in] Animation object.

  • creationData[in] Optional creation data.

AnimationInstance(const eastl::string &name, AnimationAssetRef &&assetRef)

Initialization constructor.

Parameters:
  • name[in] Name of the animation.

  • assetRef[in] Animation asset.

AnimationInstance(const eastl::string &name, const AnimationAssetRef &assetRef)

Initialization constructor.

Parameters:
  • name[in] Name of the instance.

  • assetRef[in] Animation asset.

AnimationInstance(const eastl::string &name, const AnimationInstance &source)

Copy constructor.

Parameters:

source[in] Instance to copy.

async::Task load()

Loads animation from the animation asset.

void update(AnimationController &controller, float dt, const IAnimatable::Ptr &target)

Updates animations weights and animates the target.

Parameters:
  • controller[in] Animation controller the animation instance is assigned to.

  • dt[in] Time elapsed since previous update.

  • target[in] Animated object

void restart(AnimationController &controller)

Resets the animation playback to beginning.

Parameters:

controller[in] Animation controller the animation instance is assigned to.

float getCurrentTime() const

Retrieves the number of seconds elapsed since the animation playback has been restarted.

Returns:

Current playback time in seconds.

bool isPlaying() const

Checks whether the animation is currently being played.

Returns:

true is the animation is currently being played, false otherwise.

int getCurrentFrame() const

Retrieves index of the currently played frame of the animation.

Returns:

Index of the currently played frame.

IAnimationPlayer *getPlayer()

Retrieves an animation player object that the animation instance is assigned to.

Returns:

A pointer to the animation player object.

PlayMode getPlayMode() const

Retrieves the playback mode that is currently set for the animation instance.

See m_playMode.

Returns:

Playmode of the animation instance.

void setPlayMode(PlayMode mode)

Changes the playback mode for the animation instance.

See m_playMode.

Parameters:

mode[in] Playback mode to assign.

bool isReversed() const

Checks if the playback of the animation instance is reversed.

Returns:

true if the playback is reversed, false otherwise.

void setIsReversed(bool reverse)

Sets the reverse mode of the animation instance playback.

Parameters:

reverse[in] Indicates whether the playback should be reversed.

float getWeight() const

Retrieves the weight of the animation instance.

Returns:

Animation instance weight.

void setWeight(float weight)

Changes the weight of the animation instance.

Parameters:

weight[in] The value to assign

AnimationBlendMethod getBlendMethod() const

Retrieves the blending method assigned to the animation instance.

Returns:

Blending method of the animation instance.

void setBlendMethod(AnimationBlendMethod blendMethod)

Reassignes the blending method to the animation instance.

Parameters:

blendMethod[in] blending method to assign.

bool getIgnoresController() const

Checks whether the instance weight is governed by the assigned controller.

Returns:

true if the instance ignores the controller, i.e. the instance weight can be modified with setWeight. Otherwise, false is returned and the instance weight cannot be modified manually.

void debugIgnoreController(bool ignore)

Order the instance to ignore the assigned controller, which allows for manual weight modifications.

Parameters:

ignore[in] Indicates whether the instance should ignore the assigned controller, false otherwise.

AnimationInterpolationMethod getInterpolationMethod() const

Retrieves the animation interpolation method.

Returns:

Interpolation method used for this animation instance.

void setInterpolationMethod(AnimationInterpolationMethod value)

Changes the interpolation method for the animation instance.

Parameters:

value[in] Value to assign.

const eastl::string &getName() const

Retrieves the name of the animation instance.

Returns:

Instance name.

AnimationAssetRef getAssetRef() const

Protected Functions

const Animation *getAnimation() const

Private Functions

float getDurationSeconds(AnimationController &controller) const
void advance(AnimationController &controller, float dt)
void updateBlendInOut(AnimationController &controller)
void updateEvents()
void fireEvents()

Private Members

AnimationState m_animationState
nau::Ptr<Animation> m_animation
AnimationAssetRef m_animationAsset
int m_frame = -1
PlayMode m_playMode = PlayMode::Once

Controls animation playback behavior after the last frame has been played.

  • Once: Playback stops after the last frame has been reached.

  • Looping: Playback restarts after the last frame has been reached.

  • PingPong: Playback gets reversed after the last frame has been reached.

bool m_isLoaded = false

Indicates whether the animation asset has been loaded.

eastl::string m_name

Friends

friend class KeyFrameAnimationPlayer