summaryrefslogtreecommitdiffstats
path: root/graphics/Camera3D.cpp
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 /graphics/Camera3D.cpp
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 '')
-rw-r--r--graphics/Camera3D.cpp79
1 files changed, 0 insertions, 79 deletions
diff --git a/graphics/Camera3D.cpp b/graphics/Camera3D.cpp
deleted file mode 100644
index eb740e4..0000000
--- a/graphics/Camera3D.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "Camera3D.hpp"
-
-Camera3D::Camera3D(glm::vec3 position, glm::vec3 up, GLfloat yaw, GLfloat pitch) : Front(glm::vec3(0.0f, 0.0f, -1.0f)),
- MovementSpeed(SPEED),
- MouseSensitivity(SENSITIVTY),
- Zoom(ZOOM) {
- this->Position = position;
- this->WorldUp = up;
- this->Yaw = yaw;
- this->Pitch = pitch;
- this->updateCameraVectors();
-}
-
-Camera3D::Camera3D(GLfloat posX, GLfloat posY, GLfloat posZ, GLfloat upX, GLfloat upY, GLfloat upZ, GLfloat yaw,
- GLfloat pitch) : Front(glm::vec3(0.0f, 0.0f, -1.0f)), MovementSpeed(SPEED), MouseSensitivity(SENSITIVTY),
- Zoom(ZOOM) {
- this->Position = glm::vec3(posX, posY, posZ);
- this->WorldUp = glm::vec3(upX, upY, upZ);
- this->Yaw = yaw;
- this->Pitch = pitch;
- this->updateCameraVectors();
-}
-
-glm::mat4 Camera3D::GetViewMatrix() {
- return glm::lookAt(this->Position, this->Position + this->Front, this->Up);
-}
-
-void Camera3D::ProcessKeyboard(Camera_Movement direction, GLfloat deltaTime) {
- GLfloat velocity = this->MovementSpeed * deltaTime;
- if (direction == FORWARD)
- this->Position += this->Front * velocity;
- if (direction == BACKWARD)
- this->Position -= this->Front * velocity;
- if (direction == LEFT)
- this->Position -= this->Right * velocity;
- if (direction == RIGHT)
- this->Position += this->Right * velocity;
-}
-
-void Camera3D::ProcessMouseMovement(GLfloat xoffset, GLfloat yoffset, GLboolean constrainPitch) {
- xoffset *= this->MouseSensitivity;
- yoffset *= this->MouseSensitivity;
-
- this->Yaw += xoffset;
- this->Pitch += yoffset;
-
- // Make sure that when pitch is out of bounds, screen doesn't get flipped
- if (constrainPitch) {
- if (this->Pitch > 89.0f)
- this->Pitch = 89.0f;
- if (this->Pitch < -89.0f)
- this->Pitch = -89.0f;
- }
-
- // Update Front, Right and Up Vectors using the updated Eular angles
- this->updateCameraVectors();
-}
-
-void Camera3D::ProcessMouseScroll(GLfloat yoffset) {
- if (this->Zoom >= 1.0f && this->Zoom <= 45.0f)
- this->Zoom -= yoffset/5.0f;
- if (this->Zoom <= 1.0f)
- this->Zoom = 1.0f;
- if (this->Zoom >= 45.0f)
- this->Zoom = 45.0f;
-}
-
-void Camera3D::updateCameraVectors() {
- // Calculate the new Front vector
- glm::vec3 front;
- front.x = cos(glm::radians(this->Yaw)) * cos(glm::radians(this->Pitch));
- front.y = sin(glm::radians(this->Pitch));
- front.z = sin(glm::radians(this->Yaw)) * cos(glm::radians(this->Pitch));
- this->Front = glm::normalize(front);
- // Also re-calculate the Right and Up vector
- this->Right = glm::normalize(glm::cross(this->Front,
- this->WorldUp)); // Normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement.
- this->Up = glm::normalize(glm::cross(this->Right, this->Front));
-}