added new Terrain editor noise-based 'roughen' tool

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8964 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
bre..ns 13 years ago
parent addfe4283b
commit da3b43174c
  1. 16
      sdk/jme3-core-baselibs/nbproject/genfiles.properties
  2. 346
      sdk/jme3-core-baselibs/nbproject/project.xml
  3. 11
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/Bundle.properties
  4. 13
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/ExtraToolParams.java
  5. 170
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.form
  6. 252
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainEditorTopComponent.java
  7. 16
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/TerrainToolController.java
  8. 32
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughExtraToolParams.java
  9. 55
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughTerrainTool.java
  10. 182
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/RoughTerrainToolAction.java
  11. 12
      sdk/jme3-terrain-editor/src/com/jme3/gde/terraineditor/tools/TerrainTool.java

@ -1,8 +1,8 @@
build.xml.data.CRC32=05d5b002 build.xml.data.CRC32=06721bf2
build.xml.script.CRC32=cdae6a36 build.xml.script.CRC32=cdae6a36
build.xml.stylesheet.CRC32=a56c6a5b@1.46.2 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. # 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. # 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.data.CRC32=06721bf2
nbproject/build-impl.xml.script.CRC32=246f9b81 nbproject/build-impl.xml.script.CRC32=246f9b81
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.2 nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.46.2

