8 if (glfwGetKey(window,
m_keys.
lookLeft) == GLFW_PRESS) { rotate.y -= 1.F; }
9 if (glfwGetKey(window,
m_keys.
lookRight) == GLFW_PRESS) { rotate.y += 1.F; }
10 if (glfwGetKey(window,
m_keys.
lookUp) == GLFW_PRESS) { rotate.x += 1.F; }
11 if (glfwGetKey(window,
m_keys.
lookDown) == GLFW_PRESS) { rotate.x -= 1.F; }
13 if (dot(rotate, rotate) > std::numeric_limits<float>::epsilon()) {
14 object.transform3D.rotation +=
m_lookSpeed * dt * normalize(rotate);
17 object.transform3D.rotation.x = glm::clamp(
object.transform3D.rotation.x, -1.5F, 1.5F);
18 object.transform3D.rotation.y = glm::mod(
object.transform3D.rotation.y, glm::two_pi<float>());
20 float yaw =
object.transform3D.rotation.y;
21 const glm::vec3 forwardDir{std::sin(yaw), 0.F, std::cos(yaw)};
22 const glm::vec3 rightDir{forwardDir.z, 0.F, -forwardDir.x};
23 constexpr glm::vec3 upDir{0.F, -1.F, 0.F};
25 glm::vec3 moveDir{0.F};
26 if (glfwGetKey(window,
m_keys.
moveForward) == GLFW_PRESS) {moveDir += forwardDir;}
28 if (glfwGetKey(window,
m_keys.
moveRight) == GLFW_PRESS) {moveDir += rightDir;}
29 if (glfwGetKey(window,
m_keys.
moveLeft) == GLFW_PRESS) {moveDir -= rightDir;}
30 if (glfwGetKey(window,
m_keys.
moveUp) == GLFW_PRESS) {moveDir += upDir;}
31 if (glfwGetKey(window,
m_keys.
moveDown) == GLFW_PRESS) {moveDir -= upDir;}
33 if (dot(moveDir, moveDir) > std::numeric_limits<float>::epsilon()) {
34 object.transform3D.translation +=
m_moveSpeed * dt * normalize(moveDir);