RubberBand Zoom

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

was this a dumb question?

Perhaps it is because few people seem to know what is “rubberband zoom”. Try to be more explicit about what are your needs.

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?

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);



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


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 :stuck_out_tongue: