19#include <glm/gtc/quaternion.hpp>
23#include <unordered_map>
60 std::vector<float> times;
61 std::vector<glm::vec3> vec3_values;
62 std::vector<glm::quat> quat_values;
77 auto sampleVec3(
float time)
const -> glm::vec3;
80 auto sampleQuat(
float time)
const -> glm::quat;
88 glm::vec3 translation {0.0f};
89 glm::quat rotation {1.0f, 0.0f, 0.0f, 0.0f};
90 glm::vec3 scale {1.0f};
91 bool has_translation =
false;
92 bool has_rotation =
false;
93 bool has_scale =
false;
100 std::vector<AnimationTrack> tracks;
108 auto sample(
float time)
const -> std::unordered_map<std::string, NodePose>;
112 auto wrap(
float time)
const ->
float {
116 const float wrapped = std::fmod(time,
duration);
117 return wrapped < 0.0f ? wrapped +
duration : wrapped;
146 auto jointMatrices(std::span<const glm::mat4> joint_world_transforms)
const -> std::vector<glm::mat4>;
160 explicit Animation(std::span<const uint8_t> data);
163 auto type()
const -> std::string_view
override {
168 auto clips()
const noexcept ->
const std::vector<AnimationClip>& {
173 auto skins()
const noexcept ->
const std::vector<Skin>& {
183 static auto toBinary(
const std::vector<AnimationClip>& clips,
const std::vector<Skin>& skins) -> std::vector<uint8_t>;
186 std::vector<AnimationClip> m_clips;
187 std::vector<Skin> m_skins;
constexpr uint32_t animation_format_version
Binary layout version for .tanim; readers reject anything they don't recognise.
Definition animation.hpp:30
Interpolation
How a sampler interpolates between two keyframes, matching glTF's three modes.
Definition animation.hpp:34
@ cubic_spline
Definition animation.hpp:39
TrackTarget
Which part of a node's transform a track drives.
Definition animation.hpp:43
Animation(std::span< const uint8_t > data)
Parses the binary .tanim representation.
Definition animation.cpp:255
auto findClip(std::string_view name) const -> const AnimationClip *
Definition animation.cpp:316
static auto toBinary(const std::vector< AnimationClip > &clips, const std::vector< Skin > &skins) -> std::vector< uint8_t >
Serialises clips + skins into the binary .tanim layout the constructor reads back.
Definition animation.cpp:325
Base types for the asset system.
A named set of tracks that play together.
Definition animation.hpp:97
float duration
seconds; the largest time across all tracks
Definition animation.hpp:99
auto wrap(float time) const -> float
Wraps time into [0, duration], for looping playback.
Definition animation.hpp:112
auto sample(float time) const -> std::unordered_map< std::string, NodePose >
Samples every track at time, grouped per target node.
Definition animation.cpp:226
One animated channel: a keyframe curve driving one component of one node's transform.
Definition animation.hpp:55
auto keyframeCount() const -> size_t
Definition animation.hpp:66
std::string target_node
node name, resolved against the instantiated tree at playback time
Definition animation.hpp:56
One node's sampled transform at a point in a clip.
Definition animation.hpp:87
A skeleton: the joint nodes a skinned mesh binds to.
Definition animation.hpp:127
std::vector< std::string > joints
node names, in the order joint indices refer to
Definition animation.hpp:130
std::string skeleton_root
node name, empty when glTF didn't specify one
Definition animation.hpp:129
std::vector< glm::mat4 > inverse_bind_matrices
parallel to joints; empty means identity for all
Definition animation.hpp:131
auto jointMatrices(std::span< const glm::mat4 > joint_world_transforms) const -> std::vector< glm::mat4 >
Builds the per-joint matrices a skinning shader multiplies vertices by.
Definition animation.cpp:212