Water Filter :

- fixed particle emitter disorientation when using the WaterFilter

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7610 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent 983f1414c7
commit 3746238df3
  1. 23
      engine/src/desktop-fx/com/jme3/water/WaterFilter.java

@ -112,6 +112,9 @@ public class WaterFilter extends Filter {
private boolean underWater;
private float underWaterFogDistance = 120;
private float causticsIntensity = 0.5f;
private RenderManager renderManager;
private ViewPort viewPort;
/**
* Create a Water Filter
@ -135,11 +138,6 @@ public class WaterFilter extends Filter {
public void preFrame(float tpf) {
time = time + (tpf * speed);
material.setFloat("Time", time);
savedTpf = tpf;
}
@Override
public void postQueue(RenderManager renderManager, ViewPort viewPort) {
Camera sceneCam = viewPort.getCamera();
biasMatrix.mult(sceneCam.getViewProjectionMatrix(), textureProjMatrix);
material.setMatrix4("TextureProjMatrix", textureProjMatrix);
@ -174,6 +172,7 @@ public class WaterFilter extends Filter {
float planeDistance = plane.pseudoDistance(vars.vect1);
vars.vect2.set(plane.getNormal()).multLocal(planeDistance * 2.0f);
vars.vect3.set(vars.vect1.subtractLocal(vars.vect2)).subtractLocal(loc).normalizeLocal().negateLocal();
reflectionCam.lookAt(targetLocation, vars.vect3);
assert vars.unlock();
@ -188,18 +187,28 @@ public class WaterFilter extends Filter {
renderManager.setHandleTranslucentBucket(true);
rtb = false;
}
renderManager.renderViewPort(reflectionView, savedTpf);
renderManager.renderViewPort(reflectionView, tpf);
if (!rtb) {
renderManager.setHandleTranslucentBucket(false);
}
renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer());
renderManager.setCamera(sceneCam, false);
renderManager.getRenderer().setFrameBuffer(viewPort.getOutputFrameBuffer());
underWater = false;
} else {
underWater = true;
}
}
@Override
public void init(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) {
super.init(manager, renderManager, vp, w, h);
this.renderManager=renderManager;
this.viewPort=vp;
}
@Override
public Material getMaterial() {
return material;

Loading…
Cancel
Save