38#include <unordered_map>
41#include <glm/gtc/quaternion.hpp>
42#include <glm/vec3.hpp>
44#include <glm/mat4x4.hpp>
48#include "scene/Component.h"
54struct SkeletalAnimationClip;
108 void Update(
float deltaTime)
override;
121 void RegisterClip(
const std::string &name,
const std::shared_ptr<AnimationClip> &clip);
124 void RegisterSkeletalClip(
const std::string &name,
const std::shared_ptr<SkeletalAnimationClip> &clip);
127 void SetSkeleton(
const std::shared_ptr<Skeleton> &skeleton);
130 const std::shared_ptr<Skeleton> &
GetSkeleton()
const {
return m_skeleton; }
133 void Stop() { m_isPlaying =
false; }
143 const std::vector<glm::mat4> &
GetPalette()
const {
return m_palette; }
154 void Play(
const std::string &name,
bool loop =
true);
166 glm::vec3 Interpolate(
const std::vector<KeyFrameVec3> &keys,
float time);
169 glm::quat Interpolate(
const std::vector<KeyFrameQuat> &keys,
float time);
177 void BuildBindings();
182 bool m_looping =
true;
183 bool m_isPlaying =
false;
185 std::unordered_map<std::string, std::shared_ptr<AnimationClip>> m_clips;
186 std::unordered_map<GameObject *, std::unique_ptr<ObjectBinding>>
189 std::vector<glm::mat4> m_palette;
191 std::shared_ptr<Skeleton> m_skeleton;
192 std::unordered_map<std::string, std::shared_ptr<SkeletalAnimationClip>> m_skelClips;
Shared keyframe value types for transform-track animation.
Per-frame skeletal pose: local bone transforms + final GPU palette.
Drives transform animation on a hierarchy of GameObjects.
void SetClip(AnimationClip *clip)
Set the active clip directly (bypasses the name registry).
void Stop()
Halt playback. Pose freezes at the current frame.
const std::vector< glm::mat4 > & GetPalette() const
Read-only access to the bone palette computed at the last Update().
const std::shared_ptr< Skeleton > & GetSkeleton() const
Read-only handle to the bound skeleton (may be null for non-skeletal anims).
std::vector< std::string > GetClipNames() const
List every clip name registered on this component (node + skeletal).
void Play(const std::string &name, bool loop=true)
Start playing a registered clip by name.
void SetSkeleton(const std::shared_ptr< Skeleton > &skeleton)
Bind a skeleton to the component so skeletal clips can be evaluated.
void Update(float deltaTime) override
Advance playback time and write interpolated transforms to bound objects.
void RegisterSkeletalClip(const std::string &name, const std::shared_ptr< SkeletalAnimationClip > &clip)
Register a skeletal clip (per-bone TRS tracks) — used by SkinnedMeshComponent.
void RegisterClip(const std::string &name, const std::shared_ptr< AnimationClip > &clip)
Register a named clip so it can be started via Play().
Node in the scene graph: a named transform that owns components and children.
#define COMPONENT(ComponentClass)
A named, playable animation containing one or more transform tracks.
std::string name
Clip identifier (matches GLTF animation name).
std::vector< TransformTrack > tracks
Per-node animation channels.
float duration
Total clip length in seconds.
bool looping
Whether playback wraps at the end.
Runtime binding from a TransformTrack to a live child GameObject.
std::vector< size_t > trackIndices
Indices into AnimationClip::tracks that drive this object.
Per-frame pose state for a Skeleton.