cglm icon indicating copy to clipboard operation
cglm copied to clipboard

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

Open badasahog opened this issue 1 year ago • 2 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.

badasahog avatar Jul 16 '23 23:07 badasahog

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

recp avatar Jul 17 '23 18:07 recp

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

badasahog avatar Aug 17 '23 20:08 badasahog