-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controls.cpp
48 lines (42 loc) · 1.41 KB
/
Controls.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "Controls.h"
#include <iostream>
void Controls::processInputKeyboard(GLFWwindow* window)
{
//generic part
//this is placeholder camera controls
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
forward -= movementSpeed;
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
forward += movementSpeed;
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
right -= movementSpeed;
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
right += movementSpeed;
if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
up += movementSpeed;
if (glfwGetKey(window, GLFW_KEY_C) == GLFW_PRESS)
up -= movementSpeed;
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
roll += movementSpeed * 0.2f;
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
roll -= movementSpeed * 0.2f;
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
}
void Controls::processInputMouse(GLFWwindow* window, double x, double y)
{
//generic part
if (init)
{
lastX = x;
lastY = y;
init = false;
}
float mousexOffset = (float) ((lastX - x) * sensitivity);
float mouseyOffset = (float) ((lastY - y) * sensitivity);
lastX = x;
lastY = y;
//this is placeholder camera controls
yaw -= mousexOffset * sensitivity;
pitch -= mouseyOffset * sensitivity;
}