1 #ifndef BLANK_WORLD_ENTITY_HPP_
2 #define BLANK_WORLD_ENTITY_HPP_
6 #include "../model/geometry.hpp"
7 #include "../model/EntityModel.hpp"
10 #include <glm/glm.hpp>
11 #include <glm/gtc/quaternion.hpp>
23 bool HasShape() const noexcept { return shape; }
24 const Shape *GetShape() const noexcept { return shape; }
25 void SetShape(const Shape *, const glm::vec3 &color, float texture);
26 void SetShapeless() noexcept;
28 const std::string &Name() const noexcept { return name; }
29 void Name(const std::string &n) { name = n; }
31 const AABB &Bounds() const noexcept { return bounds; }
32 void Bounds(const AABB &b) noexcept { bounds = b; }
34 bool WorldCollidable() const noexcept { return world_collision; }
35 void WorldCollidable(bool b) noexcept { world_collision = b; }
37 const glm::vec3 &Velocity() const noexcept { return velocity; }
38 void Velocity(const glm::vec3 &) noexcept;
40 const Block::Pos &Position() const noexcept { return position; }
41 void Position(const Chunk::Pos &, const Block::Pos &) noexcept;
42 void Position(const Block::Pos &) noexcept;
43 void Move(const glm::vec3 &delta) noexcept;
45 const Chunk::Pos ChunkCoords() const noexcept { return chunk; }
47 glm::vec3 AbsolutePosition() const noexcept {
48 return glm::vec3(chunk * Chunk::Extent()) + position;
50 glm::vec3 AbsoluteDifference(const Entity &other) const noexcept {
51 return glm::vec3((chunk - other.chunk) * Chunk::Extent()) + position - other.position;
54 /// direction is rotation axis, magnitude is speed in rad/ms
55 const glm::vec3 &AngularVelocity() const noexcept { return angular_velocity; }
56 void AngularVelocity(const glm::vec3 &) noexcept;
58 const glm::quat &Rotation() const noexcept { return rotation; }
59 void Rotation(const glm::quat &) noexcept;
60 void Rotate(const glm::quat &delta) noexcept;
62 glm::mat4 Transform(const Chunk::Pos &chunk_offset) const noexcept;
63 Ray Aim(const Chunk::Pos &chunk_offset) const noexcept;
65 void Remove() noexcept { remove = true; }
66 bool CanRemove() const noexcept { return remove; }
68 void Update(int dt) noexcept;
70 void Draw() noexcept {
86 glm::vec3 angular_velocity;