View Full Version : problem with my SkySquad !

02-16-2000, 02:02 PM

I have a problem with my "SkyQuad". I called it so because it is the
single-quad version of a skybox. How it works ? You simply draw a quad
that cover the whole screen. If your cam rotates, you simply move the
texture on the quad in the opposite direction. The quad has a size of
4x3 to match the 4:3 aspect ratio of most resolutions. Then you have
to find the distance from in which the quad covers the full screen.
this depends on your FOV. with a fov of 90 (and a 4.0x3.0 quad) this
distance is 3.0. But how to calculate the distance for different FOV
values ? I quickly realized that this is a trigonometric problem. I
use this formula:

float fDistance = -(1.5f / sinf((float) iFOV / 2.0f * PI_OVER_180));

...where 1.5 is my Y quad size divided by two, iFOV / 2.0f is half of
my FOV angle, and PI_OVER_180 is the usual conversion factor for converting
between degrees and radians. But this doesn't work very well, somehow wrong ;-)

Can anyone help ?


02-16-2000, 02:25 PM
i think you're doing something like the sky in doom, am i right?
if you stretch your quad, you can make it cover the screen on any plane.

i use this to project a point in 2-space (the mouse position http://www.opengl.org/discussion_boards/ubb/smile.gif) to a point in 3-space:


x,y,z the projected point in 3-space
u,v the point in 2-space
fov field of view in degrees
aspect guess...
plane the desired plane Z-coord (as in opengl. to be in front of the camera, this is <0)

the point in 2-space is normalized: lower-left corner is -1,-1 and upper-right is +1,+1
so, for instance, you choose some plane depth value, then you feed uv=(-1,-1):
you'll get a point in 3-space wich will projects to the lower-left corner of the viewport.

you can then call this function for the other 3 points of the quad,
or mirror around the origin the x and y component you just evaluated...
see what is best for you.

[This message has been edited by dmy (edited 02-17-2000).]

02-17-2000, 05:13 AM
Thanks !
It works perfect !

02-17-2000, 07:20 AM
glad to be helpful http://www.opengl.org/discussion_boards/ubb/smile.gif