PDA

View Full Version : gluPickMatrix



yaba
08-19-2002, 10:29 PM
Hi

I've been trying to implement a simple zooming function using gluPickMatrix & gluPerspective. What I want is to let the user drag out a rectangle to zoom in on. I track the mouse events to obtain the coordinates for the pick matrix. There are a few things I'm not clear about...

How should the fov angle and the near & far z clipping planes be chosen for gluPerspective? I tried it with a fov of 90 & several values for the near & far planes to see its effects, but I'm not sure I understand what is happening. The proportions of the scene appear to change. This is probably due to the aspect ratio being wrong?(I use the window width/height)

As you can tell, I'm very very confused. Sorry for the trouble =0)

Oh 1 more thing, I'm doing this in X, and I'm trying to figure out how to draw a dragging rectangle as the user picks the area for zooming. I tried to track mouse motion & use glRectd in the rendering function, but it doesn't seem to be working.

Thanks.

V-man
08-20-2002, 06:00 AM
You should use glFrustum for this since you can supply a non-symmetrical frustum.
When the user draws a rectangle, you pretend it was drawn on the near plane and use those values (normalized from -1.0 to 1.0 or whatever you want) and setup a new frustum.

You don't need gluPickMatrix, but you can adapt with that as well. You don't need to change the call to gluPerspective for that.

V-man

yaba
08-20-2002, 11:08 PM
so I use glFrustum with the x,y clipping planes set to the values obtained from the dragging rectangle(after I convert the screen coords to world coords using gluUnProject)? and the near & far z clipping planes remain the same as before?

Thanks for helping...

[This message has been edited by yaba (edited 08-21-2002).]

V-man
08-21-2002, 04:30 PM
Yep, but maybe you won't need gluUnProject since it won't make a big difference. Try and see.

The znear zfar stay the same unless you want to change that.
V-man

chief
08-21-2002, 10:20 PM
Look at http://www.codeproject.com/useritems/opengl_zooming.asp

yaba
08-22-2002, 09:53 PM
thanks v-man, glFrustum works..just 1 more problem though, in order to have the zooming rectangle match the user-dragged rectangle precisely, it has to be drawn on the plane of the eye position right? but this means that it won't be visible on the window cos it's clipped?