0

I have an OpenGL scene set up like so:

  • The scene has a single camera. The camera cannot rotate but it can zoom and pan.
  • The camera is looking directly at a textured quad.
  • I can get the raycasting result that's generated from the mouse cursor position extending to the quad.

I need the camera to center on the mouse cursor position when I press a keyboard button. How do I do this? FYI the quad most remain in place but the camera can move around.

user1765354
  • 347
  • 1
  • 5
  • 21
  • Please, imagine the camera center - the eye position. It has an up vector, a right vector and a line of sight. The line of sight intersects the quad in its center (if I understood it right). This is point P0. Pointing or clicking onto quad provides another point P1. P0 and P1 are in world coordinates (or in model coordinates and can be transformed to WC). Take the vector P1 - P0 as translation. This translation has to be applied to the camera eye position to center P1. Remember camera up and right vector which might be used to pan the camera respectively. – Scheff's Cat Dec 19 '17 at 07:24
  • what kind of projection you use? take a look at this [Zooming graphics based on current mouse position](https://stackoverflow.com/a/37269366/2521214) that one uses only zoom and pan without projections so no depth change nor rotations. To center you just take the texture coordinate for center of screen and mouse and add/sub the difference to offset ... +/- applied scale depends on the order of your transforms – Spektre Dec 19 '17 at 09:39

0 Answers0