Added property to flip y-axis to camera class
This commit is contained in:
parent
374ee215bb
commit
6c43ab37ff
1 changed files with 10 additions and 2 deletions
|
|
@ -23,11 +23,15 @@ private:
|
||||||
glm::mat4 rotM = glm::mat4(1.0f);
|
glm::mat4 rotM = glm::mat4(1.0f);
|
||||||
glm::mat4 transM;
|
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.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));
|
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)
|
if (type == CameraType::firstperson)
|
||||||
{
|
{
|
||||||
|
|
@ -51,6 +55,7 @@ public:
|
||||||
float movementSpeed = 1.0f;
|
float movementSpeed = 1.0f;
|
||||||
|
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
|
bool flipY = false;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
|
@ -85,6 +90,9 @@ public:
|
||||||
this->znear = znear;
|
this->znear = znear;
|
||||||
this->zfar = zfar;
|
this->zfar = zfar;
|
||||||
matrices.perspective = glm::perspective(glm::radians(fov), aspect, znear, zfar);
|
matrices.perspective = glm::perspective(glm::radians(fov), aspect, znear, zfar);
|
||||||
|
if (flipY) {
|
||||||
|
matrices.perspective[1, 1] *= -1.0f;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void updateAspectRatio(float aspect)
|
void updateAspectRatio(float aspect)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue