summaryrefslogtreecommitdiff
path: root/gfx/include/gfx/scene/animation.h
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/include/gfx/scene/animation.h')
-rw-r--r--gfx/include/gfx/scene/animation.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/gfx/include/gfx/scene/animation.h b/gfx/include/gfx/scene/animation.h
index 42c0c43..d95b895 100644
--- a/gfx/include/gfx/scene/animation.h
+++ b/gfx/include/gfx/scene/animation.h
@@ -5,6 +5,7 @@
5#include <gfx/sizes.h> 5#include <gfx/sizes.h>
6 6
7#include <cstring.h> 7#include <cstring.h>
8#include <math/aabb3.h>
8#include <math/defs.h> 9#include <math/defs.h>
9#include <math/mat4.h> 10#include <math/mat4.h>
10#include <math/quat.h> 11#include <math/quat.h>
@@ -22,21 +23,26 @@ typedef struct Joint Joint;
22typedef struct Skeleton Skeleton; 23typedef struct Skeleton Skeleton;
23 24
24/// Index type used to store relative indices into arrays. 25/// Index type used to store relative indices into arrays.
25typedef uint16_t rel_idx; 26typedef uint16_t joint_idx;
26 27
27/// Index value denoting no index. 28/// Index value denoting no index.
28static const rel_idx INDEX_NONE = (rel_idx)-1; 29static const joint_idx INDEX_NONE = (joint_idx)-1;
30
31typedef struct Box {
32 vec3 vertices[8];
33} Box;
29 34
30/// Joint descriptor. 35/// Joint descriptor.
31typedef struct JointDesc { 36typedef struct JointDesc {
32 rel_idx parent; /// Parent Joint; index into Anima's joints. 37 joint_idx parent; /// Parent Joint; index into Anima's joints.
33 mat4 inv_bind_matrix; /// Transforms the mesh into the joint's local space. 38 mat4 inv_bind_matrix; /// Transforms the mesh into the joint's local space.
39 aabb3 box; /// Bounding box.
34} JointDesc; 40} JointDesc;
35 41
36/// Skeleton descriptor. 42/// Skeleton descriptor.
37typedef struct SkeletonDesc { 43typedef struct SkeletonDesc {
38 size_t num_joints; 44 size_t num_joints;
39 rel_idx joints[GFX_MAX_NUM_JOINTS]; /// Indices into Anima's joints array. 45 joint_idx joints[GFX_MAX_NUM_JOINTS]; /// Indices into Anima's joints array.
40} SkeletonDesc; 46} SkeletonDesc;
41 47
42/// Animation interpolation mode. 48/// Animation interpolation mode.
@@ -67,7 +73,7 @@ typedef struct KeyframeDesc {
67 73
68/// Animation channel descriptor. 74/// Animation channel descriptor.
69typedef struct ChannelDesc { 75typedef struct ChannelDesc {
70 rel_idx target; /// Index into Anima's joints array. 76 joint_idx target; /// Index into Anima's joints array.
71 ChannelType type; 77 ChannelType type;
72 AnimationInterpolation interpolation; 78 AnimationInterpolation interpolation;
73 size_t num_keyframes; 79 size_t num_keyframes;
@@ -121,3 +127,16 @@ void gfx_stop_animation(Anima*);
121 127
122/// Return the anima's ith skeleton. 128/// Return the anima's ith skeleton.
123const Skeleton* gfx_get_anima_skeleton(const Anima* anima, size_t i); 129const Skeleton* gfx_get_anima_skeleton(const Anima* anima, size_t i);
130
131/// Return the number of joints in the skeleton.
132size_t gfx_get_skeleton_num_joints(const Skeleton*);
133
134/// Return true if the skeleton's ith joint has a bounding box.
135///
136/// IK joints that do not directly transform vertices have no bounding box.
137bool gfx_joint_has_box(const Anima*, const Skeleton*, size_t joint);
138
139/// Return the bounding box of the skeleton's ith joint.
140///
141/// IK joints that do not directly transform vertices have no box.
142Box gfx_get_joint_box(const Anima*, const Skeleton*, size_t joint);