@ -1,171 +1,175 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1"> <project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type> <type>org.netbeans.modules.apisupport.project</type>
<configuration> <configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3"> <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>com.jme3.gde.core.baselibs</code-name-base> <code-name-base>com.jme3.gde.core.baselibs</code-name-base>
<suite-component/> <suite-component/>
<module-dependencies> <module-dependencies>
<dependency> <dependency>
<code-name-base>com.jme3.gde.core.libraries</code-name-base> <code-name-base>com.jme3.gde.core.libraries</code-name-base>
<build-prerequisite/> <build-prerequisite/>
<compile-dependency/> <compile-dependency/>
<run-dependency> <run-dependency>
<release-version>1</release-version> <release-version>1</release-version>
<specification-version>3.0.0</specification-version> <specification-version>3.0.0</specification-version>
</run-dependency> </run-dependency>
</dependency> </dependency>
</module-dependencies> </module-dependencies>
<public-packages> <public-packages>
<package>checkers.quals</package> <package>checkers.quals</package>
<package>com.jme3.animation</package> <package>com.jme3.animation</package>
<package>com.jme3.app</package> <package>com.jme3.app</package>
<package>com.jme3.app.state</package> <package>com.jme3.app.state</package>
<package>com.jme3.asset</package> <package>com.jme3.asset</package>
<package>com.jme3.asset.plugins</package> <package>com.jme3.asset.plugins</package>
<package>com.jme3.audio</package> <package>com.jme3.audio</package>
<package>com.jme3.audio.lwjgl</package> <package>com.jme3.audio.lwjgl</package>
<package>com.jme3.audio.plugins</package> <package>com.jme3.audio.plugins</package>
<package>com.jme3.bounding</package> <package>com.jme3.bounding</package>
<package>com.jme3.bullet</package> <package>com.jme3.bullet</package>
<package>com.jme3.bullet.collision</package> <package>com.jme3.bullet.collision</package>
<package>com.jme3.bullet.collision.shapes</package> <package>com.jme3.bullet.collision.shapes</package>
<package>com.jme3.bullet.collision.shapes.infos</package> <package>com.jme3.bullet.collision.shapes.infos</package>
<package>com.jme3.bullet.control</package> <package>com.jme3.bullet.control</package>
<package>com.jme3.bullet.control.ragdoll</package> <package>com.jme3.bullet.control.ragdoll</package>
<package>com.jme3.bullet.joints</package> <package>com.jme3.bullet.joints</package>
<package>com.jme3.bullet.joints.motors</package> <package>com.jme3.bullet.joints.motors</package>
<package>com.jme3.bullet.objects</package> <package>com.jme3.bullet.objects</package>
<package>com.jme3.bullet.objects.infos</package> <package>com.jme3.bullet.objects.infos</package>
<package>com.jme3.bullet.util</package> <package>com.jme3.bullet.util</package>
<package>com.jme3.cinematic</package> <package>com.jme3.cinematic</package>
<package>com.jme3.cinematic.events</package> <package>com.jme3.cinematic.events</package>
<package>com.jme3.collision</package> <package>com.jme3.collision</package>
<package>com.jme3.collision.bih</package> <package>com.jme3.collision.bih</package>
<package>com.jme3.effect</package> <package>com.jme3.effect</package>
<package>com.jme3.effect.influencers</package> <package>com.jme3.effect.influencers</package>
<package>com.jme3.effect.shapes</package> <package>com.jme3.effect.shapes</package>
<package>com.jme3.export</package> <package>com.jme3.export</package>
<package>com.jme3.export.binary</package> <package>com.jme3.export.binary</package>
<package>com.jme3.export.xml</package> <package>com.jme3.export.xml</package>
<package>com.jme3.font</package> <package>com.jme3.font</package>
<package>com.jme3.font.plugins</package> <package>com.jme3.font.plugins</package>
<package>com.jme3.input</package> <package>com.jme3.input</package>
<package>com.jme3.input.awt</package> <package>com.jme3.input.awt</package>
<package>com.jme3.input.controls</package> <package>com.jme3.input.controls</package>
<package>com.jme3.input.dummy</package> <package>com.jme3.input.dummy</package>
<package>com.jme3.input.event</package> <package>com.jme3.input.event</package>
<package>com.jme3.input.lwjgl</package> <package>com.jme3.input.lwjgl</package>
<package>com.jme3.light</package> <package>com.jme3.light</package>
<package>com.jme3.material</package> <package>com.jme3.material</package>
<package>com.jme3.material.plugins</package> <package>com.jme3.material.plugins</package>
<package>com.jme3.math</package> <package>com.jme3.math</package>
<package>com.jme3.network</package> <package>com.jme3.network</package>
<package>com.jme3.network.base</package> <package>com.jme3.network.base</package>
<package>com.jme3.network.kernel</package> <package>com.jme3.network.kernel</package>
<package>com.jme3.network.kernel.tcp</package> <package>com.jme3.network.kernel.tcp</package>
<package>com.jme3.network.kernel.udp</package> <package>com.jme3.network.kernel.udp</package>
<package>com.jme3.network.message</package> <package>com.jme3.network.message</package>
<package>com.jme3.network.rmi</package> <package>com.jme3.network.rmi</package>
<package>com.jme3.network.serializing</package> <package>com.jme3.network.serializing</package>
<package>com.jme3.network.serializing.serializers</package> <package>com.jme3.network.serializing.serializers</package>
<package>com.jme3.niftygui</package> <package>com.jme3.niftygui</package>
<package>com.jme3.post</package> <package>com.jme3.post</package>
<package>com.jme3.post.filters</package> <package>com.jme3.post.filters</package>
<package>com.jme3.post.ssao</package> <package>com.jme3.post.ssao</package>
<package>com.jme3.renderer</package> <package>com.jme3.renderer</package>
<package>com.jme3.renderer.lwjgl</package> <package>com.jme3.renderer.lwjgl</package>
<package>com.jme3.renderer.queue</package> <package>com.jme3.renderer.queue</package>
<package>com.jme3.scene</package> <package>com.jme3.scene</package>
<package>com.jme3.scene.control</package> <package>com.jme3.scene.control</package>
<package>com.jme3.scene.debug</package> <package>com.jme3.scene.debug</package>
<package>com.jme3.scene.mesh</package> <package>com.jme3.scene.mesh</package>
<package>com.jme3.scene.plugins</package> <package>com.jme3.scene.plugins</package>
<package>com.jme3.scene.plugins.blender</package> <package>com.jme3.scene.plugins.blender</package>
<package>com.jme3.scene.plugins.blender.animations</package> <package>com.jme3.scene.plugins.blender.animations</package>
<package>com.jme3.scene.plugins.blender.cameras</package> <package>com.jme3.scene.plugins.blender.cameras</package>
<package>com.jme3.scene.plugins.blender.constraints</package> <package>com.jme3.scene.plugins.blender.constraints</package>
<package>com.jme3.scene.plugins.blender.curves</package> <package>com.jme3.scene.plugins.blender.curves</package>
<package>com.jme3.scene.plugins.blender.exceptions</package> <package>com.jme3.scene.plugins.blender.exceptions</package>
<package>com.jme3.scene.plugins.blender.file</package> <package>com.jme3.scene.plugins.blender.file</package>
<package>com.jme3.scene.plugins.blender.lights</package> <package>com.jme3.scene.plugins.blender.lights</package>
<package>com.jme3.scene.plugins.blender.materials</package> <package>com.jme3.scene.plugins.blender.materials</package>
<package>com.jme3.scene.plugins.blender.meshes</package> <package>com.jme3.scene.plugins.blender.meshes</package>
<package>com.jme3.scene.plugins.blender.modifiers</package> <package>com.jme3.scene.plugins.blender.modifiers</package>
<package>com.jme3.scene.plugins.blender.objects</package> <package>com.jme3.scene.plugins.blender.objects</package>
<package>com.jme3.scene.plugins.blender.particles</package> <package>com.jme3.scene.plugins.blender.particles</package>
<package>com.jme3.scene.plugins.blender.textures</package> <package>com.jme3.scene.plugins.blender.textures</package>
<package>com.jme3.scene.plugins.ogre</package> <package>com.jme3.scene.plugins.ogre</package>
<package>com.jme3.scene.plugins.ogre.matext</package> <package>com.jme3.scene.plugins.ogre.matext</package>
<package>com.jme3.scene.shape</package> <package>com.jme3.scene.shape</package>
<package>com.jme3.shader</package> <package>com.jme3.shader</package>
<package>com.jme3.shader.plugins</package> <package>com.jme3.shader.plugins</package>
<package>com.jme3.shadow</package> <package>com.jme3.shadow</package>
<package>com.jme3.system</package> <package>com.jme3.system</package>
<package>com.jme3.system.awt</package> <package>com.jme3.system.awt</package>
<package>com.jme3.system.lwjgl</package> <package>com.jme3.system.lwjgl</package>
<package>com.jme3.terrain</package> <package>com.jme3.terrain</package>
<package>com.jme3.terrain.geomipmap</package> <package>com.jme3.terrain.geomipmap</package>
<package>com.jme3.terrain.geomipmap.grid</package> <package>com.jme3.terrain.geomipmap.grid</package>
<package>com.jme3.terrain.geomipmap.lodcalc</package> <package>com.jme3.terrain.geomipmap.lodcalc</package>
<package>com.jme3.terrain.geomipmap.lodcalc.util</package> <package>com.jme3.terrain.geomipmap.lodcalc.util</package>
<package>com.jme3.terrain.geomipmap.picking</package> <package>com.jme3.terrain.geomipmap.picking</package>
<package>com.jme3.terrain.heightmap</package> <package>com.jme3.terrain.heightmap</package>
<package>com.jme3.texture</package> <package>com.jme3.terrain.noise</package>
<package>com.jme3.texture.plugins</package> <package>com.jme3.terrain.noise.basis</package>
<package>com.jme3.ui</package> <package>com.jme3.terrain.noise.filter</package>
<package>com.jme3.util</package> <package>com.jme3.terrain.noise.fractal</package>
<package>com.jme3.util.blockparser</package> <package>com.jme3.terrain.noise.modulator</package>
<package>com.jme3.util.xml</package> <package>com.jme3.texture</package>
<package>com.jme3.water</package> <package>com.jme3.texture.plugins</package>
<package>jme3tools.converters</package> <package>com.jme3.ui</package>
<package>jme3tools.converters.model</package> <package>com.jme3.util</package>
<package>jme3tools.converters.model.strip</package> <package>com.jme3.util.blockparser</package>
<package>jme3tools.navigation</package> <package>com.jme3.util.xml</package>
<package>jme3tools.nvtex</package> <package>com.jme3.water</package>
<package>jme3tools.optimize</package> <package>jme3tools.converters</package>
<package>jme3tools.savegame</package> <package>jme3tools.converters.model</package>
</public-packages> <package>jme3tools.converters.model.strip</package>
<class-path-extension> <package>jme3tools.navigation</package>
<runtime-relative-path>ext/jME3-niftygui.jar</runtime-relative-path> <package>jme3tools.optimize</package>
<binary-origin>release/modules/ext/jME3-niftygui.jar</binary-origin> <package>jme3tools.savegame</package>
</class-path-extension> </public-packages>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/jME3-blender.jar</runtime-relative-path> <runtime-relative-path>ext/jME3-niftygui.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jME3-blender.jar</binary-origin> <binary-origin>release/modules/ext/jME3-niftygui.jar</binary-origin>
</class-path-extension> </class-path-extension>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/jME3-desktop.jar</runtime-relative-path> <runtime-relative-path>ext/jME3-blender.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jME3-desktop.jar</binary-origin> <binary-origin>release/modules/ext/jME3-blender.jar</binary-origin>
</class-path-extension> </class-path-extension>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/jME3-lwjgl.jar</runtime-relative-path> <runtime-relative-path>ext/jME3-desktop.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jME3-lwjgl.jar</binary-origin> <binary-origin>release/modules/ext/jME3-desktop.jar</binary-origin>
</class-path-extension> </class-path-extension>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/jME3-terrain.jar</runtime-relative-path> <runtime-relative-path>ext/jME3-lwjgl.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jME3-terrain.jar</binary-origin> <binary-origin>release/modules/ext/jME3-lwjgl.jar</binary-origin>
</class-path-extension> </class-path-extension>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/jME3-jbullet.jar</runtime-relative-path> <runtime-relative-path>ext/jME3-terrain.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jME3-jbullet.jar</binary-origin> <binary-origin>release/modules/ext/jME3-terrain.jar</binary-origin>
</class-path-extension> </class-path-extension>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/jME3-plugins.jar</runtime-relative-path> <runtime-relative-path>ext/jME3-jbullet.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jME3-plugins.jar</binary-origin> <binary-origin>release/modules/ext/jME3-jbullet.jar</binary-origin>
</class-path-extension> </class-path-extension>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/jME3-core.jar</runtime-relative-path> <runtime-relative-path>ext/jME3-plugins.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jME3-core.jar</binary-origin> <binary-origin>release/modules/ext/jME3-plugins.jar</binary-origin>
</class-path-extension> </class-path-extension>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/jME3-lwjgl-natives.jar</runtime-relative-path> <runtime-relative-path>ext/jME3-core.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jME3-lwjgl-natives.jar</binary-origin> <binary-origin>release/modules/ext/jME3-core.jar</binary-origin>
</class-path-extension> </class-path-extension>
<class-path-extension> <class-path-extension>
<runtime-relative-path>ext/jME3-jogg.jar</runtime-relative-path> <runtime-relative-path>ext/jME3-lwjgl-natives.jar</runtime-relative-path>
<binary-origin>release/modules/ext/jME3-jogg.jar</binary-origin> <binary-origin>release/modules/ext/jME3-lwjgl-natives.jar</binary-origin>
</class-path-extension> </class-path-extension>
</data> <class-path-extension>
</configuration> <runtime-relative-path>ext/jME3-jogg.jar</runtime-relative-path>
</project> <binary-origin>release/modules/ext/jME3-jogg.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
</project>

