VisuTwin Canvas
C++ 3D Engine — Metal Backend
Loading...
Searching...
No Matches
visutwin::canvas::AnimationComponent Class Reference

#include <framework/components/animation/animationComponent.h>

Inheritance diagram for visutwin::canvas::AnimationComponent:
[legend]

Public Types

using AnimationResource = std::variant<std::shared_ptr<Animation>, std::shared_ptr<AnimTrack>>

Public Member Functions

bool activate () const
void addAnimation (const std::string &name, const std::shared_ptr< Animation > &animation)
void addAnimation (const std::string &name, const std::shared_ptr< AnimTrack > &animationTrack)
 AnimationComponent (IComponentSystem *system, Entity *entity)
const std::unordered_map< std::string, AnimationResource > & animations () const
const std::vector< int > & assets () const
void clearBlendCurve ()
float currentTime () const
float duration () const
std::shared_ptr< AnimationgetAnimation (const std::string &name) const
std::shared_ptr< AnimTrackgetAnimTrack (const std::string &name) const
void initializeComponentData () override
bool loop () const
void onBeforeRemove ()
void onEnable () override
void onSetAnimations ()
void play (const std::string &name, float blendTime=0.0f)
bool playing () const
void setActivate (bool value)
void setAnimations (const std::unordered_map< std::string, AnimationResource > &value)
void setAssets (const std::vector< int > &value)
void setBlendCurve (const Curve &curve)
void setCurrentTime (float currentTime)
void setLoop (bool value)
void setModel (GraphNode *model)
void setPlaying (bool value)
void setSpeed (float value)
float speed () const
void update (float dt)
 ~AnimationComponent () override
Public Member Functions inherited from visutwin::canvas::Component
virtual void cloneFrom (const Component *source)
 Component (IComponentSystem *system, Entity *entity)
