]> git.localhorst.tv Git - blank.git/blob - src/model/CompositeModel.hpp
fix loop removing players from world
[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 <list>
7 #include <glm/glm.hpp>
8 #include <glm/gtc/quaternion.hpp>
9
10
11 namespace blank {
12
13 class CompositeInstance;
14 class EntityModel;
15
16 class CompositeModel {
17
18 public:
19         CompositeModel();
20
21         CompositeModel(const CompositeModel &) = delete;
22         CompositeModel &operator =(const CompositeModel &) = delete;
23
24         const AABB &Bounds() const noexcept { return bounds; }
25         void Bounds(const AABB &b) noexcept { bounds = b; }
26
27         const glm::vec3 &Position() const noexcept { return position; }
28         void Position(const glm::vec3 &p) noexcept { position = p; }
29
30         const glm::quat &Orientation() const noexcept { return orientation; }
31         void Orientation(const glm::quat &o) noexcept { orientation = o; }
32
33         bool HasNodeModel() const noexcept { return node_model; }
34         void SetNodeModel(const EntityModel *m) noexcept { node_model = m; }
35
36         const EntityModel &NodeModel() const noexcept { return *node_model; }
37
38         CompositeModel &AddPart();
39         bool HasParent() const noexcept { return parent; }
40         CompositeModel &Parent() const noexcept { return *parent; }
41         bool IsRoot() const noexcept { return !HasParent(); }
42
43         glm::mat4 LocalTransform() const noexcept;
44         glm::mat4 GlobalTransform() const noexcept;
45
46         void Instantiate(CompositeInstance &) const;
47
48 private:
49         CompositeModel *parent;
50         const EntityModel *node_model;
51
52         AABB bounds;
53
54         glm::vec3 position;
55         glm::quat orientation;
56
57         std::list<CompositeModel> parts;
58
59 };
60
61 }
62
63 #endif