@ -108,5 +108,14 @@ TerrainEditorTopComponent.toolHint.level=Right click to set desired height value
TerrainEditorTopComponent.jPanel2.border.title=Material TerrainEditorTopComponent.jPanel2.border.title=Material
TerrainEditorTopComponent.jLabel1.text=Shininess TerrainEditorTopComponent.jLabel1.text=Shininess
TerrainEditorTopComponent.wardIsoCheckBox.text=WardIso TerrainEditorTopComponent.wardIsoCheckBox.text=WardIso
TerrainEditorTopComponent.shininessField.text=0.001 TerrainEditorTopComponent.shininessField.text=0.0
TerrainEditorTopComponent.shininessField.toolTipText=0 or greater 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.

@ -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 {
}

@ -39,17 +39,20 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane3" alignment="1" pref="920" max="32767" attributes="0"/> <Component id="mainScrollPane" alignment="1" pref="920" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane3" alignment="1" pref="253" max="32767" attributes="0"/> <Group type="102" alignment="0" attributes="0">
<Component id="mainScrollPane" pref="333" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane3"> <Container class="javax.swing.JScrollPane" name="mainScrollPane">
<Properties> <Properties>
<Property name="verticalScrollBarPolicy" type="int" value="22"/> <Property name="verticalScrollBarPolicy" type="int" value="22"/>
</Properties> </Properties>
@ -71,11 +74,11 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="paintingPanel" max="32767" attributes="0"/> <Component id="paintingPanel" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel2" max="32767" attributes="1"/> <Component id="jPanel2" max="32767" attributes="1"/>
<Component id="terrainOpsPanel" alignment="0" max="32767" attributes="1"/> <Component id="terrainOpsPanel" alignment="0" min="-2" max="-2" attributes="1"/>
</Group> </Group>
<EmptySpace pref="20" max="32767" attributes="0"/> <EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Component id="hintPanel" max="32767" attributes="0"/> <Component id="hintPanel" max="32767" attributes="0"/>
</Group> </Group>
<Component id="jToolBar1" alignment="0" pref="901" max="32767" attributes="0"/> <Component id="jToolBar1" alignment="0" pref="901" max="32767" attributes="0"/>
@ -86,16 +89,17 @@
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Component id="jToolBar1" min="-2" pref="27" max="-2" attributes="0"/> <Component id="jToolBar1" min="-2" pref="27" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="toolSettingsPanel" pref="218" max="32767" attributes="1"/> <Component id="hintPanel" max="32767" attributes="1"/>
<Component id="paintingPanel" max="32767" attributes="1"/>
<Component id="hintPanel" alignment="1" max="32767" attributes="1"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="terrainOpsPanel" min="-2" max="-2" attributes="1"/> <Component id="terrainOpsPanel" min="-2" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" max="32767" attributes="0"/> <Component id="jPanel2" max="32767" attributes="0"/>
</Group> </Group>
<Component id="paintingPanel" alignment="0" max="32767" attributes="1"/>
<Component id="toolSettingsPanel" alignment="0" pref="285" max="32767" attributes="1"/>
</Group> </Group>
<EmptySpace min="-2" pref="148" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -120,7 +124,7 @@
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="191" max="32767" attributes="0"/> <Component id="jScrollPane1" alignment="0" pref="258" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
@ -203,6 +207,142 @@
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="heightSliderStateChanged"/> <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="heightSliderStateChanged"/>
</Events> </Events>
</Component> </Component>
<Container class="javax.swing.JScrollPane" name="brushVariablesScrollPane">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[158, 253]"/>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="fractalBrushPanel">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="1"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="scaleLabel" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="scaleField" max="32767" attributes="1"/>
<Component id="octavesField" alignment="0" max="32767" attributes="1"/>
<Component id="lacunarityField" alignment="0" pref="36" max="32767" attributes="1"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="67" pref="67" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lacunarityField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="octavesField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="scaleLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="scaleField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="96" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.jLabel3.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.jLabel3.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="lacunarityField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.lacunarityField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="inputVerifier" type="javax.swing.InputVerifier" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new NumberInputVerifier()" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="lacunarityFieldActionPerformed"/>
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="lacunarityFieldKeyTyped"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.jLabel4.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.jLabel4.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="octavesField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.octavesField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="inputVerifier" type="javax.swing.InputVerifier" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new NumberInputVerifier()" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="octavesFieldActionPerformed"/>
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="octavesFieldKeyTyped"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="scaleLabel">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.scaleLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.scaleLabel.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="scaleField">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.scaleField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="inputVerifier" type="javax.swing.InputVerifier" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="new NumberInputVerifier()" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="scaleFieldActionPerformed"/>
<EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="scaleFieldKeyTyped"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="paintingPanel"> <Container class="javax.swing.JPanel" name="paintingPanel">
@ -250,7 +390,7 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="removeTextureButton" min="-2" max="-2" attributes="0"/> <Component id="removeTextureButton" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="jScrollPane2" pref="166" max="32767" attributes="0"/> <Component id="jScrollPane2" pref="233" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
@ -523,8 +663,10 @@
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.roughTerrainButton.actionCommand" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="com/jme3/gde/terraineditor/Bundle.properties" key="TerrainEditorTopComponent.roughTerrainButton.actionCommand" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="roughTerrainButtonActionPerformed"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JToggleButton" name="levelTerrainButton"> <Component class="javax.swing.JToggleButton" name="levelTerrainButton">
<Properties> <Properties>
@ -636,7 +778,7 @@
<Component id="shininessField" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="shininessField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace pref="43" max="32767" attributes="0"/> <EmptySpace pref="110" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>

