Texture not being saved when using BinaryExporter

Hey everyone,

my issue is pretty simple.
I try to save a scene with the BinaryExporter, which works.
However, when I load it again next time, it doesn’t have the right textures.

I figured the flaw lies in this line:
[java]
mat = assetManager.loadMaterial(“Materials/exampleMat.j3m”);
mat.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/exampleTex.png”));
[/java]

Whenever I apply custom textures during runtime, they do not get saved with the scene.
When I load the scene, the default texture of exampleMat.j3m is loaded, not exampleTex.png…

Do I have to create a different material file for every texture I wanna use or is there a simple way to save the texture as well?

Textures which are part of materials applied to the scene graph should be automatically saved when you save the scene graph.

A couple questions:

Is your material ever applied to a spatial in the scene graph?
Are you saving the entire scene graph or just a subtree?

If you load a texture from blah/foo/bar/texture.jpg and then apply it to the model, then save the model as a j3o the texture has to be in the exact same place when you load the j3o again.

@sgold said: Textures which are part of materials applied to the scene graph should be automatically saved when you save the scene graph.

A couple questions:

Is your material ever applied to a spatial in the scene graph?
Are you saving the entire scene graph or just a subtree?

Yep, it’s applied to the scene graph. Thats how I know it’s missing :smiley:

@normen said: If you load a texture from blah/foo/bar/texture.jpg and then apply it to the model, then save the model as a j3o the texture has to be in the exact same place when you load the j3o again.

Well… I don’t move or rename the texture or anything.

If the path of the texture is saved with every spatial I apply it to, shouldn’t I be able to see it in the Properties view?
Because I see that the material is saved, but I don’t see the path of the texture.

In the depicted case you would set the texture via the j3m file, it overrides any soft changes to the material when the j3o is loaded.

Hm, ok.

So what would work if I want to set the texture during runtime and save it?
Do I need to create the material during runtime as well?

Btw, happy new year everyone! =D

use a material definition instead of a material for this.

also new year :slight_smile:

1 Like
@m41q said: Hm, ok.

So what would work if I want to set the texture during runtime and save it?
Do I need to create the material during runtime as well?

Btw, happy new year everyone! =D

Just remove the j3m file.

1 Like
@Empire Phoenix said: use a material definition instead of a material for this.

also new year :slight_smile:

thanks! it works now.