#include <glm/gtc/matrix_transform.hpp>
#include "camera.hpp"
+#include "controller.hpp"
#include "init.hpp"
-#include "model.hpp"
#include "shader.hpp"
float yaw_sensitivity;
Camera cam;
- Model model;
+ FPSController model;
GLuint vtx_buf;
GLuint mvp_handle;
namespace blank {
Camera::Camera()
-: Model()
+: FPSController()
, fov(45.0f)
, aspect(1.0f)
, near_clip(0.1f)
void Camera::Update(int dt) {
- Model::Update(dt);
+ FPSController::Update(dt);
vp = projection * glm::inverse(Transform());
}
#include <glm/glm.hpp>
-#include "model.hpp"
+#include "controller.hpp"
namespace blank {
class Camera
-: public Model {
+: public FPSController {
public:
Camera();
--- /dev/null
+#include "controller.hpp"
+
+#include <glm/gtc/matrix_transform.hpp>
+#include <glm/gtx/euler_angles.hpp>
+#include <glm/gtx/transform.hpp>
+
+
+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);
+}
+
+}
--- /dev/null
+#ifndef BLANK_CONTROLLER_HPP_
+#define BLANK_CONTROLLER_HPP_
+
+#include <glm/glm.hpp>
+
+
+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
+++ /dev/null
-#include "model.hpp"
-
-#include <glm/gtc/matrix_transform.hpp>
-#include <glm/gtx/euler_angles.hpp>
-#include <glm/gtx/transform.hpp>
-
-
-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);
-}
-
-}
+++ /dev/null
-#ifndef BLANK_MODEL_HPP_
-#define BLANK_MODEL_HPP_
-
-#include <glm/glm.hpp>
-
-
-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