Skybox problem

hi,



i have a problem with the movement of my skybox…



after i created the skybox and attached it to the rootnode I call this in simpleUpdate();



skyBox.setLocalTranslation(cam.getLocation());



to move the skybox with the player...
That works fine in the game,

but if I attach my camera node (with the camera) to a flying object (it has a controller and flies on a spline)
the skybox moves jerky back and forth...

also


skyBox.setLocalTranslation(camNode.getWorldTranslation());



doesn't work..

:cry:


thy for any help

I had a similar problem I think. Make sure you update the geometry (call updateGeometricState() on your root node) before reading the translation.

thx Chamooze,



I tried that but it didn'T work :frowning:

i called any of those here (try and error :wink: but it didn't work


        rootNode.updateGeometricState(0.0f,true);
    //    skyBox.updateGeometricState(0.0f,true);
    //    fighter1.updateGeometricState(0.0f,true);
   //     cam.update();
        skyBox.getLocalTranslation().set(cam.getLocation());
    //    rootNode.updateGeometricState(0.0f,true);
    //    skyBox.updateGeometricState(0.0f,true);
     //   fighter1.updateGeometricState(0.0f,true);



I think it could have sth. do do with the controller...
or with the tree

before

rootnode -> skybox
rootnode -> flying object
rootnode -> camnode -> cam

after

rootnode -> skybox
rootnode -> flying object ->camnode -> cam

I also tried to attach the skybox to the camnode or the flying object, but that looks weird

Hm, You set the local translation of the skybox to share the camNodes world translation.

If i'm not wrong then this should be done only once as they share the same vector3f translation further on ?

(works with cam.getLocation() too)



if You do  it via skybox.getLocalTranslation.set(camNode.getWorldTranslation()) then you should do it every update.



…but this shouldn't explain the jerky movement.

Have You got a non moving reference object in the scene to show if the cam movement itself is jerky ?

Make sure that your camNode is updated before updating your skybox. This could be achieved by adding the skybox as the last spatial (at least 'behind' the camNode ancestor) to the rootNode. Or by calling updateWorldVectors() prior to rendering.

Thank you so much guys…you rule :smiley:



Finally I got it running…



it was indeed that the skybox was attached after the camNode… I changed this …thx irissor

I also call now



skyBox.setLocalTranslation(camNode.getWorldTranslation());



only once and not this:



skyBox.getLocalTranslation().set(camNode.getWorldTranslation());



every time in simpleUpdate(); as winkman said … thx winkman



I had to do these two things or it wouldn't work…



it took me ages to get it working

the only little problem i have is that the screen flickers sometimes… but that doesn't bother much …



thx again :slight_smile: