The incredible shrinknig man: Part II

This commit is contained in:
maelstrom 2024-09-27 23:21:27 +02:00
parent 432bb0d562
commit 47f36c814c
3 changed files with 12 additions and 0 deletions

View file

@ -31,6 +31,12 @@ void Camera::processMovement(Direction direction, float deltaTime) {
case DIRECTION_RIGHT:
cameraPos += glm::normalize(glm::cross(cameraFront, cameraUp)) * speed;
break;
case DIRECTION_UP:
cameraPos += cameraUp * speed;
break;
case DIRECTION_DOWN:
cameraPos -= cameraUp * speed;
break;
}
}

View file

@ -6,6 +6,8 @@ enum Direction {
DIRECTION_BACKWARDS,
DIRECTION_RIGHT,
DIRECTION_LEFT,
DIRECTION_UP,
DIRECTION_DOWN,
};
class Camera {

View file

@ -76,6 +76,10 @@ void processInput(GLFWwindow* window) {
camera.processMovement(DIRECTION_LEFT, deltaTime);
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
camera.processMovement(DIRECTION_RIGHT, deltaTime);
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
camera.processMovement(DIRECTION_UP, deltaTime);
if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS)
camera.processMovement(DIRECTION_DOWN, deltaTime);
if (mode == 2) {
float shiftFactor = (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) ? -0.5 : 0.5;