@ -52,6 +52,8 @@ import com.jme3.gde.terraineditor.tools.LevelTerrainTool;
import com.jme3.gde.terraineditor.tools.LowerTerrainTool; import com.jme3.gde.terraineditor.tools.LowerTerrainTool;
import com.jme3.gde.terraineditor.tools.PaintTerrainTool; import com.jme3.gde.terraineditor.tools.PaintTerrainTool;
import com.jme3.gde.terraineditor.tools.RaiseTerrainTool; 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.SmoothTerrainTool;
import com.jme3.gde.terraineditor.tools.TerrainTool; import com.jme3.gde.terraineditor.tools.TerrainTool;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
@ -62,6 +64,7 @@ import com.jme3.terrain.Terrain;
import com.jme3.terrain.heightmap.AbstractHeightMap; import com.jme3.terrain.heightmap.AbstractHeightMap;
import com.jme3.texture.Texture; import com.jme3.texture.Texture;
import java.awt.Component; import java.awt.Component;
import java.awt.Toolkit;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
@ -198,6 +201,25 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
} else { } else {
hintTextArea.setText(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.toolHint.default")); 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 /** This method is called from within the constructor to
@ -210,7 +232,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
terrainModButtonGroup = new ToggleButtonGroup(); terrainModButtonGroup = new ToggleButtonGroup();
textureFileChooser = new javax.swing.JFileChooser(); textureFileChooser = new javax.swing.JFileChooser();
jScrollPane3 = new javax.swing.JScrollPane(); mainScrollPane = new javax.swing.JScrollPane();
jPanel1 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel();
hintPanel = new javax.swing.JPanel(); hintPanel = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
@ -220,6 +242,14 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
radiusSlider = new javax.swing.JSlider(); radiusSlider = new javax.swing.JSlider();
heightLabel = new javax.swing.JLabel(); heightLabel = new javax.swing.JLabel();
heightSlider = new javax.swing.JSlider(); 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(); paintingPanel = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane(); jScrollPane2 = new javax.swing.JScrollPane();
textureTable = new javax.swing.JTable(); 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.setDialogTitle(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.textureFileChooser.dialogTitle_1")); // NOI18N
textureFileChooser.setFileFilter(new ImageFilter()); 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)); jPanel1.setMaximumSize(new java.awt.Dimension(32767, 300));
@ -276,7 +306,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
); );
hintPanelLayout.setVerticalGroup( hintPanelLayout.setVerticalGroup(
hintPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 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 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); 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 paintingPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(TerrainEditorTopComponent.class, "TerrainEditorTopComponent.paintingPanel.border.title"))); // NOI18N
textureTable.setModel(new TextureTableModel()); textureTable.setModel(new TextureTableModel());
@ -381,7 +503,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
.addComponent(addTextureButton) .addComponent(addTextureButton)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(removeTextureButton)) .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) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(paintingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(paintingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(remainingTexTitleLabel) .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 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.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.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); jToolBar1.add(roughTerrainButton);
terrainModButtonGroup.add(levelTerrainButton); terrainModButtonGroup.add(levelTerrainButton);
@ -575,7 +701,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .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(shininessField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1)) .addComponent(jLabel1))
.addContainerGap(43, Short.MAX_VALUE)) .addContainerGap(110, Short.MAX_VALUE))
); );
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); 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) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(paintingPanel, 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)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .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(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)) .addComponent(terrainOpsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE) .addGap(20, 20, 20)
.addComponent(hintPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .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) .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() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.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)
.addComponent(hintPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .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) .addComponent(terrainOpsPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .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); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 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.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 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())
); );
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
@ -788,10 +917,48 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
} }
}//GEN-LAST:event_shininessFieldKeyTyped }//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 // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton addTextureButton; private javax.swing.JButton addTextureButton;
private javax.swing.JScrollPane brushVariablesScrollPane;
private javax.swing.JButton createTerrainButton; private javax.swing.JButton createTerrainButton;
private javax.swing.JToggleButton eraseButton; private javax.swing.JToggleButton eraseButton;
private javax.swing.JPanel fractalBrushPanel;
private javax.swing.JButton genEntropiesButton; private javax.swing.JButton genEntropiesButton;
private javax.swing.JLabel heightLabel; private javax.swing.JLabel heightLabel;
private javax.swing.JSlider heightSlider; 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.JTextArea hintTextArea;
private javax.swing.JButton jButton1; private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JToolBar.Separator jSeparator1; private javax.swing.JToolBar.Separator jSeparator1;
private javax.swing.JToolBar.Separator jSeparator2; private javax.swing.JToolBar.Separator jSeparator2;
private javax.swing.JToolBar jToolBar1; private javax.swing.JToolBar jToolBar1;
private javax.swing.JTextField lacunarityField;
private javax.swing.JToggleButton levelTerrainButton; private javax.swing.JToggleButton levelTerrainButton;
private javax.swing.JToggleButton lowerTerrainButton; private javax.swing.JToggleButton lowerTerrainButton;
private javax.swing.JScrollPane mainScrollPane;
private javax.swing.JTextField octavesField;
private javax.swing.JToggleButton paintButton; private javax.swing.JToggleButton paintButton;
private javax.swing.JPanel paintingPanel; private javax.swing.JPanel paintingPanel;
private javax.swing.JLabel radiusLabel; 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.JLabel remainingTexturesLabel;
private javax.swing.JButton removeTextureButton; private javax.swing.JButton removeTextureButton;
private javax.swing.JToggleButton roughTerrainButton; private javax.swing.JToggleButton roughTerrainButton;
private javax.swing.JTextField scaleField;
private javax.swing.JLabel scaleLabel;
private javax.swing.JTextField shininessField; private javax.swing.JTextField shininessField;
private javax.swing.JToggleButton smoothTerrainButton; private javax.swing.JToggleButton smoothTerrainButton;
private javax.swing.ButtonGroup terrainModButtonGroup; private javax.swing.ButtonGroup terrainModButtonGroup;
@ -829,6 +1002,25 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
private javax.swing.JCheckBox wardIsoCheckBox; private javax.swing.JCheckBox wardIsoCheckBox;
// End of variables declaration//GEN-END:variables // 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 { private class ShininessVerifier extends InputVerifier {
@Override @Override
public boolean verify(JComponent input) { public boolean verify(JComponent input) {
@ -839,6 +1031,7 @@ public final class TerrainEditorTopComponent extends TopComponent implements Sce
if (f > 0) if (f > 0)
return true; return true;
} catch (Exception e) { } catch (Exception e) {
Toolkit.getDefaultToolkit().beep();
return false; 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, * Gets default instance. Do not use directly: reserved for *.settings files only,
* i.e. deserialization routines; otherwise you could get a non-deserialized instance. * 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); camController.setEditorController(editorController);
toolController.setEditorController(editorController); toolController.setEditorController(editorController);
toolController.setCameraController(camController); toolController.setCameraController(camController);
toolController.setTopComponent(this);
editorController.setToolController(toolController); editorController.setToolController(toolController);
toolController.setHeightToolRadius((float) radiusSlider.getValue() / (float) radiusSlider.getMaximum()); 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) { if (editorController.getTerrain(null) != null) {
//createTerrainButton.setEnabled(false); // only let the user add one terrain //createTerrainButton.setEnabled(false); // only let the user add one terrain
} }
brushVariablesScrollPane.setVisible(false);
} }
} }

