I have made some changes to ProjectedGrid.java to be able to change the aspect ratio in a subclass. A wierd aspect ratio is needed to make the world look ok if you dont have square pixles, and the water edges did not follow
### Eclipse Workspace Patch 1.0
#P jMonkeyEngine
Index: src/com/jmex/effects/water/ProjectedGrid.java
===================================================================
--- src/com/jmex/effects/water/ProjectedGrid.java (revision 4862)
+++ src/com/jmex/effects/water/ProjectedGrid.java (working copy)
@@ -108,8 +108,8 @@
public boolean useReal = false;
private Vector3f projectorLoc = new Vector3f();
private Timer timer;
- private Camera cam;
- private float fovY = 45.0f;
+ protected Camera cam;
+ protected float fovY = 45.0f;
private HeightGenerator heightGenerator;
private float textureScale;
@@ -189,7 +189,7 @@
}
ProjectedTextureUtil.matrixLookAt( projectorLoc, realPoint, Vector3f.UNIT_Y, modelViewMatrix );
- ProjectedTextureUtil.matrixProjection( fovY + 10.0f, viewPortWidth / viewPortHeight, cam.getFrustumNear(), cam.getFrustumFar(), projectionMatrix );
+ ProjectedTextureUtil.matrixProjection( fovY + 10.0f, getAspectRatio(), cam.getFrustumNear(), cam.getFrustumFar(), projectionMatrix );
modelViewProjectionInverse.set( modelViewMatrix ).multLocal( projectionMatrix );
modelViewProjectionInverse.invertLocal();
@@ -290,10 +290,13 @@
normBuf.put( normBufArray );
}
+ protected float getAspectRatio() {
+ return viewPortWidth / viewPortHeight;
+ }
private Matrix4f getMinMax( Vector3f fakeLoc, Vector3f fakePoint, Camera cam ) {
Matrix4f rangeMatrix;
ProjectedTextureUtil.matrixLookAt( fakeLoc, fakePoint, Vector3f.UNIT_Y, modelViewMatrix1 );
- ProjectedTextureUtil.matrixProjection( fovY, viewPortWidth / viewPortHeight, cam.getFrustumNear(), cam.getFrustumFar(), projectionMatrix1 );
+ ProjectedTextureUtil.matrixProjection( fovY, getAspectRatio(), cam.getFrustumNear(), cam.getFrustumFar(), projectionMatrix1 );
modelViewProjection1.set( modelViewMatrix1 ).multLocal( projectionMatrix1 );
modelViewProjectionInverse1.set( modelViewProjection1 ).invertLocal();
Edit: Added eclipse patch code in stead of manual diff
Edit2: Put back the "fovY +10.0f" stuff. se cooments underneeth