commit 041f83a345f71cffa41b8fbed6011e10448ab9e3
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon Dec 17 19:57:06 2018 +0000

    Some fixes for Sphere; still not completely ok though.

diff --git a/src/main/java/org/distorted/library/mesh/MeshSphere.java b/src/main/java/org/distorted/library/mesh/MeshSphere.java
index 262a5d9..f721b4e 100644
--- a/src/main/java/org/distorted/library/mesh/MeshSphere.java
+++ b/src/main/java/org/distorted/library/mesh/MeshSphere.java
@@ -41,29 +41,29 @@ public class MeshSphere extends MeshBase
   // longitude of V3 is simply midpoint of V1 and V2 so we don't have to specify it here.
 
   private static final double FACES[][] =      {
-                                                   { 0.0  , 0.4*P,  A, 0.5*P },
+                                                   { 0.0*P, 0.4*P,  A, 0.5*P },
                                                    { 0.4*P, 0.8*P,  A, 0.5*P },
                                                    { 0.8*P, 1.2*P,  A, 0.5*P },  // 5 'top' faces with
                                                    { 1.2*P, 1.6*P,  A, 0.5*P },  // the North Pole
                                                    { 1.6*P, 2.0*P,  A, 0.5*P },
 
-                                                   { 0.0  , 0.4*P,  A,    -A },
+                                                   { 0.0*P, 0.4*P,  A,    -A },
                                                    { 0.4*P, 0.8*P,  A,    -A },
                                                    { 0.8*P, 1.2*P,  A,    -A },  // 5 faces mostly above
                                                    { 1.2*P, 1.6*P,  A,    -A },  // the equator
                                                    { 1.6*P, 2.0*P,  A,    -A },
 
-                                                   { 0.2  , 0.6*P, -A,     A },
+                                                   { 0.2*P, 0.6*P, -A,     A },
                                                    { 0.6*P, 1.0*P, -A,     A },
                                                    { 1.0*P, 1.4*P, -A,     A },  // 5 faces mostly below
                                                    { 1.4*P, 1.8*P, -A,     A },  // the equator
                                                    { 1.8*P, 0.2*P, -A,     A },
 
-                                                   { 0.2  , 0.6*P, -A,-0.5*P },
+                                                   { 0.2*P, 0.6*P, -A,-0.5*P },
                                                    { 0.6*P, 1.0*P, -A,-0.5*P },
                                                    { 1.0*P, 1.4*P, -A,-0.5*P },  // 5 'bottom' faces with
                                                    { 1.4*P, 1.8*P, -A,-0.5*P },  // the South Pole
-                                                   { 1.8*P, 0.2*P, -A,-0.5*P }
+                                                   { 1.8*P, 0.2*P, -A,-0.5*P },
                                                };
   private int currentVert;
   private int numVertices;
@@ -78,7 +78,7 @@ public class MeshSphere extends MeshBase
 
   private void computeNumberOfVertices(int level)
     {
-    numVertices = 20*level*(level+4) -2;
+    numVertices = NUMFACES*level*(level+4) -2;
     currentVert = 0;
     }
 
@@ -120,6 +120,8 @@ public class MeshSphere extends MeshBase
 
   private void repeatLast(float[] attribs)
     {
+    //android.util.Log.e("sphere", "repeat last!");
+
     if( currentVert>0 )
       {
       attribs[VERT_ATTRIBS*currentVert + POS_ATTRIB  ] = attribs[VERT_ATTRIBS*(currentVert-1) + POS_ATTRIB  ];
@@ -195,12 +197,14 @@ public class MeshSphere extends MeshBase
   private void newVertex(float[] attribs, int column, int row, int level,
                          double lonV1, double lonV2, double latV12, double latV3)
     {
-    double quotX = (double)column/(level-1);
-    double quotY = (double)row   /(level-1);
+    double quotX = (double)column/level;
+    double quotY = (double)row   /level;
 
     double lonPoint = midLongitude(lonV1,lonV2, (quotX+0.5*quotY) );
     double latPoint = midLatitude(latV12,latV3, quotY);
 
+    //android.util.Log.e("sphere", "newVertex: long:"+lonPoint+" lat:"+latPoint+" column="+column+" row="+row);
+
     addVertex(lonPoint,latPoint,attribs);
     }
 
