-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModel.hpp
More file actions
75 lines (57 loc) · 1.98 KB
/
Model.hpp
File metadata and controls
75 lines (57 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef GLTF_MODELLOAD
#define GLTF_MODELLOAD
#include "Mesh.hpp"
#include "Animation.hpp"
struct Node {
std::string name;
glm::mat4 originalLocalMatrix;
glm::mat4 localMatrix;
glm::mat4 transformMatrix;
int64_t idOfSkin;
int64_t meshId;
std::vector<uint64_t> children;
int64_t parent = -1;
uint64_t amountOfJoints = 0;
uint64_t jointsIdOffset = 0;
bool hasAnimData = false;
Node() noexcept {};
Node(const std::string& aName, const glm::mat4& aGlobal, const glm::mat4& aLocal, const int64_t aIdOfSkin) noexcept
: name(aName), transformMatrix(aGlobal), originalLocalMatrix(aLocal), localMatrix(aLocal), idOfSkin(aIdOfSkin) {};
~Node() noexcept {};
};
struct Bone {
std::string name;
std::vector<uint64_t> joints;
std::vector<glm::mat4> inverseBindMatrix;
};
class Model {
friend class Animation;
public:
Model(const std::filesystem::path& aPath) noexcept;
void draw(const glm::mat4& aProjectionView, const bool aSendTransforms = false) noexcept;
void setStateAtTime(uint64_t aId, float aTime) noexcept;
void setStateAtTimeAll(float aTime) noexcept;
void drawBones(const glm::mat4& aProjectionView) noexcept;
uint64_t getAnimationAmount() const noexcept;
float getAnimationMaxTime(const uint64_t aId) const noexcept;
~Model() noexcept;
private:
std::vector<uint64_t> mRootNodes;
std::vector<Mesh> mMeshes;
std::vector<Node> mNodes;
std::vector<Bone> mBones;
std::vector<Material> mMaterials;
std::vector<Texture> mTextures;
std::vector<Animation> mAnimations;
GLuint mMaterialBuffer;
GLuint mJointMatrixBuffer;
size_t mJointsAmount;
//workaround: joint ID bound to node, we want to store in array
//get order of node, add offset
void getNodeJointAmount();
void getNodeJointOffset(uint64_t aId, uint64_t* aCurrentOffset); //call AFTER getting amount
glm::mat4 getNodeMatrix(Node& node);
void updateJoints(Node& node, std::vector<glm::mat4>& aJointMatrices);
void drawBonesSubqueue(const glm::mat4& aProjectionView, const std::vector<uint64_t>& aQueue) noexcept;
};
#endif