60 lines
1.1 KiB
C++
60 lines
1.1 KiB
C++
#pragma once
|
||
#include "ZLMath.h"
|
||
#include "Renderer.h"
|
||
#include <unordered_map>
|
||
|
||
|
||
namespace ZL
|
||
{
|
||
constexpr int MAX_BONE_COUNT = 6;
|
||
struct Bone
|
||
{
|
||
Vector3f boneStartWorld;
|
||
float boneLength;
|
||
Matrix4f boneMatrixWorld;
|
||
// boneVector = boneLength * (0, 1, 0) <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
// Then multiply by boneMatrixWorld <20> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||
|
||
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, MAX_BONE_COUNT>> verticesBoneWeight;
|
||
|
||
Matrix4f armatureMatrix;
|
||
|
||
std::vector<Bone> startBones;
|
||
std::vector<Bone> currentBones;
|
||
|
||
std::vector<Animation> animations;
|
||
|
||
void LoadFromFile(const std::string& fileName, const std::string& ZIPFileName = "");
|
||
|
||
void Interpolate(int frame);
|
||
};
|
||
|
||
|
||
|
||
|
||
}; |