openGL Camera setup for Zoom in/out centered at point under cursor

Posted by user3228921 on Game Development See other posts from Game Development or by user3228921
Published on 2014-05-11T12:06:13Z Indexed on 2014/08/21 22:28 UTC
Read the original article Hit count: 273

Filed under:
|

I am trying to implement a zoom in/out navigation mode in a openGL 3dViewer. I was able to implement zoom functionality centered at screen center just by moving eye towards the center in perspective mode.

Now i am trying to do the zoom centered at arbitrary position under the cursor. I am unable to figure out how should i move my camera forward and backward such that point under cursor remains at the same screen coordinates after zoom in/out. Any help would be appreciated.

Below are the images which show the desired effect. Just to mention, I am working in a perspective mode with eye target and up vectors to control camera.

Same effect i found in google sketchup and 'zoom to mouse position' setting in blender.

cursor position before zoom

cursor position after zoom

© Game Development or respective owner

Related posts about opengl

Related posts about camera