]> git.localhorst.tv Git - blank.git/blob - src/world/Entity.hpp
"streamlined" model/VAO handling
[blank.git] / src / world / Entity.hpp
1 #ifndef BLANK_WORLD_ENTITY_HPP_
2 #define BLANK_WORLD_ENTITY_HPP_
3
4 #include "Block.hpp"
5 #include "Chunk.hpp"
6 #include "../model/geometry.hpp"
7 #include "../model/EntityModel.hpp"
8
9 #include <string>
10 #include <glm/glm.hpp>
11 #include <glm/gtc/quaternion.hpp>
12
13
14 namespace blank {
15
16 class Shape;
17
18 class Entity {
19
20 public:
21         Entity() noexcept;
22
23         bool HasShape() const noexcept { return shape; }
24         const Shape *GetShape() const noexcept { return shape; }
25         void SetShape(const Shape *, const glm::vec3 &color);
26         void SetShapeless() noexcept;
27
28         const std::string &Name() const noexcept { return name; }
29         void Name(const std::string &n) { name = n; }
30
31         const AABB &Bounds() const noexcept { return bounds; }
32         void Bounds(const AABB &b) noexcept { bounds = b; }
33
34         bool WorldCollidable() const noexcept { return world_collision; }
35         void WorldCollidable(bool b) noexcept { world_collision = b; }
36
37         const glm::vec3 &Velocity() const noexcept { return velocity; }
38         void Velocity(const glm::vec3 &) noexcept;
39
40         const Block::Pos &Position() const noexcept { return position; }
41         void Position(const Block::Pos &) noexcept;
42         void Move(const glm::vec3 &delta) noexcept;
43
44         const Chunk::Pos ChunkCoords() const noexcept { return chunk; }
45
46         const glm::quat &AngularVelocity() const noexcept { return angular_velocity; }
47         void AngularVelocity(const glm::quat &) noexcept;
48
49         const glm::mat4 &Rotation() const noexcept { return rotation; }
50         void Rotation(const glm::mat4 &) noexcept;
51         void Rotate(const glm::quat &delta) noexcept;
52
53         glm::mat4 Transform(const Chunk::Pos &chunk_offset) const noexcept;
54         Ray Aim(const Chunk::Pos &chunk_offset) const noexcept;
55
56         void Update(int dt) noexcept;
57
58         void Draw() noexcept;
59
60 private:
61         const Shape *shape;
62         EntityModel model;
63
64         std::string name;
65
66         AABB bounds;
67
68         glm::vec3 velocity;
69         Block::Pos position;
70         Chunk::Pos chunk;
71
72         glm::quat angular_velocity;
73         glm::mat4 rotation;
74
75         bool world_collision;
76
77 };
78
79 }
80
81 #endif