2022-12-27 17:54:39 -06:00
|
|
|
#ifndef ANIM_H
|
|
|
|
#define ANIM_H
|
|
|
|
|
2023-12-04 13:38:37 -06:00
|
|
|
#include "HandmadeMath.h"
|
|
|
|
|
2022-12-27 17:54:39 -06:00
|
|
|
struct keyframe {
|
2023-05-12 13:22:05 -05:00
|
|
|
double time;
|
|
|
|
double val;
|
2022-12-27 17:54:39 -06:00
|
|
|
};
|
|
|
|
|
2023-12-04 13:38:37 -06:00
|
|
|
#define LINEAR 0
|
|
|
|
#define STEP 1
|
|
|
|
#define CUBICSPLINE 2
|
2024-01-01 17:30:42 -06:00
|
|
|
#define SLERP 3
|
|
|
|
|
2023-12-04 13:38:37 -06:00
|
|
|
typedef struct sampler {
|
|
|
|
float *times;
|
|
|
|
HMM_Vec4 *data;
|
|
|
|
int type;
|
|
|
|
} sampler;
|
|
|
|
|
|
|
|
struct anim_channel {
|
2024-04-26 16:04:31 -05:00
|
|
|
HMM_Vec4 *target;
|
|
|
|
int comps;
|
2024-10-29 12:41:17 -05:00
|
|
|
struct sampler *sampler;
|
2023-12-04 13:38:37 -06:00
|
|
|
};
|
|
|
|
|
2024-08-08 17:32:58 -05:00
|
|
|
typedef struct animation {
|
2023-12-04 13:38:37 -06:00
|
|
|
double time;
|
|
|
|
struct anim_channel *channels;
|
2024-04-26 16:04:31 -05:00
|
|
|
sampler *samplers;
|
2024-08-08 17:32:58 -05:00
|
|
|
} animation;
|
2022-12-27 17:54:39 -06:00
|
|
|
|
2024-04-26 16:04:31 -05:00
|
|
|
void animation_run(struct animation *anim, float now);
|
2023-12-04 13:38:37 -06:00
|
|
|
HMM_Vec4 sample_sampler(sampler *sampler, float time);
|
2022-12-27 17:54:39 -06:00
|
|
|
|
2023-12-04 13:38:37 -06:00
|
|
|
#endif
|