commit 418aa554d619c7c5e6dc32e78b24b7fe177300e9
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu Jul 30 23:32:19 2020 +0100

    Beginnings of support for a new Object: the Dino.

diff --git a/src/main/java/org/distorted/objects/RubikDino.java b/src/main/java/org/distorted/objects/RubikDino.java
new file mode 100644
index 00000000..731c9e59
--- /dev/null
+++ b/src/main/java/org/distorted/objects/RubikDino.java
@@ -0,0 +1,209 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2020 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Magic Cube.                                                              //
+//                                                                                               //
+// Magic Cube 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.                                                           //
+//                                                                                               //
+// Magic Cube 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 Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.objects;
+
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+
+import org.distorted.library.main.DistortedEffects;
+import org.distorted.library.main.DistortedTexture;
+import org.distorted.library.mesh.MeshBase;
+import org.distorted.library.mesh.MeshRectangles;
+import org.distorted.library.type.Static3D;
+import org.distorted.library.type.Static4D;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class RubikDino extends RubikObject
+{
+  static final float SQ3 = (float)Math.sqrt(3);
+
+  // the four rotation axis of a RubikDino. Must be normalized.
+  static final Static3D[] AXIS = new Static3D[]
+         {
+           new Static3D(+SQ3/3,+SQ3/3,+SQ3/3),
+           new Static3D(+SQ3/3,+SQ3/3,-SQ3/3),
+           new Static3D(+SQ3/3,-SQ3/3,+SQ3/3),
+           new Static3D(+SQ3/3,-SQ3/3,-SQ3/3)
+         };
+
+  private static final int[] FACE_COLORS = new int[]
+         {
+           0xffffff00, 0xffffffff,   // AXIS[0]right (right-YELLOW) AXIS[0]left (left  -WHITE)
+           0xff0000ff, 0xff00ff00,   // AXIS[1]right (top  -BLUE  ) AXIS[1]left (bottom-GREEN)
+           0xffff0000, 0xffb5651d    // AXIS[2]right (front-RED   ) AXIS[2]left (back  -BROWN)
+         };
+
+  // All legal rotation quats of a RubikDino
+  private static final Static4D[] QUATS = new Static4D[]
+         {
+           new Static4D(  0.0f,  0.0f,  0.0f,  1.0f ),
+           new Static4D(  0.5f,  0.5f,  0.5f,  0.5f ),
+           new Static4D(  0.5f,  0.5f, -0.5f,  0.5f ),
+           new Static4D(  0.5f, -0.5f,  0.5f,  0.5f ),
+           new Static4D(  0.5f, -0.5f, -0.5f,  0.5f ),
+           new Static4D(  0.5f,  0.5f,  0.5f, -0.5f ),
+           new Static4D(  0.5f,  0.5f, -0.5f, -0.5f ),
+           new Static4D(  0.5f, -0.5f,  0.5f, -0.5f ),
+           new Static4D(  0.5f, -0.5f, -0.5f, -0.5f ),
+           new Static4D(  1.0f,  0.0f,  0.0f,  0.0f ),
+           new Static4D(  0.0f,  0.0f,  1.0f,  0.0f ),
+           new Static4D(  0.0f, -1.0f,  0.0f,  0.0f )
+         };
+
+  private static MeshBase[] mMeshes;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  RubikDino(int size, Static4D quat, DistortedTexture texture,
+            MeshRectangles mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
+    {
+    super(size, 60, quat, texture, mesh, effects, moves, RubikObjectList.DINO, res, scrWidth);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  float getScreenRatio()
+    {
+    return 0.5f;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  Static4D[] getQuats()
+    {
+    return QUATS;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  int getNumFaces()
+    {
+    return FACE_COLORS.length;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  Static3D[] getCubitPositions(int size)
+    {
+    // TODO
+
+    return null;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  MeshBase createCubitMesh(int cubit)
+    {
+    // TODO
+
+    return null;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top, int side)
+    {
+    float STROKE = 0.06f*side;
+    float OFF = STROKE/2 -1;
+    float OFF2 = 0.5f*side + OFF;
+    float HEIGHT = side - OFF;
+    float RADIUS = side/12.0f;
+    float ARC1_H = 0.2f*side;
+    float ARC1_W = side*0.5f;
+    float ARC2_W = 0.153f*side;
+    float ARC2_H = 0.905f*side;
+    float ARC3_W = side-ARC2_W;
+
+    paint.setAntiAlias(true);
+    paint.setStrokeWidth(STROKE);
+    paint.setColor(FACE_COLORS[face]);
+    paint.setStyle(Paint.Style.FILL);
+
+    canvas.drawRect(left,top,left+side,top+side,paint);
+
+    paint.setColor(INTERIOR_COLOR);
+    paint.setStyle(Paint.Style.STROKE);
+
+    canvas.drawLine(           left, HEIGHT,  side       +left, HEIGHT, paint);
+    canvas.drawLine(      OFF +left, side  ,       OFF2  +left,      0, paint);
+    canvas.drawLine((side-OFF)+left, side  , (side-OFF2) +left,      0, paint);
+
+    canvas.drawArc( ARC1_W-RADIUS+left, ARC1_H-RADIUS, ARC1_W+RADIUS+left, ARC1_H+RADIUS, 225, 90, false, paint);
+    canvas.drawArc( ARC2_W-RADIUS+left, ARC2_H-RADIUS, ARC2_W+RADIUS+left, ARC2_H+RADIUS, 105, 90, false, paint);
+    canvas.drawArc( ARC3_W-RADIUS+left, ARC2_H-RADIUS, ARC3_W+RADIUS+left, ARC2_H+RADIUS, 345, 90, false, paint);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC API
+
+  public Static3D[] getRotationAxis()
+    {
+    return AXIS;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public int getBasicAngle()
+    {
+    return 3;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float returnMultiplier()
+    {
+    // TODO
+
+    return 0;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float returnRotationFactor(float offset)
+    {
+    return 1.0f;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  public float[] getRowChances()
+    {
+    int size = getSize();
+    float[] chances = new float[size];
+
+    for(int i=0; i<size; i++)
+      {
+      chances[i] = (i+1.0f) / size;
+      }
+
+    return chances;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// TODO  (only needed for solvers - there are no Dino solvers ATM)
+
+  public String retObjectString()
+    {
+    return "";
+    }
+
+}
diff --git a/src/main/java/org/distorted/objects/RubikDinoMovement.java b/src/main/java/org/distorted/objects/RubikDinoMovement.java
new file mode 100644
index 00000000..f2feae69
--- /dev/null
+++ b/src/main/java/org/distorted/objects/RubikDinoMovement.java
@@ -0,0 +1,37 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2020 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Magic Cube.                                                              //
+//                                                                                               //
+// Magic Cube 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.                                                           //
+//                                                                                               //
+// Magic Cube 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 Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.objects;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class RubikDinoMovement extends RubikObjectMovement
+{
+  RubikDinoMovement()
+    {
+    super(RubikDino.AXIS, 1.5f, 0.5f, 0.5f);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  boolean isInsideFace(float[] p)
+    {
+    return ( p[0]<=0.5f && p[0]>=-0.5f && p[1]<=0.5f && p[1]>=-0.5f );
+    }
+}
diff --git a/src/main/java/org/distorted/objects/RubikObject.java b/src/main/java/org/distorted/objects/RubikObject.java
index d3206bcd..6231ada8 100644
--- a/src/main/java/org/distorted/objects/RubikObject.java
+++ b/src/main/java/org/distorted/objects/RubikObject.java
@@ -645,7 +645,7 @@ public abstract class RubikObject extends DistortedNode
 
   public int getCubit(float[] point3D)
     {
-    float dist, minDist = Float. MAX_VALUE;
+    float dist, minDist = Float.MAX_VALUE;
     int currentBest=-1;
     float multiplier = returnMultiplier();
 
diff --git a/src/main/java/org/distorted/objects/RubikObjectList.java b/src/main/java/org/distorted/objects/RubikObjectList.java
index 2d697845..b9f479fd 100644
--- a/src/main/java/org/distorted/objects/RubikObjectList.java
+++ b/src/main/java/org/distorted/objects/RubikObjectList.java
@@ -54,6 +54,14 @@ public enum RubikObjectList
          RubikPyraminx.class,
          new RubikPyraminxMovement()
        ),
+
+  DINO (
+         new int[][] {
+                       {3 , 10, R.raw.pyra3, R.drawable.ui_small_pyra3, R.drawable.ui_medium_pyra3, R.drawable.ui_big_pyra3, R.drawable.ui_huge_pyra3} ,
+                     },
+         RubikDino.class,
+         new RubikDinoMovement()
+       ),
   ;
 
   public static final int NUM_OBJECTS = values().length;
@@ -354,6 +362,7 @@ public enum RubikObjectList
       {
       case 0: return new RubikCube    (size, quat, texture, mesh, effects, moves, res, scrWidth);
       case 1: return new RubikPyraminx(size, quat, texture, mesh, effects, moves, res, scrWidth);
+      case 2: return new RubikDino    (size, quat, texture, mesh, effects, moves, res, scrWidth);
       }
 
     return null;
diff --git a/src/main/java/org/distorted/objects/RubikObjectMovement.java b/src/main/java/org/distorted/objects/RubikObjectMovement.java
index 77f06fbb..337bc968 100644
--- a/src/main/java/org/distorted/objects/RubikObjectMovement.java
+++ b/src/main/java/org/distorted/objects/RubikObjectMovement.java
@@ -42,7 +42,7 @@ public abstract class RubikObjectMovement
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  RubikObjectMovement(Static3D[] axis, int numFacesPerAxis, float distance3D, float distance2D)
+  RubikObjectMovement(Static3D[] axis, float numFacesPerAxis, float distance3D, float distance2D)
     {
     mPoint = new float[3];
     mCamera= new float[3];
@@ -53,7 +53,7 @@ public abstract class RubikObjectMovement
 
     mAxis = axis;
     mNumAxis = mAxis.length;
-    mNumFacesPerAxis = numFacesPerAxis;
+    mNumFacesPerAxis = (int)numFacesPerAxis;  // TODO
     mDistanceCenterFace3D = distance3D; // distance from the center of the object to each of its faces
     mDistanceCenterFace2D = distance2D; // distance from the center of a face to its edge
 
diff --git a/src/main/java/org/distorted/objects/RubikPyraminx.java b/src/main/java/org/distorted/objects/RubikPyraminx.java
index 2303a4c7..f04cb93a 100644
--- a/src/main/java/org/distorted/objects/RubikPyraminx.java
+++ b/src/main/java/org/distorted/objects/RubikPyraminx.java
@@ -420,7 +420,7 @@ public class RubikPyraminx extends RubikObject
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// TODO
+// TODO  (only needed for solvers - there are no Pyraminx solvers ATM)
 
   public String retObjectString()
     {
diff --git a/src/main/res/raw/compute_quats.c b/src/main/res/raw/compute_quats.c
index 0936c6b8..bfc004c3 100644
--- a/src/main/res/raw/compute_quats.c
+++ b/src/main/res/raw/compute_quats.c
@@ -2,7 +2,7 @@
 #include <math.h>
 #include <stdlib.h>
 
-#define PYRAMIX
+#define DINO
 
 #define SQ2 1.41421356237f
 #define SQ3 1.73205080757f
@@ -20,11 +20,22 @@ float axis[NUM_AXIS][3] ={ {         0,       1,       0 } ,
 #endif
 
 #ifdef CUBE
-#define NUM_AXIS 3
+#define NUM_AXIS    3
 #define BASIC_ANGLE 4
+
 float axis[NUM_AXIS][3] = { { 1,0,0 }, {0,1,0}, {0,0,1} };
 #endif
 
+#ifdef DINO
+#define NUM_AXIS    4
+#define BASIC_ANGLE 3
+
+float axis[NUM_AXIS][3] = { {+SQ3/3,+SQ3/3,+SQ3/3} , 
+                            {+SQ3/3,+SQ3/3,-SQ3/3} , 
+                            {+SQ3/3,-SQ3/3,+SQ3/3} , 
+                            {+SQ3/3,-SQ3/3,-SQ3/3} };
+#endif
+
 float* quats;
 float* table;
 int inserted=0;
