PDA

View Full Version : How to pan, rotate, zoom object in 3D in glOrtho() view?



avstenit
11-05-2013, 12:56 PM
I am having some problems with how to solve the problem of mouse interaction for pan, rotate, zoom an object in 3D with OpenGL. As I need to create a simple CAD geometry viewer which use orthogonal (parallel) projection I am using function glOrtho(). Is the right way to use gluLookAt() and change the parameters or do you suggest different approach?

If I understand correctly, to achive zoom with parallel (orthogonal) projection using glOrtho() one has to change the parameters of glOrtho() like:
glOrtho(left*zoomFactor, right*zoomFactor, bottom*zoomFactor, top*zoomFactor, zNear, zFar)

GClements
11-06-2013, 05:58 AM
For an orthographic projection, it's more common to set the projection matrix based solely upon the window dimensions, and implement pan, rotate and scale(*) by modifying the model-view matrix.

(*) "scale" and "zoom" aren't necessarily the same thing. It's more accurate to reserve the term "zoom" for changing the field-of-view angle, which only applies to a perspective projection (and perspective needs to be applied to the projection matrix; the model-view matrix should always be affine).