From cc27b5bcf6f1082ecf947f962f77a68336f75731 Mon Sep 17 00:00:00 2001 From: "bre..ns" Date: Thu, 18 Aug 2011 15:58:51 +0000 Subject: [PATCH] terrain editor now copies default texture to assests folder git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8037 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/gde/terraineditor/AddTerrainAction.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/AddTerrainAction.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/AddTerrainAction.java index 9a35e4975..cfd7b356a 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/AddTerrainAction.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/AddTerrainAction.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; import javax.imageio.ImageIO; import javax.swing.JComponent; +import jme3tools.converters.ImageToAwt; import org.openide.DialogDisplayer; import org.openide.WizardDescriptor; import org.openide.loaders.DataObject; @@ -138,10 +139,19 @@ public class AddTerrainAction extends AbstractNewSpatialWizardAction { mat.setTexture("AlphaMap_2", tex); } - // give the first layer default texture Texture defaultTexture = manager.loadTexture(TerrainEditorController.DEFAULT_TERRAIN_TEXTURE); - defaultTexture.setWrap(WrapMode.Repeat); - mat.setTexture("DiffuseMap", defaultTexture); + + // copy the default texture to the assets folder if it doesn't exist there yet + String dirtTextureName = "/Textures/dirt.jpg"; + File dirtTextureFile = new File(assetFolder+dirtTextureName); + if (!dirtTextureFile.exists()) { + BufferedImage bi = ImageToAwt.convert(defaultTexture.getImage(), false, true, 0); + ImageIO.write(bi, "jpg", dirtTextureFile); + } + // give the first layer default texture + Texture dirtTexture = manager.loadTexture(dirtTextureName); + dirtTexture.setWrap(WrapMode.Repeat); + mat.setTexture("DiffuseMap", dirtTexture); mat.setFloat("DiffuseMap_0_scale", TerrainEditorController.DEFAULT_TEXTURE_SCALE); mat.setBoolean("WardIso", true);