|
Monad Engine da02fba2
> Undercity Codex_
|
Drives transform animation on a hierarchy of GameObjects. More...
#include <AnimationComponent.h>
Inheritance diagram for mnd::AnimationComponent:
Collaboration diagram for mnd::AnimationComponent:Public Member Functions | |
| void | Update (float deltaTime) override |
| Advance playback time and write interpolated transforms to bound objects. | |
| void | SetClip (AnimationClip *clip) |
| Set the active clip directly (bypasses the name registry). | |
| void | RegisterClip (const std::string &name, const std::shared_ptr< AnimationClip > &clip) |
| Register a named clip so it can be started via Play(). | |
| void | RegisterSkeletalClip (const std::string &name, const std::shared_ptr< SkeletalAnimationClip > &clip) |
| Register a skeletal clip (per-bone TRS tracks) — used by SkinnedMeshComponent. | |
| void | SetSkeleton (const std::shared_ptr< Skeleton > &skeleton) |
| Bind a skeleton to the component so skeletal clips can be evaluated. | |
| const std::shared_ptr< Skeleton > & | GetSkeleton () const |
| Read-only handle to the bound skeleton (may be null for non-skeletal anims). | |
| void | Stop () |
| Halt playback. Pose freezes at the current frame. | |
| bool | IsPlaying () |
| const std::vector< glm::mat4 > & | GetPalette () const |
| Read-only access to the bone palette computed at the last Update(). | |
| void | Play (const std::string &name, bool loop=true) |
| Start playing a registered clip by name. | |
| std::vector< std::string > | GetClipNames () const |
| List every clip name registered on this component (node + skeletal). | |
| virtual void | LoadProperties (const nlohmann::json &json) |
| virtual void | Init () |
| virtual size_t | GetTypeId () const =0 |
| GameObject * | GetOwner () |
Static Public Member Functions | |
| template<typename T > | |
| static size_t | StaticTypeId () |
Protected Attributes | |
| GameObject * | m_owner = nullptr |
Drives transform animation on a hierarchy of GameObjects.
Attach to the root of a GLTF-loaded hierarchy. Register the clips loaded from the file (this is done automatically by GameObject::LoadGLTF), then call Play() to start playback.
Definition at line 100 of file AnimationComponent.h.
| std::vector< std::string > mnd::AnimationComponent::GetClipNames | ( | ) | const |
List every clip name registered on this component (node + skeletal).
Names are deduplicated and returned sorted. Useful for editor UIs that want to enumerate available animations without poking at the maps.
Definition at line 12 of file AnimationComponent.cpp.
|
inherited |
Definition at line 12 of file Component.cpp.
References mnd::Component::m_owner.
Referenced by mnd::MeshComponent::Update(), and mnd::SkinnedMeshComponent::Update().
|
inline |
Read-only access to the bone palette computed at the last Update().
Empty until a skeletal clip is registered and Play() has been called. SkinnedMeshComponent reads this to upload uBones[] each frame.
Definition at line 143 of file AnimationComponent.h.
Referenced by mnd::SkinnedMeshComponent::Update().
|
inline |
Read-only handle to the bound skeleton (may be null for non-skeletal anims).
Definition at line 130 of file AnimationComponent.h.
|
pure virtualinherited |
|
virtualinherited |
Reimplemented in mnd::PhysicsComponent, and mnd::PlayerControllerComponent.
Definition at line 10 of file Component.cpp.
Referenced by mnd::GameObject::AddComponent().
| bool mnd::AnimationComponent::IsPlaying | ( | ) |
Definition at line 272 of file AnimationComponent.cpp.
|
virtualinherited |
Reimplemented in mnd::AudioComponent, mnd::HealthComponent, mnd::LightComponent, mnd::MeshComponent, mnd::ParticleEmitterComponent, and mnd::PhysicsComponent.
Definition at line 8 of file Component.cpp.
| void mnd::AnimationComponent::Play | ( | const std::string & | name, |
| bool | loop = true |
||
| ) |
Start playing a registered clip by name.
Resolves target GameObjects by name (BuildBindings) and resets m_time to 0. Calling Play() while already playing restarts from the beginning.
| name | Loop key registered via RegisterClip. |
| loop | true to loop indefinitely; false to play once and stop. |
Definition at line 110 of file AnimationComponent.cpp.
References mnd::ResetPoseToBind(), and SetClip().
| void mnd::AnimationComponent::RegisterClip | ( | const std::string & | name, |
| const std::shared_ptr< AnimationClip > & | clip | ||
| ) |
Register a named clip so it can be started via Play().
| name | Lookup key (typically the GLTF animation name). |
| clip | Shared AnimationClip loaded from GLTF. |
Definition at line 94 of file AnimationComponent.cpp.
Referenced by mnd::ModelImporter::Import().
| void mnd::AnimationComponent::RegisterSkeletalClip | ( | const std::string & | name, |
| const std::shared_ptr< SkeletalAnimationClip > & | clip | ||
| ) |
Register a skeletal clip (per-bone TRS tracks) — used by SkinnedMeshComponent.
Definition at line 99 of file AnimationComponent.cpp.
Referenced by mnd::ModelImporter::Import().
| void mnd::AnimationComponent::SetClip | ( | AnimationClip * | clip | ) |
Set the active clip directly (bypasses the name registry).
| clip | Raw pointer to the clip to play; not owned. |
Definition at line 88 of file AnimationComponent.cpp.
Referenced by Play().
| void mnd::AnimationComponent::SetSkeleton | ( | const std::shared_ptr< Skeleton > & | skeleton | ) |
Bind a skeleton to the component so skeletal clips can be evaluated.
Definition at line 105 of file AnimationComponent.cpp.
Referenced by mnd::ModelImporter::Import().
|
inlinestaticinherited |
Definition at line 50 of file Component.h.
|
inline |
Halt playback. Pose freezes at the current frame.
Definition at line 133 of file AnimationComponent.h.
|
overridevirtual |
Advance playback time and write interpolated transforms to bound objects.
| deltaTime | Seconds since the previous frame. |
Implements mnd::Component.
Definition at line 24 of file AnimationComponent.cpp.
References mnd::ComputePalette(), mnd::SkeletalAnimationClip::duration, mnd::AnimationClip::duration, mnd::EvaluatePose(), mnd::Pose::finalPalette, and mnd::AnimationClip::tracks.
|
protectedinherited |
Definition at line 57 of file Component.h.
Referenced by mnd::GameObject::AddComponent(), mnd::HealthComponent::ApplyDamage(), mnd::Component::GetOwner(), mnd::CameraComponent::GetViewMatrix(), mnd::PhysicsComponent::Init(), mnd::PlayerControllerComponent::Init(), mnd::PlayerControllerComponent::Update(), mnd::AudioComponent::Update(), mnd::AudioListenerComponent::Update(), and mnd::PhysicsComponent::Update().