recp / cglm

📽 Highly Optimized 2D / 3D Graphics Math (glm) for C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I mirror the camera along the X axis without offsetting the camera's position?

badasahog opened this issue · comments

I want to mirror the screen along the X axis.

Right now I've implemented this by hand using the following code:

glm_lookat_lh(cameraPosition, cameraFront, cameraUp, cameraViewMat);	
cameraViewMat[0][0] *= -1.f;
cameraViewMat[0][1] *= -1.f;
cameraViewMat[0][2] *= -1.f;
cameraViewMat[0][3] *= -1.f;

This approach makes it so that the X coordinate of the camera's position is inverted, which I don't want.

Hi @badasahog,

What about flipping cameraUp for instance {1,0,0} to {-1,0,0}? glm_vec4_negate() will simply flip the vector.

glm_mirror_x(view), glm_mirror_y(view), glm_mirror_z(view), glm_mirror(vec, view, dest) could also help to flip existing view maybe 🤔

Modifying projected matrix could also be an option to flip scene

that won't work because it would just flip the scene upside down (z axis).

What I want to do is use a coordinate system where x increases in the opposite direction that it does by default.

as for glm_mirror_x, etc, these functions don't appear to exist