How can I make skybox to not move withn the other world (like in quake2 or something else)?
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.
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’
Double correct - what Bob said was correct … but not intuitive.
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.
…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).]
There. I got it work thaks to you all.
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.