Learning OpenGL for N-body Sims #4 - WASD control of camera

Camera control using the keyboard (WASD), we add a file controls.cpp that uses to update our camera viewpoint.



// Move forward if (glfwGetKey( window, GLFW_KEY_UP ) == GLFW_PRESS){
position += direction * deltaTime * speed;
}
// Move backward
if (glfwGetKey( window, GLFW_KEY_DOWN ) == GLFW_PRESS){
position -= direction * deltaTime * speed;
}
// Strafe right
if (glfwGetKey( window, GLFW_KEY_RIGHT ) == GLFW_PRESS){
position += right * deltaTime * speed;
}
// Strafe left
if (glfwGetKey( window, GLFW_KEY_LEFT ) == GLFW_PRESS){
position -= right * deltaTime * speed;
}

Moving around cube

Source code on Github

Popular posts from this blog

Visualizing TLE Orbital Elements with Python and matplotlib

Learning TensorFlow #1 - Using Computer Vision to turn a Chessboard image into chess tiles

Building a PID hover controller for Kerbal Space Program with kOS and IPython Notebook