]> git.localhorst.tv Git - blank.git/blob - src/model/CompositeModel.hpp
b548a9c8485dbe20337f7e5af52959fbcee6ae3e
[blank.git] / src / model / CompositeModel.hpp
1 #ifndef BLANK_MODEL_COMPOSITEMODEL_HPP_
2 #define BLANK_MODEL_COMPOSITEMODEL_HPP_
3
4 #include <list>
5 #include <glm/glm.hpp>
6 #include <glm/gtc/quaternion.hpp>
7
8
9 namespace blank {
10
11 class DirectionalLighting;
12 class EntityModel;
13
14 class CompositeModel {
15
16 public:
17         CompositeModel();
18
19         CompositeModel(const CompositeModel &) = delete;
20         CompositeModel &operator =(const CompositeModel &) = delete;
21
22         const glm::vec3 &Position() const noexcept { return position; }
23         void Position(const glm::vec3 &p) noexcept { position = p; }
24
25         const glm::quat &Orientation() const noexcept { return orientation; }
26         void Orientation(const glm::quat &o) noexcept { orientation = o; }
27
28         bool HasNodeModel() const noexcept { return node_model; }
29         void SetNodeModel(const EntityModel *m) noexcept { node_model = m; }
30
31         const EntityModel &NodeModel() const noexcept { return *node_model; }
32
33         CompositeModel &AddPart();
34         bool HasParent() const noexcept { return parent; }
35         CompositeModel &Parent() const noexcept { return *parent; }
36         bool IsRoot() const noexcept { return !HasParent(); }
37
38         glm::mat4 LocalTransform() const noexcept;
39         glm::mat4 GlobalTransform() const noexcept;
40
41         void Render(const glm::mat4 &, DirectionalLighting &) const;
42
43 private:
44         CompositeModel *parent;
45         const EntityModel *node_model;
46
47         glm::vec3 position;
48         glm::quat orientation;
49
50         std::list<CompositeModel> parts;
51
52 };
53
54 }
55
56 #endif