X-Git-Url: https://git.lukelau.me/?p=opengl.git;a=blobdiff_plain;f=model.hpp;h=5c74cb386ef50a1bca316dc3bd286132710c939c;hp=358b92d07701211a99eff67692e1ec56045f6468;hb=be8759aec179d6d7bed58732134673870c596b4f;hpb=511a2c92fcb9dda82dd5d38b91ea03790d0cb7b2 diff --git a/model.hpp b/model.hpp index 358b92d..5c74cb3 100644 --- a/model.hpp +++ b/model.hpp @@ -1,4 +1,5 @@ #include +#include #ifdef __APPLE__ #include #else @@ -13,32 +14,50 @@ class Model { + struct Animation { + double duration; + std::vector nodeAnims; + }; + + typedef std::map> BoneMap; + typedef std::map> AnimMap; + typedef std::map BoneTransforms; + + struct VertBones { + unsigned int ids[4] = {0, 0, 0 ,0}; + float weights[4] = {1, 0, 0, 0}; + }; + struct Mesh { Mesh(const aiMesh *aiMesh, GLuint progId); GLuint progId, vao, numIndices; unsigned int materialIndex; + BoneMap boneMap; }; public: Model(const std::string &path, Program p); - void draw(Skybox skybox) const; + void draw(Skybox skybox, const float tick) const; class Node { public: - Node(const aiNode &aiNode, GLuint progId); - void draw(const std::vector &meshes, const std::vector &materials, const Skybox s, glm::mat4 parentModel) const; + Node(const aiNode &aiNode, GLuint progId, AnimMap *animMap); + void draw(const std::vector &meshes, const std::vector &materials, const Skybox s, const float tick, glm::mat4 parentModel, BoneTransforms boneTransforms) const; const std::vector &getChildren() const { return children; } Node* findNode(const aiNode &aiNode); glm::mat4 model = glm::mat4(1); const aiNode &ai; + private: const GLuint progId; + const AnimMap *animMap; std::vector children; std::vector meshIndices; }; Node* getRoot() { return root; } + Node* find(const aiString name); Node* find(const std::string &name); private: