Added property to flip y-axis to camera class

This commit is contained in:
Sascha Willems 2020-04-13 16:04:59 +02:00
parent 374ee215bb
commit 6c43ab37ff

View file

@ -23,11 +23,15 @@ private:
glm::mat4 rotM = glm::mat4(1.0f);
glm::mat4 transM;
rotM = glm::rotate(rotM, glm::radians(rotation.x), glm::vec3(1.0f, 0.0f, 0.0f));
rotM = glm::rotate(rotM, glm::radians(rotation.x * (flipY ? -1.0f : 1.0f)), glm::vec3(1.0f, 0.0f, 0.0f));
rotM = glm::rotate(rotM, glm::radians(rotation.y), glm::vec3(0.0f, 1.0f, 0.0f));
rotM = glm::rotate(rotM, glm::radians(rotation.z), glm::vec3(0.0f, 0.0f, 1.0f));
transM = glm::translate(glm::mat4(1.0f), position);
glm::vec3 translation = position;
if (flipY) {
translation.y *= -1.0f;
}
transM = glm::translate(glm::mat4(1.0f), translation);
if (type == CameraType::firstperson)
{
@ -51,6 +55,7 @@ public:
float movementSpeed = 1.0f;
bool updated = false;
bool flipY = false;
struct
{
@ -85,6 +90,9 @@ public:
this->znear = znear;
this->zfar = zfar;
matrices.perspective = glm::perspective(glm::radians(fov), aspect, znear, zfar);
if (flipY) {
matrices.perspective[1, 1] *= -1.0f;
}
};
void updateAspectRatio(float aspect)