Better TestMultiPostWater

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10457 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 12 years ago
parent 08edd2715c
commit 1871a1831d
  1. 44
      engine/src/test/jme3test/water/TestMultiPostWater.java

@ -1,30 +1,17 @@
package jme3test.water; package jme3test.water;
import com.jme3.app.SimpleApplication; import com.jme3.app.SimpleApplication;
import com.jme3.audio.AudioNode;
import com.jme3.audio.LowPassFilter;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.light.DirectionalLight; import com.jme3.light.DirectionalLight;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.ColorRGBA; import com.jme3.math.ColorRGBA;
import com.jme3.math.FastMath; import com.jme3.math.FastMath;
import com.jme3.math.Quaternion; import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f; import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor; import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.BloomFilter;
import com.jme3.post.filters.DepthOfFieldFilter;
import com.jme3.post.filters.LightScatteringFilter;
import com.jme3.renderer.Camera; import com.jme3.renderer.Camera;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.renderer.queue.RenderQueue.ShadowMode; import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings; import com.jme3.system.AppSettings;
import com.jme3.terrain.geomipmap.TerrainQuad; import com.jme3.terrain.geomipmap.TerrainQuad;
import com.jme3.terrain.heightmap.AbstractHeightMap; import com.jme3.terrain.heightmap.AbstractHeightMap;
@ -39,22 +26,27 @@ import java.util.List;
/** /**
* test * test
*
* @author normenhansen * @author normenhansen
*/ */
public class TestMultiPostWater extends SimpleApplication { public class TestMultiPostWater extends SimpleApplication {
private Vector3f lightDir = new Vector3f(-4.9236743f, -1.27054665f, 5.896916f); private Vector3f lightDir = new Vector3f(-4.9236743f, -1.27054665f, 5.896916f);
private WaterFilter water; private WaterFilter water;
TerrainQuad terrain; private TerrainQuad terrain;
Material matRock; private Material matRock;
AudioNode waves; private static float WATER_HEIGHT = 90;
LowPassFilter underWaterAudioFilter = new LowPassFilter(0.5f, 0.1f);
LowPassFilter underWaterReverbFilter = new LowPassFilter(0.5f, 0.1f);
LowPassFilter aboveWaterAudioFilter = new LowPassFilter(1, 1);
public static void main(String[] args) { public static void main(String[] args) {
TestMultiPostWater app = new TestMultiPostWater(); TestMultiPostWater app = new TestMultiPostWater();
app.setSettings(new AppSettings(true)); AppSettings s = new AppSettings(true);
s.setRenderer(AppSettings.LWJGL_OPENGL2);
s.setAudioRenderer(AppSettings.LWJGL_OPENAL);
//
// s.setRenderer("JOGL");
// s.setAudioRenderer("JOAL");
app.setSettings(s);
app.start(); app.start();
} }
@ -77,7 +69,7 @@ public class TestMultiPostWater extends SimpleApplication {
//cam.setLocation(new Vector3f(-700, 100, 300)); //cam.setLocation(new Vector3f(-700, 100, 300));
//cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z)); //cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
cam.setLocation(new Vector3f(-327.21957f, 61.6459f, 126.884346f)); cam.setLocation(new Vector3f(-327.21957f, 251.6459f, 126.884346f));
cam.setRotation(new Quaternion().fromAngles(new float[]{FastMath.PI * 0.06f, FastMath.PI * 0.65f, 0})); cam.setRotation(new Quaternion().fromAngles(new float[]{FastMath.PI * 0.06f, FastMath.PI * 0.65f, 0}));
@ -99,13 +91,13 @@ public class TestMultiPostWater extends SimpleApplication {
water.setFoamExistence(new Vector3f(1f, 4, 0.5f)); water.setFoamExistence(new Vector3f(1f, 4, 0.5f));
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg")); water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
water.setRefractionStrength(0.2f); water.setRefractionStrength(0.2f);
water.setWaterHeight(0.8f); water.setWaterHeight(WATER_HEIGHT);
fpp.addFilter(water); fpp.addFilter(water);
WaterFilter water2 = new WaterFilter(rootNode, lightDir); WaterFilter water2 = new WaterFilter(rootNode, lightDir);
water2.setCenter(new Vector3f(-280.46027f, -24.971727f, -271.71976f)); water2.setCenter(new Vector3f(-280.46027f, -24.971727f, -271.71976f));
water2.setRadius(260); water2.setRadius(260);
water2.setWaterHeight(0.8f); water2.setWaterHeight(WATER_HEIGHT);
water2.setUseFoam(false); water2.setUseFoam(false);
water2.setUseRipples(false); water2.setUseRipples(false);
water2.setDeepWaterColor(ColorRGBA.Brown); water2.setDeepWaterColor(ColorRGBA.Brown);
@ -125,13 +117,12 @@ public class TestMultiPostWater extends SimpleApplication {
WaterFilter water3 = new WaterFilter(rootNode, lightDir); WaterFilter water3 = new WaterFilter(rootNode, lightDir);
water3.setCenter(new Vector3f(319.6663f, -18.367947f, -236.67674f)); water3.setCenter(new Vector3f(319.6663f, -18.367947f, -236.67674f));
water3.setRadius(260); water3.setRadius(260);
water3.setWaterHeight(0.8f); water3.setWaterHeight(WATER_HEIGHT);
water3.setWaveScale(0.003f); water3.setWaveScale(0.003f);
water3.setMaxAmplitude(2f); water3.setMaxAmplitude(2f);
water3.setFoamExistence(new Vector3f(1f, 4, 0.5f)); water3.setFoamExistence(new Vector3f(1f, 4, 0.5f));
water3.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg")); water3.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
water3.setRefractionStrength(0.2f); water3.setRefractionStrength(0.2f);
water3.setWaterHeight(0.8f);
water3.setDeepWaterColor(ColorRGBA.Red); water3.setDeepWaterColor(ColorRGBA.Red);
water3.setWaterColor(ColorRGBA.Red.mult(2.0f)); water3.setWaterColor(ColorRGBA.Red.mult(2.0f));
water3.setLightColor(ColorRGBA.Red); water3.setLightColor(ColorRGBA.Red);
@ -139,7 +130,7 @@ public class TestMultiPostWater extends SimpleApplication {
viewPort.addProcessor(fpp); viewPort.addProcessor(fpp);
//fpp.setNumSamples(4);
} }
private void createTerrain(Node rootNode) { private void createTerrain(Node rootNode) {
@ -192,6 +183,5 @@ public class TestMultiPostWater extends SimpleApplication {
@Override @Override
public void simpleUpdate(float tpf) { public void simpleUpdate(float tpf) {
} }
} }

Loading…
Cancel
Save