[SOLVED] jme2 – Saving and loading scene, texture

Hello, I’m currently trying to save and load my scene. Everything else seems to work fine, except for texture in texturestate which doesn’t seem to be saved or loaded? I’m sure, I must be missing something here. I haven’t been able to find a fix for this issue, so I wonder what I have missed here?



Here is the code



[java]//Save and load

try {

if(evt.getTriggerIndex() == 65) {

System.out.println(“Saving”);

BinaryExporter.getInstance().save(worldScene, new File(“world1.scene”));

} else if(evt.getTriggerIndex() == 67) {

System.out.println(“Loading”);

worldScene.detachAllChildren();

rootNode.updateGeometricState(0, false);



rootNode.updateRenderState();

Node loadedNode = (Node) BinaryImporter.getInstance().load(new File(“world1.scene”));

ArrayList<Spatial> allspat = new ArrayList<Spatial>();

allspat.addAll(loadedNode.getChildren());





for(Spatial s : allspat) {

worldScene.attachChild(s);

}





rootNode.updateGeometricState(0, false);

rootNode.updateRenderState();



}

} catch (Exception e) {

e.printStackTrace();

}[/java]

From what I remember textures are not saved completely, only the name to the file. Have a look at Texture.DEFAULT_STORE_TEXTURE which normally ist set to false… because textures are normally present in a resource package and reused, you would not want to save them out…

Well setting t.setStoreTexture(true) fixed it, Thank you…



But I guess thats not the correct way of doing it, so I will be looking into other solutions…