diff options
author | omnisci3nce <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-04 22:53:13 +1100 |
---|---|---|
committer | omnisci3nce <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-04 22:53:13 +1100 |
commit | 9baff5661f2ba8b57e1b0794e490e239b7ef80ca (patch) | |
tree | 11ae178c14f59c4fcb380cdcc1bf38d065c9eee2 /src/animation.h | |
parent | af97c4330a27a92d2362e30b70990e3aa5c9954a (diff) |
loading animation data - step 1
Diffstat (limited to 'src/animation.h')
-rw-r--r-- | src/animation.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/animation.h b/src/animation.h new file mode 100644 index 0000000..b7c8ca4 --- /dev/null +++ b/src/animation.h @@ -0,0 +1,53 @@ +#pragma once + +#include "darray.h" +#include "defines.h" +#include "maths_types.h" + +KITC_DECL_TYPED_ARRAY(f32) + +typedef enum interpolation { INTERPOLATION_LINEAR, INTERPOLATION_COUNT } interpolation; + +typedef enum keyframe_kind { + KEYFRAME_ROTATION, + KEYFRAME_TRANSLATION, + KEYFRAME_SCALE, + KEYFRAME_WEIGHTS, +} keyframe_kind; + +typedef union keyframe { + quat rotation; + vec3 translation; + vec3 scale; + float* weights; +} keyframe; + +typedef struct keyframes { + keyframe_kind kind; + keyframe* values; + size_t count; +} keyframes; + +typedef struct animation_spline { + f32_darray timestamps; + keyframes values; + interpolation interpolation; +} animation_spline; + +typedef struct animation_sampler { + int current_index; + animation_spline animation; +} animation_sampler; + +/** @brief Sample an animation at a given time `t` */ +keyframe animation_sample(animation_sampler sampler, f32 t); + +typedef struct animation_clip { + // A clip contains one or more animation curves + // for now I think we can just enumerate all of the properties (assuming *only* one per type is in + // a clip) NULL = this property is not animated in this clip + animation_sampler* rotation; + animation_sampler* translation; + animation_sampler* scale; + animation_sampler* weights; +} animation_clip;
\ No newline at end of file |