From: Daniel Karbach Date: Sun, 15 Feb 2015 10:48:30 +0000 (+0100) Subject: make forward key actually go forward ^^ X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=32a385382b73072438c99b533686a4bb9ba4742c;p=blank.git make forward key actually go forward ^^ --- diff --git a/src/app.cpp b/src/app.cpp index 652e1c1..e7ed579 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -322,7 +322,7 @@ void Application::Update(int dt) { } else if (front && !back) { vel.z = -move_velocity; } - cam.Velocity(vel); + cam.OrientationVelocity(vel); cam.Update(dt); modelCtrl.Update(dt); diff --git a/src/controller.cpp b/src/controller.cpp index 19adf1b..5d547b7 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -2,6 +2,7 @@ #include #include +#include #include @@ -25,6 +26,11 @@ glm::mat4 FPSController::Transform() const { } +void FPSController::OrientationVelocity(const glm::vec3 &vel) { + velocity = glm::rotateY(vel, yaw); +} + + void FPSController::Update(int dt) { position += velocity * float(dt); } diff --git a/src/controller.hpp b/src/controller.hpp index 8b2cd4e..013b3e4 100644 --- a/src/controller.hpp +++ b/src/controller.hpp @@ -15,6 +15,7 @@ public: glm::mat4 Transform() const; void Velocity(glm::vec3 vel) { velocity = vel; } + void OrientationVelocity(const glm::vec3 &vel); void Position(glm::vec3 pos) { position = pos; } void Move(glm::vec3 delta) { position += delta; }