]> git.localhorst.tv Git - blank.git/blob - src/controller.hpp
853eeff3bd244603727866d03df28f0f858621b7
[blank.git] / src / controller.hpp
1 #ifndef BLANK_CONTROLLER_HPP_
2 #define BLANK_CONTROLLER_HPP_
3
4 #include "geometry.hpp"
5
6 #include <SDL.h>
7 #include <glm/glm.hpp>
8
9
10 namespace blank {
11
12 class FPSController {
13
14 public:
15         FPSController();
16
17         const glm::mat4 &Transform() const;
18         Ray Aim() const;
19
20         void Velocity(glm::vec3 vel) { velocity = vel; dirty = true; }
21         void OrientationVelocity(const glm::vec3 &vel);
22         void Position(glm::vec3 pos) { position = pos; dirty = true; }
23         void Move(glm::vec3 delta) { Position(position + delta); }
24
25         // all angles in radians (full circle = 2π)
26         float Pitch() const { return pitch; }
27         void Pitch(float p);
28         void RotatePitch(float delta);
29         float Yaw() const { return yaw; }
30         void Yaw(float y);
31         void RotateYaw(float delta);
32
33         void HandleKeyboard(const SDL_KeyboardEvent &);
34         void HandleMouse(const SDL_MouseMotionEvent &);
35
36         void Update(int dt);
37
38 private:
39         glm::vec3 velocity;
40         glm::vec3 position;
41         float pitch;
42         float yaw;
43
44         mutable glm::mat4 transform;
45         mutable bool dirty;
46
47         float move_velocity;
48         float pitch_sensitivity;
49         float yaw_sensitivity;
50
51         bool front, back, left, right, up, down;
52
53 };
54
55 }
56
57 #endif