commit 12e379d6dc091432d8c95e1ec2497446284765f8
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Fri Feb 21 11:27:50 2020 +0000

    Rename MeshFlat MeshRectangles.

diff --git a/src/main/java/org/distorted/library/mesh/MeshFlat.java b/src/main/java/org/distorted/library/mesh/MeshFlat.java
deleted file mode 100644
index 22b0e4a..0000000
--- a/src/main/java/org/distorted/library/mesh/MeshFlat.java
+++ /dev/null
@@ -1,200 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                               //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// Distorted is free software: you can redistribute it and/or modify                             //
-// it under the terms of the GNU General Public License as published by                          //
-// the Free Software Foundation, either version 2 of the License, or                             //
-// (at your option) any later version.                                                           //
-//                                                                                               //
-// Distorted is distributed in the hope that it will be useful,                                  //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
-// GNU General Public License for more details.                                                  //
-//                                                                                               //
-// You should have received a copy of the GNU General Public License                             //
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library.mesh;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Create a flat, rectangular grid.
- * <p>
- * Perfect if you just want to display a flat Texture. If you are not planning to apply any VERTEX
- * effects to it, use MeshFlat(1,1), i.e. a Quad. Otherwise, create more vertices for more realistic effects!
- */
-public class MeshFlat extends MeshBase
-  {
-  private int mCols, mRows;
-  private int remainingVert;
-  private int numVertices;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Create a flat, full grid.
-
-  private void computeNumberOfVertices(int cols, int rows)
-     {
-     mRows=rows;
-     mCols=cols;
-
-     if( cols==1 && rows==1 )
-       {
-       numVertices = 4;
-       }
-     else
-       {
-       numVertices = 2*( mRows*mCols +2*mRows - 1) +2*(mCols>=2 ? mRows:0) +
-                     (mCols>=2 && mRows>=2 ? 2*mRows-2 : 1);
-       }
-
-     //android.util.Log.e("MeshFlat","vertices="+numVertices+" rows="+mRows+" cols="+mCols);
-
-     remainingVert = numVertices;
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int addVertex(int vertex, float x, float y, float[] attribs)
-     {
-     remainingVert--;
-
-     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = x-0.5f;
-     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = 0.5f-y;
-     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = 0.0f;
-
-     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = 0.0f;
-     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = 0.0f;
-     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = 1.0f;
-
-     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = (x-0.5f);
-     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = (0.5f-y);
-     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.01f   ;  // Inflated surface needs to be slightly in front
-
-     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = x;
-     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f-y;
-
-     return vertex+1;
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private int repeatLast(int vertex, float[] attribs)
-     {
-     //android.util.Log.e("MeshFlat", "repeating last vertex!");
-
-     if( vertex>0 )
-       {
-       remainingVert--;
-
-       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB  ];
-       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+1];
-       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+2];
-
-       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB  ];
-       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+1];
-       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+2];
-
-       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB  ];
-       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+1];
-       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+2];
-
-       attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB  ];
-       attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB+1];
-
-       vertex++;
-       }
-
-     return vertex;
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void buildGrid(float[] attribs)
-     {
-     boolean lastBlockIsNE = false;
-     boolean currentBlockIsNE;
-     int vertex = 0;
-
-     float x,y;
-     final float X = 1.0f/mCols;
-     final float Y = 1.0f/mRows;
-
-     //android.util.Log.d("MeshFlat", "buildGrid");
-
-     y = 0.0f;
-
-     for(int row=0; row<mRows; row++)
-       {
-       x = 0.0f;
-
-       for(int col=0; col<mCols; col++)
-         {
-         currentBlockIsNE = (2*row<=mRows-1)^(2*col<=mCols-1);
-
-         if( col==0 || (lastBlockIsNE^currentBlockIsNE) )
-           {
-           if( row!=0 && col==0 ) vertex = repeatLast(vertex,attribs);
-           vertex= addVertex( vertex, x, y+(currentBlockIsNE?0:Y), attribs);
-           if( row!=0 && col==0 ) vertex = repeatLast(vertex,attribs);
-           if( lastBlockIsNE^currentBlockIsNE)  vertex = repeatLast(vertex,attribs);
-           vertex= addVertex( vertex, x, y+(currentBlockIsNE?Y:0), attribs);
-           }
-         vertex= addVertex( vertex, x+X, y+(currentBlockIsNE?0:Y), attribs);
-         vertex= addVertex( vertex, x+X, y+(currentBlockIsNE?Y:0), attribs);
-
-         lastBlockIsNE = currentBlockIsNE;
-         x+=X;
-         }
-
-       y+=Y;
-       }
-
-     //android.util.Log.d("MeshFlat", "buildGrid done");
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/*
-  private static String debug(float[] val, int stop)
-     {
-     String ret="";
-
-     for(int i=0; i<val.length; i++)
-        {
-        if( i%stop==0 ) ret+="\n";
-        ret+=(" "+val[i]);
-        }
-
-     return ret;
-     }
-*/
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// PUBLIC API
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Creates the underlying grid of vertices, normals and texture coords.
- *
- * @param cols Number of columns in the grid.
- * @param rows Number of rows in the grid.
- */
- public MeshFlat(int cols, int rows)
-    {
-    super(0.0f);
-    computeNumberOfVertices(cols,rows);
-
-    float[] attribs= new float[VERT_ATTRIBS*numVertices];
-
-    buildGrid(attribs);
-
-    //android.util.Log.e("MeshFlat", "dataLen="+numVertices);
-    //android.util.Log.d("MeshFlat", "attribs: "+debug(attribs,VERT_ATTRIBS) );
-
-    if( remainingVert!=0 )
-      android.util.Log.d("MeshFlat", "remainingVert " +remainingVert );
-
-    setAttribs(attribs);
-    }
- }
\ No newline at end of file
diff --git a/src/main/java/org/distorted/library/mesh/MeshQuad.java b/src/main/java/org/distorted/library/mesh/MeshQuad.java
index 5353988..4d2acf2 100644
--- a/src/main/java/org/distorted/library/mesh/MeshQuad.java
+++ b/src/main/java/org/distorted/library/mesh/MeshQuad.java
@@ -24,7 +24,7 @@ package org.distorted.library.mesh;
  * Create a quad, i.e. two triangles with vertices at (+-0.5,+-0.5).
  * <p>
  * Mainly to have a simple example showing how to create a Mesh; otherwise a MeshQuad can be perfectly
