]> git.localhorst.tv Git - blank.git/blobdiff - src/controller.hpp
move controller from camera to world
[blank.git] / src / controller.hpp
index f636bcdccd15bc64339a287044a32cabae9fc45a..853eeff3bd244603727866d03df28f0f858621b7 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef BLANK_CONTROLLER_HPP_
 #define BLANK_CONTROLLER_HPP_
 
+#include "geometry.hpp"
+
+#include <SDL.h>
 #include <glm/glm.hpp>
 
 
@@ -11,20 +14,24 @@ class FPSController {
 public:
        FPSController();
 
-       glm::mat4 Transform() const;
+       const glm::mat4 &Transform() const;
+       Ray Aim() const;
 
-       void Velocity(glm::vec3 vel) { velocity = vel; }
+       void Velocity(glm::vec3 vel) { velocity = vel; dirty = true; }
        void OrientationVelocity(const glm::vec3 &vel);
-       void Position(glm::vec3 pos) { position = pos; }
-       void Move(glm::vec3 delta) { position += delta; }
+       void Position(glm::vec3 pos) { position = pos; dirty = true; }
+       void Move(glm::vec3 delta) { Position(position + delta); }
 
        // all angles in radians (full circle = 2π)
        float Pitch() const { return pitch; }
-       void Pitch(float p) { pitch = p; }
-       void RotatePitch(float delta) { pitch += delta; }
+       void Pitch(float p);
+       void RotatePitch(float delta);
        float Yaw() const { return yaw; }
-       void Yaw(float y) { yaw = y; }
-       void RotateYaw(float delta) { yaw += delta; }
+       void Yaw(float y);
+       void RotateYaw(float delta);
+
+       void HandleKeyboard(const SDL_KeyboardEvent &);
+       void HandleMouse(const SDL_MouseMotionEvent &);
 
        void Update(int dt);
 
@@ -34,6 +41,15 @@ private:
        float pitch;
        float yaw;
 
+       mutable glm::mat4 transform;
+       mutable bool dirty;
+
+       float move_velocity;
+       float pitch_sensitivity;
+       float yaw_sensitivity;
+
+       bool front, back, left, right, up, down;
+
 };
 
 }