PDA

View Full Version : zooming



08-12-2002, 11:06 PM
How can I convert the x-y coordinates obtained in the glutMouseFunc to world coordinates? I want to allow the user to zoom in on a particular part of the scene, centred on the mouse position clicked; maybe even to select a rectangle within the window to zoom in on. What would be the best way of achieving this?

Thanks.

Rob The Bloke
08-13-2002, 12:02 AM
gluUnProject (or selection buffer) - do a search

08-13-2002, 11:56 PM
I tried this out, it seems to work *sometimes*, which is definitely bad. What am I doing wrong?

/*calculate the width, ht & centre of the zoom window*/
width = maxX - minX;
ht = maxY - minY;
cX = minX + width/2;
cY = minY + ht/2;

/*get current viewport*/
glGetIntegerv(GL_VIEWPORT, viewport);

/*initialise projection mode*/
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

/*zoom in*/
gluPickMatrix( (GLdouble)cX, (GLdouble)cY,
(GLdouble)width, (GLdouble)ht, viewport);

/*multiply perspective matrix by the pick matrix*/
gluPerspective(90, width/ht, -0.8, 0.8);
glMatrixMode(GL_MODELVIEW);
glutPostRedisplay();

Also, how should I decide what values to use for near & far z clipping planes for gluPerspective?

How can I trace out the picking rectangle drawn by the user as they drag the mouse?(I'm doing this in X)

Pls help....thanks.

Swift
08-14-2002, 09:47 PM
The following website might of some help: http://cheo.resnet.wayne.edu/miguel/

I remind there is a sample in this website that Zoom In using mouse