Replace Textures at runtime Problem

I currently try to build a precompiler for models, that loads models based on some parameters ina config file, and saves it as a j3o then.

That tool should be able to load a model with textures, convert those textures to dds and save the j3o with the texture path’s changed to the dds. My current attempt is this:


if(model instanceof Geometry){

Geometry mygeom = (Geometry)model;

Material mat = mygeom.getMaterial();

for(MatParam para:mat.getParams()){


Texture2D tex = (Texture2D) para.getValue();

String name = tex.getName();

int split = name.lastIndexOf(".");

String simplename = name.substring(0,split);

AssetKey key = tex.getKey();

Field namefield = key.getClass().getField(“name”); //this was a second attempt to mofiy the key, however the key is null.

System.out.println(namefield.get(key) + " Assetkeyname");


mat.setTexture(para.getName(), tex);





However this only seems to change the Name of the texture, but not the texture itself.

When I try to load I get an error about loading the embedded texture. The name it shows points to the correct path tho.

How can I make this to actually change the Texture it uses and saves with the j3o later, without changing any other texturespecific parameter?

(like flip, repeat ect)

uh, not sure about it but the issue might be you are trying to load an embed texture as a dds but it’s not a dds, only has the name of it.

You would have to load the new texture and assign it to the material


TextureKey key=new TextureKey(simplename+“dds”);

TExture2D newTexture= assetManager.loadTexture(TextureKey);

mat.setTexture(para.getName(), newTexture);


Hm yes loadinga new texture and then copying the properties from the old one seems to work.