StandardGame Vision Problem (Front <--> Behind) SOLVED

I have a serious problem. Standard Game works fine, but I have problems with the vision of objects.

I have a gate and a tree( both *.3ds).



Position of gate

gate.setLocalTranslation(0.0f,-2.0f,19.0f);



Position of tree

tree.setLocalTranslation(0.0f,-3.0f,5.0f);



Logical the gate must be in front of the door, because of the position. Wrong. The tree got "painted" over the gate.

If I change the code position( first tree, then gate), it's correct. It's similar of a layers, one upper layer and one bottom layer. The size and the position of the gate and the tree are correct, but not, what's in front and what should be behind.



Both gate and tree are in a Node which is loaded into a BasicGameState:





StandardGame Code:



BasicGameState backgroundscreen = new BasicGameState("Background");

GameStateManager.getInstance().attachChild(backgroundscreen);

backgroundscreen.setActive(true);



BackgroundMenu bg = new BackgroundMenu();//A Node with the tree and the gate

   

bg.updateRenderState();

backgroundscreen.getRootNode().attachChild(bg);









BackgroundMenu Code:



public class BackgroundMenu extends Node{



public BackgroundMenu(){



Mesh tree = new Mesh("game/data/mesh/object/tree.3ds");

tree.setTexture("game/data/texture/weapon/glock_17.jpg");

this.attachChild(tree);

tree.setLocalTranslation(0.0f,-3.0f,5.0f);

tree.setLocalScale(10.0f);



Mesh gate = new Mesh("game/data/mesh/object/gate.3ds");

gate.setTexture("game/data/texture/weapon/glock_17.jpg");

this.attachChild(gate);

gate.setLocalTranslation(0.0f,-2.0f,19.0f);

gate.setLocalScale(10.0f);



}

}







Hope you know advise!





EDIT:

I found the error! I forgot to use—>

backgroundscreen.getRootNode().updateRenderState();



Silly me!