commit f7936f2f07157e8ff313d7ce4f82d343647c08dc
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed Dec 16 15:31:09 2020 +0100

    Rex Cube - new mesh, textures and icon.

diff --git a/src/main/java/org/distorted/examples/meshfile/FactoryCubit.java b/src/main/java/org/distorted/examples/meshfile/FactoryCubit.java
index 0edff64..58d5afd 100644
--- a/src/main/java/org/distorted/examples/meshfile/FactoryCubit.java
+++ b/src/main/java/org/distorted/examples/meshfile/FactoryCubit.java
@@ -43,7 +43,7 @@ class FactoryCubit
   private static final int   IVY_N = 8;
   private static final float IVY_C = 0.59f;
   private static final float IVY_M = 0.35f;
-  private static final float REX_D = 0.03f;
+  private static final float REX_D = 0.2f;
   private static final int   REX_N = 5;
 
   private static final Static1D RADIUS = new Static1D(1);
@@ -697,62 +697,31 @@ class FactoryCubit
 
   MeshBase createFacesRexEdge()
     {
-    MeshBase[] meshes = new MeshBase[1];
-
-    final float angle = (float)Math.PI/(6*REX_N);
-    float[] vertices = new float[4*REX_N + 6];
-    final float H = 1.0f - SQ3/2;
-    final float D = 0.5f - REX_D;
-    final float F = 0.5f*H;
-
-    final float V1x = -D;
-    final float V1y = +D + F - 0.5f;
-    final float V2x = 0.0f;
-    final float V2y = -F;
-
-    final float C1x = -D;
-    final float C1y = -D + F - 0.5f;
-    final float C2x = +D;
-    final float C2y = C1y;
-
-    for(int i=0; i<REX_N; i++)
-      {
-      writeVertex(C1x,C1y,V1x,V1y,-i*angle, vertices, 2*i          );
-      writeVertex(C2x,C2y,V2x,V2y,-i*angle, vertices, 2*i + 2*REX_N);
-      }
-
-    vertices[4*REX_N  ] = +D;
-    vertices[4*REX_N+1] = +F-REX_D;
-    vertices[4*REX_N+2] = +D;
-    vertices[4*REX_N+3] = +F;
-    vertices[4*REX_N+4] = -D;
-    vertices[4*REX_N+5] = +F;
+    MeshBase[] meshes = new MeshPolygon[6];
 
-/*
-    vertices[0] = V1x;
-    vertices[1] = V1y;
-    vertices[2] = V2x;
-    vertices[3] = V2y;
-    vertices[4] = +D;
-    vertices[5] = +F-REX_D;
-    vertices[6] = +D;
-    vertices[7] = +F;
-    vertices[8] = -D;
-    vertices[9] = +F;
-*/
-    float[] bands0 = computeBands(+0.02f, 9,0.5f,0.5f,5);
-    float[] bands1 = computeBands( 0.00f,45,0.5f,0.0f,2);
+    float E = 0.5f - REX_D;
+    float F = 0.5f;
+    float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
+    float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
 
-    meshes[0] = new MeshPolygon(vertices,bands0,1,2);
+    meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
     meshes[0].setEffectAssociation(0,1,0);
- /*
     meshes[1] = meshes[0].copy(true);
     meshes[1].setEffectAssociation(0,2,0);
-    meshes[2] = new MeshPolygon(vertices,bands1,0,0);
+
+    float G = (float)Math.sqrt(E*E+F*F);
+    float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
+    float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
+
+    meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
     meshes[2].setEffectAssociation(0,4,0);
     meshes[3] = meshes[2].copy(true);
     meshes[3].setEffectAssociation(0,8,0);
-*/
+    meshes[4] = meshes[2].copy(true);
+    meshes[4].setEffectAssociation(0,16,0);
+    meshes[5] = meshes[2].copy(true);
+    meshes[5].setEffectAssociation(0,32,0);
+
     return new MeshJoined(meshes);
     }
 
