From 3746238df36124ef69a8c7fc2a39cb449ad87376 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Mon, 13 Jun 2011 17:19:42 +0000 Subject: [PATCH] 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 --- .../com/jme3/water/WaterFilter.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/engine/src/desktop-fx/com/jme3/water/WaterFilter.java b/engine/src/desktop-fx/com/jme3/water/WaterFilter.java index 092221577..49927b00a 100644 --- a/engine/src/desktop-fx/com/jme3/water/WaterFilter.java +++ b/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;