From: Daniel Karbach Date: Fri, 13 Feb 2015 09:04:39 +0000 (+0100) Subject: rename model -> controller X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=81531352f0af10ef357e82595098fa596795f000;p=blank.git rename model -> controller --- diff --git a/src/app.hpp b/src/app.hpp index c5a5098..d949567 100644 --- a/src/app.hpp +++ b/src/app.hpp @@ -5,8 +5,8 @@ #include #include "camera.hpp" +#include "controller.hpp" #include "init.hpp" -#include "model.hpp" #include "shader.hpp" @@ -42,7 +42,7 @@ private: float yaw_sensitivity; Camera cam; - Model model; + FPSController model; GLuint vtx_buf; GLuint mvp_handle; diff --git a/src/camera.cpp b/src/camera.cpp index 239ddb2..8a3a8a1 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -7,7 +7,7 @@ namespace blank { Camera::Camera() -: Model() +: FPSController() , fov(45.0f) , aspect(1.0f) , near_clip(0.1f) @@ -53,7 +53,7 @@ void Camera::Clip(float near, float far) { void Camera::Update(int dt) { - Model::Update(dt); + FPSController::Update(dt); vp = projection * glm::inverse(Transform()); } diff --git a/src/camera.hpp b/src/camera.hpp index 1ab086a..33c69d3 100644 --- a/src/camera.hpp +++ b/src/camera.hpp @@ -3,13 +3,13 @@ #include -#include "model.hpp" +#include "controller.hpp" namespace blank { class Camera -: public Model { +: public FPSController { public: Camera(); diff --git a/src/controller.cpp b/src/controller.cpp new file mode 100644 index 0000000..19adf1b --- /dev/null +++ b/src/controller.cpp @@ -0,0 +1,32 @@ +#include "controller.hpp" + +#include +#include +#include + + +namespace blank { + +FPSController::FPSController() +: velocity(0, 0, 0) +, position(0, 0, 0) +, pitch(0) +, yaw(0) { + +} + +FPSController::~FPSController() { + +} + + +glm::mat4 FPSController::Transform() const { + return glm::translate(position) * glm::eulerAngleYX(yaw, pitch); +} + + +void FPSController::Update(int dt) { + position += velocity * float(dt); +} + +} diff --git a/src/controller.hpp b/src/controller.hpp new file mode 100644 index 0000000..8b2cd4e --- /dev/null +++ b/src/controller.hpp @@ -0,0 +1,41 @@ +#ifndef BLANK_CONTROLLER_HPP_ +#define BLANK_CONTROLLER_HPP_ + +#include + + +namespace blank { + +class FPSController { + +public: + FPSController(); + ~FPSController(); + + glm::mat4 Transform() const; + + void Velocity(glm::vec3 vel) { velocity = vel; } + void Position(glm::vec3 pos) { position = pos; } + void Move(glm::vec3 delta) { 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; } + float Yaw() const { return yaw; } + void Yaw(float y) { yaw = y; } + void RotateYaw(float delta) { yaw += delta; } + + void Update(int dt); + +private: + glm::vec3 velocity; + glm::vec3 position; + float pitch; + float yaw; + +}; + +} + +#endif diff --git a/src/model.cpp b/src/model.cpp deleted file mode 100644 index 7335ed9..0000000 --- a/src/model.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "model.hpp" - -#include -#include -#include - - -namespace blank { - -Model::Model() -: velocity(0, 0, 0) -, position(0, 0, 0) -, pitch(0) -, yaw(0) { - -} - -Model::~Model() { - -} - - -glm::mat4 Model::Transform() const { - return glm::translate(position) * glm::eulerAngleYX(yaw, pitch); -} - - -void Model::Update(int dt) { - position += velocity * float(dt); -} - -} diff --git a/src/model.hpp b/src/model.hpp deleted file mode 100644 index b2a6e21..0000000 --- a/src/model.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef BLANK_MODEL_HPP_ -#define BLANK_MODEL_HPP_ - -#include - - -namespace blank { - -class Model { - -public: - Model(); - ~Model(); - - glm::mat4 Transform() const; - - void Velocity(glm::vec3 vel) { velocity = vel; } - void Position(glm::vec3 pos) { position = pos; } - void Move(glm::vec3 delta) { 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; } - float Yaw() const { return yaw; } - void Yaw(float y) { yaw = y; } - void RotateYaw(float delta) { yaw += delta; } - - void Update(int dt); - -private: - glm::vec3 velocity; - glm::vec3 position; - float pitch; - float yaw; - -}; - -} - -#endif