PDA

View Full Version : Zoom for CAD using glOrtho



PERTINAX2001
07-27-2010, 10:01 AM
Hi,

I am currently developing a 3D CAD application by using glOrtho. How can I create a zoom, with the typical CAD features? I mean, the zoom tool in which the user makes 1st click with the mouse + dynamic window indicating zoom extencion+2nd mouse click (this is the end of zoom).

Thank you.

Javier

jvitela
10-07-2010, 07:08 AM
Well, I'm not shure if this is the response you are looking for, but the actual "zooming" can be done with the glOrtho function, for example, if you first set your orthographic proyection to something like:

glOrtho(0,800,0,600,-1,1);

meaning that you have a coordinate system with the origin at screen's left-bottom and the screen right most position is 800 and the top most is 600

and you select with the mouse a rectangle at left-top P0( 200,400 ) and right-bottom ( 600,200 ), then you can zoom your view by changing the orthographic view to:

glOrtho(
p0.x, p1.x, // left, right
p1.y, p0.y, // bottom, top
-1.0f,1.0f // near, far
);

PERTINAX2001
01-02-2011, 04:04 AM
I solved the matter time ago. Actually it is required to do two things: glOrtho adjustment to the new captured window (i.e. the zoom window) and also to translate the coordinate system to the center of that box.