summaryrefslogtreecommitdiff
path: root/kon/konmodel.h
diff options
context:
space:
mode:
authorKonAki <konaki@anokonaki.org>2026-10-09 13:39:26 +0800
committerKonAki <konaki@anokonaki.org>2026-10-09 13:39:26 +0800
commit402304dca923efb39e19a4a093458921a17e63f7 (patch)
tree4da686c4ca444fe5eec99cdf132ffd34dc39e15c /kon/konmodel.h
parenta26a2f7e3cea3a621e46fe82a0e410100afe8a36 (diff)
Add pose blending, shared clips and bone masks
Diffstat (limited to 'kon/konmodel.h')
-rw-r--r--kon/konmodel.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/kon/konmodel.h b/kon/konmodel.h
index 4b4e7e7..1c64891 100644
--- a/kon/konmodel.h
+++ b/kon/konmodel.h
@@ -121,6 +121,29 @@ int kon_modelFindClip(const kon_model_t *model, const char *name);
a looping clip wraps around, otherwise time stops at the end */
void kon_modelSample(const kon_model_t *model, int clip, float time, int loop, kon_mat4_t *skin);
+/* a pose is where every bone is relative to its parent, for mixing animations before skinning */
+typedef struct kon_pose {
+ kon_vec3_t position[KON_MODEL_MAX_BONES];
+ kon_vec4_t rotation[KON_MODEL_MAX_BONES];
+ kon_vec3_t scale[KON_MODEL_MAX_BONES];
+} kon_pose_t;
+
+void kon_poseRest(const kon_model_t *model, kon_pose_t *pose);
+
+/* writes the bones the clip moves into pose and leaves the others as they were.
+ clipModel is the model the clip is stored in, it can be another model or NULL for the same one. bones are matched by name,
+ so a clip from a different model works on any model whose skeleton uses the same bone names */
+void kon_poseClip(const kon_model_t *model, const kon_model_t *clipModel, int clip, float time, int loop, kon_pose_t *pose);
+
+/* out = a at t 0, b at t 1. mask has one weight per bone to blend some bones more than others, or NULL for all.
+ out can be the same as a or b */
+void kon_poseBlend(const kon_model_t *model, const kon_pose_t *a, const kon_pose_t *b, float t, const float *mask, kon_pose_t *out);
+
+/* sets mask to 1 for the named bone and everything below it, 0 for the rest. returns 0 if there is no such bone */
+int kon_modelMaskBranch(const kon_model_t *model, const char *bone, float *mask);
+
+void kon_poseSkin(const kon_model_t *model, const kon_pose_t *pose, kon_mat4_t *skin);
+
/* skin can be NULL to draw without animation. light and flags work like in kon_drawMesh.
not safe to call for the same model from two threads */
void kon_modelDraw(kon_framebuffer_t *fb, kon_mat4_t viewProjection, kon_mat4_t world, kon_model_t *model, const kon_mat4_t *skin, const kon_light_t *light, kon_renderFlags_t flags);