diff --git a/sdk/jme3-core-baselibs/nbproject/genfiles.properties b/sdk/jme3-core-baselibs/nbproject/genfiles.properties index 47567115a..ea71377a2 100644 --- a/sdk/jme3-core-baselibs/nbproject/genfiles.properties +++ b/sdk/jme3-core-baselibs/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=05d5b002 -build.xml.script.CRC32=cdae6a36 -build.xml.stylesheet.CRC32=a56c6a5b@1.46.2 -# 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=05d5b002 -nbproject/build-impl.xml.script.CRC32=246f9b81 -nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.2 +build.xml.data.CRC32=06721bf2 +build.xml.script.CRC32=cdae6a36 +build.xml.stylesheet.CRC32=a56c6a5b@1.46.2 +# 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=06721bf2 +nbproject/build-impl.xml.script.CRC32=246f9b81 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.2 diff --git a/sdk/jme3-core-baselibs/nbproject/project.xml b/sdk/jme3-core-baselibs/nbproject/project.xml index 3b10162fd..0c5d3b80c 100644 --- a/sdk/jme3-core-baselibs/nbproject/project.xml +++ b/sdk/jme3-core-baselibs/nbproject/project.xml @@ -1,171 +1,175 @@ - - - org.netbeans.modules.apisupport.project - - - com.jme3.gde.core.baselibs - - - - com.jme3.gde.core.libraries - - - - 1 - 3.0.0 - - - - - checkers.quals - com.jme3.animation - com.jme3.app - com.jme3.app.state - com.jme3.asset - com.jme3.asset.plugins - com.jme3.audio - com.jme3.audio.lwjgl - com.jme3.audio.plugins - com.jme3.bounding - com.jme3.bullet - com.jme3.bullet.collision - com.jme3.bullet.collision.shapes - com.jme3.bullet.collision.shapes.infos - com.jme3.bullet.control - com.jme3.bullet.control.ragdoll - com.jme3.bullet.joints - com.jme3.bullet.joints.motors - com.jme3.bullet.objects - com.jme3.bullet.objects.infos - com.jme3.bullet.util - com.jme3.cinematic - com.jme3.cinematic.events - com.jme3.collision - com.jme3.collision.bih - com.jme3.effect - com.jme3.effect.influencers - com.jme3.effect.shapes - com.jme3.export - com.jme3.export.binary - com.jme3.export.xml - com.jme3.font - com.jme3.font.plugins - com.jme3.input - com.jme3.input.awt - com.jme3.input.controls - com.jme3.input.dummy - com.jme3.input.event - com.jme3.input.lwjgl - com.jme3.light - com.jme3.material - com.jme3.material.plugins - com.jme3.math - com.jme3.network - com.jme3.network.base - com.jme3.network.kernel - com.jme3.network.kernel.tcp - com.jme3.network.kernel.udp - com.jme3.network.message - com.jme3.network.rmi - com.jme3.network.serializing - com.jme3.network.serializing.serializers - com.jme3.niftygui - com.jme3.post - com.jme3.post.filters - com.jme3.post.ssao - com.jme3.renderer - com.jme3.renderer.lwjgl - com.jme3.renderer.queue - com.jme3.scene - com.jme3.scene.control - com.jme3.scene.debug - com.jme3.scene.mesh - com.jme3.scene.plugins - com.jme3.scene.plugins.blender - com.jme3.scene.plugins.blender.animations - com.jme3.scene.plugins.blender.cameras - com.jme3.scene.plugins.blender.constraints - com.jme3.scene.plugins.blender.curves - com.jme3.scene.plugins.blender.exceptions - com.jme3.scene.plugins.blender.file - com.jme3.scene.plugins.blender.lights - com.jme3.scene.plugins.blender.materials - com.jme3.scene.plugins.blender.meshes - com.jme3.scene.plugins.blender.modifiers - com.jme3.scene.plugins.blender.objects - com.jme3.scene.plugins.blender.particles - com.jme3.scene.plugins.blender.textures - com.jme3.scene.plugins.ogre - com.jme3.scene.plugins.ogre.matext - com.jme3.scene.shape - com.jme3.shader - com.jme3.shader.plugins - com.jme3.shadow - com.jme3.system - com.jme3.system.awt - com.jme3.system.lwjgl - com.jme3.terrain - com.jme3.terrain.geomipmap - com.jme3.terrain.geomipmap.grid - com.jme3.terrain.geomipmap.lodcalc - com.jme3.terrain.geomipmap.lodcalc.util - com.jme3.terrain.geomipmap.picking - com.jme3.terrain.heightmap - com.jme3.texture - com.jme3.texture.plugins - com.jme3.ui - com.jme3.util - com.jme3.util.blockparser - com.jme3.util.xml - com.jme3.water - jme3tools.converters - jme3tools.converters.model - jme3tools.converters.model.strip - jme3tools.navigation - jme3tools.nvtex - jme3tools.optimize - jme3tools.savegame - - - ext/jME3-niftygui.jar - release/modules/ext/jME3-niftygui.jar - - - ext/jME3-blender.jar - release/modules/ext/jME3-blender.jar - - - ext/jME3-desktop.jar - release/modules/ext/jME3-desktop.jar - - - ext/jME3-lwjgl.jar - release/modules/ext/jME3-lwjgl.jar - - - ext/jME3-terrain.jar - release/modules/ext/jME3-terrain.jar - - - ext/jME3-jbullet.jar - release/modules/ext/jME3-jbullet.jar - - - ext/jME3-plugins.jar - release/modules/ext/jME3-plugins.jar - - - ext/jME3-core.jar - release/modules/ext/jME3-core.jar - - - ext/jME3-lwjgl-natives.jar - release/modules/ext/jME3-lwjgl-natives.jar - - - ext/jME3-jogg.jar - release/modules/ext/jME3-jogg.jar - - - - + + + org.netbeans.modules.apisupport.project + + + com.jme3.gde.core.baselibs + + + + com.jme3.gde.core.libraries + + + + 1 + 3.0.0 + + + + + checkers.quals + com.jme3.animation + com.jme3.app + com.jme3.app.state + com.jme3.asset + com.jme3.asset.plugins + com.jme3.audio + com.jme3.audio.lwjgl + com.jme3.audio.plugins + com.jme3.bounding + com.jme3.bullet + com.jme3.bullet.collision + com.jme3.bullet.collision.shapes + com.jme3.bullet.collision.shapes.infos + com.jme3.bullet.control + com.jme3.bullet.control.ragdoll + com.jme3.bullet.joints + com.jme3.bullet.joints.motors + com.jme3.bullet.objects + com.jme3.bullet.objects.infos + com.jme3.bullet.util + com.jme3.cinematic + com.jme3.cinematic.events + com.jme3.collision + com.jme3.collision.bih + com.jme3.effect + com.jme3.effect.influencers + com.jme3.effect.shapes + com.jme3.export + com.jme3.export.binary + com.jme3.export.xml + com.jme3.font + com.jme3.font.plugins + com.jme3.input + com.jme3.input.awt + com.jme3.input.controls + com.jme3.input.dummy + com.jme3.input.event + com.jme3.input.lwjgl + com.jme3.light + com.jme3.material + com.jme3.material.plugins + com.jme3.math + com.jme3.network + com.jme3.network.base + com.jme3.network.kernel + com.jme3.network.kernel.tcp + com.jme3.network.kernel.udp + com.jme3.network.message + com.jme3.network.rmi + com.jme3.network.serializing + com.jme3.network.serializing.serializers + com.jme3.niftygui + com.jme3.post + com.jme3.post.filters + com.jme3.post.ssao + com.jme3.renderer + com.jme3.renderer.lwjgl + com.jme3.renderer.queue + com.jme3.scene + com.jme3.scene.control + com.jme3.scene.debug + com.jme3.scene.mesh + com.jme3.scene.plugins + com.jme3.scene.plugins.blender + com.jme3.scene.plugins.blender.animations + com.jme3.scene.plugins.blender.cameras + com.jme3.scene.plugins.blender.constraints + com.jme3.scene.plugins.blender.curves + com.jme3.scene.plugins.blender.exceptions + com.jme3.scene.plugins.blender.file + com.jme3.scene.plugins.blender.lights + com.jme3.scene.plugins.blender.materials + com.jme3.scene.plugins.blender.meshes + com.jme3.scene.plugins.blender.modifiers + com.jme3.scene.plugins.blender.objects + com.jme3.scene.plugins.blender.particles + com.jme3.scene.plugins.blender.textures + com.jme3.scene.plugins.ogre + com.jme3.scene.plugins.ogre.matext + com.jme3.scene.shape + com.jme3.shader + com.jme3.shader.plugins + com.jme3.shadow + com.jme3.system + com.jme3.system.awt + com.jme3.system.lwjgl + com.jme3.terrain + com.jme3.terrain.geomipmap + com.jme3.terrain.geomipmap.grid + com.jme3.terrain.geomipmap.lodcalc + com.jme3.terrain.geomipmap.lodcalc.util + com.jme3.terrain.geomipmap.picking + com.jme3.terrain.heightmap + com.jme3.terrain.noise + com.jme3.terrain.noise.basis + com.jme3.terrain.noise.filter + com.jme3.terrain.noise.fractal + com.jme3.terrain.noise.modulator + com.jme3.texture + com.jme3.texture.plugins + com.jme3.ui + com.jme3.util + com.jme3.util.blockparser + com.jme3.util.xml + com.jme3.water + jme3tools.converters + jme3tools.converters.model + jme3tools.converters.model.strip + jme3tools.navigation + jme3tools.optimize + jme3tools.savegame + + + ext/jME3-niftygui.jar + release/modules/ext/jME3-niftygui.jar + + + ext/jME3-blender.jar + release/modules/ext/jME3-blender.jar + + + ext/jME3-desktop.jar + release/modules/ext/jME3-desktop.jar + + + ext/jME3-lwjgl.jar + release/modules/ext/jME3-lwjgl.jar + + + ext/jME3-terrain.jar + release/modules/ext/jME3-terrain.jar + + + ext/jME3-jbullet.jar + release/modules/ext/jME3-jbullet.jar + + + ext/jME3-plugins.jar + release/modules/ext/jME3-plugins.jar + + + ext/jME3-core.jar + release/modules/ext/jME3-core.jar + + + ext/jME3-lwjgl-natives.jar + release/modules/ext/jME3-lwjgl-natives.jar + + + ext/jME3-jogg.jar + release/modules/ext/jME3-jogg.jar + + + + 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 e6a6ec690..262fab164 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 @@ -108,5 +108,14 @@ TerrainEditorTopComponent.toolHint.level=Right click to set desired height value TerrainEditorTopComponent.jPanel2.border.title=Material TerrainEditorTopComponent.jLabel1.text=Shininess TerrainEditorTopComponent.wardIsoCheckBox.text=WardIso -TerrainEditorTopComponent.shininessField.text=0.001 +TerrainEditorTopComponent.shininessField.text=0.0 TerrainEditorTopComponent.shininessField.toolTipText=0 or greater +TerrainEditorTopComponent.jLabel3.text=Sharpness +TerrainEditorTopComponent.lacunarityField.text=2 +TerrainEditorTopComponent.jLabel4.text=Hill frequency +TerrainEditorTopComponent.octavesField.text=6 +TerrainEditorTopComponent.scaleLabel.text=Density +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. diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/ExtraToolParams.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/ExtraToolParams.java new file mode 100644 index 000000000..c6ed1d920 --- /dev/null +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/ExtraToolParams.java @@ -0,0 +1,13 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.gde.terraineditor; + +/** + * Extra parameters for specific terrain tools. + * @author Brent Owens + */ +public interface ExtraToolParams { + +} 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 a7703210a..b466c00da 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 @@ -39,17 +39,20 @@ - + - + + + + - + @@ -71,11 +74,11 @@ - + - + - + @@ -86,16 +89,17 @@ - - - - + + + + + @@ -120,7 +124,7 @@ - + @@ -203,6 +207,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -250,7 +390,7 @@ - + @@ -523,8 +663,10 @@ - + + + @@ -636,7 +778,7 @@ - + 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 5929a61a5..876e19d5c 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 @@ -52,6 +52,8 @@ import com.jme3.gde.terraineditor.tools.LevelTerrainTool; import com.jme3.gde.terraineditor.tools.LowerTerrainTool; import com.jme3.gde.terraineditor.tools.PaintTerrainTool; import com.jme3.gde.terraineditor.tools.RaiseTerrainTool; +import com.jme3.gde.terraineditor.tools.RoughExtraToolParams; +import com.jme3.gde.terraineditor.tools.RoughTerrainTool; import com.jme3.gde.terraineditor.tools.SmoothTerrainTool; import com.jme3.gde.terraineditor.tools.TerrainTool; import com.jme3.math.Vector3f; @@ -62,6 +64,7 @@ import com.jme3.terrain.Terrain; import com.jme3.terrain.heightmap.AbstractHeightMap; import com.jme3.texture.Texture; import java.awt.Component; +import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -198,6 +201,25 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce } else { hintTextArea.setText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.toolHint.default")); } + + // show/hide the extra tool variables scroll pane + if (tool == null) { + brushVariablesScrollPane.setVisible(false); + fractalBrushPanel.setVisible(false); + } else if (tool.getClass() == RoughTerrainTool.class) { + if (roughTerrainButton.isSelected()) { + brushVariablesScrollPane.setVisible(true); + fractalBrushPanel.setVisible(true); + } else { + brushVariablesScrollPane.setVisible(false); + fractalBrushPanel.setVisible(false); + } + } else { + brushVariablesScrollPane.setVisible(false); + fractalBrushPanel.setVisible(false); + } + mainScrollPane.validate(); + } /** This method is called from within the constructor to @@ -210,7 +232,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce terrainModButtonGroup = new ToggleButtonGroup(); textureFileChooser = new javax.swing.JFileChooser(); - jScrollPane3 = new javax.swing.JScrollPane(); + mainScrollPane = new javax.swing.JScrollPane(); jPanel1 = new javax.swing.JPanel(); hintPanel = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); @@ -220,6 +242,14 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce radiusSlider = new javax.swing.JSlider(); heightLabel = new javax.swing.JLabel(); heightSlider = new javax.swing.JSlider(); + brushVariablesScrollPane = new javax.swing.JScrollPane(); + fractalBrushPanel = new javax.swing.JPanel(); + jLabel3 = new javax.swing.JLabel(); + lacunarityField = new javax.swing.JTextField(); + jLabel4 = new javax.swing.JLabel(); + octavesField = new javax.swing.JTextField(); + scaleLabel = new javax.swing.JLabel(); + scaleField = new javax.swing.JTextField(); paintingPanel = new javax.swing.JPanel(); jScrollPane2 = new javax.swing.JScrollPane(); textureTable = new javax.swing.JTable(); @@ -252,7 +282,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce textureFileChooser.setDialogTitle(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.textureFileChooser.dialogTitle_1")); // NOI18N textureFileChooser.setFileFilter(new ImageFilter()); - jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + mainScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); jPanel1.setMaximumSize(new java.awt.Dimension(32767, 300)); @@ -276,7 +306,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce ); hintPanelLayout.setVerticalGroup( hintPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE) ); toolSettingsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.toolSettingsPanel.border.title"))); // NOI18N @@ -312,6 +342,98 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce }); toolSettingsPanel.add(heightSlider); + brushVariablesScrollPane.setPreferredSize(new java.awt.Dimension(158, 253)); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.jLabel3.text")); // NOI18N + jLabel3.setToolTipText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.jLabel3.toolTipText")); // NOI18N + + lacunarityField.setText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.lacunarityField.text")); // NOI18N + lacunarityField.setInputVerifier(new NumberInputVerifier()); + lacunarityField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + lacunarityFieldActionPerformed(evt); + } + }); + lacunarityField.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + lacunarityFieldKeyTyped(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.jLabel4.text")); // NOI18N + jLabel4.setToolTipText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.jLabel4.toolTipText")); // NOI18N + + octavesField.setText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.octavesField.text")); // NOI18N + octavesField.setInputVerifier(new NumberInputVerifier()); + octavesField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + octavesFieldActionPerformed(evt); + } + }); + octavesField.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + octavesFieldKeyTyped(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(scaleLabel, org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.scaleLabel.text")); // NOI18N + scaleLabel.setToolTipText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.scaleLabel.toolTipText")); // NOI18N + + scaleField.setText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.scaleField.text")); // NOI18N + scaleField.setInputVerifier(new NumberInputVerifier()); + scaleField.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + scaleFieldActionPerformed(evt); + } + }); + scaleField.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent evt) { + scaleFieldKeyTyped(evt); + } + }); + + javax.swing.GroupLayout fractalBrushPanelLayout = new javax.swing.GroupLayout(fractalBrushPanel); + fractalBrushPanel.setLayout(fractalBrushPanelLayout); + fractalBrushPanelLayout.setHorizontalGroup( + fractalBrushPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(fractalBrushPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(fractalBrushPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3) + .addGroup(fractalBrushPanelLayout.createSequentialGroup() + .addGroup(fractalBrushPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(scaleLabel) + .addComponent(jLabel4)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(fractalBrushPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(scaleField) + .addComponent(octavesField) + .addComponent(lacunarityField, javax.swing.GroupLayout.DEFAULT_SIZE, 36, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGap(67, 67, 67)) + ); + fractalBrushPanelLayout.setVerticalGroup( + fractalBrushPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(fractalBrushPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(fractalBrushPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(lacunarityField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(fractalBrushPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(octavesField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(fractalBrushPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(scaleLabel) + .addComponent(scaleField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(96, Short.MAX_VALUE)) + ); + + brushVariablesScrollPane.setViewportView(fractalBrushPanel); + + toolSettingsPanel.add(brushVariablesScrollPane); + paintingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.paintingPanel.border.title"))); // NOI18N textureTable.setModel(new TextureTableModel()); @@ -381,7 +503,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce .addComponent(addTextureButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(removeTextureButton)) - .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(paintingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(remainingTexTitleLabel) @@ -480,7 +602,11 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce org.openide.awt.Mnemonics.setLocalizedText(roughTerrainButton, org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.roughTerrainButton.text")); // NOI18N roughTerrainButton.setToolTipText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.roughTerrainButton.toolTipText")); // NOI18N roughTerrainButton.setActionCommand(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.roughTerrainButton.actionCommand")); // NOI18N - roughTerrainButton.setEnabled(false); + roughTerrainButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + roughTerrainButtonActionPerformed(evt); + } + }); jToolBar1.add(roughTerrainButton); terrainModButtonGroup.add(levelTerrainButton); @@ -575,7 +701,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(shininessField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) - .addContainerGap(43, Short.MAX_VALUE)) + .addContainerGap(110, Short.MAX_VALUE)) ); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); @@ -587,10 +713,10 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(paintingPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(terrainOpsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) + .addComponent(terrainOpsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(20, 20, 20) .addComponent(hintPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 901, Short.MAX_VALUE) ); @@ -599,27 +725,30 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(toolSettingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE) - .addComponent(paintingPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(hintPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() + .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(terrainOpsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(paintingPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(toolSettingsPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE)) + .addGap(148, 148, 148)) ); - jScrollPane3.setViewportView(jPanel1); + mainScrollPane.setViewportView(jPanel1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 920, Short.MAX_VALUE) + .addComponent(mainScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 920, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 333, Short.MAX_VALUE) + .addContainerGap()) ); }// //GEN-END:initComponents @@ -788,10 +917,48 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce } }//GEN-LAST:event_shininessFieldKeyTyped + private void octavesFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_octavesFieldActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_octavesFieldActionPerformed + + private void roughTerrainButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_roughTerrainButtonActionPerformed + if (roughTerrainButton.isSelected()) { + RoughTerrainTool tool = new RoughTerrainTool(); + toolController.setTerrainEditButtonState(tool); + updateRoughenFractalToolParams(); + setHintText(tool); + } else { + toolController.setTerrainEditButtonState(null); + setHintText((TerrainTool) null); + } + }//GEN-LAST:event_roughTerrainButtonActionPerformed + + private void lacunarityFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lacunarityFieldKeyTyped + updateRoughenFractalToolParams(); + }//GEN-LAST:event_lacunarityFieldKeyTyped + + private void octavesFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_octavesFieldKeyTyped + updateRoughenFractalToolParams(); + }//GEN-LAST:event_octavesFieldKeyTyped + + private void scaleFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_scaleFieldKeyTyped + updateRoughenFractalToolParams(); + }//GEN-LAST:event_scaleFieldKeyTyped + + private void lacunarityFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lacunarityFieldActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_lacunarityFieldActionPerformed + + private void scaleFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scaleFieldActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_scaleFieldActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addTextureButton; + private javax.swing.JScrollPane brushVariablesScrollPane; private javax.swing.JButton createTerrainButton; private javax.swing.JToggleButton eraseButton; + private javax.swing.JPanel fractalBrushPanel; private javax.swing.JButton genEntropiesButton; private javax.swing.JLabel heightLabel; private javax.swing.JSlider heightSlider; @@ -799,16 +966,20 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce private javax.swing.JTextArea hintTextArea; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; - private javax.swing.JScrollPane jScrollPane3; private javax.swing.JToolBar.Separator jSeparator1; private javax.swing.JToolBar.Separator jSeparator2; private javax.swing.JToolBar jToolBar1; + private javax.swing.JTextField lacunarityField; private javax.swing.JToggleButton levelTerrainButton; private javax.swing.JToggleButton lowerTerrainButton; + private javax.swing.JScrollPane mainScrollPane; + private javax.swing.JTextField octavesField; private javax.swing.JToggleButton paintButton; private javax.swing.JPanel paintingPanel; private javax.swing.JLabel radiusLabel; @@ -818,6 +989,8 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce private javax.swing.JLabel remainingTexturesLabel; private javax.swing.JButton removeTextureButton; private javax.swing.JToggleButton roughTerrainButton; + private javax.swing.JTextField scaleField; + private javax.swing.JLabel scaleLabel; private javax.swing.JTextField shininessField; private javax.swing.JToggleButton smoothTerrainButton; private javax.swing.ButtonGroup terrainModButtonGroup; @@ -829,6 +1002,25 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce private javax.swing.JCheckBox wardIsoCheckBox; // End of variables declaration//GEN-END:variables + /** + * Validate text fields for Float number values + */ + protected class NumberInputVerifier extends InputVerifier { + @Override + public boolean verify(JComponent input) { + try { + javax.swing.JTextField textField = (javax.swing.JTextField)input; + String a=textField.getText(); + Float.parseFloat(a); + } + catch (NumberFormatException e) { + Toolkit.getDefaultToolkit().beep(); + return false; + } + return true; + } + } + private class ShininessVerifier extends InputVerifier { @Override public boolean verify(JComponent input) { @@ -839,6 +1031,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce if (f > 0) return true; } catch (Exception e) { + Toolkit.getDefaultToolkit().beep(); return false; } } @@ -847,6 +1040,27 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce } + private void updateRoughenFractalToolParams() { + try { + RoughExtraToolParams params = new RoughExtraToolParams(); + //params.amplitude = new Float(amplitudeField.getText()); + //params.frequency = new Float(frequencyField.getText()); + params.lacunarity = new Float(lacunarityField.getText()); + params.octaves = new Float(octavesField.getText()); + //params.roughness = new Float(roughnessField.getText()); + params.scale = new Float(scaleField.getText()); + toolController.setExtraToolParams(params); + + } catch (NumberFormatException e) {} + } + + protected void getExtraToolParams() { + if (toolController.getCurrentTerrainTool() != null) { + if (toolController.getCurrentTerrainTool().getClass() == RoughTerrainTool.class) + updateRoughenFractalToolParams(); + } + } + /** * Gets default instance. Do not use directly: reserved for *.settings files only, * i.e. deserialization routines; otherwise you could get a non-deserialized instance. @@ -1172,6 +1386,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce camController.setEditorController(editorController); toolController.setEditorController(editorController); toolController.setCameraController(camController); + toolController.setTopComponent(this); editorController.setToolController(toolController); toolController.setHeightToolRadius((float) radiusSlider.getValue() / (float) radiusSlider.getMaximum()); @@ -1183,6 +1398,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce if (editorController.getTerrain(null) != null) { //createTerrainButton.setEnabled(false); // only let the user add one terrain } + brushVariablesScrollPane.setVisible(false); } } diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java index e86819c17..9f0462733 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java @@ -56,6 +56,7 @@ public class TerrainToolController extends SceneToolController { private TerrainTool terrainTool; private TerrainEditorController editorController; private TerrainCameraController cameraController; + private TerrainEditorTopComponent topComponent; private float toolRadius; private float toolWeight; @@ -75,6 +76,10 @@ public class TerrainToolController extends SceneToolController { this.cameraController = cameraController; } + public void setTopComponent(TerrainEditorTopComponent topComponent) { + this.topComponent = topComponent; + } + /** * @param heightToolHeight percent of the slider */ @@ -171,6 +176,7 @@ public class TerrainToolController extends SceneToolController { if (terrainTool != null) { Vector3f point = getMarkerLocation(); if (point != null) { + topComponent.getExtraToolParams(); terrainTool.actionPrimary(point, selectedTextureIndex, jmeRootNode, editorController.getCurrentDataObject()); } @@ -192,4 +198,14 @@ public class TerrainToolController extends SceneToolController { } + void setExtraToolParams(ExtraToolParams params) { + if (terrainTool != null) { + terrainTool.setExtraParams(params); + } + } + + public TerrainTool getCurrentTerrainTool() { + return terrainTool; + } + } diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughExtraToolParams.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughExtraToolParams.java new file mode 100644 index 000000000..8460cf12e --- /dev/null +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughExtraToolParams.java @@ -0,0 +1,32 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.gde.terraineditor.tools; + +import com.jme3.gde.terraineditor.ExtraToolParams; + +/** + * Parameters, and default values, for the fractal roughen tool + * @author Brent Owens + */ +public class RoughExtraToolParams implements ExtraToolParams{ + public float roughness = 1.2f; + public float frequency = 0.2f; + public float amplitude = 1.0f; + public float lacunarity = 2.12f; + public float octaves = 8; + public float scale = 1.0f; + + + // the below parameters are not get in the UI yet: + + float perturbMagnitude = 0.2f; + float erodeRadius = 5; + float erodeTalus = 0.011f; + + float smoothRadius = 1; + float smoothEffect = 0.1f; + + int iterations = 1; +} diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughTerrainTool.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughTerrainTool.java new file mode 100644 index 000000000..bca1095c6 --- /dev/null +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughTerrainTool.java @@ -0,0 +1,55 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.gde.terraineditor.tools; + +import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode; +import com.jme3.gde.terraineditor.ExtraToolParams; +import com.jme3.math.ColorRGBA; +import com.jme3.math.Vector3f; +import com.jme3.scene.Node; +import org.openide.loaders.DataObject; + +/** + * Roughens the terrain using a fractal noise routine. + * @author Brent Owens + */ +public class RoughTerrainTool extends TerrainTool { + + private RoughExtraToolParams params; + + @Override + public void actionPrimary(Vector3f point, int textureIndex, AbstractSceneExplorerNode rootNode, DataObject dataObject) { + if (radius == 0 || weight == 0) + return; + RoughTerrainToolAction action = new RoughTerrainToolAction(point, radius, weight, (RoughExtraToolParams)params); + action.doActionPerformed(rootNode, dataObject); + } + + @Override + public void actionSecondary(Vector3f point, int textureIndex, AbstractSceneExplorerNode rootNode, DataObject dataObject) { + // do nothing + } + + @Override + public void addMarkerPrimary(Node parent) { + super.addMarkerPrimary(parent); + markerPrimary.getMaterial().setColor("Color", ColorRGBA.Yellow); + } + + @Override + public void setExtraParams(ExtraToolParams params) { + this.params = (RoughExtraToolParams) params; + } + + @Override + public ExtraToolParams getExtraParams() { + return params; + } + + @Override + public void extraParamsChanged(ExtraToolParams params) { + this.params = (RoughExtraToolParams) params; + } +} diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughTerrainToolAction.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughTerrainToolAction.java new file mode 100644 index 000000000..c40983b1f --- /dev/null +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughTerrainToolAction.java @@ -0,0 +1,182 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.jme3.gde.terraineditor.tools; + +import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode; +import com.jme3.gde.terraineditor.ExtraToolParams; +import com.jme3.math.Vector2f; +import com.jme3.math.Vector3f; +import com.jme3.scene.Node; +import com.jme3.terrain.Terrain; +import com.jme3.terrain.noise.Basis; +import com.jme3.terrain.noise.ShaderUtils; +import com.jme3.terrain.noise.basis.FilteredBasis; +import com.jme3.terrain.noise.filter.IterativeFilter; +import com.jme3.terrain.noise.filter.OptimizedErode; +import com.jme3.terrain.noise.filter.PerturbFilter; +import com.jme3.terrain.noise.filter.SmoothFilter; +import com.jme3.terrain.noise.fractal.FractalSum; +import com.jme3.terrain.noise.modulator.NoiseModulator; +import java.nio.FloatBuffer; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author sploreg + */ +public class RoughTerrainToolAction extends AbstractTerrainToolAction { + + private Vector3f worldLoc; + private float radius; + private float weight; + private RoughExtraToolParams params; + + List undoLocs; + List undoHeights; + + public RoughTerrainToolAction(Vector3f markerLocation, float radius, float weight, ExtraToolParams params) { + this.worldLoc = markerLocation.clone(); + this.radius = radius; + this.weight = weight; + this.params = (RoughExtraToolParams)params; + name = "Rough terrain"; + } + + @Override + protected Object doApplyTool(AbstractSceneExplorerNode rootNode) { + Terrain terrain = getTerrain(rootNode.getLookup().lookup(Node.class)); + if (terrain == null) + return null; + roughen(terrain, radius, weight, params); + return terrain; + } + + @Override + protected void doUndoTool(AbstractSceneExplorerNode rootNode, Object undoObject) { + if (undoObject == null) + return; + if (undoLocs == null || undoHeights == null) + return; + resetHeight((Terrain)undoObject, undoLocs, undoHeights); + } + + private void roughen(Terrain terrain, float radius, float weight, RoughExtraToolParams params) { + Basis fractalFilter = createFractalGenerator(params, weight); + + List locs = new ArrayList(); + List heights = new ArrayList(); + + // offset it by radius because in the loop we iterate through 2 radii + int radiusStepsX = (int) (radius / ((Node)terrain).getLocalScale().x); + int radiusStepsZ = (int) (radius / ((Node)terrain).getLocalScale().z); + float xStepAmount = ((Node)terrain).getLocalScale().x; + float zStepAmount = ((Node)terrain).getLocalScale().z; + + int r2 = (int) (radius*2); + FloatBuffer fb = fractalFilter.getBuffer(worldLoc.x, worldLoc.z, 0, r2); + + //for (int y=0; y undoLocs, List undoHeights) { + List neg = new ArrayList(); + for (Float f : undoHeights) + neg.add( f * -1f ); + + terrain.adjustHeight(undoLocs, neg); + ((Node)terrain).updateModelBound(); + } + + private Basis createFractalGenerator(RoughExtraToolParams params, float weight) { + FractalSum base = new FractalSum(); + base.setRoughness(params.roughness); + base.setFrequency(params.frequency); + base.setAmplitude(weight); + base.setLacunarity(params.lacunarity <= 1 ? 1.1f : params.lacunarity); // make it greater than 1.0f + base.setOctaves(params.octaves); + float scale = params.scale; + if (scale > 1.0f) + scale = 1.0f; + if (scale < 0) + scale = 0; + base.setScale(scale);//0.02125f + base.addModulator(new NoiseModulator() { + @Override + public float value(float... in) { + return ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1); + } + }); + + FilteredBasis ground = new FilteredBasis(base); + + PerturbFilter perturb = new PerturbFilter(); + perturb.setMagnitude(0.2f);//0.119 the higher, the slower it is + + OptimizedErode therm = new OptimizedErode(); + therm.setRadius(5); + therm.setTalus(0.011f); + + SmoothFilter smooth = new SmoothFilter(); + smooth.setRadius(1); + smooth.setEffect(0.1f); // 0.7 + + IterativeFilter iterate = new IterativeFilter(); + iterate.addPreFilter(perturb); + iterate.addPostFilter(smooth); + iterate.setFilter(therm); + iterate.setIterations(1); + + ground.addPreFilter(iterate); + + return ground; + } +} diff --git a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/TerrainTool.java b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/TerrainTool.java index e6b8017e6..0e75c7b06 100644 --- a/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/TerrainTool.java +++ b/sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/TerrainTool.java @@ -33,6 +33,7 @@ package com.jme3.gde.terraineditor.tools; import com.jme3.asset.AssetManager; import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode; +import com.jme3.gde.terraineditor.ExtraToolParams; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector3f; @@ -180,5 +181,16 @@ public abstract class TerrainTool { this.toolHintTextKey = toolHintTextKey; } + public void setExtraParams(ExtraToolParams params) { + // override in subclasses that need it + } + public ExtraToolParams getExtraParams() { + // override in subclasses that need it + return null; + } + + public void extraParamsChanged(ExtraToolParams params) { + // override in subclasses that need it + } }