an only add one terrain to the scene now in jmp

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7202 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 14 years ago
parent 6c776e7bb3
commit d5c2a14602
  1. 12
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.form
  2. 48
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java

@ -13,7 +13,7 @@
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.textureFileChooser.approveButtonText_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="currentDirectory" type="java.io.File" editor="org.netbeans.beaninfo.editors.FileEditor">
<SerializedValue value="-84,-19,0,5,115,114,0,12,106,97,118,97,46,105,111,46,70,105,108,101,4,45,-92,69,14,13,-28,-1,3,0,1,76,0,4,112,97,116,104,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,120,112,116,0,16,47,65,115,115,101,116,115,47,84,101,120,116,117,114,101,115,119,2,0,47,120"/>
<SerializedValue value="-84,-19,0,5,115,114,0,12,106,97,118,97,46,105,111,46,70,105,108,101,4,45,-92,69,14,13,-28,-1,3,0,1,76,0,4,112,97,116,104,116,0,18,76,106,97,118,97,47,108,97,110,103,47,83,116,114,105,110,103,59,120,112,116,0,16,92,65,115,115,101,116,115,92,84,101,120,116,117,114,101,115,119,2,0,92,120"/>
</Property>
<Property name="dialogTitle" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.textureFileChooser.dialogTitle_1" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
@ -96,7 +96,7 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="236" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="283" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -169,7 +169,7 @@
<Component id="heightLabel" min="-2" max="-2" attributes="0"/>
<Component id="heightSlider" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="69" max="32767" attributes="0"/>
<EmptySpace pref="76" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -245,7 +245,7 @@
<Component id="remainingTexTitleLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="remainingTexturesLabel" min="-2" pref="24" max="-2" attributes="0"/>
<EmptySpace pref="153" max="32767" attributes="0"/>
<EmptySpace pref="228" max="32767" attributes="0"/>
<Component id="triPlanarCheckBox" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
@ -262,7 +262,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="removeTextureButton" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane2" pref="124" max="32767" attributes="0"/>
<Component id="jScrollPane2" pref="126" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@ -395,7 +395,7 @@
<Component id="genEntropiesButton" min="-2" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="89" max="32767" attributes="0"/>
<EmptySpace pref="99" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>

@ -39,6 +39,7 @@ import com.jme3.gde.core.scene.SceneListener;
import com.jme3.gde.core.scene.SceneRequest;
import com.jme3.gde.core.sceneexplorer.nodes.JmeNode;
import com.jme3.gde.core.sceneexplorer.nodes.JmeSpatial;
import com.jme3.gde.core.sceneexplorer.nodes.JmeTerrainQuad;
import com.jme3.gde.core.sceneexplorer.nodes.NodeUtility;
import com.jme3.gde.core.sceneexplorer.nodes.properties.TexturePropertyEditor;
import com.jme3.gde.core.util.DataObjectSaveNode;
@ -53,6 +54,9 @@ import com.jme3.texture.Texture;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeListenerProxy;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
@ -78,6 +82,9 @@ import jme3tools.converters.ImageToAwt;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.nodes.NodeEvent;
import org.openide.nodes.NodeMemberEvent;
import org.openide.nodes.NodeReorderEvent;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
@ -89,6 +96,7 @@ import org.openide.NotifyDescriptor.Confirmation;
import org.openide.WizardDescriptor;
import org.openide.cookies.SaveCookie;
import org.openide.loaders.DataObject;
import org.openide.nodes.NodeListener;
import org.openide.util.Exceptions;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup.Result;
@ -117,6 +125,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
private CreateTerrainWizardAction terrainWizard;
private SkyboxWizardAction skyboxWizard;
private JmeSpatial selectedSpat;
private TerrainNodeListener terrainDeletedNodeListener;
public enum TerrainEditButton {none, raiseTerrain, lowerTerrain, smoothTerrain, levelTerrain, paintTerrain, eraseTerrain};
@ -762,6 +771,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
refreshSelected();
createTerrainButton.setEnabled(false); // only let the user add one terrain
}
public void generateSkybox(WizardDescriptor wiz) {
@ -817,9 +827,35 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
private void selectSpatial(JmeSpatial spatial) {
selectedSpat = spatial;
if (selectedSpat instanceof JmeTerrainQuad) { //TODO shouldn't be terrainQuad, should be a generic JmeTerrain
selectedSpat.removeNodeListener(terrainDeletedNodeListener); // remove it if it exists, no way to check if it is there already
selectedSpat.addNodeListener(terrainDeletedNodeListener); // add it back
}
}
/**
* When the terrain is deleted, enable the 'add terrain' button again
* and reinitialize the texture table
*/
private class TerrainNodeListener implements NodeListener {
public void childrenAdded(NodeMemberEvent nme) {
}
public void childrenRemoved(NodeMemberEvent nme) {
}
public void childrenReordered(NodeReorderEvent nre) {
}
public void nodeDestroyed(NodeEvent ne) {
createTerrainButton.setEnabled(true);
reinitTextureTable();
}
public void propertyChange(PropertyChangeEvent evt) {
}
}
/*
*
@ -923,6 +959,8 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
request.setWindowTitle("TerrainEditor - " + manager.getRelativeAssetPath(file.getPrimaryFile().getPath()));
request.setToolNode(new Node("TerrainEditorToolNode"));
SceneApplication.getApplication().requestScene(request);
terrainDeletedNodeListener = new TerrainNodeListener();
}
// run on GL thread
@ -955,8 +993,8 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
toolController.cleanup();
}
for (int i=0; i<textureTable.getModel().getRowCount(); i++)
((TextureTableModel)textureTable.getModel()).removeRow(i);
//for (int i=0; i<textureTable.getModel().getRowCount(); i++)
// ((TextureTableModel)textureTable.getModel()).removeRow(i);
toolController = new TerrainToolController(currentRequest.getToolNode(), currentRequest.getManager().getManager(), request.getJmeNode());
camController = new TerrainCameraController(SceneApplication.getApplication().getCamera());
@ -974,6 +1012,8 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
reinitTextureTable(); // update the UI
if (editorController.getTerrain(null) != null)
createTerrainButton.setEnabled(false); // only let the user add one terrain
}
});
//editorController.getAlphaSaveDataObject(this);
@ -1088,6 +1128,10 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
textureTable.getColumnModel().getColumn(2).setCellRenderer(rendererNormal); // normal
textureTable.getColumnModel().getColumn(2).setCellEditor(rendererNormal);
// empty out the table
for (int i=0; i<textureTable.getModel().getRowCount(); i++)
((TextureTableModel)textureTable.getModel()).removeRow(i);
if (editorController.getTerrain(null) == null)
return;

Loading…
Cancel
Save