Locking the skybox

I have a skybox with stars textured onto it that I always want to be the same distance from the camera as even travelling across our solar system would not yield any noticable relative motion. Anyway, in my never ending quest to always do things the "right way" I'm wondering if there's a better way to lock the skybox to the camera position? What I currently do is the following in my stateUpdate:



skybox.setLocalTranslation(cam.getLocation());



It works and is smooth, but just wanted to see if I was missing something and perhaps also to mention that it might be nice to be able to have this functionality added to the existing Skybox, although I don't see a real easy way to do that.


I think someone posted code for a skydome a while back – you could search for it. Could be what you're looking for.



Otherwise, HelloIntersection doesn't use a real skybox texture. A skybox consists of six textures – one for each face, which when applied should turn out seamless.



There's a great program called terragen that can generate such textures for you.

Here's how I load my skyboxes – especially note the lines at the bottom where I map the loaded textures to each face of the skybox:



   public static Skybox loadSkybox(String name) {
      Skybox skybox = new Skybox("skybox", 10, 10, 10);

      Texture north = TextureManager.loadTexture(
            getResource(SKYBOX_DIR + name + "/north.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR,
            Image.GUESS_FORMAT_NO_S3TC,
            1.0f,
            true);
      Texture south = TextureManager.loadTexture(
            getResource(SKYBOX_DIR + name + "/south.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR,
            Image.GUESS_FORMAT_NO_S3TC,
            maxAnisotropic,
            true);
      Texture east = TextureManager.loadTexture(
            getResource(SKYBOX_DIR + name + "/east.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR,
            Image.GUESS_FORMAT_NO_S3TC,
            1.0f,
            true);
      Texture west = TextureManager.loadTexture(
            getResource(SKYBOX_DIR + name + "/west.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR,
            Image.GUESS_FORMAT_NO_S3TC,
            1.0f,
            true);
      Texture up = TextureManager.loadTexture(
            getResource(SKYBOX_DIR + name + "/top.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR,
            Image.GUESS_FORMAT_NO_S3TC,
            1.0f,
            true);
      Texture down = TextureManager.loadTexture(
            getResource(SKYBOX_DIR + name + "/bottom.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR,
            Image.GUESS_FORMAT_NO_S3TC,
            1.0f,
            true);
      
      skybox.setTexture(Skybox.NORTH, north);
      skybox.setTexture(Skybox.WEST, west);
      skybox.setTexture(Skybox.SOUTH, south);
      skybox.setTexture(Skybox.EAST, east);
      skybox.setTexture(Skybox.UP, up);
      skybox.setTexture(Skybox.DOWN, down);
      skybox.preloadTextures();
      
      return skybox;
   }

I do it the same way, but could think of using a CameraNode and attach the skybox to it ?

That's the way to do it.



Or if you were using a CameraNode you could do:


skybox.getLocalTranslation = cameraNode.getLocalTranslation()



... which would make them share their translation.

Cool. Thanks.

I would like to ask one more question about skybox :

Is there a way to have one which doesn't look like a box? I mean i've used the sky texture given in the sample HelloIntersection and unfortunately inner corners  appear. How can i avoid this ?



Thanks for your help.

I've used terragen to generate my world but how do i get my six faces of the cube for my skybox?

OK thx, but how did you generate the east.jpg, north.jpg, south.jpg, west.jpg, bottom.jpg and top.jpg with terragen?

Oh, there's an option somewhere. I havn't done this myself – I worked with an "artist" friend of mine who dug it up after a while.



There's also a few free resources on the web if you search a bit.

You have to set the correct field of view somewhere ( 45 if i recall that correctly) and set the directions and cam position for rendering via the dialog manually.

You should really do some googeling for "skybox" here.

If You do this right then You get a seamless skybox.



edit: typo