]> git.localhorst.tv Git - blank.git/blob - src/entity.hpp
423cb88d3a18bb5877b50d5d18e518b4089bc7c9
[blank.git] / src / entity.hpp
1 #ifndef BLANK_ENTITY_HPP_
2 #define BLANK_ENTITY_HPP_
3
4 #include "block.hpp"
5 #include "chunk.hpp"
6 #include "geometry.hpp"
7 #include "model.hpp"
8 #include "shape.hpp"
9
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();
22
23         bool HasShape() const { return shape; }
24         const Shape *GetShape() const { return shape; }
25         void SetShape(Shape *, const glm::vec3 &color);
26         void SetShapeless();
27
28         const glm::vec3 &Velocity() const { return velocity; }
29         void Velocity(const glm::vec3 &);
30
31         const Block::Pos &Position() const { return position; }
32         void Position(const Block::Pos &);
33         void Move(const glm::vec3 &delta);
34
35         const Chunk::Pos ChunkCoords() const { return chunk; }
36
37         const glm::quat &AngularVelocity() const { return angular_velocity; }
38         void AngularVelocity(const glm::quat &);
39
40         const glm::mat4 &Rotation() const { return rotation; }
41         void Rotation(const glm::mat4 &);
42         void Rotate(const glm::quat &delta);
43
44         glm::mat4 Transform(const Chunk::Pos &chunk_offset) const;
45         Ray Aim(const Chunk::Pos &chunk_offset) const;
46
47         void Update(int dt);
48
49         void Draw();
50
51 private:
52         Shape *shape;
53         Model model;
54
55         glm::vec3 velocity;
56         Block::Pos position;
57         Chunk::Pos chunk;
58
59         glm::quat angular_velocity;
60         glm::mat4 rotation;
61
62 };
63
64 }
65
66 #endif