system
August 12, 2002, 11:06pm
1
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.
gluUnProject (or selection buffer) - do a search
system
August 13, 2002, 11:56pm
3
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
August 14, 2002, 9:47pm
4
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