Created
April 22, 2019 03:13
-
-
Save ac101m/97b5adbb24188ab3640690b1e22fda2d to your computer and use it in GitHub Desktop.
Camera rotation opengl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// member function changes direction camera is looking | |
void Camera::MoveLook(const float dx, const float dy, const float dr) { | |
// rotate cam.fwd & cam.right around cam.up by dx | |
this->fwd = glm::rotate(this->fwd, dx, this->up); | |
this->right = glm::rotate(this->right, dx, this->up); | |
// rotate cam.up & cam.fwd around cam.right by dy | |
this->up = glm::rotate(this->up, dy, this->right); | |
this->fwd = glm::rotate(this->fwd, dy, this->right); | |
// rotate cam.up & cam.right around cam.fwd by dr | |
this->up = glm::rotate(this->up, dr, this->fwd); | |
this->right = glm::rotate(this->right, dr, this->fwd); | |
// recalculate view matrix | |
this->UpdateViewMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment