Hello I am trying to save a terrain block to a file in jme format using BinaryExporter. Then I want to use BinaryImporter to load it later. I am able to do that but the loaded terrain is textureless although I get no "unable to locate" errors from ResourceLocator.
Is it possible achieve what I want using BinaryExporter and BinaryImporter? If so, what possible error causes textures to be lost?
Yes, I did that. Here is my code to generate terrain and to save terrain block.
private void buildTerrain() {
MidPointHeightMap heightMap = new MidPointHeightMap(64, 1f);
// Scale the data
Vector3f terrainScale = new Vector3f(256, 0.0575f, 256);
// create a terrainblock
tb = new TerrainBlock("Terrain", heightMap.getSize(), terrainScale,
heightMap.getHeightMap(), new Vector3f(0, 0, 0));
// generate a terrain texture with 2 textures
ProceduralTextureGenerator pt = new ProceduralTextureGenerator(
heightMap);
pt.addTexture(new ImageIcon(TestTerrain.class.getClassLoader().getResource("jmetest/data/texture/grassb.png")), -128, 0, 128);
pt.addTexture(new ImageIcon(TestTerrain.class.getClassLoader().getResource("jmetest/data/texture/dirt.jpg")), 0, 128, 255);
pt.addTexture(new ImageIcon(TestTerrain.class.getClassLoader().getResource("jmetest/data/texture/highest.jpg")), 128, 255,
384);
pt.createTexture(32);
// assign the texture to the terrain
TextureState ts = display.getRenderer().createTextureState();
Texture t1 = TextureManager.loadTexture(pt.getImageIcon().getImage(),
Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear, true);
ts.setTexture(t1, 0);
//load a detail texture and set the combine modes for the two terrain textures.
Texture t2 = TextureManager.loadTexture(
TestTerrain.class.getClassLoader().getResource(
"jmetest/data/texture/Detail.jpg"),
Texture.MinificationFilter.Trilinear,
Texture.MagnificationFilter.Bilinear);