group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
CharacterAnimator.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
7#include "CharacterRig.hpp"
8#include "SkinningBackend.hpp"
9
10#include <array>
11#include <glm/glm.hpp>
12#include <memory>
13#include <vector>
14
20{
21 glm::vec3 velocityWorld{0.0f};
22 float yawRad = 0.0f;
23 float pitchRad = 0.0f;
24 bool grounded = false;
25 bool sprinting = false;
26 bool crouching = false;
27 int moveMode = 0;
28 int wallRunSide = 0;
29};
30
38static constexpr size_t kNumSamplerSlots = 5;
39
42{
44 float timeRatio = 0.0f;
45 float playbackSpeed = 1.0f;
46 float weight = 0.0f;
47 bool active = false;
48};
49
59{
60public:
61 CharacterAnimator(const CharacterRig& rig, const AnimationLibrary& library);
66 CharacterAnimator& operator=(CharacterAnimator&&) noexcept = delete;
67
71 void setSkinningBackend(const ISkinningBackend* backend);
72
76 void update(const AnimationInputs& inputs, float dt);
77
80 void computeSkinnedVertices(std::vector<std::vector<ModelVertex>>& out) const;
81
85 void setDebugOverride(ClipId id, bool loop = true);
86
88 [[nodiscard]] ClipId debugOverride() const noexcept;
89
91 [[nodiscard]] const std::array<ClipSampler, kNumSamplerSlots>& samplers() const noexcept;
92
94 void setDebugPlaybackSpeed(float mul) noexcept;
95
97 [[nodiscard]] int numJoints() const noexcept;
98
99private:
100 struct Impl;
101 std::unique_ptr<Impl> impl_;
102};
Catalog of ozz animation clips shared across all animated entities.
ClipId
Enumerated clip IDs.
Definition AnimationLibrary.hpp:21
static constexpr size_t kNumSamplerSlots
Number of sampler slots available for the per-frame blend.
Definition CharacterAnimator.hpp:38
Shared skinned-character rig: skeleton, bind-pose mesh, skin weights.
Pluggable skinning interface — phase-1 CPU LBS; GPU backend slots in later.
Collection of animation clips loaded on top of a shared skeleton.
Definition AnimationLibrary.hpp:55
Per-entity animator.
Definition CharacterAnimator.hpp:59
void setSkinningBackend(const ISkinningBackend *backend)
Set the skinning backend (non-owning).
Definition CharacterAnimator.cpp:193
void setDebugPlaybackSpeed(float mul) noexcept
Playback-speed multiplier applied in debug-override mode.
Definition CharacterAnimator.cpp:216
ClipId debugOverride() const noexcept
Current debug override clip (_Count = no override).
Definition CharacterAnimator.cpp:206
const std::array< ClipSampler, kNumSamplerSlots > & samplers() const noexcept
Snapshot of the current sampler slots (for UI inspection).
Definition CharacterAnimator.cpp:211
CharacterAnimator(CharacterAnimator &&) noexcept=delete
int numJoints() const noexcept
Number of joints in the underlying rig.
Definition CharacterAnimator.cpp:221
CharacterAnimator(const CharacterAnimator &)=delete
void computeSkinnedVertices(std::vector< std::vector< ModelVertex > > &out) const
Apply CPU skinning to every rig mesh, producing animated vertices.
Definition CharacterAnimator.cpp:658
void update(const AnimationInputs &inputs, float dt)
Advance the state machine, sample + blend, and compute skin matrices.
Definition CharacterAnimator.cpp:349
void setDebugOverride(ClipId id, bool loop=true)
Force a single clip to play, bypassing the graph.
Definition CharacterAnimator.cpp:198
CharacterAnimator & operator=(const CharacterAnimator &)=delete
Shared skinned rig — skeleton + bind-pose meshes + joint map.
Definition CharacterRig.hpp:42
Abstract skinning backend.
Definition SkinningBackend.hpp:20
Driving inputs for the animation state machine.
Definition CharacterAnimator.hpp:20
float pitchRad
Player pitch (radians, positive = looking down).
Definition CharacterAnimator.hpp:23
bool crouching
Crouch currently held (phase 1: note-only).
Definition CharacterAnimator.hpp:26
bool sprinting
Sprint key currently held.
Definition CharacterAnimator.hpp:25
glm::vec3 velocityWorld
World-space velocity (u/s).
Definition CharacterAnimator.hpp:21
float yawRad
Player yaw (radians).
Definition CharacterAnimator.hpp:22
bool grounded
Touching the ground this tick.
Definition CharacterAnimator.hpp:24
int wallRunSide
WallSide value: 0=None, 1=Left, 2=Right.
Definition CharacterAnimator.hpp:28
int moveMode
MoveMode value: 0=OnFoot, 1=Sliding, 2=WallRunning, 3=Climbing, 4=LedgeGrabbing.
Definition CharacterAnimator.hpp:27
Definition CharacterAnimator.cpp:92
One active sampler slot contributing to the per-frame blend.
Definition CharacterAnimator.hpp:42
bool active
False = slot unused this frame.
Definition CharacterAnimator.hpp:47
float playbackSpeed
Multiplier applied to clip duration when advancing.
Definition CharacterAnimator.hpp:45
float weight
Blend weight; slots with weight 0 are skipped.
Definition CharacterAnimator.hpp:46
float timeRatio
Normalised playback time ∈ [0, 1].
Definition CharacterAnimator.hpp:44
One vertex in a loaded 3-D model (PBR-ready).
Definition ModelLoader.hpp:19