View Full Version : Trying to get dimentions of the plane where an object resides.

02-27-2003, 07:26 AM
Hi guys,

I am using Open GL and have a little problem: I have a sphere (a globe) that I am able to zoom, rotate and pan with. I need to be able to limit the panning of the globe so that the globe does not pan off the screen. I have figgured out a way to do this if I do not zoom the scene, but as soon as I start zooming, my screen dimention calculations are way off. Because I am able to zoom the object (by using a glTranslate call), I need to somehow figgure out the dimentions of the current plane that the globe resides by facturing in the zooming distance.

My viewport is set up so that my FOV angle is 20 degrees, my aspect ratio is defined as FormWidth/FormHeight, my neer clipping range is 5, and my far clipping range is FormWidth (approximitly 1900).

To get the height of the plane where my sphere resides I do the following:

planeHeight = zoomDistance * (tan(FOV/2)); // where FOV = 20, Zoom Distance is the distance that we zoomed in or out.

planeWidth = planeHeight * aspect ratio;

Now this formula that I have currently works so long as I keep the zoomDistance is it's defaulted value at startup (-280). Once I zoom in or out, this formula does not give me the correct dimentions of the current plane.

Any ideas??