[committed]ProjectedGrid.java. Changes to improve subclassing

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

So, fovY +10 is changed to fovY other than the private -> protected change.  Why is that needed ?

Core-Dump said:

So, fovY +10 is changed to fovY other than the private -> protected change.  Why is that needed ?


What was the purpose it served in the first place?  I'm not sure of the rationale..

buestad said:
Edit: added eclipse patch code in stead of manual diff


Aside from the comments that say Eclipse, you'll get the same thing from diff -u ;)
Core-Dump said:

So, fovY +10 is changed to fovY other than the private -> protected change.  Why is that needed ?


The private -> protected stuff plus the new method getAspectRatio() is needed because we subclass this class.

We use multiple cameras, and have to set the current camera to the ProjectedGrid. Also we need to set the aspect ratio to a different one than the screens actual aspect ratio. We have for example three plasma screens on top of each other connected together which report a resolutoin of 1920x1080. That looks really wierd with the default aspect ratio.

The +10 thing was probably just a safety margin to make the water edges go abit outside the canvas, to be absolutely sure that you dont se the edge. I dont think you need it. It may lower the fps, but I can do some more test before I remove it

the fovY +10.0f seems to be a good idea after all. I will update the patch code

committed