]> git.localhorst.tv Git - blank.git/blob - src/model/Part.hpp
linear model instance state
[blank.git] / src / model / Part.hpp
1 #ifndef BLAMK_MODEL_PART_HPP_
2 #define BLAMK_MODEL_PART_HPP_
3
4 #include "geometry.hpp"
5
6 #include <cstdint>
7 #include <list>
8 #include <vector>
9 #include <glm/glm.hpp>
10 #include <glm/gtc/quaternion.hpp>
11
12
13 namespace blank {
14
15 class DirectionalLighting;
16 class EntityMesh;
17 class Model;
18
19 struct Part {
20
21         std::uint16_t id;
22         AABB bounds;
23         struct State {
24                 glm::vec3 position = glm::vec3(0.0f, 0.0f, 0.0f);
25                 glm::quat orientation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f);
26         } initial;
27         const EntityMesh *mesh;
28
29         Part();
30         ~Part();
31
32         Part &AddChild();
33         const std::list<Part> &Children() const noexcept { return children; }
34
35         std::uint16_t Enumerate(std::uint16_t) noexcept;
36         void Index(std::vector<Part *> &) noexcept;
37
38         glm::mat4 LocalTransform(const std::vector<State> &) const noexcept;
39         glm::mat4 GlobalTransform(const std::vector<State> &) const noexcept;
40
41         void Render(const glm::mat4 &, const std::vector<State> &, DirectionalLighting &) const;
42
43 private:
44         const Part *parent;
45         std::list<Part> children;
46
47 };
48
49 }
50
51 #endif