]> git.localhorst.tv Git - blank.git/blob - src/model/Part.hpp
store shapes in models rather than meshes
[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 Instance;
17 class Model;
18 class Shape;
19
20 struct Part {
21
22         std::uint16_t id;
23         AABB bounds;
24         struct State {
25                 glm::vec3 position = glm::vec3(0.0f, 0.0f, 0.0f);
26                 glm::quat orientation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f);
27         } initial;
28         const Shape *shape;
29
30         Part();
31         ~Part();
32
33         Part &AddChild();
34         const std::list<Part> &Children() const noexcept { return children; }
35
36         std::uint16_t Enumerate(std::uint16_t) noexcept;
37         void Index(std::vector<Part *> &) noexcept;
38
39         glm::mat4 LocalTransform(const Instance &) const noexcept;
40         glm::mat4 GlobalTransform(const Instance &) const noexcept;
41
42         void LoadMeshes(Instance &) const;
43         void Render(
44                 const glm::mat4 &,
45                 const Instance &,
46                 DirectionalLighting &) const;
47
48 private:
49         const Part *parent;
50         std::list<Part> children;
51
52 };
53
54 }
55
56 #endif