]> git.localhorst.tv Git - blank.git/blob - src/model/CompositeModel.hpp
model -> mesh
[blank.git] / src / model / CompositeModel.hpp
1 #ifndef BLANK_MODEL_COMPOSITEMODEL_HPP_
2 #define BLANK_MODEL_COMPOSITEMODEL_HPP_
3
4 #include "geometry.hpp"
5
6 #include <cstdint>
7 #include <list>
8 #include <glm/glm.hpp>
9 #include <glm/gtc/quaternion.hpp>
10
11
12 namespace blank {
13
14 class CompositeInstance;
15 class EntityMesh;
16
17 class CompositeModel {
18
19 public:
20         CompositeModel();
21
22         CompositeModel(const CompositeModel &) = delete;
23         CompositeModel &operator =(const CompositeModel &) = delete;
24
25         std::uint32_t ID() const noexcept { return id; }
26         void ID(std::uint32_t i) noexcept { id = i; }
27
28         const AABB &Bounds() const noexcept { return bounds; }
29         void Bounds(const AABB &b) noexcept { bounds = b; }
30
31         const glm::vec3 &Position() const noexcept { return position; }
32         void Position(const glm::vec3 &p) noexcept { position = p; }
33
34         const glm::quat &Orientation() const noexcept { return orientation; }
35         void Orientation(const glm::quat &o) noexcept { orientation = o; }
36
37         bool HasNodeMesh() const noexcept { return node_mesh; }
38         void SetNodeMesh(const EntityMesh *m) noexcept { node_mesh = m; }
39
40         const EntityMesh &NodeMesh() const noexcept { return *node_mesh; }
41
42         CompositeModel &AddPart();
43         bool HasParent() const noexcept { return parent; }
44         CompositeModel &Parent() const noexcept { return *parent; }
45         bool IsRoot() const noexcept { return !HasParent(); }
46
47         glm::mat4 LocalTransform() const noexcept;
48         glm::mat4 GlobalTransform() const noexcept;
49
50         void Instantiate(CompositeInstance &) const;
51
52 private:
53         CompositeModel *parent;
54         const EntityMesh *node_mesh;
55
56         std::uint32_t id;
57
58         AABB bounds;
59
60         glm::vec3 position;
61         glm::quat orientation;
62
63         std::list<CompositeModel> parts;
64
65 };
66
67 }
68
69 #endif