space-game001/BoneAnimatedModel.h
2025-03-01 01:39:19 +03:00

57 lines
908 B
C++

#pragma once
#include "Math.h"
#include "Renderer.h"
#include <unordered_map>
namespace ZL
{
struct Bone
{
Vector3f boneStartWorld;
float boneLength;
Matrix3f boneMatrixWorld;
// boneVector = boneLength * (0, 1, 0) â îñÿõ áëåíäåðà
// Then multiply by boneMatrixWorld è âû ïîëó÷èòå êîíå÷íóþ òî÷êó
int parent;
std::vector<int> children;
};
struct BoneWeight
{
int boneIndex = -1;
float weight = 0;
};
struct AnimationKeyFrame
{
int frame;
std::vector<Bone> bones;
};
struct Animation
{
std::vector<AnimationKeyFrame> keyFrames;
};
struct BoneSystem
{
VertexDataStruct mesh;
VertexDataStruct startMesh;
std::vector<std::array<BoneWeight, 3>> verticesBoneWeight;
std::vector<Bone> startBones;
std::vector<Bone> currentBones;
std::vector<Animation> animations;
void LoadFromFile(const std::string& fileName);
void Interpolate(int frame);
};
};