PDA

View Full Version : Non-moving skybox



blender
03-16-2002, 08:53 AM
How can I make skybox to not move withn the other world (like in quake2 or something else)?

Bob
03-16-2002, 10:58 AM
A sky box can be a little bit tricky. They should be affected by the viewpoint rotation, but not the viewpoint translation.

A viewpoint transform is a rotation and a translation. You should draw the sky box after the rotation, but before the translation.

Shag
03-16-2002, 05:54 PM
Correction ... you should draw the sky box before anything, with depth testing disabled ...

The principle is pretty simple. A skybox is drawn before anything else, at a fixed distance fom the camera. This guarantees that it will be drawn with a fixed distance from the user's viewpoint. which means it won't be translated from the user with the rest of the 'world'

Shag
03-16-2002, 05:56 PM
Double correct - what Bob said was correct ... but not intuitive.

blender
03-17-2002, 07:53 AM
Ok.
Unfortunetly that will mess up a little my engine code, but I'll try to add the sky there as you said.

But then another question:
If I make a sky box in map editor and it becomes a rectangle instead of a cube, then the sky will be badly scaled.
In quake2 sky can be a rectangle and still looks like a box. http://www.opengl.org/discussion_boards/ubb/confused.gif

Jambolo
03-17-2002, 11:06 AM
...You should draw the sky box after the rotation, but before the translation.

Here's the easy way to do the skybox:






gluLookAt( ex, ey, ez, cx, cy, cz, ux, uy, uz );
glPushMatrix();
glTranslatef( ex, ey, ez );
DrawSkyBox();
glPopMatrix();
...


As far as the skybox texture, I use a different texture for each face, but you could put them all into one texture and figure out the uv's. Like this:





+-------------------+
| +---+ |
| | | |
| +---+---+---+---+ |
| | | | | | |
| +---+---+---+---+ |
| | | |
| +---+ |
+-------------------+



[This message has been edited by Jambolo (edited 03-17-2002).]

blender
03-18-2002, 10:25 AM
There. I got it work thaks to you all. http://www.opengl.org/discussion_boards/ubb/smile.gif
I made that my program calculates the skybox,
so it doesn't have to be done in map editor (don't know why it had to be with Quake2).
I made that it loads different textures for each side (sky_ft, sky_bk ...), I also made a cloud layer that is a moving multitexture.