Model displays Texture of the Skybox

i don’t know what i am doing wrong and i am not sure if it is a ZBuffer, MaterialState, Lightning or another kind of problem.

I am creating objects which i add to the RootNode during the update().

The RootNode has a ZBufferstate and a LightState set, the model is a .obj with Texture, but i tried also with a simple Box with the same result.



When i create my object it seems invisible, but thats only because the newly created object displays the Texture of my SkyBox. The object gets visible tho if i move very close to it:



Further away the object only display the skybox’s texture and gets kinda invisible.





Really close, now the texture is there, but the border of the object already gets transparent





Does anyone have any hints what i should check?

Any help is greatly appreciated.

play around with renderstates. this is what helps me most of the time.

Ok i found the problem.

After i removed the ZBufferState from the RootNode, everything gets displayed as it should.

But i am a bit confused, because now i am never setting a ZBufferState.



When are ZBufferstates needed, and do you set them usualy on the RootNode once, or for every SceneElement ?

i set my defaults at the root and overwrite them at single nodes when they need special treatment

heh ok, no ZBuffer is a bad idea too, after i rearranged a few things i got again strange visuals results.



But i think i fixed it now, my initial Problem was that i didn't set the correct ZBuffer Function on the root Node.

The default function is CF_LESS, and with that things are getting drawn in the wrong order (see 1st Screenshot).



What i had to do is set CF_LEQUAL.



        ZBufferState z = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
        z.setFunction(ZBufferState.CF_LEQUAL);
        rootNode.setRenderState(z);



And call updateRenderState on newly created Objects of course.

But it still gives me headaches, CF_LESS and CF_LEQUAL should give about the same results no?
There should only be a difference when two objects have exactly the same z depth, which is very seldom the case no?
I'm going to read that stuff up a bit more carefully now.