fixed add terrain bug, now they all use the same action

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8022 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 13 years ago
parent 54b6974778
commit 9bd9e1dc08
  1. 41
      engine/nbproject/build-impl.xml
  2. 4
      engine/nbproject/genfiles.properties
  3. 74
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/AddTerrainAction.java
  4. 12
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorController.java

@ -926,68 +926,69 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.core.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.core.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.core-data.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.core-data.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.core-plugins.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.core-plugins.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.terrain.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.terrain.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.networking.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.networking.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.desktop.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.desktop.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.desktop-fx.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.desktop-fx.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.games.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.games.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.jbullet.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.jbullet.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.niftygui.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.niftygui.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.jogg.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.jogg.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.lwjgl-oal.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.lwjgl-oal.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.lwjgl-ogl.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.lwjgl-ogl.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.ogre.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.ogre.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.blender.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.blender.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.pack.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.pack.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.jheora.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.jheora.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.test.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.test.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.tools.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.tools.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${src.xml.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.xml.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

@ -4,8 +4,8 @@ build.xml.stylesheet.CRC32=958a1d3e
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=8a1eda4b
nbproject/build-impl.xml.script.CRC32=047b53c9
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=fc0d2890
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
nbproject/profiler-build-impl.xml.data.CRC32=aff514c1
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1

@ -13,6 +13,7 @@ import com.jme3.gde.core.sceneexplorer.nodes.actions.NewSpatialAction;
import com.jme3.renderer.Camera;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.terrain.Terrain;
import com.jme3.terrain.geomipmap.TerrainLodControl;
import com.jme3.terrain.geomipmap.TerrainQuad;
import com.jme3.terrain.heightmap.AbstractHeightMap;
@ -77,7 +78,7 @@ public class AddTerrainAction extends AbstractNewSpatialWizardAction {
protected Spatial generateTerrain(Node parent, final WizardDescriptor wizardDescriptor) throws IOException {
org.openide.nodes.Node selectedNode = (org.openide.nodes.Node) wizardDescriptor.getProperty("main_node");
final Spatial spatial = selectedNode.getLookup().lookup(Spatial.class);
final ProjectAssetManager manager = selectedNode.getLookup().lookup(ProjectAssetManager.class);
String sceneName = selectedNode.getLookup().lookup(DataObject.class).getName();
@ -92,43 +93,49 @@ public class AddTerrainAction extends AbstractNewSpatialWizardAction {
heightmapData = heightmap.getHeightMap();
}
// eg. Scenes/newScene1.j3o
TerrainQuad terrain = null;
return doCreateTerrain(parent, totalSize, patchSize, alphaTextureSize, heightmapData, sceneName, selectedNode);
}
protected Spatial doCreateTerrain(Node parent,
int totalSize,
int patchSize,
int alphaTextureSize,
float[] heightmapData,
String sceneName,
org.openide.nodes.Node selectedNode) throws IOException
{
final ProjectAssetManager manager = selectedNode.getLookup().lookup(ProjectAssetManager.class);
terrain = new TerrainQuad("terrain-" + sceneName, patchSize, totalSize, heightmapData); //TODO make this pluggable for different Terrain implementations
Terrain terrain = new TerrainQuad("terrain-"+sceneName, patchSize, totalSize, heightmapData); //TODO make this pluggable for different Terrain implementations
com.jme3.material.Material mat = new com.jme3.material.Material(manager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
String assetFolder = "";
if (manager != null && manager instanceof ProjectAssetManager) {
assetFolder = ((ProjectAssetManager) manager).getAssetFolderName();
}
if (manager != null && manager instanceof ProjectAssetManager)
assetFolder = ((ProjectAssetManager)manager).getAssetFolderName();
// write out 3 alpha blend images
for (int i = 0; i < TerrainEditorController.NUM_ALPHA_TEXTURES; i++) {
for (int i=0; i<TerrainEditorController.NUM_ALPHA_TEXTURES; i++) {
BufferedImage alphaBlend = new BufferedImage(alphaTextureSize, alphaTextureSize, BufferedImage.TYPE_INT_ARGB);
if (i == 0) {
// the first alpha level should be opaque so we see the first texture over the whole terrain
for (int h = 0; h < alphaTextureSize; h++) {
for (int w = 0; w < alphaTextureSize; w++) {
for (int h=0; h<alphaTextureSize; h++)
for (int w=0; w<alphaTextureSize; w++)
alphaBlend.setRGB(w, h, 0x00FF0000);//argb
}
}
}
File alphaFolder = new File(assetFolder + "/Textures/terrain-alpha/");
if (!alphaFolder.exists()) {
File alphaFolder = new File(assetFolder+"/Textures/terrain-alpha/");
if (!alphaFolder.exists())
alphaFolder.mkdir();
}
String alphaBlendFileName = "/Textures/terrain-alpha/" + sceneName + "-" + terrain.getName() + "-alphablend" + i + ".png";
File alphaImageFile = new File(assetFolder + alphaBlendFileName);
String alphaBlendFileName = "/Textures/terrain-alpha/"+sceneName+"-"+((Node)terrain).getName()+"-alphablend"+i+".png";
File alphaImageFile = new File(assetFolder+alphaBlendFileName);
ImageIO.write(alphaBlend, "png", alphaImageFile);
Texture tex = manager.loadAsset(new TextureKey(alphaBlendFileName, false));
if (i == 0) {
if (i == 0)
mat.setTexture("AlphaMap", tex);
}
/*else if (i == 1) // add these in when they are supported
mat.setTexture("AlphaMap_1", tex);
else if (i == 1)
mat.setTexture("AlphaMap_1", tex);
else if (i == 2)
mat.setTexture("AlphaMap_2", tex);*/
mat.setTexture("AlphaMap_2", tex);
}
// give the first layer default texture
@ -138,21 +145,22 @@ public class AddTerrainAction extends AbstractNewSpatialWizardAction {
mat.setFloat("DiffuseMap_0_scale", TerrainEditorController.DEFAULT_TEXTURE_SCALE);
mat.setBoolean("WardIso", true);
terrain.setMaterial(mat);
terrain.setModelBound(new BoundingBox());
terrain.updateModelBound();
terrain.setLocalTranslation(0, 0, 0);
terrain.setLocalScale(1f, 1f, 1f);
((Node)terrain).setMaterial(mat);
((Node)terrain).setModelBound(new BoundingBox());
((Node)terrain).updateModelBound();
((Node)terrain).setLocalTranslation(0, 0, 0);
((Node)terrain).setLocalScale(4f, 1f, 4f);
// add the lod control
List<Camera> cameras = new ArrayList<Camera>();
cameras.add(SceneApplication.getApplication().getCamera());
TerrainLodControl control = new TerrainLodControl(terrain, cameras);
//terrain.addControl(control); // removing this until we figure out a way to have it get the cameras when saved/loaded
TerrainLodControl control = new TerrainLodControl(terrain, SceneApplication.getApplication().getCamera());
((Node)terrain).addControl(control);
parent.attachChild((Node)terrain);
return terrain;
//createTerrainButton.setEnabled(false); // only let the user add one terrain
//setNeedsSave(true);
//addSpatialUndo(parent, (Node)terrain, jmeNodeParent);
return (Spatial)terrain;
}
/**

@ -629,7 +629,9 @@ public class TerrainEditorController {
Terrain terrain =
SceneApplication.getApplication().enqueue(new Callable<Terrain>() {
public Terrain call() throws Exception {
return doCreateTerrain(parent, totalSize, patchSize, alphaTextureSize, heightmapData, sceneName, jmeNodeParent);
//return doCreateTerrain(parent, totalSize, patchSize, alphaTextureSize, heightmapData, sceneName, jmeNodeParent);
AddTerrainAction a = new AddTerrainAction();
return (Terrain) a.doCreateTerrain(parent, totalSize, patchSize, alphaTextureSize, heightmapData, sceneName, jmeRootNode);
}
}).get();
return terrain;
@ -638,11 +640,11 @@ public class TerrainEditorController {
} catch (ExecutionException ex) {
Exceptions.printStackTrace(ex);
}
//doCreateTerrain(totalSize, patchSize, alphaTextureSize, heightmapData, sceneName, defaultTextureScale);
return null; // if failed
}
private Terrain doCreateTerrain(Node parent,
/*private Terrain doCreateTerrain(Node parent,
int totalSize,
int patchSize,
int alphaTextureSize,
@ -677,7 +679,7 @@ public class TerrainEditorController {
Texture tex = manager.loadAsset(new TextureKey(alphaBlendFileName, false));
if (i == 0)
mat.setTexture("AlphaMap", tex);
else if (i == 1) // add these in when they are supported
else if (i == 1)
mat.setTexture("AlphaMap_1", tex);
else if (i == 2)
mat.setTexture("AlphaMap_2", tex);
@ -707,7 +709,7 @@ public class TerrainEditorController {
addSpatialUndo(parent, (Node)terrain, jmeNodeParent);
return terrain;
}
}*/
private void addSpatialUndo(final Node undoParent, final Spatial undoSpatial, final AbstractSceneExplorerNode parentNode) {
//add undo

Loading…
Cancel
Save