1 #ifndef BLANK_APP_FPSCONTROLLER_HPP_
2 #define BLANK_APP_FPSCONTROLLER_HPP_
4 #include "../model/geometry.hpp"
5 #include "../world/Entity.hpp"
12 /// Sets entity rotation and velocity according to stored velocity
13 /// and pitch/yaw components.
14 /// Rotation is applied in yaw,pitch order (YX). Velocity is relative
15 /// to yaw only (Y axis).
19 explicit FPSController(Entity &) noexcept;
22 Entity &Controlled() noexcept { return entity; }
23 const Entity &Controlled() const noexcept { return entity; }
25 /// get position and face direction of controlled entity
26 Ray Aim() const noexcept { return entity.Aim(entity.ChunkCoords()); }
28 /// velocity, relative to heading (yaw only)
29 const glm::vec3 &Velocity() const noexcept { return velocity; }
30 void Velocity(const glm::vec3 &vel) noexcept { velocity = vel; }
32 // all angles in radians (full circle = 2π)
33 float Pitch() const noexcept { return pitch; }
34 void Pitch(float p) noexcept;
35 void RotatePitch(float delta) noexcept;
36 float Yaw() const noexcept { return yaw; }
37 void Yaw(float y) noexcept;
38 void RotateYaw(float delta) noexcept;
40 void Update(int dt) noexcept;