WaterFilter : the size of the reflection map can now be changed at run time.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10476 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 12 years ago
parent c1efd70e3d
commit c591260ab5
  1. 5
      engine/src/core-effects/com/jme3/water/WaterFilter.java
  2. 29
      engine/src/test/jme3test/water/TestPostWater.java

@ -853,6 +853,11 @@ public class WaterFilter extends Filter {
*/ */
public void setReflectionMapSize(int reflectionMapSize) { public void setReflectionMapSize(int reflectionMapSize) {
this.reflectionMapSize = reflectionMapSize; this.reflectionMapSize = reflectionMapSize;
reflectionPass.init(renderManager.getRenderer(), reflectionMapSize, reflectionMapSize, Format.RGBA8, Format.Depth);
reflectionCam.resize(reflectionMapSize, reflectionMapSize, true);
reflectionProcessor.setReflectionBuffer(reflectionPass.getRenderFrameBuffer());
material.setTexture("ReflectionMap", reflectionPass.getRenderedTexture());
} }
/** /**

@ -5,6 +5,7 @@ import com.jme3.audio.AudioNode;
import com.jme3.audio.LowPassFilter; import com.jme3.audio.LowPassFilter;
import com.jme3.effect.ParticleEmitter; import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh; import com.jme3.effect.ParticleMesh;
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.DirectionalLight; import com.jme3.light.DirectionalLight;
@ -38,6 +39,7 @@ import java.util.List;
/** /**
* test * test
*
* @author normenhansen * @author normenhansen
*/ */
public class TestPostWater extends SimpleApplication { public class TestPostWater extends SimpleApplication {
@ -150,7 +152,6 @@ public class TestPostWater extends SimpleApplication {
viewPort.addProcessor(fpp); viewPort.addProcessor(fpp);
inputManager.addListener(new ActionListener() { inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) { public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed) { if (isPressed) {
if (name.equals("foam1")) { if (name.equals("foam1")) {
@ -162,12 +163,23 @@ public class TestPostWater extends SimpleApplication {
if (name.equals("foam3")) { if (name.equals("foam3")) {
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam3.jpg")); water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam3.jpg"));
} }
if (name.equals("upRM")) {
water.setReflectionMapSize(Math.min(water.getReflectionMapSize() * 2, 4096));
System.out.println("Reflection map size : " + water.getReflectionMapSize());
}
if (name.equals("downRM")) {
water.setReflectionMapSize(Math.max(water.getReflectionMapSize() / 2, 32));
System.out.println("Reflection map size : " + water.getReflectionMapSize());
}
} }
} }
}, "foam1", "foam2", "foam3"); }, "foam1", "foam2", "foam3", "upRM", "downRM");
inputManager.addMapping("foam1", new KeyTrigger(keyInput.KEY_1)); inputManager.addMapping("foam1", new KeyTrigger(KeyInput.KEY_1));
inputManager.addMapping("foam2", new KeyTrigger(keyInput.KEY_2)); inputManager.addMapping("foam2", new KeyTrigger(KeyInput.KEY_2));
inputManager.addMapping("foam3", new KeyTrigger(keyInput.KEY_3)); inputManager.addMapping("foam3", new KeyTrigger(KeyInput.KEY_3));
inputManager.addMapping("upRM", new KeyTrigger(KeyInput.KEY_PGUP));
inputManager.addMapping("downRM", new KeyTrigger(KeyInput.KEY_PGDN));
// createBox(); // createBox();
// createFire(); // createFire();
} }
@ -200,7 +212,9 @@ public class TestPostWater extends SimpleApplication {
} }
private void createFire() { private void createFire() {
/** Uses Texture from jme3-test-data library! */ /**
* Uses Texture from jme3-test-data library!
*/
ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30); ParticleEmitter fire = new ParticleEmitter("Emitter", ParticleMesh.Type.Triangle, 30);
Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md"); Material mat_red = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png")); mat_red.setTexture("Texture", assetManager.loadTexture("Effects/Explosion/flame.png"));
@ -273,8 +287,9 @@ public class TestPostWater extends SimpleApplication {
//This part is to emulate tides, slightly varrying the height of the water plane //This part is to emulate tides, slightly varrying the height of the water plane
private float time = 0.0f; private float time = 0.0f;
private float waterHeight = 0.0f; private float waterHeight = 0.0f;
private float initialWaterHeight = 0.8f; private float initialWaterHeight = 90f;//0.8f;
private boolean uw = false; private boolean uw = false;
@Override @Override
public void simpleUpdate(float tpf) { public void simpleUpdate(float tpf) {
super.simpleUpdate(tpf); super.simpleUpdate(tpf);

Loading…
Cancel
Save