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. 2477
      engine/nbproject/build-impl.xml
  2. 22
      engine/nbproject/genfiles.properties
  3. 80
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/AddTerrainAction.java
  4. 12
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorController.java

File diff suppressed because it is too large Load Diff

@ -1,11 +1,11 @@
build.xml.data.CRC32=52f8cb9e
build.xml.script.CRC32=34d4c2f2
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/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
build.xml.data.CRC32=52f8cb9e
build.xml.script.CRC32=34d4c2f2
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=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;
@ -73,11 +74,11 @@ public class AddTerrainAction extends AbstractNewSpatialWizardAction {
}
return null;
}
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,45 +93,51 @@ public class AddTerrainAction extends AbstractNewSpatialWizardAction {
heightmapData = heightmap.getHeightMap();
}
// eg. Scenes/newScene1.j3o
TerrainQuad terrain = null;
terrain = new TerrainQuad("terrain-" + sceneName, patchSize, totalSize, heightmapData); //TODO make this pluggable for different Terrain implementations
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 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
Texture defaultTexture = manager.loadTexture(TerrainEditorController.DEFAULT_TERRAIN_TEXTURE);
defaultTexture.setWrap(WrapMode.Repeat);
@ -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);
return terrain;
//createTerrainButton.setEnabled(false); // only let the user add one terrain
parent.attachChild((Node)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