PDA

View Full Version : RubberBand Zoom

gbiv
09-16-2008, 07:55 AM
Hello All,
I'm trying to implement rubber band zoom functionality in my application. I understand how to draw the rubber band and reposition my camera in the xy plane of the camera but how do I calculate the distance along the view vector to move the camera?
I thought I could use some simple trig with similar triangles(like finding the distance between the near and far plane given the view angle) but it didn't quite work for me.
Thanks for any input here
biv

gbiv
09-18-2008, 06:19 AM

dletozeun
09-18-2008, 06:53 AM
Perhaps it is because few people seem to know what is "rubberband zoom". Try to be more explicit about what are your needs.

gbiv
09-22-2008, 03:00 PM
By rubber band zoom I meant, left mouse drag draws a rectangular region on the screen. Upon release of the left mouse, the camera "zooms" to the rectangular region.
Does that make more sense?

Rosetta
09-22-2008, 03:39 PM
I never knew it was called a "Rubber Band Zoom" but I have implemented this in my current project. I wrote a fairly large class that helps to draw the "Rubber Band" and animate the zooming but the part to actually make it zoom is either

gl.glOrtho(zoomBox[0] * windowRatio, zoomBox[2] * windowRatio, zoomBox[1],zoomBox[3], 5.0f, 60.0f);

[/B]
OR

gl.glFrustum(zoomBox[0] * windowRatio, zoomBox[2] * windowRatio, zoomBox[1], zoomBox[3], 5.0f, 0.0f);

[/B]

Where originally zoomBox = {-14.0f, -14.0f, 14.0f, 14.0f}, but if I draw a "Rubber Band" it could go to {1.5f, -1.0f, 4.0f, 5.0f}

So you have to update the GL_PROJECTION matrix

I dont know If I have been clear enough :p