SleakEngine 1.0.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)
AnimationStateMachineCreateStateMachine ()
 Replaces any existing state machine with a fresh, empty one.
RefPtr< RenderEngine::BufferBaseGetBoneBuffer () const
const std::vector< AnimationClip * > & GetClips () const
const std::string & GetCurrentClipName () const
float GetCurrentTime () const
SkeletonGetSkeleton () const
float GetSpeed () const
AnimationStateMachineGetStateMachine () 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)
GameObjectGetOwner ()
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
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
GameObjectowner

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 12 of file AnimatorComponent.cpp.

◆ ~AnimatorComponent()

Sleak::AnimatorComponent::~AnimatorComponent ( )
virtual

Definition at line 17 of file AnimatorComponent.cpp.

Member Function Documentation

◆ AddClip()

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

Definition at line 114 of file AnimatorComponent.cpp.

◆ CreateStateMachine()

AnimationStateMachine * Sleak::AnimatorComponent::CreateStateMachine ( )

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

Definition at line 108 of file AnimatorComponent.cpp.

◆ GetBoneBuffer()

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

Definition at line 372 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 365 of file AnimatorComponent.cpp.

◆ GetCurrentTime()

float Sleak::AnimatorComponent::GetCurrentTime ( ) const

Definition at line 361 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 353 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 21 of file AnimatorComponent.cpp.

◆ IsPlaying()

bool Sleak::AnimatorComponent::IsPlaying ( ) const

Definition at line 357 of file AnimatorComponent.cpp.

◆ Pause()

void Sleak::AnimatorComponent::Pause ( )

Definition at line 340 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 314 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 324 of file AnimatorComponent.cpp.

◆ Resume()

void Sleak::AnimatorComponent::Resume ( )

Definition at line 344 of file AnimatorComponent.cpp.

◆ SetSpeed()

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

Definition at line 349 of file AnimatorComponent.cpp.

◆ Stop()

void Sleak::AnimatorComponent::Stop ( )

Definition at line 335 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 57 of file AnimatorComponent.cpp.