summaryrefslogtreecommitdiffstats
path: root/src/graphics/Camera3D.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-18 16:03:05 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-18 16:03:05 +0200
commit4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79 (patch)
tree548911d4e341fd5717acff3b5bc752c7b5650bf4 /src/graphics/Camera3D.hpp
parent2017-05-13 (diff)
downloadAltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.gz
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.bz2
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.lz
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.xz
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.zst
AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.zip
Diffstat (limited to 'src/graphics/Camera3D.hpp')
-rw-r--r--src/graphics/Camera3D.hpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/graphics/Camera3D.hpp b/src/graphics/Camera3D.hpp
new file mode 100644
index 0000000..eac1f47
--- /dev/null
+++ b/src/graphics/Camera3D.hpp
@@ -0,0 +1,66 @@
+#pragma once
+
+// Std. Includes
+#include <vector>
+
+// GL Includes
+#include <GL/glew.h>
+#include <glm/glm.hpp>
+#include <glm/gtc/matrix_transform.hpp>
+
+
+// Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods
+enum Camera_Movement {
+ FORWARD,
+ BACKWARD,
+ LEFT,
+ RIGHT
+};
+
+// Default camera values
+const GLfloat YAW = -90.0f;
+const GLfloat PITCH = 0.0f;
+const GLfloat SPEED = 30.0f;
+const GLfloat SENSITIVTY = 0.2f;
+const GLfloat ZOOM = 45.0f;
+
+// An abstract camera class that processes input and calculates the corresponding Eular Angles, Vectors and Matrices for use in OpenGL
+class Camera3D {
+public:
+ // Camera3D Attributes
+ glm::vec3 Position;
+ glm::vec3 Front;
+ glm::vec3 Up;
+ glm::vec3 Right;
+ glm::vec3 WorldUp;
+ // Eular Angles
+ GLfloat Yaw;
+ GLfloat Pitch;
+ // Camera3D options
+ GLfloat MovementSpeed;
+ GLfloat MouseSensitivity;
+ GLfloat Zoom;
+
+ // Constructor with vectors
+ explicit Camera3D(glm::vec3 position = glm::vec3(0.0f, 0.0f, 3.0f), glm::vec3 up = glm::vec3(0.0f, 1.0f, 0.0f),
+ GLfloat yaw = YAW, GLfloat pitch = PITCH);
+
+ // Constructor with scalar values
+ Camera3D(GLfloat posX, GLfloat posY, GLfloat posZ, GLfloat upX, GLfloat upY, GLfloat upZ, GLfloat yaw, GLfloat pitch);
+
+ // Returns the view matrix calculated using Eular Angles and the LookAt Matrix
+ glm::mat4 GetViewMatrix();
+
+ // Processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems)
+ void ProcessKeyboard(Camera_Movement direction, GLfloat deltaTime);
+
+ // Processes input received from a mouse input system. Expects the offset value in both the x and y direction.
+ void ProcessMouseMovement(GLfloat xoffset, GLfloat yoffset, GLboolean constrainPitch = true);
+
+ // Processes input received from a mouse scroll-wheel event. Only requires input on the vertical wheel-axis
+ void ProcessMouseScroll(GLfloat yoffset);
+
+private:
+ // Calculates the front vector from the Camera3D's (updated) Eular Angles
+ void updateCameraVectors();
+}; \ No newline at end of file