SleakEngine 0.1.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::AnimatorComponent Class Reference

#include <AnimatorComponent.hpp>

Inheritance diagram for Sleak::AnimatorComponent:

Public Member Functions

 AnimatorComponent (GameObject *owner, Skeleton *skeleton, std::vector< AnimationClip * > clips)
virtual ~AnimatorComponent ()
void AddClip (AnimationClip *clip)
AnimationStateMachine * CreateStateMachine ()
 Replaces any existing state machine with a fresh, empty one.
RefPtr< RenderEngine::BufferBase > GetBoneBuffer () const
const std::vector< AnimationClip * > & GetClips () const
const std::string & GetCurrentClipName () const
float GetCurrentTime () const
Skeleton * GetSkeleton () const
float GetSpeed () const
AnimationStateMachine * GetStateMachine () const
virtual bool Initialize () override
 Allocates the bone constant buffer and attaches it to the sibling MeshComponent.
bool IsPlaying () const
void Pause ()
void Play (const std::string &clipName, bool loop=true)
 Switches to the clip by name, restarting from time zero.
void Play (int clipIndex, bool loop=true)
 Switches to the clip by index, restarting from time zero.
void Resume ()
void SetSpeed (float speed)
void Stop ()
virtual void Update (float deltaTime) override
 Samples the active state machine or clip and pushes the resulting bone matrices to the GPU.
Public Member Functions inherited from Sleak::Component
 Component (GameObject *object)
virtual ~Component ()=default
virtual void FixedUpdate (float fixedDeltaTime)
GameObject * GetOwner ()
bool IsInitialized () const
 True once Initialize() has run and succeeded.
virtual void LateUpdate (float deltaTime)
virtual void OnDestroy ()
 Called when the component is detached or the owner is destroyed.
virtual void OnDisable ()
virtual void OnEnable ()
Public Member Functions inherited from Sleak::Object
 Object (const std::string &name="Object")
virtual ~Object ()=default
std::string GetDebugName () const
 Name plus unique ID, for logs where names can repeat.
const std::string & GetName () const
uint64_t GetUniqueID () const
void SetName (const std::string &value)

Additional Inherited Members

Protected Attributes inherited from Sleak::Component
bool bIsInitialized
GameObject * owner

Detailed Description

Samples a skeleton's bones from clips or a state machine and uploads the result to the sibling MeshComponent's bone buffer each frame.

Definition at line 23 of file AnimatorComponent.hpp.

Constructor & Destructor Documentation

◆ AnimatorComponent()

Sleak::AnimatorComponent::AnimatorComponent ( GameObject * owner,
Skeleton * skeleton,
std::vector< AnimationClip * > clips )

Definition at line 13 of file AnimatorComponent.cpp.

◆ ~AnimatorComponent()

Sleak::AnimatorComponent::~AnimatorComponent ( )
virtual

Definition at line 18 of file AnimatorComponent.cpp.

Member Function Documentation

◆ AddClip()

void Sleak::AnimatorComponent::AddClip ( AnimationClip * clip)

Definition at line 115 of file AnimatorComponent.cpp.

◆ CreateStateMachine()

AnimationStateMachine * Sleak::AnimatorComponent::CreateStateMachine ( )

Replaces any existing state machine with a fresh, empty one.

Definition at line 109 of file AnimatorComponent.cpp.

◆ GetBoneBuffer()

RefPtr< RenderEngine::BufferBase > Sleak::AnimatorComponent::GetBoneBuffer ( ) const

Definition at line 375 of file AnimatorComponent.cpp.

◆ GetClips()

const std::vector< AnimationClip * > & Sleak::AnimatorComponent::GetClips ( ) const
inline

Definition at line 56 of file AnimatorComponent.hpp.

◆ GetCurrentClipName()

const std::string & Sleak::AnimatorComponent::GetCurrentClipName ( ) const

Definition at line 368 of file AnimatorComponent.cpp.

◆ GetCurrentTime()

float Sleak::AnimatorComponent::GetCurrentTime ( ) const

Definition at line 364 of file AnimatorComponent.cpp.

◆ GetSkeleton()

Skeleton * Sleak::AnimatorComponent::GetSkeleton ( ) const
inline

Definition at line 55 of file AnimatorComponent.hpp.

◆ GetSpeed()

float Sleak::AnimatorComponent::GetSpeed ( ) const

Definition at line 356 of file AnimatorComponent.cpp.

◆ GetStateMachine()

AnimationStateMachine * Sleak::AnimatorComponent::GetStateMachine ( ) const
inline

Definition at line 51 of file AnimatorComponent.hpp.

◆ Initialize()

bool Sleak::AnimatorComponent::Initialize ( )
overridevirtual

Allocates the bone constant buffer and attaches it to the sibling MeshComponent.

Implements Sleak::Component.

Definition at line 22 of file AnimatorComponent.cpp.

◆ IsPlaying()

bool Sleak::AnimatorComponent::IsPlaying ( ) const

Definition at line 360 of file AnimatorComponent.cpp.

◆ Pause()

void Sleak::AnimatorComponent::Pause ( )

Definition at line 343 of file AnimatorComponent.cpp.

◆ Play() [1/2]

void Sleak::AnimatorComponent::Play ( const std::string & clipName,
bool loop = true )

Switches to the clip by name, restarting from time zero.

Definition at line 317 of file AnimatorComponent.cpp.

◆ Play() [2/2]

void Sleak::AnimatorComponent::Play ( int clipIndex,
bool loop = true )

Switches to the clip by index, restarting from time zero.

Definition at line 327 of file AnimatorComponent.cpp.

◆ Resume()

void Sleak::AnimatorComponent::Resume ( )

Definition at line 347 of file AnimatorComponent.cpp.

◆ SetSpeed()

void Sleak::AnimatorComponent::SetSpeed ( float speed)

Definition at line 352 of file AnimatorComponent.cpp.

◆ Stop()

void Sleak::AnimatorComponent::Stop ( )

Definition at line 338 of file AnimatorComponent.cpp.

◆ Update()

void Sleak::AnimatorComponent::Update ( float deltaTime)
overridevirtual

Samples the active state machine or clip and pushes the resulting bone matrices to the GPU.

Implements Sleak::Component.

Definition at line 58 of file AnimatorComponent.cpp.