@ -56,6 +56,7 @@ public class TerrainToolController extends SceneToolController {
private TerrainTool terrainTool; private TerrainTool terrainTool;
private TerrainEditorController editorController; private TerrainEditorController editorController;
private TerrainCameraController cameraController; private TerrainCameraController cameraController;
private TerrainEditorTopComponent topComponent;
private float toolRadius; private float toolRadius;
private float toolWeight; private float toolWeight;
@ -75,6 +76,10 @@ public class TerrainToolController extends SceneToolController {
this.cameraController = cameraController; this.cameraController = cameraController;
} }
public void setTopComponent(TerrainEditorTopComponent topComponent) {
this.topComponent = topComponent;
}
/** /**
* @param heightToolHeight percent of the slider * @param heightToolHeight percent of the slider
*/ */
@ -171,6 +176,7 @@ public class TerrainToolController extends SceneToolController {
if (terrainTool != null) { if (terrainTool != null) {
Vector3f point = getMarkerLocation(); Vector3f point = getMarkerLocation();
if (point != null) { if (point != null) {
topComponent.getExtraToolParams();
terrainTool.actionPrimary(point, selectedTextureIndex, jmeRootNode, editorController.getCurrentDataObject()); 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;
}
} }

@ -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;
}

@ -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;
}
}

