commit ac2ee4b3d4f4cd097e247ae06cfaab628ebcb28a
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sun May 9 22:11:36 2021 +0200

    Progress with RubikControl - sub-stages 1 and 2 of the 'whole' stage finished.

diff --git a/src/main/java/org/distorted/control/RubikControlWhole.java b/src/main/java/org/distorted/control/RubikControlWhole.java
index 58ff0baa..57921a68 100644
--- a/src/main/java/org/distorted/control/RubikControlWhole.java
+++ b/src/main/java/org/distorted/control/RubikControlWhole.java
@@ -29,6 +29,7 @@ import org.distorted.library.main.DistortedNode;
 import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.mesh.MeshQuad;
+import org.distorted.library.message.EffectListener;
 import org.distorted.library.type.Dynamic;
 import org.distorted.library.type.Dynamic3D;
 import org.distorted.library.type.Static3D;
@@ -40,7 +41,7 @@ import java.io.InputStream;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-class RubikControlWhole
+class RubikControlWhole implements EffectListener
   {
   private static final int NUM_NODE = 4;
   private static final int NUM_EFFE = 4;
@@ -49,10 +50,15 @@ class RubikControlWhole
   private DistortedEffects[] mEffects;
   private DistortedNode[] mNodes;
   private long mEffectID;
+  private int mStageFinished, mWidth, mHeight;
+
   private MeshQuad mQuad;
+  private DistortedTexture mTextureHand, mTextureShad, mTextureCirc;
 
-  private Dynamic3D mDynamicHand1;
-  private MatrixEffectMove mMoveHand1;
+  private Dynamic3D mDynMoveHand1, mDynMoveShad1;
+  private Dynamic3D mDynScaleHand1, mDynScaleShad1;
+  private MatrixEffectMove mMoveHand1, mMoveShad1;
+  private MatrixEffectScale mScaleHand1, mScaleShad1;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -70,6 +76,83 @@ class RubikControlWhole
      return null;
      }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void createEffectsStage1()
