change camera axis

This commit is contained in:
Łukasz Śliwiński 2022-01-31 16:23:28 +01:00
parent 5b5335164c
commit fb7f30a406

View File

@ -22,6 +22,7 @@ Core::RenderContext sphereContext;
glm::vec3 cameraPos = glm::vec3(0, 0, 5);
glm::vec3 cameraDir; // Wektor "do przodu" kamery
glm::vec3 cameraSide; // Wektor "w bok" kamery
glm::vec3 cameraUp;
float cameraAngle = 0;
int lastMouseX, lastMouseY, mouseX, mouseY;
@ -60,10 +61,11 @@ void mouse(int x, int y)
glm::mat4 createCameraMatrix()
{
rotation = glm::normalize(rotation * glm::angleAxis((float)(mouseX * 0.01), cameraDir) * glm::angleAxis((float)(mouseY * 0.01), cameraSide));
rotation = glm::normalize(rotation * glm::angleAxis((float)(mouseX * 0.01), cameraUp) * glm::angleAxis((float)(mouseY * 0.01), cameraSide));
mouseX = mouseY = 0;
cameraDir = glm::inverse(rotation) * glm::vec3(0, 0, -1);
cameraSide = glm::inverse(rotation) * glm::vec3(-1, 0, 0);
cameraUp = glm::inverse(rotation) * glm::vec3(0, -1, 0);
return Core::createViewMatrixQuat(cameraPos, rotation);
}