virtual bool enabled () const
Entityentity () const
virtual void onDisable ()
virtual void onPostStateChange ()
virtual void setEnabled (bool value)
IComponentSystemsystem () const
virtual ~Component ()=default
Public Member Functions inherited from visutwin::canvas::EventHandler
template<typename... Args>
EventHandlerfire (const std::string &name, Args &&... args)
bool hasEvent (const std::string &name) const
void initEventHandler ()
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleroff (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleroff (const std::string &name="", const HandleEventCallback &callback=HandleEventCallback(), void *scope=nullptr)
EventHandleroffByHandle (EventHandle *handle)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleon (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleon (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
template<typename Callback>
requires (!std::is_same_v<std::decay_t<Callback>, HandleEventCallback>)
EventHandleonce (const std::string &name, Callback &&callback, void *scope=nullptr)
EventHandleonce (const std::string &name, HandleEventCallback callback, void *scope=nullptr)
virtual ~EventHandler ()=default

Static Public Member Functions

static const std::vector< AnimationComponent * > & instances ()

Additional Inherited Members

Protected Member Functions inherited from visutwin::canvas::Component
virtual void onSetEnabled (bool oldValue, bool newValue)
Protected Member Functions inherited from visutwin::canvas::EventHandler
EventHandleaddCallback (const std::string &name, HandleEventCallback callback, void *scope=nullptr, bool once=false)
Protected Attributes inherited from visutwin::canvas::Component
bool _enabled = true
Entity_entity

Detailed Description

Definition at line 23 of file animationComponent.h.

Member Typedef Documentation

◆ AnimationResource

using visutwin::canvas::AnimationComponent::AnimationResource = std::variant<std::shared_ptr<Animation>, std::shared_ptr<AnimTrack>>

Definition at line 26 of file animationComponent.h.

Constructor & Destructor Documentation

◆ AnimationComponent()

visutwin::canvas::AnimationComponent::AnimationComponent ( IComponentSystem * system,
Entity * entity )

◆ ~AnimationComponent()

visutwin::canvas::AnimationComponent::~AnimationComponent ( )
override

Definition at line 18 of file animationComponent.cpp.

Member Function Documentation

◆ activate()

bool visutwin::canvas::AnimationComponent::activate ( ) const
inline

Definition at line 70 of file animationComponent.h.

◆ addAnimation() [1/2]

void visutwin::canvas::AnimationComponent::addAnimation ( const std::string & name,
const std::shared_ptr< Animation > & animation )

Definition at line 32 of file animationComponent.cpp.

References onSetAnimations().

◆ addAnimation() [2/2]

void visutwin::canvas::AnimationComponent::addAnimation ( const std::string & name,
const std::shared_ptr< AnimTrack > & animationTrack )

Definition at line 38 of file animationComponent.cpp.

References onSetAnimations().

◆ animations()

const std::unordered_map< std::string, AnimationResource > & visutwin::canvas::AnimationComponent::animations ( ) const
inline

Definition at line 36 of file animationComponent.h.

◆ assets()

const std::vector< int > & visutwin::canvas::AnimationComponent::assets ( ) const
inline

Definition at line 39 of file animationComponent.h.

◆ clearBlendCurve()

void visutwin::canvas::AnimationComponent::clearBlendCurve ( )

Definition at line 381 of file animationComponent.cpp.

◆ currentTime()

float visutwin::canvas::AnimationComponent::currentTime ( ) const

Definition at line 59 of file animationComponent.cpp.

Referenced by setCurrentTime(), and update().

◆ duration()

float visutwin::canvas::AnimationComponent::duration ( ) const

Definition at line 75 of file animationComponent.cpp.

Referenced by update().

◆ getAnimation()

std::shared_ptr< Animation > visutwin::canvas::AnimationComponent::getAnimation ( const std::string & name) const

Definition at line 124 of file animationComponent.cpp.

References visutwin::canvas::GraphNode::find().

Referenced by play().

◆ getAnimTrack()

std::shared_ptr< AnimTrack > visutwin::canvas::AnimationComponent::getAnimTrack ( const std::string & name) const

Definition at line 138 of file animationComponent.cpp.

Referenced by play().

◆ initializeComponentData()

void visutwin::canvas::AnimationComponent::initializeComponentData ( )
inlineoverridevirtual

Implements visutwin::canvas::Component.

Definition at line 31 of file animationComponent.h.

◆ instances()

const std::vector< AnimationComponent * > & visutwin::canvas::AnimationComponent::instances ( )
inlinestatic

Definition at line 33 of file animationComponent.h.

◆ loop()

bool visutwin::canvas::AnimationComponent::loop ( ) const
inline

Definition at line 47 of file animationComponent.h.

◆ onBeforeRemove()

void visutwin::canvas::AnimationComponent::onBeforeRemove ( )

Definition at line 301 of file animationComponent.cpp.

◆ onEnable()

void visutwin::canvas::AnimationComponent::onEnable ( )
overridevirtual

Reimplemented from visutwin::canvas::Component.

Definition at line 292 of file animationComponent.cpp.

References visutwin::canvas::Component::onEnable(), and play().

◆ onSetAnimations()

void visutwin::canvas::AnimationComponent::onSetAnimations ( )

◆ play()

void visutwin::canvas::AnimationComponent::play ( const std::string & name,
float blendTime = 0.0f )

◆ playing()

bool visutwin::canvas::AnimationComponent::playing ( ) const
inline

Definition at line 76 of file animationComponent.h.

◆ setActivate()

void visutwin::canvas::AnimationComponent::setActivate ( bool value)
inline

Definition at line 69 of file animationComponent.h.

◆ setAnimations()

void visutwin::canvas::AnimationComponent::setAnimations ( const std::unordered_map< std::string, AnimationResource > & value)

Definition at line 26 of file animationComponent.cpp.

References onSetAnimations().

◆ setAssets()

void visutwin::canvas::AnimationComponent::setAssets ( const std::vector< int > & value)
inline

Definition at line 38 of file animationComponent.h.

◆ setBlendCurve()

void visutwin::canvas::AnimationComponent::setBlendCurve ( const Curve & curve)

Definition at line 375 of file animationComponent.cpp.

◆ setCurrentTime()

void visutwin::canvas::AnimationComponent::setCurrentTime ( float currentTime)

Definition at line 44 of file animationComponent.cpp.

References currentTime().

◆ setLoop()

void visutwin::canvas::AnimationComponent::setLoop ( bool value)

Definition at line 93 of file animationComponent.cpp.

◆ setModel()

void visutwin::canvas::AnimationComponent::setModel ( GraphNode * model)

Definition at line 110 of file animationComponent.cpp.

References play().

Referenced by onSetAnimations().

◆ setPlaying()

void visutwin::canvas::AnimationComponent::setPlaying ( bool value)
inline

Definition at line 75 of file animationComponent.h.

◆ setSpeed()

void visutwin::canvas::AnimationComponent::setSpeed ( float value)
inline

Definition at line 72 of file animationComponent.h.

◆ speed()

float visutwin::canvas::AnimationComponent::speed ( ) const
inline

Definition at line 73 of file animationComponent.h.

◆ update()

void visutwin::canvas::AnimationComponent::update ( float dt)

Definition at line 310 of file animationComponent.cpp.

References currentTime(), and duration().


The documentation for this class was generated from the following files: