1#ifndef _ANIMATORCOMPONENT_HPP_
2#define _ANIMATORCOMPONENT_HPP_
26 std::vector<AnimationClip*> clips);
32 virtual void Update(
float deltaTime)
override;
36 void Play(
const std::string& clipName,
bool loop =
true);
38 void Play(
int clipIndex,
bool loop =
true);
56 const std::vector<AnimationClip*>&
GetClips()
const {
return m_clips; }
64 void ComputeBoneTransformsForClip(
AnimationClip* clip,
float animTime,
65 std::vector<Math::Matrix4>& outMatrices);
67 void ProcessNodeHierarchyForClip(
int nodeIndex,
const Math::Matrix4& parentTransform,
69 std::vector<Math::Matrix4>& outMatrices);
73 void ComputeBoneTransforms(
float animTime);
75 void ProcessNodeHierarchy(
int nodeIndex,
const Math::Matrix4& parentTransform,
80 static void BlendBoneMatrices(
const std::vector<Math::Matrix4>& a,
81 const std::vector<Math::Matrix4>& b,
83 std::vector<Math::Matrix4>& out);
94 std::vector<AnimationClip*> m_clips;
96 int m_currentClip = -1;
97 float m_currentTime = 0.0f;
99 bool m_playing =
false;
103 std::vector<Math::Matrix4> m_boneMatrices;
104 std::vector<Math::Matrix4> m_boneMatricesB;
const std::string & GetCurrentClipName() const
AnimationStateMachine * GetStateMachine() const
AnimationStateMachine * CreateStateMachine()
Replaces any existing state machine with a fresh, empty one.
float GetCurrentTime() const
virtual void Update(float deltaTime) override
Samples the active state machine or clip and pushes the resulting bone matrices to the GPU.
Skeleton * GetSkeleton() const
AnimatorComponent(GameObject *owner, Skeleton *skeleton, std::vector< AnimationClip * > clips)
void Play(const std::string &clipName, bool loop=true)
Switches to the clip by name, restarting from time zero.
const std::vector< AnimationClip * > & GetClips() const
void SetSpeed(float speed)
virtual bool Initialize() override
Allocates the bone constant buffer and attaches it to the sibling MeshComponent.
Component(GameObject *object)
Represents a quaternion for 3D rotations.
Backend-agnostic GPU buffer: vertex, index, constant, or resource view target.
Matrix< float, 4, 4 > Matrix4
Backend-facing rendering layer shared by the four graphics backends.
Root namespace for everything the engine exposes.