Files
pke/src/render/animation.h
2026-03-11 23:25:46 +03:00

72 lines
1.1 KiB
C++

#ifndef ANIMATION_H
#define ANIMATION_H
#include <vector>
#include "render_shared.h"
#define INVALID_ANIMATION_HANDLE -1
// Animation types
typedef /*int16_t*/ int AnimationId_t;
class Model;
/* Joint */
struct Joint
{
char name[64];
int parentId;
glm::vec3 origin;
glm::quat orient;
};
/* Animation */
struct Animation
{
char name[64];
uint32_t numPoses;
uint32_t numFrames;
float framerate;
std::vector< glm::vec3 > origin;
std::vector< glm::quat > orient;
};
/* Skeleton */
class SkeletonInstance
{
public:
Model* m_model;
std::vector<Joint> m_joints;
std::vector<glm::mat4> m_jointMatrices;
std::vector<glm::mat4> m_finalMatrices;
AnimationId_t m_animation;
float m_time;
float m_speed;
bool m_looped;
public:
SkeletonInstance();
~SkeletonInstance();
bool IsValid();
void LoadAnimation(const char* filename);
AnimationId_t FindAnimation(const char* name);
uint32_t GetNumAnimations();
float GetAnimationTime(AnimationId_t id);
void PlayAnimation(AnimationId_t id, bool looped);
void StopAnimation();
void SetAnimationSpeed(float speed);
AnimationId_t GetCurrentAnimation();
float GetCurrentTime();
};
#endif // !ANIMATION_H