Weird scale behaviour

hi all



I was trying to scale my game down a bit by using rootNode.setlocalScale(0.5f);

However this produced weird camera behaviour. My chasecamera would no longer follow his node instead it would go much faster leaving his target far behind him. Also the skybox does not keep in sync with the camera position anymore.



I then decided to try it in a basic example SImplegame, a skybox and a scaled rootNode.


public class TestScale extends SimpleGame
{

   private Skybox   skybox;

   @Override
   protected void simpleInitGame()
   {
      buildSkyBox();
      skybox.setModelBound(new BoundingBox());
      skybox.updateModelBound();

      rootNode.attachChild(skybox);

      rootNode.setLocalScale(0.5f);
      rootNode.updateGeometricState(0, true);
   }

   @Override
   protected void simpleUpdate()
   {
      skybox.getLocalTranslation().set(cam.getLocation());
   }

   private void buildSkyBox()
   {
      skybox = new Skybox("skybox", 10, 10, 10);

      String dir = "jmetest/data/skybox1/";
      Texture north = TextureManager.loadTexture(TestScale.class
            .getClassLoader().getResource(dir + "1.jpg"),
            Texture.MM_LINEAR, Texture.FM_LINEAR);
      Texture south = TextureManager.loadTexture(TestScale.class
            .getClassLoader().getResource(dir + "3.jpg"),
            Texture.MM_LINEAR, Texture.FM_LINEAR);
      Texture east = TextureManager.loadTexture(TestScale.class
            .getClassLoader().getResource(dir + "2.jpg"),
            Texture.MM_LINEAR, Texture.FM_LINEAR);
      Texture west = TextureManager.loadTexture(TestScale.class
            .getClassLoader().getResource(dir + "4.jpg"),
            Texture.MM_LINEAR, Texture.FM_LINEAR);
      Texture up = TextureManager.loadTexture(TestScale.class
            .getClassLoader().getResource(dir + "6.jpg"),
            Texture.MM_LINEAR, Texture.FM_LINEAR);
      Texture down = TextureManager.loadTexture(TestScale.class
            .getClassLoader().getResource(dir + "5.jpg"),
            Texture.MM_LINEAR, Texture.FM_LINEAR);

      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();

      CullState cullState = display.getRenderer().createCullState();
      cullState.setCullMode(CullState.CS_BACK);
      cullState.setEnabled(true);
      skybox.setRenderState(cullState);

      skybox.updateRenderState();

   }

   public static void main(String[] args)
   {
      TestScale app = new TestScale();
      app.start();
   }

}



I even tried it with calling all possible updatemethods  neither had any effect.

Is this a bug or am i missing something here ?

try calling updateWorldBound() on root node after u scale the root node.

Thanks for the reply,

I tried that but it has no effect, the skybox still doesn't move with the camera.

The problem is that the Camera is NOT attached to the root node, and thus, its translation is not affected by the scale… that creates a discrepancy between the translation required to keep the skybox centered and the camera absolute translation.

You are setting the local skybox translation to the camera's location, but this is then being updated by the new scale from the root node when the skybox's world translation is recalculated.  Probably something similar is happening with the chase camera.

Thanks that makes sense