commit c622889d66df5395d19a079e9168a08665931210
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sun May 12 22:18:50 2019 +0100

    Invert the order of Matrix Effects. Now, just as in the other queues, the first matrix effect is actually the first to act on the object - not the other way around!

diff --git a/src/main/java/org/distorted/effect/AppearEffectMove.java b/src/main/java/org/distorted/effect/AppearEffectMove.java
index 23a30360..c69e3b9b 100644
--- a/src/main/java/org/distorted/effect/AppearEffectMove.java
+++ b/src/main/java/org/distorted/effect/AppearEffectMove.java
@@ -32,7 +32,7 @@ class AppearEffectMove extends AppearEffect
   {
   public int createEffects(int duration)
     {
-    mCubeEffectPosition = new int[] {2};
+    mCubeEffectPosition = new int[] {6};
     mCubeEffects        = new Effect[mCubeEffectPosition.length];
 
     Dynamic3D oldCube0 = new Dynamic3D(duration, 0.5f);
diff --git a/src/main/java/org/distorted/effect/AppearEffectRound.java b/src/main/java/org/distorted/effect/AppearEffectRound.java
index 15743117..020b6147 100644
--- a/src/main/java/org/distorted/effect/AppearEffectRound.java
+++ b/src/main/java/org/distorted/effect/AppearEffectRound.java
@@ -33,20 +33,23 @@ class AppearEffectRound extends AppearEffect
   {
   public int createEffects(int duration)
     {
-    mCubeEffectPosition = new int[] {2, 2};
-    mCubeEffects        = new Effect[mCubeEffectPosition.length];
-
-    Dynamic3D oldCube0 = new Dynamic3D(duration/2, 0.5f);
-    oldCube0.add(new Static3D(-TEXTURE_SIZE,0,0));
-    oldCube0.add(new Static3D(            0,0,0));
-    mCubeEffects[0] = new MatrixEffectMove(oldCube0);
+    float X = TEXTURE_SIZE;
 
-    Dynamic3D oldCube1 = new Dynamic3D(duration/2, 0.5f);
-    oldCube1.add(new Static3D(0.01f, 0.01f, 0.01f));
-    oldCube1.add(new Static3D(1.00f, 1.00f, 1.00f));
-    mCubeEffects[1] = new MatrixEffectScale(oldCube1);
+    mCubeEffectPosition = new int[] {6};
+    mCubeEffects        = new Effect[mCubeEffectPosition.length];
+/*
+    Dynamic3D d0 = new Dynamic3D(duration, 0.5f);
+    d0.add(new Static3D( 0.01f, 0.01f, 0.01f));
+    d0.add(new Static3D( 1.00f, 1.00f, 1.00f));
+    mCubeEffects[0] = new MatrixEffectScale(d0);
+*/
+    Dynamic3D d1 = new Dynamic3D(duration, 0.5f);
+    d1.add(new Static3D( 0, 0, 0));
+    d1.add(new Static3D(-X, 0, 0));
+    d1.add(new Static3D( 0, 0, 0));
+    mCubeEffects[0] = new MatrixEffectMove(d1);
 
-    return 2;
+    return 1;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/effect/AppearEffectScale.java b/src/main/java/org/distorted/effect/AppearEffectScale.java
index 8ed71da0..e288c9ff 100644
--- a/src/main/java/org/distorted/effect/AppearEffectScale.java
+++ b/src/main/java/org/distorted/effect/AppearEffectScale.java
@@ -30,7 +30,7 @@ class AppearEffectScale extends AppearEffect
   {
   public int createEffects(int duration)
     {
-    mCubeEffectPosition = new int[] {5};
+    mCubeEffectPosition = new int[] {6};
     mCubeEffects        = new Effect[mCubeEffectPosition.length];
 
     Dynamic3D oldCube0 = new Dynamic3D(duration, 0.5f);
diff --git a/src/main/java/org/distorted/effect/DisappearEffectMove.java b/src/main/java/org/distorted/effect/DisappearEffectMove.java
index a7fce5d6..bfca298b 100644
--- a/src/main/java/org/distorted/effect/DisappearEffectMove.java
+++ b/src/main/java/org/distorted/effect/DisappearEffectMove.java
@@ -32,7 +32,7 @@ class DisappearEffectMove extends DisappearEffect
   {
   public int createEffects(int duration)
     {
-    mCubeEffectPosition = new int[] {2};
+    mCubeEffectPosition = new int[] {6};
     mCubeEffects        = new Effect[mCubeEffectPosition.length];
 
     Dynamic3D oldCube0 = new Dynamic3D(duration, 0.5f);
diff --git a/src/main/java/org/distorted/effect/DisappearEffectRound.java b/src/main/java/org/distorted/effect/DisappearEffectRound.java
index a31392ed..1bf16069 100644
--- a/src/main/java/org/distorted/effect/DisappearEffectRound.java
+++ b/src/main/java/org/distorted/effect/DisappearEffectRound.java
@@ -33,20 +33,23 @@ class DisappearEffectRound extends DisappearEffect
   {
   public int createEffects(int duration)
     {
-    mCubeEffectPosition = new int[] {2, 2};
-    mCubeEffects        = new Effect[mCubeEffectPosition.length];
-
-    Dynamic3D oldCube0 = new Dynamic3D(duration/2, 0.5f);
-    oldCube0.add(new Static3D(           0,0,0));
-    oldCube0.add(new Static3D(TEXTURE_SIZE,0,0));
-    mCubeEffects[0] = new MatrixEffectMove(oldCube0);
+    float X = TEXTURE_SIZE;
 
-    Dynamic3D oldCube1 = new Dynamic3D(duration/2, 0.5f);
-    oldCube1.add(new Static3D(1.0f, 1.0f, 1.0f));
-    oldCube1.add(new Static3D(0.01f, 0.01f, 0.01f));
-    mCubeEffects[1] = new MatrixEffectScale(oldCube1);
+    mCubeEffectPosition = new int[] {6};
+    mCubeEffects        = new Effect[mCubeEffectPosition.length];
+/*
+    Dynamic3D d0 = new Dynamic3D(duration, 0.5f);
+    d0.add(new Static3D( 1.00f, 1.00f, 1.00f));
+    d0.add(new Static3D( 0.01f, 0.01f, 0.01f));
+    mCubeEffects[0] = new MatrixEffectScale(d0);
+*/
+    Dynamic3D d1 = new Dynamic3D(duration, 0.5f);
+    d1.add(new Static3D( 0, 0, 0));
+    d1.add(new Static3D(+X, 0, 0));
+    d1.add(new Static3D( 0, 0, 0));
+    mCubeEffects[0] = new MatrixEffectMove(d1);
 
-    return 2;
+    return 1;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/effect/DisappearEffectScale.java b/src/main/java/org/distorted/effect/DisappearEffectScale.java
index b40fdf30..5a4eb258 100644
--- a/src/main/java/org/distorted/effect/DisappearEffectScale.java
+++ b/src/main/java/org/distorted/effect/DisappearEffectScale.java
@@ -30,7 +30,7 @@ class DisappearEffectScale extends DisappearEffect
   {
   public int createEffects(int duration)
     {
-    mCubeEffectPosition = new int[] {5};
+    mCubeEffectPosition = new int[] {6};
     mCubeEffects        = new Effect[mCubeEffectPosition.length];
 
     Dynamic3D oldCube0 = new Dynamic3D(duration, 0.5f);
diff --git a/src/main/java/org/distorted/magic/RubikCube.java b/src/main/java/org/distorted/magic/RubikCube.java
index c481e568..24d6cf6a 100644
--- a/src/main/java/org/distorted/magic/RubikCube.java
+++ b/src/main/java/org/distorted/magic/RubikCube.java
@@ -102,20 +102,21 @@ public class RubikCube extends DistortedNode
 
       Static3D[][][] cubeVectors = new Static3D[mSize][mSize][mSize];
 
-      Static3D center = new Static3D(TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f);
+      Static3D sinkCenter = new Static3D(TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f);
+      Static3D matrCenter = new Static3D(0,0,0);
       Static4D region = new Static4D(0,0,0, TEXTURE_SIZE*0.72f);
 
-      VertexEffectSink        sinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), center, region );
+      VertexEffectSink        sinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), sinkCenter, region );
       MatrixEffectMove        moveEffect = new MatrixEffectMove(mMove);
       MatrixEffectScale      scaleEffect = new MatrixEffectScale(mScale);
-      MatrixEffectQuaternion quatCEffect = new MatrixEffectQuaternion(quatC, center);
-      MatrixEffectQuaternion quatAEffect = new MatrixEffectQuaternion(quatA, center);
+      MatrixEffectQuaternion quatCEffect = new MatrixEffectQuaternion(quatC, matrCenter);
+      MatrixEffectQuaternion quatAEffect = new MatrixEffectQuaternion(quatA, matrCenter);
 
       MatrixEffectMove       nodeMoveEffect  = new MatrixEffectMove(mNodeMove);
       MatrixEffectScale      nodeScaleEffect = new MatrixEffectScale(mNodeScale);
 
-      effects.apply(nodeMoveEffect);
       effects.apply(nodeScaleEffect);
+      effects.apply(nodeMoveEffect);
 
       // 3x2 bitmap = 6 squares:
       //
@@ -138,7 +139,7 @@ public class RubikCube extends DistortedNode
       final Static4D mapBlack = new Static4D(ze,ze, ze+of,ze+of);
 
       Static4D tmpFront, tmpBack, tmpLeft, tmpRight, tmpTop, tmpBottom;
-      float nc = 0.5f*(mSize-1);
+      float nc = 0.5f*mSize;
       int vertices = (int)(24.0f/mSize + 2.0f);
 
       for(int x = 0; x< mSize; x++)
@@ -160,17 +161,17 @@ public class RubikCube extends DistortedNode
               mRotationAngle[x][y][z]   = new Dynamic1D();
               mRotationAxis[x][y][z]    = new Static3D(1,0,0);
               mCurrentPosition[x][y][z] = new Static3D(x,y,z);
-              mRotateEffect[x][y][z]    = new MatrixEffectRotate(mRotationAngle[x][y][z], mRotationAxis[x][y][z], center);
+              mRotateEffect[x][y][z]    = new MatrixEffectRotate(mRotationAngle[x][y][z], mRotationAxis[x][y][z], matrCenter);
 
               mEffects[x][y][z] = new DistortedEffects();
               mEffects[x][y][z].apply(sinkEffect);
-              mEffects[x][y][z].apply(moveEffect);
-              mEffects[x][y][z].apply(scaleEffect);
-              mEffects[x][y][z].apply(quatCEffect);
-              mEffects[x][y][z].apply(quatAEffect);
-              mEffects[x][y][z].apply(mRotateEffect[x][y][z]);
-              mEffects[x][y][z].apply( new MatrixEffectQuaternion(mQuatScramble[x][y][z], center));
               mEffects[x][y][z].apply( new MatrixEffectMove(cubeVectors[x][y][z]) );
+              mEffects[x][y][z].apply( new MatrixEffectQuaternion(mQuatScramble[x][y][z], matrCenter));
+              mEffects[x][y][z].apply(mRotateEffect[x][y][z]);
+              mEffects[x][y][z].apply(quatAEffect);
+              mEffects[x][y][z].apply(quatCEffect);
+              mEffects[x][y][z].apply(scaleEffect);
+              mEffects[x][y][z].apply(moveEffect);
 
               mNodes[x][y][z] = new DistortedNode(mTexture,mEffects[x][y][z],mCubes[x][y][z]);
 
@@ -481,7 +482,7 @@ public class RubikCube extends DistortedNode
 
      float scaleFactor = (size/(TEXTURE_SIZE*mSize)) * (float)texW/(screenWidth>screenHeight ? screenHeight:screenWidth);
 
-     mMove.set( (texW-scaleFactor*TEXTURE_SIZE)/2 , (texH-scaleFactor*TEXTURE_SIZE)/2 , -scaleFactor*TEXTURE_SIZE/2 );
+     mMove.set( texW*0.5f , texH*0.5f , 0.0f );
      mScale.set(scaleFactor,scaleFactor,scaleFactor);
      }
 
