gdk-graphics 0a0aef92e917cfbac53dffbc32c295e4de914093
Loading...
Searching...
No Matches
profile.h
1// © Joseph Cameron - MIT License
2
3#ifndef GDK_GRAPHICS_EXT_ANIMATION_PROFILE_H
4#define GDK_GRAPHICS_EXT_ANIMATION_PROFILE_H
5
6#include <gdk/graphics/ext/animation/skeleton.h>
7
8#include <string>
9#include <string_view>
10#include <vector>
11
12namespace gdk::graphics::animation {
13 struct rig_profile final {
15 std::string name;
16
17 struct role final {
19 std::string name;
20
22 std::vector<std::string> aliases;
23
25 std::string mirror;
26 };
27
28 std::vector<role> roles;
29
31 std::vector<std::string> ground_contacts;
32
34 [[nodiscard]] const role *find(std::string_view aName) const;
35 };
36
38 class rig_binding final {
39 public:
41 [[nodiscard]] int bone_for(std::string_view aRole) const;
42
44 [[nodiscard]] std::vector<std::size_t> ground_contact_bones() const;
45
47 [[nodiscard]] std::size_t placed() const;
48
50 [[nodiscard]] std::size_t bone_count() const { return m_BoneCount; }
51
52 [[nodiscard]] const rig_profile &profile() const { return m_Profile; }
53
56 rig_binding(rig_profile aProfile, std::vector<int> aBones, const std::size_t aBoneCount);
57
58 private:
59 rig_profile m_Profile;
60
61 std::vector<int> m_Bones;
62
63 std::size_t m_BoneCount = 0;
64 };
65
67 [[nodiscard]] rig_binding bind_profile(const rig_profile &aProfile, const skeleton &aSkeleton);
68
70 [[nodiscard]] const rig_profile &humanoid_profile();
71
73 [[nodiscard]] std::vector<int> map_by_profile(const rig_binding &aSource,
74 const rig_binding &aTarget);
75}
76
77#endif
a profile resolved against one particular skeleton.
Definition profile.h:38
std::size_t placed() const
how many of the profile's roles this rig actually fills
rig_binding(rig_profile aProfile, std::vector< int > aBones, const std::size_t aBoneCount)
std::vector< std::size_t > ground_contact_bones() const
the bones filling the profile's ground contacts, skipping any the rig does not have
int bone_for(std::string_view aRole) const
the bone filling a role, or -1
std::size_t bone_count() const
how many bones the skeleton this was bound against has
Definition profile.h:50
std::vector< std::string > aliases
names a rig might use for this role instead.
Definition profile.h:22
std::string name
the canonical name, and what a mapping is keyed on
Definition profile.h:19
std::string mirror
the role this one mirrors to, or empty if it mirrors to itself.
Definition profile.h:25
const role * find(std::string_view aName) const
the role of that name, or nullptr
std::vector< std::string > ground_contacts
the roles that touch the ground, for foot planting.
Definition profile.h:31
std::string name
what this profile describes for messages. eg: "humanoid", "quadruped"
Definition profile.h:15
a chain of bones in bind pose.
Definition skeleton.h:16
a target's limits
Definition profile.h:18