Changing Texturestate of a (3ds) model to toggle textures on / off

Hi,



I have a question concerning the texturestate of an already loaded (3ds-) model.

I've searched the forum, but it seems that nobody of you have ever had a question to this.



okay… I've loaded a 3ds model, overwrote the texturepath and everything works nice… (no modelloading problem!!!)



But now I want to change the texturestate of the textures applied to the model by 3ds, so for example I want to toggle the textures on / off, apply some filtering to the textures and so on.



How can I do this? How can I modify the properties of the textures without applying a completely new texture? Is there a way to get the current texturestate provided (as it seems to me) automatically by the modelloader? Is there already one?



Please help me.

Have you tried getting the TextureState from the model (Node) and disabling it? Ie:



(Node) new SceneElement().getRenderState(RenderState.RS_TEXTURE).setEnabled(false);



Obviously you wouldnt use the above code, it just demonstrates the appropriate classes.

this returns only a null-value and crashes.


...
model = ModelLoader.loadModel("model.3ds", TEXTURE_PATH);
if(level != null)
{
model.setModelBound(new BoundingBox());
model.updateModelBound();
model.getRenderState(RenderState.RS_TEXTURE).setEnabled(false);
scene.attachChild(level);
}
...


Maybe the TextureState doesnt exist for that immediate node. Maybe you need to recurse all child nodes and check if they have a TextureState then disbale. I dont know the best way to do it.

Yes, adamgp is right, you need to recurse into the scenegraph nodes/geoms to find the ones with the texture states.

You may be able to rely on named nodes - that way you can build in custom render states