diff options
author | Omni <omniscient.oce@gmail.com> | 2024-08-17 17:17:11 +1000 |
---|---|---|
committer | Omni <omniscient.oce@gmail.com> | 2024-08-17 17:17:11 +1000 |
commit | eadfaaa86c29c36dd5ef5d0b6b6fa27af0cdb8b3 (patch) | |
tree | af18d90ba02d5e26dd6ca746154ce9df6d3b0327 /src/animation.c | |
parent | cfd7266c21a43cbd37fa712725cea85cdd1f7aab (diff) |
improving the way I load animation data and store it. Load -> Tick(Armature*) -> RenderEnt.Armature -> matrix shenanigans
Diffstat (limited to 'src/animation.c')
-rw-r--r-- | src/animation.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/animation.c b/src/animation.c index 48a5ff1..274602c 100644 --- a/src/animation.c +++ b/src/animation.c @@ -4,7 +4,6 @@ #include "maths.h" #include "maths_types.h" #include "ral_types.h" -#include "transform_hierarchy.h" Keyframe Animation_Sample(AnimationSampler* sampler, f32 t) { size_t previous_index = 0; @@ -47,6 +46,26 @@ Keyframe Animation_Sample(AnimationSampler* sampler, f32 t) { } } +void Animation_Tick(AnimationClip* clip, Armature* armature, f32 time) { + TRACE("Ticking animation %s", clip->clip_name); + + for (u32 c_i = 0; c_i < clip->channels->len; c_i++) { + AnimationSampler* sampler = clip->channels->data; + + // Interpolated keyframe based on time + Keyframe k = Animation_Sample(sampler, time); + + // Get the joint in the armature + Joint* joint = &armature->joints->data[sampler->target_joint_idx]; + if (sampler->animation.values.kind == KEYFRAME_ROTATION) { + // Update the joints rotation + joint->transform_components.rotation = k.rotation; + } else { + WARN("not yet implemented animation kind"); + } + } +} + void Animation_VisualiseJoints(Armature* armature) { for (int j = 0; j < armature->joints->len; j++) { Joint joint = armature->joints->data[j]; |