Add AnimationData;

This commit is contained in:
bjorn 2017-11-01 22:53:51 -07:00
parent be087fd108
commit 28dec31e18
2 changed files with 46 additions and 0 deletions

17
src/loaders/animation.c Normal file
View File

@ -0,0 +1,17 @@
#include "loaders/animation.h"
#include <stdlib.h>
AnimationData* lovrAnimationDataCreate(const char* name) {
AnimationData* animationData = malloc(sizeof(AnimationData));
if (!animationData) return NULL;
animationData->name = name;
map_init(&animationData->channels);
return animationData;
}
void lovrAnimationDataDestroy(AnimationData* animationData) {
map_deinit(&animationData->channels);
free(animationData);
}

29
src/loaders/animation.h Normal file
View File

@ -0,0 +1,29 @@
#include "lib/vec/vec.h"
#include "lib/map/map.h"
#pragma once
typedef struct {
double time;
float data[4];
} Keyframe;
typedef vec_t(Keyframe) vec_keyframe_t;
typedef struct {
const char* node;
vec_keyframe_t positionKeyframes;
vec_keyframe_t rotationKeyframes;
vec_keyframe_t scaleKeyframes;
} AnimationChannel;
typedef map_t(AnimationChannel) map_channel_t;
typedef struct {
const char* name;
map_channel_t channels;
int channelCount;
} AnimationData;
AnimationData* lovrAnimationDataCreate(const char* name);
void lovrAnimationDataDestroy(AnimationData* animationData);