@@ -1187,26 +1156,54 @@ class FactoryCubit
 
   VertexEffect[] createVertexEffectsRexEdge()
     {
-    final float H = 1.0f - SQ3/2;
-    final float D = 0.5f - REX_D;
-    final float F = H*D;
+    float E = 0.5f - REX_D;
+    float F = 0.5f;
+    float G = (float)Math.sqrt(E*E+F*F);
+    float A = (float)((180/Math.PI)*Math.asin(E/G));
 
-    Static3D move  = new Static3D(0.0f,   -F, 0.0f);
-    Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
-    Static3D axisX = new Static3D(1.0f, 0.0f, 0.0f);
-    Static3D axisY = new Static3D(0.0f, 1.0f, 0.0f);
+    Static3D move1 = new Static3D(    0.0f, -E/3, 0.0f);
+    Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
+
+    Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
+    Static3D center1= new Static3D(  -F, 0.0f, 0.0f);
+    Static3D center2= new Static3D(  +F, 0.0f, 0.0f);
+    Static3D axisX  = new Static3D(1.0f, 0.0f, 0.0f);
+    Static3D axisY  = new Static3D(0.0f, 1.0f, 0.0f);
+    Static3D axisZ  = new Static3D(0.0f, 0.0f, 1.0f);
 
     Static1D angle180 = new Static1D(180);
     Static1D angle90  = new Static1D( 90);
+    Static1D angle270 = new Static1D(270);
+    Static1D angle1   = new Static1D(+A);
+    Static1D angle2   = new Static1D(-A);
 
-    VertexEffect[] effect = new VertexEffect[3];
-
-    effect[0] = new VertexEffectMove(move);
-    effect[1] = new VertexEffectRotate(angle180, axisY, center);
-    effect[2] = new VertexEffectRotate(angle90 , axisX, center);
+    VertexEffect[] effect = new VertexEffect[12];
 
-    effect[1].setMeshAssociation(10,-1);  // meshes 1 & 3
-    effect[2].setMeshAssociation(10,-1);  // meshes 1 & 3
+    effect[0] = new VertexEffectMove(move1);
+    effect[1] = new VertexEffectMove(move2);
+    effect[2] = new VertexEffectRotate(  angle90, axisX, center0 );
+    effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
+    effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
+    effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
+    effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
+    effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
+    effect[8] = new VertexEffectRotate(   angle1, axisY, center1);
+    effect[9] = new VertexEffectRotate(   angle2, axisY, center2);
+    effect[10]= new VertexEffectRotate(   angle2, axisZ, center1);
+    effect[11]= new VertexEffectRotate(   angle1, axisZ, center2);
+
+    effect[0].setMeshAssociation( 3,-1);  // meshes 0 & 1
+    effect[1].setMeshAssociation(60,-1);  // meshes 2,3,4,5
+    effect[2].setMeshAssociation( 2,-1);  // meshes 1
+    effect[3].setMeshAssociation(12,-1);  // meshes 2,3
+    effect[4].setMeshAssociation(48,-1);  // meshes 4,5
+    effect[5].setMeshAssociation(32,-1);  // mesh 5
+    effect[6].setMeshAssociation( 8,-1);  // apply to mesh 3
+    effect[7].setMeshAssociation( 2,-1);  // apply to mesh 1
+    effect[8].setMeshAssociation(16,-1);  // apply to mesh 4
+    effect[9].setMeshAssociation(32,-1);  // apply to mesh 5
+    effect[10].setMeshAssociation(4,-1);  // apply to mesh 2
+    effect[11].setMeshAssociation(8,-1);  // apply to mesh 3
 
     return effect;
     }
@@ -1561,7 +1558,7 @@ class FactoryCubit
     MeshBase mesh = createFacesRexEdge();
     VertexEffect[] effects = createVertexEffectsRexEdge();
     for( VertexEffect effect : effects ) mesh.apply(effect);
-
+/*
     Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
     Static3D[] vertices = new Static3D[2];
     vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
@@ -1569,7 +1566,7 @@ class FactoryCubit
     roundCorners(mesh,center,vertices,0.03f,0.10f);
 
     mesh.mergeEffComponents();
-
+*/
     return mesh;
     }
   }