@ -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<Vector2f> undoLocs;
List<Float> 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<Vector2f> locs = new ArrayList<Vector2f>();
List<Float> heights = new ArrayList<Float>();
// 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<r2; y++) {
// for (int x=0; x<r2; x++) {
int xfb=0,yfb=0;
for (int z = -radiusStepsZ; z < radiusStepsZ; z++) {
for (int x = -radiusStepsX; x < radiusStepsX; x++) {
float locX = worldLoc.x + (x * xStepAmount);
float locZ = worldLoc.z + (z * zStepAmount);
float height = fb.get(yfb*r2 + xfb);
if (isInRadius(locX - worldLoc.x, locZ - worldLoc.z, radius)) {
// see if it is in the radius of the tool
float h = calculateHeight(radius, height, locX - worldLoc.x, locZ - worldLoc.z);
locs.add(new Vector2f(locX, locZ));
heights.add(h);
}
xfb++;
}
yfb++;
xfb = 0;
}
undoLocs = locs;
undoHeights = heights;
// do the actual height adjustment
terrain.adjustHeight(locs, heights);
((Node)terrain).updateModelBound(); // or else we won't collide with it where we just edited
}
private boolean isInRadius(float x, float y, float radius) {
Vector2f point = new Vector2f(x, y);
// return true if the distance is less than equal to the radius
return point.length() <= radius;
}
private float calculateHeight(float radius, float heightFactor, float x, float z) {
// find percentage for each 'unit' in radius
Vector2f point = new Vector2f(x, z);
float val = point.length() / radius;
val = 1 - val;
if (val <= 0) {
val = 0;
}
return heightFactor * val * 0.1f; // 0.1 scales it down a bit to lower the impact of the tool
}
private void resetHeight(Terrain terrain, List<Vector2f> undoLocs, List<Float> undoHeights) {
List<Float> neg = new ArrayList<Float>();
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;
}
}

@ -33,6 +33,7 @@ package com.jme3.gde.terraineditor.tools;
import com.jme3.asset.AssetManager; import com.jme3.asset.AssetManager;
import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode; import com.jme3.gde.core.sceneexplorer.nodes.AbstractSceneExplorerNode;
import com.jme3.gde.terraineditor.ExtraToolParams;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
@ -180,5 +181,16 @@ public abstract class TerrainTool {
this.toolHintTextKey = toolHintTextKey; 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
}
} }

Loading…
Cancel
Save