+    {
+    float x0 = mWidth*0.55f;
+    float x1 = mWidth*0.45f;
+    float x2 = mWidth*0.35f;
+    float y1 = mHeight*0.28f;
+    float z  = 0;
+    float d  = mWidth*0.01f;
+    float s  = mWidth*0.33f;
+
+    Static3D point0h = new Static3D(-x0    ,-y1    , z);
+    Static3D point1h = new Static3D(-x1    ,-y1    , z);
+    Static3D point2h = new Static3D(-x2    ,-y1    , z);
+    Static3D point3h = new Static3D(-x2  +d,-y1  +d, z);
+    Static3D point0s = new Static3D(-x0+2*d,-y1+2*d, z);
+    Static3D point1s = new Static3D(-x1+2*d,-y1+2*d, z);
+    Static3D point2s = new Static3D(-x2+2*d,-y1+2*d, z);
+    Static3D point3s = new Static3D(-x2  +d,-y1  +d, z);
+
+    Static3D pointSc = new Static3D(s,s,s);
+
+    mDynMoveHand1.add(point0h);
+    mDynMoveHand1.add(point1h);
+    mDynMoveHand1.add(point2h);
+    mDynMoveHand1.add(point2h);
+    mDynMoveHand1.add(point3h);
+    mDynMoveShad1.add(point0s);
+    mDynMoveShad1.add(point1s);
+    mDynMoveShad1.add(point2s);
+    mDynMoveShad1.add(point2s);
+    mDynMoveShad1.add(point3s);
+    mDynScaleHand1.add(pointSc);
+    mDynScaleShad1.add(pointSc);
+
+    mStageFinished = 1;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void createEffectsStage2()
+    {
+    float x2 = mWidth*0.35f;
+    float y1 = mHeight*0.28f;
+    float z  = 0;
+    float d  = mWidth*0.01f;
+    float sS = mWidth*0.0001f;
+    float sF = mWidth*0.16f;
+
+    Static3D point3h = new Static3D(-x2  +d,-y1  +d, z);
+    Static3D scaleS  = new Static3D(sS,sS,sS);
+    Static3D scaleF  = new Static3D(sF,sF,sF);
+
+    mDynMoveHand1.removeAll();
+    mDynMoveHand1.add(point3h);
+    mDynMoveShad1.removeAll();
+    mDynMoveShad1.add(point3h);
+    mDynScaleShad1.removeAll();
+    mDynScaleShad1.add(scaleS);
+    mDynScaleShad1.add(scaleF);
+    mDynScaleShad1.resetToBeginning();
+
+    mNodes[0].changeInputSurface(mTextureCirc);
+
+    mStageFinished = 2;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  private void reloadEffectsStage1()
+    {
+    mDynMoveHand1.resetToBeginning();
+    mDynMoveShad1.resetToBeginning();
+    mMoveHand1.notifyWhenFinished(this);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   private void createEffects()
@@ -79,52 +162,40 @@ class RubikControlWhole
       mEffects = new DistortedEffects[NUM_EFFE];
       for(int i=0; i<NUM_EFFE; i++) mEffects[i]= new DistortedEffects();
 
-      DistortedScreen screen = mControl.getScreen();
-      int wid = screen.getWidth();
-      int hei = screen.getHeight();
-
-      float x1 = wid*0.35f;
-      float y1 = hei*0.28f;
-      float z  = 0;
-      float handScale = wid*0.33f;
-      float circScale = handScale*0.5f;
-
-      Static3D point0 = new Static3D(-x1,-y1,z);
-      Static3D point1 = new Static3D(  0,-y1,z);
-      Static3D point2 = new Static3D(+x1,-y1,z);
-      Static3D point3 = new Static3D(+x1,  0,z);
-      Static3D point4 = new Static3D(+x1,+y1,z);
-      Static3D point5 = new Static3D(  0,  0,z);
-
-      mDynamicHand1 = new Dynamic3D(15000,0.5f);
-      mDynamicHand1.add(point0);
-      mDynamicHand1.add(point0);
-      mDynamicHand1.add(point1);
-      mDynamicHand1.add(point2);
-      mDynamicHand1.add(point2);
-      mDynamicHand1.add(point3);
-      mDynamicHand1.add(point4);
-      mDynamicHand1.add(point4);
-      mDynamicHand1.add(point5);
-      mDynamicHand1.add(point0);
-      mDynamicHand1.add(point0);
-      mDynamicHand1.setMode(Dynamic.MODE_PATH);
-      mDynamicHand1.setConvexity(0.0f);
-
-      mMoveHand1 = new MatrixEffectMove(mDynamicHand1);
-      mMoveHand1.notifyWhenFinished(mControl);
-      mEffectID = mMoveHand1.getID();
-
-      mEffects[0].apply( new MatrixEffectScale(circScale));
-      mEffects[0].apply(mMoveHand1);
-      mEffects[2].apply( new MatrixEffectScale(handScale));
+      int time = 3000;
+
+      mDynMoveHand1 = new Dynamic3D(time,0.5f);
+      mDynMoveHand1.setMode(Dynamic.MODE_PATH);
+      mDynMoveHand1.setConvexity(0.0f);
+      mDynMoveShad1 = new Dynamic3D(time,0.5f);
+      mDynMoveShad1.setMode(Dynamic.MODE_PATH);
+      mDynMoveShad1.setConvexity(0.0f);
+      mDynScaleHand1 = new Dynamic3D(time,0.5f);
+      mDynScaleHand1.setMode(Dynamic.MODE_PATH);
+      mDynScaleHand1.setConvexity(0.0f);
+      mDynScaleShad1 = new Dynamic3D(time,0.5f);
+      mDynScaleShad1.setMode(Dynamic.MODE_PATH);
+      mDynScaleShad1.setConvexity(0.0f);
+
+      mMoveHand1 = new MatrixEffectMove(mDynMoveHand1);
+      mMoveShad1 = new MatrixEffectMove(mDynMoveShad1);
+      mScaleHand1= new MatrixEffectScale(mDynScaleHand1);
+      mScaleShad1= new MatrixEffectScale(mDynScaleShad1);
+
+      mMoveHand1.notifyWhenFinished(this);
+
+      mEffects[0].apply(mScaleShad1);
+      mEffects[0].apply(mMoveShad1);
+      mEffects[2].apply(mScaleHand1);
       mEffects[2].apply(mMoveHand1);
+
+      DistortedScreen screen = mControl.getScreen();
+      mWidth = screen.getWidth();
+      mHeight= screen.getHeight();
+
+      createEffectsStage1();
       }
-    else
-      {
-      mDynamicHand1.resetToBeginning();
-      mMoveHand1.notifyWhenFinished(mControl);
-      }
+    else reloadEffectsStage1();
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -142,16 +213,20 @@ class RubikControlWhole
     if( act!=null )
       {
       Bitmap bmpCirc = openBitmap(act, R.drawable.ui_fading_circle);
-      DistortedTexture textureCirc = new DistortedTexture();
-      textureCirc.setTexture(bmpCirc);
-      mNodes[0]= new DistortedNode(textureCirc,mEffects[0],mQuad);
-      mNodes[1]= new DistortedNode(textureCirc,mEffects[1],mQuad);
-
+      Bitmap bmpShad = openBitmap(act, R.drawable.ui_hand_shadow);
       Bitmap bmpHand = openBitmap(act, R.drawable.ui_hand_pointer);
-      DistortedTexture textureHand = new DistortedTexture();
-      textureHand.setTexture(bmpHand);
-      mNodes[2]= new DistortedNode(textureHand,mEffects[2],mQuad);
-      mNodes[3]= new DistortedNode(textureHand,mEffects[3],mQuad);
+
+      mTextureCirc = new DistortedTexture();
+      mTextureCirc.setTexture(bmpCirc);
+      mTextureShad = new DistortedTexture();
+      mTextureShad.setTexture(bmpShad);
+      mTextureHand = new DistortedTexture();
+      mTextureHand.setTexture(bmpHand);
+
+      mNodes[0]= new DistortedNode(mTextureShad,mEffects[0],mQuad);
+      mNodes[1]= new DistortedNode(mTextureShad,mEffects[1],mQuad);
+      mNodes[2]= new DistortedNode(mTextureHand,mEffects[2],mQuad);
+      mNodes[3]= new DistortedNode(mTextureHand,mEffects[3],mQuad);
       }
     else
       {
@@ -189,4 +264,19 @@ class RubikControlWhole
     {
     mControl = control;
     }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// PUBLIC
+
+  public void effectFinished(long effectID)
+    {
+    switch( mStageFinished )
+      {
+      case 1: createEffectsStage2();
+              break;
+      case 2: mEffectID = -1;
+              mControl.effectFinished(mEffectID);
+              break;
+      }
+    }
   }
diff --git a/src/main/res/drawable-nodpi/ui_hand_shadow.png b/src/main/res/drawable-nodpi/ui_hand_shadow.png
new file mode 100644
index 00000000..58e737b8
Binary files /dev/null and b/src/main/res/drawable-nodpi/ui_hand_shadow.png differ
