Centering skybox around camera

Started by
3 comments, last by python_regious 19 years ago
Hi I have a planets simulation. The look direction is always the center(sun) but the user can rotate the solar system and change and the view distance. The problem now is that the skybox should, no matter which distance user user looks from never be scaled that is, always be the same size which means it should be centered around the camera. This is my code but it does not seem to center the skybox: Vector3 camPos = new Vector3(0, 0, camDist); Matrix mat = Matrix.RotationYawPitchRoll(camYAngle, camXAngle, 0) * Matrix.Translation(camPos); device.Transform.View = mat; // make skybox big enough and center it around camera device.Transform.World = Matrix.Scaling(40f, 40f, 40f) * Matrix.Translation(camPos); skyBox.Show(); // draw skybox with current world transform [Edited by - codymanix on March 20, 2005 12:43:55 PM]
Advertisement
Just center your skybox around your camera, turn depth-writing off and render it. Then turn depth-testing back on and render the rest of your scene.

Best regards,
Roq
Isn't centering the skybox just as simple as this:

skybox.position = camera.position;

you should only create the skybox once, if you are scaling it or whatever every frame you are doing something wrong. It's just a textured cube, so essentially it's just like any other object in your world, except it's drawn as suggested above.

-me
> Isn't centering the skybox just as simple as this:
> skybox.position = camera.position;

Isn't that the same as

device.Transform.World = Matrix.Scaling(40f, 40f, 40f) * Matrix.Translation(camPos);

?

To Roquqkie: I already turned depth writing off.
Quote:Original post by codymanix
To Roquqkie: I already turned depth writing off.


Then you shouldn't have to worry about centering the skybox around the camera if you have depth writing and testing disabled, just worry about it's orientation.
If at first you don't succeed, redefine success.

This topic is closed to new replies.

Advertisement