commit 2fcfce813a08e359576a4cc54b9ab2e540e36cf0
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Oct 13 11:40:48 2020 +0100

    CubitFactory: unify creating MeshPolygon bands.

diff --git a/src/main/java/org/distorted/objects/CubitFactory.java b/src/main/java/org/distorted/objects/CubitFactory.java
index 629c98e5..f6bd59f2 100644
--- a/src/main/java/org/distorted/objects/CubitFactory.java
+++ b/src/main/java/org/distorted/objects/CubitFactory.java
@@ -59,6 +59,114 @@ public class CubitFactory
     return mThis;
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// H - height of the band in the middle
+// alpha - angle of the edge  [0,90]
+// dist - often in a polygon the distance from edge to center is not 1, but something else.
+// This is the distance.
+// K - where to begin the second, much more flat part of the band. [0,1]
+// N - number of bands. N>=3
+//
+// theory: two distinct parts to the band:
+// 1) (0,B) - steep
+// 2) (B,1) - flat
+//
+// In first part, we have y = g(x) ; in second - y = g(f(x)) where
+//
+// g(x) = sqrt( R^2 - (x-D)^2 ) - R*cos(alpha)
+// f(x) = ((D-B)/(1-B)*x + B*(1-D)/(1-B)
+// h(x) = R*(sin(alpha) - sin(x))
+// R = H/(1-cos(alpha))
+// D = H*sin(alpha)
+// B = h(K*alpha)
+//
+// The N points are taken at:
+//
+// 1) in the second part, there are K2 = (N-3)/3 such points
+// 2) in the first - K1 = (N-3) - K2
+// 3) also, the 3 points 0,B,1
+//
+// so we have the sequence A[i] of N points
+//
+// 0
+// h((i+1)*(1-K)*alpha/(K1+1)) (i=0,1,...,K1-1)
+// B
+// (1-B)*(i+1)/(K2+1) + B   (i=0,i,...,K2-1)
+// 1
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private float f(float D, float B, float x)
+    {
+    return ((D-B)*x + B*(1-D))/(1-B);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private float g(float R, float D, float x, float cosAlpha)
+    {
+    float d = x-D;
+    return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private float h(float R, float sinAlpha, float x)
+    {
+    return R*(sinAlpha-(float)Math.sin(x));
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private float[] computeBands(float H, int alpha, float dist, float K, int N)
+    {
+    float[] bands = new float[2*N];
+
+    bands[0] = 1.0f;
+    bands[1] = 0.0f;
+
+    float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
+    float sinBeta = (float)Math.sin(beta);
+    float cosBeta = (float)Math.cos(beta);
+    float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
+    float D = R*sinBeta;
+    float B = h(R,sinBeta,K*beta);
+
+    if( D>1.0f )
+      {
+      for(int i=1; i<N; i++)
+        {
+        bands[2*i  ] = (float)(N-1-i)/(N-1);
+        bands[2*i+1] = H*(1-bands[2*i]);
+        }
+      }
+    else
+      {
+      int K2 = (int)((N-3)*K);
+      int K1 = (N-3)-K2;
+
+      for(int i=0; i<=K1; i++)
+        {
+        float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
+        float x = h(R,sinBeta,angle);
+        bands[2*i+2] = 1.0f - x;
+        bands[2*i+3] = g(R,D,x,cosBeta);
+        }
+
+      for(int i=0; i<=K2; i++)
+        {
+        float x = (1-B)*(i+1)/(K2+1) + B;
+        bands[2*K1+2 + 2*i+2] = 1.0f - x;
+        bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
+        }
+      }
+
+    bands[2*N-2] = 0.0f;
+    bands[2*N-1] =    H;
+
+    return bands;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
@@ -82,63 +190,36 @@ public class CubitFactory
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  MeshBase createFacesCube(int index)
+  MeshBase createFacesCube(int sizeIndex)
     {
-    final int MESHES=6;
-    MeshBase[] meshes = new MeshPolygon[MESHES];
-    int association = 1;
+    MeshBase[] meshes = new MeshPolygon[6];
 
-    float[] bands;
-    float D = 0.027f;
-    float E = 0.5f-D;
-    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
-    int extraI, extraV;
+    float E = 0.5f;
+    int extraI, extraV, num;
 
-    switch(index)
+    switch(sizeIndex)
       {
-      case 0 : bands = new float[] { 1.0f    ,-D,
-                                     1.0f-D/2,-D*0.55f,
-                                     1.0f-D  ,-D*0.25f,
-                                     1.0f-2*D, 0.0f,
-                                     0.50f   , 0.040f,
-                                     0.0f    , 0.048f };
-               extraI = 2;
-               extraV = 2;
-               break;
-      case 1 : bands = new float[] { 1.0f       ,-D,
-                                     1.0f-D*1.2f,-D*0.55f,
-                                     1.0f-2*D   , 0.0f,
-                                     0.50f      , 0.040f,
-                                     0.0f       , 0.048f };
-               extraI = 2;
-               extraV = 2;
-               break;
-      case 2 : bands = new float[] { 1.0f       ,-D,
-                                     1.0f-D*1.2f,-D*0.55f,
-                                     1.0f-2*D   , 0.0f,
-                                     0.50f      , 0.040f,
-                                     0.0f       , 0.048f };
-               extraI = 1;
-               extraV = 2;
-               break;
-      default: bands = new float[] { 1.0f    ,-D,
-                                     1.0f-2*D, 0.0f,
-                                     0.50f   , 0.025f,
-                                     0.0f    , 0.030f };
-               extraI = 1;
-               extraV = 1;
-               break;
+      case 0 : num = 6; extraI = 2; extraV = 2; break;
+      case 1 : num = 5; extraI = 2; extraV = 2; break;
+      case 2 : num = 5; extraI = 1; extraV = 2; break;
+      default: num = 4; extraI = 1; extraV = 1; break;
       }
 
-    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
-    meshes[0].setEffectAssociation(0,association,0);
+    float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
+    float[] bands = computeBands(0.048f,35,E,0.7f,num);
 
-    for(int i=1; i<MESHES; i++)
-      {
-      association <<=1;
-      meshes[i] = meshes[0].copy(true);
-      meshes[i].setEffectAssociation(0,association,0);
-      }
+    meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
+    meshes[0].setEffectAssociation(0,1,0);
+    meshes[1] = meshes[0].copy(true);
+    meshes[1].setEffectAssociation(0,2,0);
+    meshes[2] = meshes[0].copy(true);
+    meshes[2].setEffectAssociation(0,4,0);
+    meshes[3] = meshes[0].copy(true);
+    meshes[3].setEffectAssociation(0,8,0);
+    meshes[4] = meshes[0].copy(true);
+    meshes[4].setEffectAssociation(0,16,0);
+    meshes[5] = meshes[0].copy(true);
+    meshes[5].setEffectAssociation(0,32,0);
 
     return new MeshJoined(meshes);
     }
@@ -147,21 +228,12 @@ public class CubitFactory
 
   MeshBase createFacesSkewbCorner()
     {
-    float D = 0.02f;
+    MeshBase[] meshes = new MeshBase[6];
+
     float E = 0.5f;
     float F = SQ2/2;
-
     float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
-
-    float[] bands0 = { 1.0f    , 0,
-                       1.0f-2*D, D*0.25f,
-                       1.0f-4*D, D*0.35f,
-                       1.0f-8*D, D*0.6f,
-                       0.60f   , D*1.0f,
-                       0.30f   , D*1.375f,
-                       0.0f    , D*1.4f };
-
-    MeshBase[] meshes = new MeshBase[6];
+    float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
 
     meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
     meshes[0].setEffectAssociation(0,1,0);
@@ -171,7 +243,7 @@ public class CubitFactory
     meshes[2].setEffectAssociation(0,4,0);
 
     float[] vertices1 = { 0,0, F,0, F/2,(SQ3/2)*F };
-    float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
+    float[] bands1 = computeBands(0,0,1,0,3);
 
     meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
     meshes[3].setEffectAssociation(0,8,0);
@@ -187,24 +259,17 @@ public class CubitFactory
 
   MeshBase createFacesSkewbFace()
     {
-    float D = 0.03f;
+    MeshBase[] meshes = new MeshBase[5];
+
     float E = SQ2/4;
     float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
+    float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
 
-    float[] bands0 = { 1.0f    , 0,
-                       1.0f-D/2, D*0.30f,
-                       1.0f- D , D*0.50f,
-                       1.0f-2*D, D*0.80f,
-                       0.60f   , D*1.40f,
-                       0.30f   , D*1.60f,
-                       0.0f    , D*1.70f };
-
-    MeshBase[] meshes = new MeshBase[5];
     meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
     meshes[0].setEffectAssociation(0,1,0);
 
     float[] vertices1 = { -E,-SQ3*E, +E,-SQ3*E, 0,0 };
-    float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
+    float[] bands1 = computeBands(0,0,1,0,3);
 
     meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
     meshes[1].setEffectAssociation(0,2,0);
@@ -222,32 +287,29 @@ public class CubitFactory
 
   MeshBase createFacesOcta()
     {
-    int association = 1;
+    MeshBase[] meshes = new MeshPolygon[8];
 
-    float C = 0.06f;
-    float D = 0.031f;
     float E = SQ3/2;
     float F = 0.5f;
-
     float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
+    float[] bands = computeBands(0.05f,35,F,0.8f,6);
 
-    float[] bands = new float[] { 1.0f    , 0,
-                                  1.0f  -C, D*0.55f,
-                                  1.0f-2*C, D*0.85f,
-                                  1.0f-4*C, D*1.20f,
-                                  0.5f    , D*1.40f,
-                                  0.0f    , D*1.50f };
-
-    MeshBase[] meshes = new MeshPolygon[8];
     meshes[0] = new MeshPolygon(vertices, bands, 2,2);
-    meshes[0].setEffectAssociation(0,association,0);
-
-    for(int i=1; i<8; i++)
-      {
-      association <<= 1;
-      meshes[i] = meshes[0].copy(true);
-      meshes[i].setEffectAssociation(0,association,0);
-      }
+    meshes[0].setEffectAssociation(0,1,0);
+    meshes[1] = meshes[0].copy(true);
+    meshes[1].setEffectAssociation(0,2,0);
+    meshes[2] = meshes[0].copy(true);
+    meshes[2].setEffectAssociation(0,4,0);
+    meshes[3] = meshes[0].copy(true);
+    meshes[3].setEffectAssociation(0,8,0);
+    meshes[4] = meshes[0].copy(true);
+    meshes[4].setEffectAssociation(0,16,0);
+    meshes[5] = meshes[0].copy(true);
+    meshes[5].setEffectAssociation(0,32,0);
+    meshes[6] = meshes[0].copy(true);
+    meshes[6].setEffectAssociation(0,64,0);
+    meshes[7] = meshes[0].copy(true);
+    meshes[7].setEffectAssociation(0,128,0);
 
     return new MeshJoined(meshes);
     }
@@ -257,31 +319,20 @@ public class CubitFactory
   MeshBase createFacesTetra()
     {
     MeshBase[] meshes = new MeshBase[4];
-    int association = 1;
 
-    float C = 0.06f;
-    float D = 0.035f;
     float E = SQ3/2;
     float F = 0.5f;
-
     float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
-
-    float[] bands = new float[] { 1.0f    , 0,
-                                  1.0f  -C, D*0.50f,
-                                  1.0f-2*C, D*0.80f,
-                                  1.0f-4*C, D*1.10f,
-                                  0.5f    , D*1.30f,
-                                  0.0f    , D*1.35f };
+    float[] bands = computeBands(0.05f,35,F,0.8f,6);
 
     meshes[0] = new MeshPolygon(vertices, bands, 2,2);
-    meshes[0].setEffectAssociation(0,association,0);
-
-    for(int i=1; i<4; i++)
-      {
-      association <<= 1;
-      meshes[i] = meshes[0].copy(true);
-      meshes[i].setEffectAssociation(0,association,0);
-      }
+    meshes[0].setEffectAssociation(0,1,0);
+    meshes[1] = meshes[0].copy(true);
+    meshes[1].setEffectAssociation(0,2,0);
+    meshes[2] = meshes[0].copy(true);
+    meshes[2].setEffectAssociation(0,4,0);
+    meshes[3] = meshes[0].copy(true);
+    meshes[3].setEffectAssociation(0,8,0);
 
     return new MeshJoined(meshes);
     }
@@ -290,33 +341,20 @@ public class CubitFactory
 
   MeshBase createFacesDino()
     {
-    final int MESHES=4;
+    MeshBase[] meshes = new MeshPolygon[4];
 
-    float D = 0.02f;
     float E = 0.5f*SQ2;
     float F = 0.5f;
-
-    float[] bands0 = { 1.0f    , 0,
-                       1.0f-2*D, D*0.25f,
-                       1.0f-4*D, D*0.35f,
-                       1.0f-8*D, D*0.6f,
-                       0.60f   , D*1.0f,
-                       0.30f   , D*1.375f,
-                       0.0f    , D*1.4f };
-
     float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
+    float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
 
-    MeshBase[] meshes = new MeshPolygon[MESHES];
     meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
     meshes[0].setEffectAssociation(0,1,0);
     meshes[1] = meshes[0].copy(true);
     meshes[1].setEffectAssociation(0,2,0);
 
-    float[] bands1 = { 1.0f    , 0,
-                       0.50f   , 0.10f,
-                       0.0f    , 0.20f };
-
     float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
+    float[] bands1 = computeBands(0.02f,45,F/3,0.2f,3);
 
     meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
     meshes[2].setEffectAssociation(0,4,0);
@@ -330,21 +368,13 @@ public class CubitFactory
 
   MeshBase createFacesHelicopterCorner()
     {
-    float D = 0.02f;
+    MeshBase[] meshes = new MeshBase[6];
+
     float E = 0.5f;
     float F = SQ2/4;
-
+    float G = 1.0f/12;
     float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
-
-    float[] bands0 = { 1.0f    , 0,
-                       1.0f-2*D, D*0.25f,
-                       1.0f-4*D, D*0.35f,
-                       1.0f-8*D, D*0.6f,
-                       0.60f   , D*1.0f,
-                       0.30f   , D*1.375f,
-                       0.0f    , D*1.4f };
-
-    MeshBase[] meshes = new MeshBase[6];
+    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
 
     meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
     meshes[0].setEffectAssociation(0,1,0);
@@ -353,9 +383,8 @@ public class CubitFactory
     meshes[2] = meshes[0].copy(true);
     meshes[2].setEffectAssociation(0,4,0);
 
-    float[] vertices1 = { -F,-1.0f/12, +F,-1.0f/12, 0,1.0f/6 };
-    float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
-
+    float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
+    float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
     meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
     meshes[3].setEffectAssociation(0,8,0);
     meshes[4] = meshes[3].copy(true);
@@ -372,40 +401,24 @@ public class CubitFactory
     {
     MeshBase[] meshes = new MeshBase[4];
 
-    float D = 0.02f;
     float E = 0.5f;
     float F = SQ2/4;
     float G = 1.0f/12;
-
     float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
-
-    float[] bands0 = { 1.0f    , 0,
-                       1.0f-2*D, D*0.25f,
-                       1.0f-4*D, D*0.35f,
-                       1.0f-8*D, D*0.6f,
-                       0.60f   , D*1.0f,
-                       0.30f   , D*1.375f,
-                       0.0f    , D*1.4f };
+    float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
 
     meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
     meshes[0].setEffectAssociation(0,1,0);
 
     float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
-
-    float[] bands1 = { 1.0f   , 0.0f,
-                       0.5f   , 0.01f,
-                       0.0f   , 0.01f };
+    float[] bands1 = computeBands(0.01f,45,F,0.0f,3);
 
     meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
     meshes[1].setEffectAssociation(0,2,0);
 
     float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
 
-    float[] bands2 = { 1.0f   , 0.0f,
-                       0.5f   , 0.01f,
-                       0.0f   , 0.01f };
-
-    meshes[2] = new MeshPolygon(vertices2, bands2, 1, 3);
+    meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
     meshes[2].setEffectAssociation(0,4,0);
     meshes[3] = meshes[2].copy(true);
     meshes[3].setEffectAssociation(0,8,0);
@@ -417,32 +430,18 @@ public class CubitFactory
 
   MeshBase createFacesRediEdge()
     {
-    final int MESHES=6;
+    MeshBase[] meshes = new MeshPolygon[6];
 
-    float C = 0.02f;
-    float D = 0.02f;
     float F = 0.25f;
-
-    float[] bands0 = { 1.0f    , 0,
-                       1.0f-2*C, D*0.25f,
-                       1.0f-4*C, D*0.35f,
-                       1.0f-8*C, D*0.6f,
-                       0.60f   , D*1.0f,
-                       0.30f   , D*1.375f,
-                       0.0f    , D*1.4f };
-
     float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
+    float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
 
-    MeshBase[] meshes = new MeshPolygon[MESHES];
     meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
     meshes[0].setEffectAssociation(0,1,0);
     meshes[1] = meshes[0].copy(true);
     meshes[1].setEffectAssociation(0,2,0);
 
-    float[] bands1 = { 1.0f    , 0,
-                       0.90f   , D,
-                       0.0f    , D };
-
+    float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3);
     float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
 
     meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
@@ -450,16 +449,11 @@ public class CubitFactory
     meshes[3] = meshes[2].copy(true);
     meshes[3].setEffectAssociation(0,8,0);
 
-    float[] bands2 = { 1.0f    , 0,
-                       0.90f   , D,
-                       0.0f    , D };
-
     float X = 0.25f*SQ2;
     float Y = SQ6/16;
-
     float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
 
-    meshes[4] = new MeshPolygon(vertices2, bands2, 1, 1);
+    meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
     meshes[4].setEffectAssociation(0,16,0);
     meshes[5] = meshes[4].copy(true);
     meshes[5].setEffectAssociation(0,32,0);
@@ -471,22 +465,13 @@ public class CubitFactory
 
   MeshBase createFacesRediCorner()
     {
-    final int MESHES=6;
-    MeshBase[] meshes = new MeshBase[MESHES];
+    MeshBase[] meshes = new MeshBase[6];
 
-    float C = 0.027f;
-    float D = 0.027f;
     float E = 0.5f;
-    float[] vertices1 = { -E,-E, +E,-E, +E,+E, -E,+E };
-
-    float[] bands1 = new float[] { 1.0f   ,-D,
-                                  1.0f-C/2,-D*0.55f,
-                                  1.0f-C  ,-D*0.25f,
-                                  1.0f-2*C, 0.0f,
-                                  0.50f   , D*1.5f,
-                                  0.0f    , D*1.75f };
+    float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
+    float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
 
-    meshes[0] = new MeshPolygon(vertices1,bands1,2,2);
+    meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
     meshes[0].setEffectAssociation(0,1,0);
     meshes[1] = meshes[0].copy(true);
     meshes[1].setEffectAssociation(0,2,0);
@@ -495,13 +480,11 @@ public class CubitFactory
 
     float F = SQ2/2;
     float X = 0.5f;
+    float G = 0.72f;
+    float[] vertices1 = { -E,+F, -E+X,0, -E,-F, -E*G,-F, +E*G,-F, +E,-F, +E-X,0, +E,+F, +E*G,+F, -E*G,+F };
+    float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
 
-    float[] vertices2 = { -E,+F, -E+X,0, -E,-F, +E,-F, +E-X,0, +E,+F };
-
-    float[] bands2 = new float[] { 1.0f,0.0f,
-                                   0.0f,0.0f };
-
-    meshes[3] = new MeshPolygon(vertices2,bands2,0,0);
+    meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
     meshes[3].setEffectAssociation(0,8,0);
     meshes[4] = meshes[3].copy(true);
     meshes[4].setEffectAssociation(0,16,0);
@@ -511,6 +494,8 @@ public class CubitFactory
     return new MeshJoined(meshes);
     }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// EFFECTS
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   VertexEffect[] createVertexEffectsCube()
@@ -694,8 +679,8 @@ public class CubitFactory
     float F = 0.5f;
     final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
 
-    Static1D angle1 = new Static1D(+ANGLE);
-    Static1D angle2 = new Static1D(-ANGLE);
+    Static1D angle1 = new Static1D(-ANGLE);
+    Static1D angle2 = new Static1D(+ANGLE);
     Static3D axisX  = new Static3D(1,0,0);
     Static3D axisY  = new Static3D(0,1,0);
     Static3D axisZ  = new Static3D(0,-1,1);
@@ -1081,7 +1066,7 @@ public class CubitFactory
     verticesType2[0] = new Static3D(-E, 0, 0);
     verticesType2[1] = new Static3D( 0,-E, 0);
     verticesType2[2] = new Static3D( 0, 0,-E);
-    roundCorners(mesh,roundingCenter,verticesType2,0.10f,0.20f);
+    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
 
     mesh.mergeEffComponents();
 
@@ -1106,7 +1091,7 @@ public class CubitFactory
     Static3D[] verticesType2 = new Static3D[2];
     verticesType2[0] = new Static3D(-E+E/3, E/3  , 0);
     verticesType2[1] = new Static3D( E/3  ,-E+E/3, 0);
-    roundCorners(mesh,roundingCenter,verticesType2,0.10f,0.20f);
+    roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
 
     mesh.mergeEffComponents();
     mesh.addEmptyTexComponent();
@@ -1125,12 +1110,9 @@ public class CubitFactory
     for( VertexEffect effect : effects ) mesh.apply(effect);
 
     Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
-    Static3D[] vertices = new Static3D[4];
+    Static3D[] vertices = new Static3D[2];
     vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
     vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
-    vertices[2] = new Static3D(0.0f, 0.0f,-1.5f);
-    vertices[3] = new Static3D(0.0f,-1.5f, 0.0f);
-
     roundCorners(mesh,center,vertices,0.06f,0.20f);
 
     mesh.mergeEffComponents();
diff --git a/src/main/java/org/distorted/objects/TwistyCube.java b/src/main/java/org/distorted/objects/TwistyCube.java
index f89cb249..8c98660b 100644
--- a/src/main/java/org/distorted/objects/TwistyCube.java
+++ b/src/main/java/org/distorted/objects/TwistyCube.java
@@ -129,7 +129,7 @@ class TwistyCube extends TwistyObject
     {
     float F =  0.5f;
     float R = 0.10f;
-    float S = 0.10f;
+    float S = 0.08f;
     float[] vertices = { -F,-F, +F,-F, +F,+F, -F,+F};
 
     drawRoundedPolygon(canvas, paint, left, vertices, S, FACE_COLORS[face], R);
diff --git a/src/main/java/org/distorted/objects/TwistyDino.java b/src/main/java/org/distorted/objects/TwistyDino.java
index 632761a9..6b8a1e5a 100644
--- a/src/main/java/org/distorted/objects/TwistyDino.java
+++ b/src/main/java/org/distorted/objects/TwistyDino.java
@@ -209,7 +209,7 @@ public abstract class TwistyDino extends TwistyObject
   void createFaceTexture(Canvas canvas, Paint paint, int face, int left)
     {
     float F = 0.5f;
-    float R = 0.032f;
+    float R = 0.025f;
     float S = 0.05f;
     float[] vertices = { -F,F/3, 0,-2*F/3, +F,F/3 };
 
diff --git a/src/main/java/org/distorted/objects/TwistyObject.java b/src/main/java/org/distorted/objects/TwistyObject.java
index 3c490cf6..28395efe 100644
--- a/src/main/java/org/distorted/objects/TwistyObject.java
+++ b/src/main/java/org/distorted/objects/TwistyObject.java
@@ -69,7 +69,7 @@ public abstract class TwistyObject extends DistortedNode
   private static final float MAX_SIZE_CHANGE = 1.35f;
   private static final float MIN_SIZE_CHANGE = 0.8f;
 
-  private static boolean mCreateFromDMesh = true;
+  private static boolean mCreateFromDMesh = false;
 
   private static final Static3D CENTER = new Static3D(0,0,0);
   private static final int POST_ROTATION_MILLISEC = 500;