- * emulated by a MeshFlat(1,1) or a MeshCubes(1,1,0).
+ * emulated by a MeshRectangles(1,1) or a MeshCubes(1,1,0).
  */
 public class MeshQuad extends MeshBase
   {
diff --git a/src/main/java/org/distorted/library/mesh/MeshRectangles.java b/src/main/java/org/distorted/library/mesh/MeshRectangles.java
new file mode 100644
index 0000000..5c7f2bc
--- /dev/null
+++ b/src/main/java/org/distorted/library/mesh/MeshRectangles.java
@@ -0,0 +1,200 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2016 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.library.mesh;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Create a flat, rectangular grid.
+ * <p>
+ * Perfect if you just want to display a flat Texture. If you are not planning to apply any VERTEX
+ * effects to it, use MeshRectangles(1,1), i.e. a Quad. Otherwise, create more vertices for more realistic effects!
+ */
+public class MeshRectangles extends MeshBase
+  {
+  private int mCols, mRows;
+  private int remainingVert;
+  private int numVertices;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Create a flat, full grid.
+
+  private void computeNumberOfVertices(int cols, int rows)
+     {
+     mRows=rows;
+     mCols=cols;
+
+     if( cols==1 && rows==1 )
+       {
+       numVertices = 4;
+       }
+     else
+       {
+       numVertices = 2*( mRows*mCols +2*mRows - 1) +2*(mCols>=2 ? mRows:0) +
+                     (mCols>=2 && mRows>=2 ? 2*mRows-2 : 1);
+       }
+
+     //android.util.Log.e("MeshRectangles","vertices="+numVertices+" rows="+mRows+" cols="+mCols);
+
+     remainingVert = numVertices;
+     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private int addVertex(int vertex, float x, float y, float[] attribs)
+     {
+     remainingVert--;
+
+     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = x-0.5f;
+     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = 0.5f-y;
+     attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = 0.0f;
+
+     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = 0.0f;
+     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = 0.0f;
+     attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = 1.0f;
+
+     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = (x-0.5f);
+     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = (0.5f-y);
+     attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = 0.01f   ;  // Inflated surface needs to be slightly in front
+
+     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = x;
+     attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = 1.0f-y;
+
+     return vertex+1;
+     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private int repeatLast(int vertex, float[] attribs)
+     {
+     //android.util.Log.e("MeshRectangles", "repeating last vertex!");
+
+     if( vertex>0 )
+       {
+       remainingVert--;
+
+       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB  ];
+       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+1];
+       attribs[VERT_ATTRIBS*vertex + POS_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + POS_ATTRIB+2];
+
+       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB  ];
+       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+1];
+       attribs[VERT_ATTRIBS*vertex + NOR_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + NOR_ATTRIB+2];
+
+       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB  ];
+       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+1];
+       attribs[VERT_ATTRIBS*vertex + INF_ATTRIB+2] = attribs[VERT_ATTRIBS*(vertex-1) + INF_ATTRIB+2];
+
+       attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB  ] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB  ];
+       attribs[VERT_ATTRIBS*vertex + TEX_ATTRIB+1] = attribs[VERT_ATTRIBS*(vertex-1) + TEX_ATTRIB+1];
+
+       vertex++;
+       }
+
+     return vertex;
+     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void buildGrid(float[] attribs)
+     {
+     boolean lastBlockIsNE = false;
+     boolean currentBlockIsNE;
+     int vertex = 0;
+
+     float x,y;
+     final float X = 1.0f/mCols;
+     final float Y = 1.0f/mRows;
+
+     //android.util.Log.d("MeshRectangles", "buildGrid");
+
+     y = 0.0f;
+
+     for(int row=0; row<mRows; row++)
+       {
+       x = 0.0f;
+
+       for(int col=0; col<mCols; col++)
+         {
+         currentBlockIsNE = (2*row<=mRows-1)^(2*col<=mCols-1);
+
+         if( col==0 || (lastBlockIsNE^currentBlockIsNE) )
+           {
+           if( row!=0 && col==0 ) vertex = repeatLast(vertex,attribs);
+           vertex= addVertex( vertex, x, y+(currentBlockIsNE?0:Y), attribs);
+           if( row!=0 && col==0 ) vertex = repeatLast(vertex,attribs);
+           if( lastBlockIsNE^currentBlockIsNE)  vertex = repeatLast(vertex,attribs);
+           vertex= addVertex( vertex, x, y+(currentBlockIsNE?Y:0), attribs);
+           }
+         vertex= addVertex( vertex, x+X, y+(currentBlockIsNE?0:Y), attribs);
+         vertex= addVertex( vertex, x+X, y+(currentBlockIsNE?Y:0), attribs);
+
+         lastBlockIsNE = currentBlockIsNE;
+         x+=X;
+         }
+
+       y+=Y;
+       }
+
+     //android.util.Log.d("MeshRectangles", "buildGrid done");
+     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/*
+  private static String debug(float[] val, int stop)
+     {
+     String ret="";
+
+     for(int i=0; i<val.length; i++)
+        {
+        if( i%stop==0 ) ret+="\n";
+        ret+=(" "+val[i]);
+        }
+
+     return ret;
+     }
+*/
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Creates the underlying grid of vertices, normals and texture coords.
+ *
+ * @param cols Number of columns in the grid.
+ * @param rows Number of rows in the grid.
+ */
+ public MeshRectangles(int cols, int rows)
+    {
+    super(0.0f);
+    computeNumberOfVertices(cols,rows);
+
+    float[] attribs= new float[VERT_ATTRIBS*numVertices];
+
+    buildGrid(attribs);
+
+    //android.util.Log.e("MeshRectangles", "dataLen="+numVertices);
+    //android.util.Log.d("MeshRectangles", "attribs: "+debug(attribs,VERT_ATTRIBS) );
+
+    if( remainingVert!=0 )
+      android.util.Log.d("MeshRectangles", "remainingVert " +remainingVert );
+
+    setAttribs(attribs);
+    }
+ }
\ No newline at end of file
