- add rotation fix for SimpleWater plane , thanks to @batkid

http://jmonkeyengine.org/groups/effects/forum/topic/changing-the-rotation-of-simplewaterprocessor/

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7147 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
nor..67 2011-03-31 22:42:13 +00:00
parent 43c0d1edfe
commit d80616ef89

View File

@ -54,6 +54,7 @@ import com.jme3.texture.Image.Format;
import com.jme3.texture.Texture.WrapMode; import com.jme3.texture.Texture.WrapMode;
import com.jme3.texture.Texture2D; import com.jme3.texture.Texture2D;
import com.jme3.ui.Picture; import com.jme3.ui.Picture;
import com.jme3.util.TempVars;
/** /**
* *
@ -179,7 +180,16 @@ public class SimpleWaterProcessor implements SceneProcessor {
sceneCam.getFrustumRight(), sceneCam.getFrustumRight(),
sceneCam.getFrustumTop(), sceneCam.getFrustumTop(),
sceneCam.getFrustumBottom()); sceneCam.getFrustumBottom());
reflectionCam.lookAt(targetLocation, Vector3f.UNIT_Y); TempVars vars=TempVars.get();
vars.lock();
// tempVec and calcVect are just temporary vector3f objects
vars.vect1.set( sceneCam.getLocation() ).addLocal( sceneCam.getUp() );
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();
// now set the up vector
reflectionCam.lookAt(targetLocation, vars.vect3);
vars.unlock();
if (inv) { if (inv) {
reflectionCam.setAxes(reflectionCam.getLeft().negateLocal(), reflectionCam.getUp(), reflectionCam.getDirection().negateLocal()); reflectionCam.setAxes(reflectionCam.getLeft().negateLocal(), reflectionCam.getUp(), reflectionCam.getDirection().negateLocal());
} }