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;
21 Entity &Controlled() noexcept { return entity; }
22 const Entity &Controlled() const noexcept { return entity; }
24 /// get position and face direction of controlled entity
25 Ray Aim() const noexcept { return entity.Aim(entity.ChunkCoords()); }
27 /// velocity, relative to heading (yaw only)
28 const glm::vec3 &Velocity() const noexcept { return velocity; }
29 void Velocity(const glm::vec3 &vel) noexcept { velocity = vel; }
31 // all angles in radians (full circle = 2π)
32 float Pitch() const noexcept { return pitch; }
33 void Pitch(float p) noexcept;
34 void RotatePitch(float delta) noexcept;
35 float Yaw() const noexcept { return yaw; }
36 void Yaw(float y) noexcept;
37 void RotateYaw(float delta) noexcept;
39 void Update(int dt) noexcept;