terrain editor now copies default texture to assests folder

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8037 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 13 years ago
parent ab26912f60
commit cc27b5bcf6
  1. 16
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/AddTerrainAction.java

@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.JComponent; import javax.swing.JComponent;
import jme3tools.converters.ImageToAwt;
import org.openide.DialogDisplayer; import org.openide.DialogDisplayer;
import org.openide.WizardDescriptor; import org.openide.WizardDescriptor;
import org.openide.loaders.DataObject; import org.openide.loaders.DataObject;
@ -138,10 +139,19 @@ public class AddTerrainAction extends AbstractNewSpatialWizardAction {
mat.setTexture("AlphaMap_2", tex); mat.setTexture("AlphaMap_2", tex);
} }
// give the first layer default texture
Texture defaultTexture = manager.loadTexture(TerrainEditorController.DEFAULT_TERRAIN_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.setFloat("DiffuseMap_0_scale", TerrainEditorController.DEFAULT_TEXTURE_SCALE);
mat.setBoolean("WardIso", true); mat.setBoolean("WardIso", true);

Loading…
Cancel
Save