3#ifndef GDK_GRAPHICS_EXT_ANIMATION_SKELETON_H
4#define GDK_GRAPHICS_EXT_ANIMATION_SKELETON_H
6#include <gdk/graphics/ext/animation/animation_types.h>
14namespace gdk::graphics::animation {
19 vector3_type local_position;
20 quaternion_type local_rotation;
24 std::vector<bone> bones;
25 std::vector<matrix4x4_type> supplied_inverse_binds;
42 [[nodiscard]]
float height()
const {
return highest - lowest; }
48 [[nodiscard]]
float limb_half_width(
const skeleton &aSkeleton);
51 [[nodiscard]]
int find_bone(
const skeleton &aSkeleton, std::string_view aName);
54 [[nodiscard]] std::vector<std::string> duplicate_bone_names(
const skeleton &aSkeleton);
58 std::vector<quaternion_type> local_rotations;
60 [[nodiscard]]
static pose rest(
const skeleton &aSkeleton);
64 [[nodiscard]]
pose blend(
const pose &aFrom,
const pose &aTo,
const float aT);
67 using bone_mask = std::vector<float>;
70 [[nodiscard]] bone_mask mask_for_subtree(
const skeleton &aSkeleton,
const std::size_t aRoot,
71 const float aWeight = 1.0f);
74 [[nodiscard]]
pose blend(
const pose &aFrom,
const pose &aTo,
const bone_mask &aMask);
77 [[nodiscard]]
pose difference(
const pose &aBase,
const pose &aTarget);
80 [[nodiscard]]
pose add(
const pose &aBase,
const pose &aDelta,
const bone_mask &aMask);
83 [[nodiscard]]
pose add(
const pose &aBase,
const pose &aDelta,
const float aWeight);
90 vector3_type root_position;
93 std::vector<key> keys;
94 float duration = 1.0f;
95 vector3_type root_motion_per_cycle;
100 [[nodiscard]]
pose sample(
const clip &aClip,
const float aTime);
103 [[nodiscard]] vector3_type sample_root_position(
const clip &aClip,
const float aTime);
106 [[nodiscard]] vector3_type root_delta(
const clip &aClip,
const float aFrom,
const float aTo);
109 [[nodiscard]] std::vector<matrix4x4_type> pose_world_transforms(
114 std::size_t bone = 0;
115 matrix4x4_type offset;
119 [[nodiscard]] matrix4x4_type socket_transform(std::span<const matrix4x4_type> aWorld,
123 [[nodiscard]] quaternion_type bone_world_rotation(
const skeleton &aSkeleton,
const pose &aPose,
124 const std::size_t aBone);
127 [[nodiscard]] std::vector<matrix4x4_type> skinning_palette(
129 std::span<const matrix4x4_type> aInverseBind
a looping sequence of keyframed poses
Definition skeleton.h:86
one bone rotation per bone, relative to its parent.
Definition skeleton.h:57
a chain of bones in bind pose.
Definition skeleton.h:16
skeleton with_oriented_bone_frames() const
the same skeleton with each bone's local frame pointing +Y at its first child
std::vector< matrix4x4_type > inverse_bind_transforms() const
the inverse of each bind-pose world transform
std::vector< matrix4x4_type > bind_world_transforms() const
world-space transform of each bone in bind pose
a thing attached to a bone: which bone, and where it sits in that bone's space.
Definition skeleton.h:113
the vertical span of a rig in bind pose
Definition skeleton.h:38