diff options
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]; |