Strange texture behaviour

I have loaded a few models into a scene. Each model uses a different texture including the floor which has a green texture.



The problem I am having is that as I navigate round objects and move to the left or right, suddenly the object texture changes to the one I used for the floor.



Its a very odd behaviour which doesnt go away even when I do



            TextureState modTex = display.getRenderer().createTextureState();
            modTex.setEnabled(true);
            Texture tr = TextureManager.loadTexture(
                TestNav.class.getClassLoader().getResource(modeldir+"/"+texname), Texture.MM_LINEAR,
                Texture.FM_LINEAR, true);
            modTex.setTexture(tr);       
       
       //i.setModelBound(new BoundingBox());
       //i.updateModelBound();
            i.setRenderState(modTex); 
            i.setTextureCombineMode(TextureState.REPLACE);



does anybody know whats going on?
tomcat

Can you provide a simple example for testing?

this would take me a little time as the code is a bit big and messy. I will try to get something for you. btw am I doing all the right things here? my understanding of textures is near zero.

tomcat

from the code you posted it looks fine, but it’s a small sample… Are you calling updateRenderState on i or a tree ancestor of i?

good point as I dont do this. do I call it in the update method or as soon as I create the node?

tomcat

You call it whenever states change on the scenegraph. typically you call it once on the root node at the end of setting up your scene (done for you if you use SimpleGame) then you’d only need to call it again if you change states around like swap in a new texture, etc.

ok, I will add this and see what change does it make.

tomcat

Thx renanse. I was missing the updateRenderState. It seems to be working ok now.

tomcat

Good to hear.