Add skinning

This commit is contained in:
2026-03-05 14:19:46 +03:00
parent d57ac17b69
commit 65cf326f25
21 changed files with 1305 additions and 117 deletions

68
src/render/animation.h Normal file
View File

@@ -0,0 +1,68 @@
#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;
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();
AnimationId_t GetCurrentAnimation();
float GetCurrentTime();
};
#endif // !ANIMATION_H