1 #ifndef BLANK_WORLD_ENTITY_HPP_
2 #define BLANK_WORLD_ENTITY_HPP_
5 #include "../model/CompositeModel.hpp"
6 #include "../model/geometry.hpp"
10 #include <glm/gtc/quaternion.hpp>
15 class DirectionalLighting;
23 CompositeModel &GetModel() noexcept { return model; }
24 const CompositeModel &GetModel() const noexcept { return model; }
26 const std::string &Name() const noexcept { return name; }
27 void Name(const std::string &n) { name = n; }
29 const AABB &Bounds() const noexcept { return bounds; }
30 void Bounds(const AABB &b) noexcept { bounds = b; }
32 bool WorldCollidable() const noexcept { return world_collision; }
33 void WorldCollidable(bool b) noexcept { world_collision = b; }
35 const glm::vec3 &Velocity() const noexcept { return velocity; }
36 void Velocity(const glm::vec3 &v) noexcept { velocity = v; }
38 const glm::vec3 &Position() const noexcept { return model.Position(); }
39 void Position(const Chunk::Pos &, const glm::vec3 &) noexcept;
40 void Position(const glm::vec3 &) noexcept;
41 void Move(const glm::vec3 &delta) noexcept;
43 const Chunk::Pos ChunkCoords() const noexcept { return chunk; }
45 glm::vec3 AbsolutePosition() const noexcept {
46 return glm::vec3(chunk * Chunk::Extent()) + Position();
48 glm::vec3 AbsoluteDifference(const Entity &other) const noexcept {
49 return glm::vec3((chunk - other.chunk) * Chunk::Extent()) + Position() - other.Position();
52 /// direction is rotation axis, magnitude is speed in rad/ms
53 const glm::vec3 &AngularVelocity() const noexcept { return angular_velocity; }
54 void AngularVelocity(const glm::vec3 &v) noexcept { angular_velocity = v; }
56 const glm::quat &Orientation() const noexcept { return model.Orientation(); }
57 void Orientation(const glm::quat &o) noexcept { model.Orientation(o); }
58 void Rotate(const glm::quat &delta) noexcept;
60 glm::mat4 ChunkTransform(const Chunk::Pos &chunk_offset) const noexcept;
61 glm::mat4 Transform(const Chunk::Pos &chunk_offset) const noexcept;
62 Ray Aim(const Chunk::Pos &chunk_offset) const noexcept;
64 void Remove() noexcept { remove = true; }
65 bool CanRemove() const noexcept { return remove; }
67 void Update(int dt) noexcept;
69 void Render(const glm::mat4 &M, DirectionalLighting &prog) noexcept {
70 model.Render(M, prog);
83 glm::vec3 angular_velocity;