|
|
@ -8,6 +8,7 @@ import com.jme3.effect.ParticleMesh; |
|
|
|
import com.jme3.input.KeyInput; |
|
|
|
import com.jme3.input.KeyInput; |
|
|
|
import com.jme3.input.controls.ActionListener; |
|
|
|
import com.jme3.input.controls.ActionListener; |
|
|
|
import com.jme3.input.controls.KeyTrigger; |
|
|
|
import com.jme3.input.controls.KeyTrigger; |
|
|
|
|
|
|
|
import com.jme3.light.AmbientLight; |
|
|
|
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.material.RenderState.BlendMode; |
|
|
@ -18,6 +19,7 @@ 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.BloomFilter; |
|
|
|
import com.jme3.post.filters.DepthOfFieldFilter; |
|
|
|
import com.jme3.post.filters.DepthOfFieldFilter; |
|
|
|
|
|
|
|
import com.jme3.post.filters.FXAAFilter; |
|
|
|
import com.jme3.post.filters.LightScatteringFilter; |
|
|
|
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.Bucket; |
|
|
@ -70,13 +72,12 @@ public class TestPostWater extends SimpleApplication { |
|
|
|
createTerrain(mainScene); |
|
|
|
createTerrain(mainScene); |
|
|
|
DirectionalLight sun = new DirectionalLight(); |
|
|
|
DirectionalLight sun = new DirectionalLight(); |
|
|
|
sun.setDirection(lightDir); |
|
|
|
sun.setDirection(lightDir); |
|
|
|
sun.setColor(ColorRGBA.White.clone().multLocal(1.7f)); |
|
|
|
sun.setColor(ColorRGBA.White.clone().multLocal(1f)); |
|
|
|
mainScene.addLight(sun); |
|
|
|
mainScene.addLight(sun); |
|
|
|
|
|
|
|
|
|
|
|
DirectionalLight l = new DirectionalLight(); |
|
|
|
AmbientLight al = new AmbientLight(); |
|
|
|
l.setDirection(Vector3f.UNIT_Y.mult(-1)); |
|
|
|
al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f)); |
|
|
|
l.setColor(ColorRGBA.White.clone().multLocal(0.3f)); |
|
|
|
mainScene.addLight(al); |
|
|
|
// mainScene.addLight(l);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flyCam.setMoveSpeed(50); |
|
|
|
flyCam.setMoveSpeed(50); |
|
|
|
|
|
|
|
|
|
|
@ -97,49 +98,52 @@ public class TestPostWater extends SimpleApplication { |
|
|
|
|
|
|
|
|
|
|
|
mainScene.attachChild(sky); |
|
|
|
mainScene.attachChild(sky); |
|
|
|
cam.setFrustumFar(4000); |
|
|
|
cam.setFrustumFar(4000); |
|
|
|
//cam.setFrustumNear(100);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//private FilterPostProcessor fpp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Water Filter
|
|
|
|
water = new WaterFilter(rootNode, lightDir); |
|
|
|
water = new WaterFilter(rootNode, lightDir); |
|
|
|
|
|
|
|
water.setWaterColor(new ColorRGBA().setAsSrgb(0.0078f, 0.3176f, 0.5f, 1.0f)); |
|
|
|
|
|
|
|
water.setDeepWaterColor(new ColorRGBA().setAsSrgb(0.0039f, 0.00196f, 0.145f, 1.0f)); |
|
|
|
|
|
|
|
water.setUnderWaterFogDistance(80); |
|
|
|
|
|
|
|
water.setWaterTransparency(0.12f); |
|
|
|
|
|
|
|
water.setFoamIntensity(0.4f); |
|
|
|
|
|
|
|
water.setFoamHardness(0.3f); |
|
|
|
|
|
|
|
water.setFoamExistence(new Vector3f(0.8f, 8f, 1f)); |
|
|
|
|
|
|
|
water.setReflectionDisplace(50); |
|
|
|
|
|
|
|
water.setRefractionConstant(0.25f); |
|
|
|
|
|
|
|
water.setColorExtinction(new Vector3f(30, 50, 70)); |
|
|
|
|
|
|
|
water.setCausticsIntensity(0.4f); |
|
|
|
|
|
|
|
water.setWaveScale(0.003f); |
|
|
|
|
|
|
|
water.setMaxAmplitude(2f); |
|
|
|
|
|
|
|
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg")); |
|
|
|
|
|
|
|
water.setRefractionStrength(0.2f); |
|
|
|
|
|
|
|
water.setWaterHeight(initialWaterHeight); |
|
|
|
|
|
|
|
|
|
|
|
FilterPostProcessor fpp = new FilterPostProcessor(assetManager); |
|
|
|
//Bloom Filter
|
|
|
|
|
|
|
|
|
|
|
|
fpp.addFilter(water); |
|
|
|
|
|
|
|
BloomFilter bloom = new BloomFilter(); |
|
|
|
BloomFilter bloom = new BloomFilter(); |
|
|
|
//bloom.getE
|
|
|
|
|
|
|
|
bloom.setExposurePower(55); |
|
|
|
bloom.setExposurePower(55); |
|
|
|
bloom.setBloomIntensity(1.0f); |
|
|
|
bloom.setBloomIntensity(1.0f); |
|
|
|
fpp.addFilter(bloom); |
|
|
|
|
|
|
|
|
|
|
|
//Light Scattering Filter
|
|
|
|
LightScatteringFilter lsf = new LightScatteringFilter(lightDir.mult(-300)); |
|
|
|
LightScatteringFilter lsf = new LightScatteringFilter(lightDir.mult(-300)); |
|
|
|
lsf.setLightDensity(1.0f); |
|
|
|
lsf.setLightDensity(0.5f); |
|
|
|
fpp.addFilter(lsf); |
|
|
|
|
|
|
|
|
|
|
|
//Depth of field Filter
|
|
|
|
DepthOfFieldFilter dof = new DepthOfFieldFilter(); |
|
|
|
DepthOfFieldFilter dof = new DepthOfFieldFilter(); |
|
|
|
dof.setFocusDistance(0); |
|
|
|
dof.setFocusDistance(0); |
|
|
|
dof.setFocusRange(100); |
|
|
|
dof.setFocusRange(100); |
|
|
|
fpp.addFilter(dof); |
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fpp.addFilter(new TranslucentBucketFilter());
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fpp.setNumSamples(4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FilterPostProcessor fpp = new FilterPostProcessor(assetManager); |
|
|
|
|
|
|
|
|
|
|
|
water.setWaveScale(0.003f); |
|
|
|
fpp.addFilter(water); |
|
|
|
water.setMaxAmplitude(2f); |
|
|
|
fpp.addFilter(bloom); |
|
|
|
water.setFoamExistence(new Vector3f(1f, 4, 0.5f)); |
|
|
|
fpp.addFilter(dof); |
|
|
|
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg")); |
|
|
|
fpp.addFilter(lsf); |
|
|
|
//water.setNormalScale(0.5f);
|
|
|
|
fpp.addFilter(new FXAAFilter()); |
|
|
|
|
|
|
|
|
|
|
|
//water.setRefractionConstant(0.25f);
|
|
|
|
// fpp.addFilter(new GammaCorrectionFilter());
|
|
|
|
water.setRefractionStrength(0.2f); |
|
|
|
// fpp.addFilter(new TranslucentBucketFilter());
|
|
|
|
//water.setFoamHardness(0.6f);
|
|
|
|
// fpp.setNumSamples(4);
|
|
|
|
|
|
|
|
|
|
|
|
water.setWaterHeight(initialWaterHeight); |
|
|
|
|
|
|
|
uw = cam.getLocation().y < waterHeight; |
|
|
|
uw = cam.getLocation().y < waterHeight; |
|
|
|
|
|
|
|
|
|
|
|
waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false); |
|
|
|
waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false); |
|
|
@ -184,7 +188,7 @@ public class TestPostWater extends SimpleApplication { |
|
|
|
inputManager.addMapping("upRM", new KeyTrigger(KeyInput.KEY_PGUP)); |
|
|
|
inputManager.addMapping("upRM", new KeyTrigger(KeyInput.KEY_PGUP)); |
|
|
|
inputManager.addMapping("downRM", new KeyTrigger(KeyInput.KEY_PGDN)); |
|
|
|
inputManager.addMapping("downRM", new KeyTrigger(KeyInput.KEY_PGDN)); |
|
|
|
// createBox();
|
|
|
|
// createBox();
|
|
|
|
// createFire();
|
|
|
|
// createFire();
|
|
|
|
} |
|
|
|
} |
|
|
|
Geometry box; |
|
|
|
Geometry box; |
|
|
|
|
|
|
|
|
|
|
@ -234,9 +238,9 @@ public class TestPostWater extends SimpleApplication { |
|
|
|
fire.setLowLife(0.5f); |
|
|
|
fire.setLowLife(0.5f); |
|
|
|
fire.setHighLife(1.5f); |
|
|
|
fire.setHighLife(1.5f); |
|
|
|
fire.getParticleInfluencer().setVelocityVariation(0.3f); |
|
|
|
fire.getParticleInfluencer().setVelocityVariation(0.3f); |
|
|
|
fire.setLocalTranslation(-350, 40, 430); |
|
|
|
fire.setLocalTranslation(-600, 50, 300); |
|
|
|
|
|
|
|
|
|
|
|
fire.setQueueBucket(Bucket.Transparent); |
|
|
|
fire.setQueueBucket(Bucket.Translucent); |
|
|
|
rootNode.attachChild(fire); |
|
|
|
rootNode.attachChild(fire); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -296,21 +300,21 @@ public class TestPostWater extends SimpleApplication { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void simpleUpdate(float tpf) { |
|
|
|
public void simpleUpdate(float tpf) { |
|
|
|
super.simpleUpdate(tpf); |
|
|
|
super.simpleUpdate(tpf); |
|
|
|
// // box.updateGeometricState();
|
|
|
|
// box.updateGeometricState();
|
|
|
|
// time += tpf;
|
|
|
|
time += tpf; |
|
|
|
// waterHeight = (float) Math.cos(((time * 0.6f) % FastMath.TWO_PI)) * 1.5f;
|
|
|
|
waterHeight = (float) Math.cos(((time * 0.6f) % FastMath.TWO_PI)) * 1.5f; |
|
|
|
// water.setWaterHeight(initialWaterHeight + waterHeight);
|
|
|
|
water.setWaterHeight(initialWaterHeight + waterHeight); |
|
|
|
// if (water.isUnderWater() && !uw) {
|
|
|
|
if (water.isUnderWater() && !uw) { |
|
|
|
//
|
|
|
|
|
|
|
|
// waves.setDryFilter(new LowPassFilter(0.5f, 0.1f));
|
|
|
|
waves.setDryFilter(new LowPassFilter(0.5f, 0.1f)); |
|
|
|
// uw = true;
|
|
|
|
uw = true; |
|
|
|
// }
|
|
|
|
} |
|
|
|
// if (!water.isUnderWater() && uw) {
|
|
|
|
if (!water.isUnderWater() && uw) { |
|
|
|
// uw = false;
|
|
|
|
uw = false; |
|
|
|
// //waves.setReverbEnabled(false);
|
|
|
|
//waves.setReverbEnabled(false);
|
|
|
|
// waves.setDryFilter(new LowPassFilter(1, 1f));
|
|
|
|
waves.setDryFilter(new LowPassFilter(1, 1f)); |
|
|
|
// //waves.setDryFilter(new LowPassFilter(1,1f));
|
|
|
|
//waves.setDryFilter(new LowPassFilter(1,1f));
|
|
|
|
//
|
|
|
|
|
|
|
|
// }
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|