Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
Pose.h
Go to the documentation of this file.
1/**
2 * @file Pose.h
3 * @ingroup mnd_animation
4 * @brief Per-frame skeletal pose: local bone transforms + final GPU palette.
5 */
6
7#pragma once
8
9#include <vector>
10
11#include <glm/mat4x4.hpp>
12
13#include "Types.h"
14
15namespace mnd
16{
17
18class Skeleton;
19struct SkeletalAnimationClip;
20
21/**
22 * @brief Per-frame pose state for a Skeleton.
23 *
24 * `localTransforms[i]` is bone i's TRS relative to its parent for the current
25 * playback time. `finalPalette[i]` is the matrix actually uploaded as
26 * `uBones[i]` to the skinned vertex shader: it transforms a vertex from
27 * mesh-bind space into mesh-posed space.
28 */
29struct Pose
30{
31 std::vector<glm::mat4> localTransforms; ///< Animated TRS per bone (parent-relative).
32 std::vector<glm::mat4> finalPalette; ///< Skinning matrices: globalPose * offsetMatrix.
33};
34
35/// Resize `pose` buffers to match `skeleton` and reset to bind pose.
36void ResetPoseToBind(const Skeleton &skeleton, Pose &pose);
37
38/**
39 * @brief Sample `clip` at `time` and write each animated bone's TRS into `pose.localTransforms`.
40 *
41 * Bones not driven by the clip retain their bind-pose local transform.
42 */
43void EvaluatePose(const SkeletalAnimationClip &clip, const Skeleton &skeleton, f32 time, Pose &pose);
44
45/**
46 * @brief Concatenate parent transforms and apply offsetMatrix to produce the GPU palette.
47 *
48 * Skeleton bones must be stored such that a parent comes before its children
49 * (topological order). ModelImporter guarantees this.
50 */
51void ComputePalette(const Skeleton &skeleton, Pose &pose);
52
53} // namespace mnd
Engine-wide primitive type aliases and GLM math imports.
float f32
32-bit IEEE float — the standard GL scalar type.
Definition Types.h:40
void ComputePalette(const Skeleton &skeleton, Pose &pose)
Concatenate parent transforms and apply offsetMatrix to produce the GPU palette.
Definition Pose.cpp:127
void ResetPoseToBind(const Skeleton &skeleton, Pose &pose)
Resize pose buffers to match skeleton and reset to bind pose.
Definition Pose.cpp:84
void EvaluatePose(const SkeletalAnimationClip &clip, const Skeleton &skeleton, f32 time, Pose &pose)
Sample clip at time and write each animated bone's TRS into pose.localTransforms.
Definition Pose.cpp:96
Per-frame pose state for a Skeleton.
Definition Pose.h:30
std::vector< glm::mat4 > localTransforms
Animated TRS per bone (parent-relative).
Definition Pose.h:31
std::vector< glm::mat4 > finalPalette
Skinning matrices: globalPose * offsetMatrix.
Definition Pose.h:32