From 694b61cf58e2b4689ab082981eb601051163acb3 Mon Sep 17 00:00:00 2001 From: "bre..ns" Date: Tue, 6 Mar 2012 18:53:03 +0000 Subject: [PATCH] improved terrain editor wizard git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9235 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../gde/terraineditor/AddTerrainAction.java | 3 + .../jme3/gde/terraineditor/Bundle.properties | 4 + .../CreateTerrainVisualPanel2.form | 239 +++++++++++------ .../CreateTerrainVisualPanel2.java | 247 ++++++++++++------ .../CreateTerrainWizardPanel2.java | 24 +- .../TerrainEditorTopComponent.form | 5 +- .../TerrainEditorTopComponent.java | 5 +- sdk/nbproject/build-impl.xml | 5 +- sdk/nbproject/genfiles.properties | 7 +- 9 files changed, 360 insertions(+), 179 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 5d3504ff6..27c85fdf8 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 @@ -91,6 +91,9 @@ public class AddTerrainAction extends AbstractNewSpatialWizardAction { heightmap = (AbstractHeightMap) wizardDescriptor.getProperty("abstractHeightMap"); if (heightmap != null) { heightmap.load(); // can take a while + Float smooth = (Float) wizardDescriptor.getProperty("heightMapSmooth"); + if (smooth > 0) + heightmap.smooth(smooth, 2); heightmapData = heightmap.getHeightMap(); } diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/Bundle.properties b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/Bundle.properties index 87ca6b029..8ecab7707 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/Bundle.properties +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/Bundle.properties @@ -115,3 +115,7 @@ TerrainEditorTopComponent.scaleField.text=0.1 TerrainEditorTopComponent.jLabel3.toolTipText=How steep the slopes are. Lower is steeper (must be greater than 1.0) TerrainEditorTopComponent.jLabel4.toolTipText=Hill area in terms of octaves. Larger is smaller hill, values of 8 or lower are wide hills. TerrainEditorTopComponent.scaleLabel.toolTipText=How close together the bumps are. Larger is closer. +CreateTerrainVisualPanel2.smoothIterationsLabel.text=Rough +CreateTerrainVisualPanel2.jLabel6.text=Smooth +CreateTerrainVisualPanel2.jLabel7.text=Height Scale: +CreateTerrainVisualPanel2.heightScale.text=1 diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainVisualPanel2.form b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainVisualPanel2.form index be1ffb743..8837c9a1c 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainVisualPanel2.form +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainVisualPanel2.form @@ -34,7 +34,10 @@ - + + + + @@ -50,16 +53,20 @@ - - - - - - - - + + + + + + + + - + + + + + @@ -73,12 +80,10 @@ - - + + - - - + @@ -116,7 +121,7 @@ - + @@ -145,17 +150,45 @@ - - + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + - - + @@ -169,7 +202,20 @@ - + + + + + + + + + + + + + + @@ -184,6 +230,7 @@ + @@ -199,6 +246,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -209,34 +291,39 @@ - - - - - - - - + + + - - - + + + + + + + + + + + + + - + + + + + + + + + + + - - - - - - - - - - @@ -259,7 +346,9 @@ - + + + @@ -328,38 +417,38 @@ - - - + - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainVisualPanel2.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainVisualPanel2.java index 583ec1d4c..f11e23eb6 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainVisualPanel2.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainVisualPanel2.java @@ -4,9 +4,9 @@ */ package com.jme3.gde.terraineditor; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; +import com.jme3.gde.core.properties.TexturePropertyEditor; +import com.jme3.texture.Texture; +import java.awt.Component; import javax.swing.JComboBox; import javax.swing.JPanel; import javax.swing.JTextField; @@ -14,7 +14,8 @@ import javax.swing.JTextField; public final class CreateTerrainVisualPanel2 extends JPanel { //String[] types = {"Flat", "Image Based", "Hill", "Fault Fractal"}; - + private Texture browsedTexture; + private CreateTerrainWizardPanel2 wizardPanel; /** Creates new form CreateTerrainVisualPanel2 */ public CreateTerrainVisualPanel2() { @@ -50,6 +51,11 @@ public final class CreateTerrainVisualPanel2 extends JPanel { _imageDescriptionLabel = new javax.swing.JLabel(); _imageBrowseTextField = new javax.swing.JTextField(); _imageBrowseButton = new javax.swing.JButton(); + smoothIterationsLabel = new javax.swing.JLabel(); + smoothSlider = new javax.swing.JSlider(); + jLabel6 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + heightScale = new javax.swing.JTextField(); _hillPanel = new javax.swing.JPanel(); _hillDescriptionLabel = new javax.swing.JLabel(); _hillIterationsTextField = new javax.swing.JTextField(); @@ -65,7 +71,7 @@ public final class CreateTerrainVisualPanel2 extends JPanel { imageFileChooser.setApproveButtonText(org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2.imageFileChooser.approveButtonText")); // NOI18N imageFileChooser.setApproveButtonToolTipText(org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2.imageFileChooser.approveButtonToolTipText")); // NOI18N - imageFileChooser.setCurrentDirectory(new java.io.File("C:\\Java\\NetBeans 6.9.1")); + imageFileChooser.setCurrentDirectory(new java.io.File("C:\\Program Files\\NetBeans 7.0")); imageFileChooser.setDialogTitle(org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2.imageFileChooser.dialogTitle")); // NOI18N jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); @@ -87,7 +93,7 @@ public final class CreateTerrainVisualPanel2 extends JPanel { .addGroup(_flatPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(_flatDescriptionLabel) - .addContainerGap(267, Short.MAX_VALUE)) + .addContainerGap(269, Short.MAX_VALUE)) ); _flatPanelLayout.setVerticalGroup( _flatPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -99,6 +105,7 @@ public final class CreateTerrainVisualPanel2 extends JPanel { org.openide.awt.Mnemonics.setLocalizedText(_imageDescriptionLabel, org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2._imageDescriptionLabel.text")); // NOI18N + _imageBrowseTextField.setEditable(false); _imageBrowseTextField.setText(org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2._imageBrowseTextField.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(_imageBrowseButton, org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2._imageBrowseButton.text")); // NOI18N @@ -108,19 +115,50 @@ public final class CreateTerrainVisualPanel2 extends JPanel { } }); + org.openide.awt.Mnemonics.setLocalizedText(smoothIterationsLabel, org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2.smoothIterationsLabel.text")); // NOI18N + + smoothSlider.setMinorTickSpacing(10); + smoothSlider.setPaintLabels(true); + smoothSlider.setPaintTicks(true); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel6, org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2.jLabel6.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel7, org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2.jLabel7.text")); // NOI18N + + heightScale.setText(org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2.heightScale.text")); // NOI18N + javax.swing.GroupLayout _imagePanelLayout = new javax.swing.GroupLayout(_imagePanel); _imagePanel.setLayout(_imagePanelLayout); _imagePanelLayout.setHorizontalGroup( _imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(_imagePanelLayout.createSequentialGroup() - .addContainerGap() .addGroup(_imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(_imagePanelLayout.createSequentialGroup() - .addComponent(_imageBrowseTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(_imageBrowseButton)) - .addComponent(_imageDescriptionLabel)) - .addContainerGap(99, Short.MAX_VALUE)) + .addContainerGap() + .addGroup(_imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(_imageDescriptionLabel) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, _imagePanelLayout.createSequentialGroup() + .addComponent(_imageBrowseTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(6, 6, 6) + .addComponent(_imageBrowseButton) + .addGap(606, 606, 606)))) + .addGroup(_imagePanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(_imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(_imagePanelLayout.createSequentialGroup() + .addComponent(jLabel7) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(heightScale, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(_imagePanelLayout.createSequentialGroup() + .addComponent(smoothIterationsLabel) + .addGroup(_imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(_imagePanelLayout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(smoothSlider, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(_imagePanelLayout.createSequentialGroup() + .addGap(119, 119, 119) + .addComponent(jLabel6))))))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); _imagePanelLayout.setVerticalGroup( _imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -131,7 +169,17 @@ public final class CreateTerrainVisualPanel2 extends JPanel { .addGroup(_imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(_imageBrowseTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(_imageBrowseButton)) - .addContainerGap(44, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(_imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(smoothSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(_imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(smoothIterationsLabel) + .addComponent(jLabel6))) + .addGap(35, 35, 35) + .addGroup(_imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel7) + .addComponent(heightScale, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(64, 64, 64)) ); org.openide.awt.Mnemonics.setLocalizedText(_hillDescriptionLabel, org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2._hillDescriptionLabel.text")); // NOI18N @@ -152,6 +200,25 @@ public final class CreateTerrainVisualPanel2 extends JPanel { _hillMaxRadiusTextField.setText(org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2._hillMaxRadiusTextField.text")); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(_faultDescriptionLabel, org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2._faultDescriptionLabel.text")); // NOI18N + + javax.swing.GroupLayout _faultPanelLayout = new javax.swing.GroupLayout(_faultPanel); + _faultPanel.setLayout(_faultPanelLayout); + _faultPanelLayout.setHorizontalGroup( + _faultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(_faultPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(_faultDescriptionLabel) + .addContainerGap(64, Short.MAX_VALUE)) + ); + _faultPanelLayout.setVerticalGroup( + _faultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(_faultPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(_faultDescriptionLabel) + .addContainerGap(75, Short.MAX_VALUE)) + ); + javax.swing.GroupLayout _hillPanelLayout = new javax.swing.GroupLayout(_hillPanel); _hillPanel.setLayout(_hillPanelLayout); _hillPanelLayout.setHorizontalGroup( @@ -159,27 +226,30 @@ public final class CreateTerrainVisualPanel2 extends JPanel { .addGroup(_hillPanelLayout.createSequentialGroup() .addContainerGap() .addGroup(_hillPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(_hillDescriptionLabel, javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, _hillPanelLayout.createSequentialGroup() - .addGroup(_hillPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, _hillPanelLayout.createSequentialGroup() - .addComponent(jLabel5) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(_hillFlatteningTextField)) - .addGroup(_hillPanelLayout.createSequentialGroup() - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(_hillIterationsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addGap(70, 70, 70))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(_hillPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(jLabel3) - .addComponent(jLabel4)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addGroup(_hillPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(_hillMinRadiusTextField) - .addComponent(_hillMaxRadiusTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE)) - .addContainerGap(23, Short.MAX_VALUE)) + .addGroup(_hillPanelLayout.createSequentialGroup() + .addGroup(_hillPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(_hillDescriptionLabel, javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, _hillPanelLayout.createSequentialGroup() + .addGroup(_hillPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, _hillPanelLayout.createSequentialGroup() + .addComponent(jLabel5) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(_hillFlatteningTextField)) + .addGroup(_hillPanelLayout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(_hillIterationsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(70, 70, 70))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(_hillPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel3) + .addComponent(jLabel4)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(_hillPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(_hillMinRadiusTextField) + .addComponent(_hillMaxRadiusTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE))) + .addComponent(_faultPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) ); _hillPanelLayout.setVerticalGroup( _hillPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -198,26 +268,9 @@ public final class CreateTerrainVisualPanel2 extends JPanel { .addComponent(_hillFlatteningTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4) .addComponent(_hillMaxRadiusTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(31, Short.MAX_VALUE)) - ); - - org.openide.awt.Mnemonics.setLocalizedText(_faultDescriptionLabel, org.openide.util.NbBundle.getMessage(CreateTerrainVisualPanel2.class, "CreateTerrainVisualPanel2._faultDescriptionLabel.text")); // NOI18N - - javax.swing.GroupLayout _faultPanelLayout = new javax.swing.GroupLayout(_faultPanel); - _faultPanel.setLayout(_faultPanelLayout); - _faultPanelLayout.setHorizontalGroup( - _faultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(_faultPanelLayout.createSequentialGroup() - .addContainerGap() - .addComponent(_faultDescriptionLabel) - .addContainerGap(37, Short.MAX_VALUE)) - ); - _faultPanelLayout.setVerticalGroup( - _faultPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(_faultPanelLayout.createSequentialGroup() - .addContainerGap() - .addComponent(_faultDescriptionLabel) - .addContainerGap(75, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(_faultPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); @@ -225,15 +278,17 @@ public final class CreateTerrainVisualPanel2 extends JPanel { jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() - .addGap(30, 30, 30) - .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(jLabel1) - .addComponent(_hillPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(_imagePanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(_flatPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(heightmapTypeComboBox, 0, 428, Short.MAX_VALUE) - .addComponent(_faultPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(_imagePanel, javax.swing.GroupLayout.Alignment.LEADING, 0, 455, Short.MAX_VALUE) + .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel1) + .addComponent(_flatPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(heightmapTypeComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGap(34, 34, 34)) + .addGroup(jPanel2Layout.createSequentialGroup() + .addComponent(_hillPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(24, 24, 24)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -245,19 +300,19 @@ public final class CreateTerrainVisualPanel2 extends JPanel { .addGap(18, 18, 18) .addComponent(_flatPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(_imagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(_imagePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(_hillPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) - .addComponent(_faultPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(27, Short.MAX_VALUE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -265,20 +320,21 @@ public final class CreateTerrainVisualPanel2 extends JPanel { ); }// //GEN-END:initComponents - + protected void setWizardPanel(CreateTerrainWizardPanel2 wizardPanel) { + this.wizardPanel = wizardPanel; + } + private void openFileActionPerformed(java.awt.event.ActionEvent evt) { - int returnVal = imageFileChooser.showOpenDialog(this); - if (returnVal == imageFileChooser.APPROVE_OPTION) { - File file = imageFileChooser.getSelectedFile(); - //try { - // What to do with the file, e.g. display it in a TextArea - _imageBrowseTextField.setText( file.getAbsolutePath() ); - //} catch (IOException ex) { - // System.out.println("problem accessing file"+file.getAbsolutePath()); - //} - } else { - System.out.println("File access cancelled by user."); - } + TexturePropertyEditor editor = new TexturePropertyEditor(); + Component view = editor.getCustomEditor(); + view.setVisible(true); + Texture tex = (Texture) editor.getValue(); + browsedTexture = tex; + if (tex != null) + _imageBrowseTextField.setText(tex.getName()); + else + _imageBrowseTextField.setText("..."); + wizardPanel.fireChangeEvent(); } private void heightmapTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_heightmapTypeComboBoxActionPerformed @@ -306,7 +362,7 @@ public final class CreateTerrainVisualPanel2 extends JPanel { _hillPanel.setVisible(false); _faultPanel.setVisible(true); } - + wizardPanel.fireChangeEvent(); this.validate(); }//GEN-LAST:event_heightmapTypeComboBoxActionPerformed @@ -329,6 +385,7 @@ public final class CreateTerrainVisualPanel2 extends JPanel { private javax.swing.JTextField _imageBrowseTextField; private javax.swing.JLabel _imageDescriptionLabel; private javax.swing.JPanel _imagePanel; + private javax.swing.JTextField heightScale; private javax.swing.JComboBox heightmapTypeComboBox; private javax.swing.JFileChooser imageFileChooser; private javax.swing.JLabel jLabel1; @@ -336,7 +393,11 @@ public final class CreateTerrainVisualPanel2 extends JPanel { private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; private javax.swing.JPanel jPanel2; + private javax.swing.JLabel smoothIterationsLabel; + private javax.swing.JSlider smoothSlider; // End of variables declaration//GEN-END:variables public JComboBox getHeightmapTypeComboBox() { @@ -359,9 +420,25 @@ public final class CreateTerrainVisualPanel2 extends JPanel { return _hillMinRadiusTextField; } - public JTextField getImageBrowseTextField() { - return _imageBrowseTextField; + public Texture getImageBrowseTexture() { + return browsedTexture; } + public float getSmoothEffect() { + float smooth = smoothSlider.getValue()/100f; + if (smooth > 1.0f) + smooth = 1.0f; + if (smooth < 0) + smooth = 0; + return smooth; + } + public float getHeightScale() { + try { + Float scale = new Float(heightScale.getText()); + return Math.abs(scale); + } catch (NumberFormatException e) { + return 1; + } + } } diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainWizardPanel2.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainWizardPanel2.java index ce0fed86c..8441c99d2 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainWizardPanel2.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/CreateTerrainWizardPanel2.java @@ -31,9 +31,6 @@ */ package com.jme3.gde.terraineditor; -import com.jme3.asset.AssetManager; -import com.jme3.asset.TextureKey; -import com.jme3.gde.core.scene.SceneApplication; import com.jme3.terrain.heightmap.AbstractHeightMap; import com.jme3.terrain.heightmap.HillHeightMap; import com.jme3.terrain.heightmap.ImageBasedHeightMap; @@ -66,6 +63,7 @@ public class CreateTerrainWizardPanel2 implements WizardDescriptor.Panel { public Component getComponent() { if (component == null) { component = new CreateTerrainVisualPanel2(); + ((CreateTerrainVisualPanel2)component).setWizardPanel(this); } return component; } @@ -82,7 +80,7 @@ public class CreateTerrainWizardPanel2 implements WizardDescriptor.Panel { CreateTerrainVisualPanel2 comp = (CreateTerrainVisualPanel2) getComponent(); if ("Image Based".equals(comp.getHeightmapTypeComboBox().getSelectedItem())) { - //new File(comp.getImageBrowseTextField().getText()) + return comp.getImageBrowseTexture() != null; } return true; @@ -104,6 +102,7 @@ public class CreateTerrainWizardPanel2 implements WizardDescriptor.Panel { synchronized (listeners) { listeners.add(l); } + System.out.println("############ Wizard panel listener added: "+l.toString()); } public final void removeChangeListener(ChangeListener l) { synchronized (listeners) { @@ -135,13 +134,21 @@ public class CreateTerrainWizardPanel2 implements WizardDescriptor.Panel { CreateTerrainVisualPanel2 comp = (CreateTerrainVisualPanel2) getComponent(); + WizardDescriptor wiz = (WizardDescriptor) settings; + wiz.putProperty("abstractHeightMap", heightmap); + wiz.putProperty("heightMapSmooth", 0f); + if ("Flat".equals(comp.getHeightmapTypeComboBox().getSelectedItem()) ) { heightmap = new FlatHeightmap(terrainTotalSize); } else if ("Image Based".equals(comp.getHeightmapTypeComboBox().getSelectedItem()) ) { - AssetManager assetManager = SceneApplication.getApplication().getAssetManager(); - Texture tex = assetManager.loadTexture(new TextureKey(comp.getImageBrowseTextField().getText())); - heightmap = new ImageBasedHeightMap(tex.getImage()); + Texture tex = comp.getImageBrowseTexture(); + float heightScale = comp.getHeightScale(); + if (tex != null) { + heightmap = new ImageBasedHeightMap(tex.getImage(), heightScale); + Float smooth = comp.getSmoothEffect(); + wiz.putProperty("heightMapSmooth", smooth); + } } else if ("Hill".equals(comp.getHeightmapTypeComboBox().getSelectedItem()) ) { int iterations = new Integer(comp.getHillIterationsTextField().getText()); @@ -155,7 +162,6 @@ public class CreateTerrainWizardPanel2 implements WizardDescriptor.Panel { } } - WizardDescriptor wiz = (WizardDescriptor) settings; - wiz.putProperty("abstractHeightMap", heightmap); + } } diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.form b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.form index c209e4416..6d64a8499 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.form +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.form @@ -306,9 +306,8 @@ - - - + + diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java index 194fe2807..f4caa4b76 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java @@ -412,9 +412,8 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce org.openide.awt.Mnemonics.setLocalizedText(radiusLabel, org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.radiusLabel.text")); // NOI18N jToolBar1.add(radiusLabel); - radiusSlider.setMajorTickSpacing(5); - radiusSlider.setMaximum(20); - radiusSlider.setMinorTickSpacing(1); + radiusSlider.setMajorTickSpacing(10); + radiusSlider.setMinorTickSpacing(5); radiusSlider.setPaintTicks(true); radiusSlider.setSnapToTicks(true); radiusSlider.setToolTipText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.radiusSlider.toolTipText")); // NOI18N diff --git a/sdk/nbproject/build-impl.xml b/sdk/nbproject/build-impl.xml index cde5d02a8..01fefe84f 100644 --- a/sdk/nbproject/build-impl.xml +++ b/sdk/nbproject/build-impl.xml @@ -38,10 +38,11 @@ - + + - + diff --git a/sdk/nbproject/genfiles.properties b/sdk/nbproject/genfiles.properties index 7c5821921..161b11dc8 100644 --- a/sdk/nbproject/genfiles.properties +++ b/sdk/nbproject/genfiles.properties @@ -4,5 +4,8 @@ build.xml.stylesheet.CRC32=531c622b@1.31.1.7 # 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=cbef27ca -nbproject/build-impl.xml.script.CRC32=ce1d717c -nbproject/build-impl.xml.stylesheet.CRC32=183e6ef3@1.42.2 +nbproject/build-impl.xml.script.CRC32=6de91798 +nbproject/build-impl.xml.stylesheet.CRC32=0f381476@2.47.1 +nbproject/platform.xml.data.CRC32=cbef27ca +nbproject/platform.xml.script.CRC32=db9e1f43 +nbproject/platform.xml.stylesheet.CRC32=df8ac4dd@2.47.1