commit 9208e27b112d0607504303e75297a4f7f7b70da0
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue May 7 21:06:20 2019 +0100

    Progress with DistortedCube.

diff --git a/src/main/java/org/distorted/effect/TransitionEffect.java b/src/main/java/org/distorted/effect/TransitionEffect.java
index f4b1605f..6d8bfff1 100644
--- a/src/main/java/org/distorted/effect/TransitionEffect.java
+++ b/src/main/java/org/distorted/effect/TransitionEffect.java
@@ -19,15 +19,17 @@
 
 package org.distorted.effect;
 
+import org.distorted.library.effect.Effect;
 import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.message.EffectListener;
+import org.distorted.library.message.EffectMessage;
 import org.distorted.magic.RubikCube;
 
 import java.lang.reflect.Method;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-public abstract class TransitionEffect
+public abstract class TransitionEffect implements EffectListener
   {
   public enum Type
     {
@@ -38,7 +40,11 @@ public abstract class TransitionEffect
     /**
      * Gradually make the old cube more and more transparent until it disappears, then make the new one appear.
      */
-    DISAPPEAR  (TransitionEffectDisappear.class);
+    DISAPPEAR  (TransitionEffectDisappear.class),
+    /**
+     * Move the old cube to the right and the new one from the left.
+     */
+    MOVE       (TransitionEffectMove.class);
 
     private final Class<? extends TransitionEffect> effectClass;
 
@@ -48,14 +54,61 @@ public abstract class TransitionEffect
       }
     }
 
+  private final int MOVE_POSITION;
+  private long mDisappearID, mAppearID;
+  private EffectListener mListener;
+  private DistortedScreen mScreen;
+  private RubikCube mOld, mNew;
+
+  Effect mDisappear, mAppear;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  TransitionEffect(int position)
+    {
+    MOVE_POSITION = position;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// whenever we get the message that the old cube completely disappeared, make the new one appear
+// The calling RubikRenderer will get the message that this (final) transition is over and do whatever
+// it wants to do with this.
+
+  public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
+    {
+    if( effectID == mDisappearID )
+      {
+      mScreen.detach(mOld);
+      mOld.remove(mDisappearID);
+      mOld.deregisterForMessages(this);
+
+      mNew.apply(mAppear,MOVE_POSITION);
+      mNew.registerForMessages(mListener);
+      mScreen.attach(mNew);
+      }
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public abstract long prepare(EffectListener listener);
-  public abstract void start(DistortedScreen screen, RubikCube oldCube, RubikCube newCube);
+  public long start(DistortedScreen screen, RubikCube oldCube, RubikCube newCube,EffectListener listener)
+    {
+    mScreen   = screen;
+    mNew      = newCube;
+    mOld      = oldCube;
+    mListener = listener;
+
+    mDisappearID = mDisappear.getID();
+    mAppearID    = mAppear.getID();
+
+    mOld.apply(mDisappear,MOVE_POSITION);
+    mOld.registerForMessages(this);
+
+    return mAppearID;
+    }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  public static TransitionEffect createEffect(Type type) throws InstantiationException, IllegalAccessException
+  public static TransitionEffect create(Type type) throws InstantiationException, IllegalAccessException
     {
     return type.effectClass.newInstance();
     }
diff --git a/src/main/java/org/distorted/effect/TransitionEffectDisappear.java b/src/main/java/org/distorted/effect/TransitionEffectDisappear.java
index eac7570e..04401641 100644
--- a/src/main/java/org/distorted/effect/TransitionEffectDisappear.java
+++ b/src/main/java/org/distorted/effect/TransitionEffectDisappear.java
@@ -20,92 +20,37 @@
 package org.distorted.effect;
 
 import org.distorted.library.effect.FragmentEffectAlpha;
-import org.distorted.library.main.DistortedScreen;
-import org.distorted.library.message.EffectListener;
-import org.distorted.library.message.EffectMessage;
 import org.distorted.library.type.Dynamic1D;
 import org.distorted.library.type.Static1D;
-import org.distorted.magic.RubikCube;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-class TransitionEffectDisappear extends TransitionEffect implements EffectListener
+class TransitionEffectDisappear extends TransitionEffect
   {
-  private static final int DURATION_IN_MILLIS = 1000;
-
-  private EffectListener mListener;
-  private FragmentEffectAlpha mDisappear, mAppear;
-  private DistortedScreen mScreen;
-  private RubikCube mOld, mNew;
-
-  private long mDisappearID;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
   TransitionEffectDisappear()
     {
+    super(-1);
 
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// enable all effects we are using in this Transition.
-// called by reflection from the parent class.
-
-  @SuppressWarnings("unused")
-  static void enable()
-    {
-    FragmentEffectAlpha.enable();
-    }
+    final int DURATION_IN_MILLIS = 1000;
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  public long prepare(EffectListener listener)
-    {
-    mListener = listener;
-
-    Dynamic1D disappearDyn = new Dynamic1D(DURATION_IN_MILLIS, 0.5f);  // this means - linearily change the
-    disappearDyn.add(new Static1D(1.0f));                              // alpha of the old cube from 1.0 (100%)
-    disappearDyn.add(new Static1D(0.0f));                              // to 0.0 (0%) within DURATION millisecs.
+    Dynamic1D disappearDyn = new Dynamic1D(DURATION_IN_MILLIS, 0.5f);
+    disappearDyn.add(new Static1D(1.0f));
+    disappearDyn.add(new Static1D(0.0f));
     mDisappear = new FragmentEffectAlpha(disappearDyn);
 
-    Dynamic1D appearDyn = new Dynamic1D(DURATION_IN_MILLIS, 0.5f);     // the opposite - make the new cube
-    appearDyn.add(new Static1D(0.0f));                                 // more and more opaque.
-    appearDyn.add(new Static1D(1.0f));                                 //
+    Dynamic1D appearDyn = new Dynamic1D(DURATION_IN_MILLIS, 0.5f);
+    appearDyn.add(new Static1D(0.0f));
+    appearDyn.add(new Static1D(1.0f));
     mAppear = new FragmentEffectAlpha(appearDyn);
-
-    mDisappearID = mDisappear.getID();
-
-    return mAppear.getID();
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// At the start, oldCube is attached to the screen, new is not.
-// Gradually make the old cube disappear and wait for the message that this is done.
-
-  public void start(DistortedScreen screen, RubikCube oldCube, RubikCube newCube)
-    {
-    mScreen = screen;
-    mNew    = newCube;
-    mOld    = oldCube;
-
-    mOld.apply(mDisappear);
-    mOld.registerForMessages(this);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// whenever we get the message that the old cube completely disappeared, make the new one appear
-// The calling RubikRenderer will get the message that this (final) transition is over and do whatever
-// it wants to do with this.
+// enable all effects used in this Transition.
+// called by reflection from the parent class.
 
-  public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
+  @SuppressWarnings("unused")
+  static void enable()
     {
-    if( effectID == mDisappearID )
-      {
-      mScreen.detachAll();
-      mNew.attachToScreen(mScreen);
-      mNew.apply(mAppear);
-      mOld.deregisterForMessages(this);
-      mNew.registerForMessages(mListener);
-      }
+    FragmentEffectAlpha.enable();
     }
   }
diff --git a/src/main/java/org/distorted/effect/TransitionEffectEmpty.java b/src/main/java/org/distorted/effect/TransitionEffectEmpty.java
index a69344ad..6eb5430f 100644
--- a/src/main/java/org/distorted/effect/TransitionEffectEmpty.java
+++ b/src/main/java/org/distorted/effect/TransitionEffectEmpty.java
@@ -19,27 +19,31 @@
 
 package org.distorted.effect;
 
-import org.distorted.library.main.DistortedScreen;
-import org.distorted.library.message.EffectListener;
-import org.distorted.magic.RubikCube;
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.type.Dynamic3D;
+import org.distorted.library.type.Static3D;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 class TransitionEffectEmpty extends TransitionEffect
   {
-  private static final int FAKE_EFFECT_ID = -1;
-
-  private EffectListener mListener;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
   TransitionEffectEmpty()
     {
+    super(-1);
+
+    final int DURATION_IN_MILLIS = 1;
 
+    Dynamic3D disappearDyn = new Dynamic3D(DURATION_IN_MILLIS, 0.5f);
+    disappearDyn.add(new Static3D(0,0,0));
+    mDisappear = new MatrixEffectMove(disappearDyn);
+
+    Dynamic3D appearDyn = new Dynamic3D(DURATION_IN_MILLIS, 0.5f);
+    appearDyn.add(new Static3D(0,0,0));
+    mAppear = new MatrixEffectMove(appearDyn);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// enable all effects we are using in this Transition (here: none).
+// enable all effects used in this Transition (here: none).
 // called by reflection from the parent class.
 
   @SuppressWarnings("unused")
@@ -47,25 +51,4 @@ class TransitionEffectEmpty extends TransitionEffect
     {
 
     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// return a fake effect ID (because there's no real effect here - empty transition!
-
-  public long prepare(EffectListener listener)
-    {
-    mListener = listener;
-    return FAKE_EFFECT_ID;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// we just detach the old cube, attach the new one and manually send a message with the '-1' id
-// back to the listener (RubikRenderer)
-
-  public void start(DistortedScreen screen, RubikCube oldCube, RubikCube newCube)
-    {
-    screen.detachAll();
-    newCube.attachToScreen(screen);
-
-    mListener.effectMessage(null, FAKE_EFFECT_ID, 0);
-    }
   }
diff --git a/src/main/java/org/distorted/effect/TransitionEffectMove.java b/src/main/java/org/distorted/effect/TransitionEffectMove.java
new file mode 100644
index 00000000..3461c157
--- /dev/null
+++ b/src/main/java/org/distorted/effect/TransitionEffectMove.java
@@ -0,0 +1,59 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2019 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted 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.                                                           //
+//                                                                                               //
+// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.effect;
+
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.type.Dynamic3D;
+import org.distorted.library.type.Static3D;
+
+import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class TransitionEffectMove extends TransitionEffect
+  {
+  TransitionEffectMove()
+    {
+    super(2);
+
+    final int DURATION_IN_MILLIS = 1000;
+
+    Dynamic3D disappearDyn = new Dynamic3D(DURATION_IN_MILLIS, 0.5f);
+    disappearDyn.add(new Static3D(0,0,0));
+    disappearDyn.add(new Static3D(TEXTURE_SIZE,0,0));
+    mDisappear = new MatrixEffectMove(disappearDyn);
+
+    Dynamic3D appearDyn = new Dynamic3D(DURATION_IN_MILLIS, 0.5f);
+    appearDyn.add(new Static3D(-TEXTURE_SIZE,0,0));
+    appearDyn.add(new Static3D(0,0,0));
+    mAppear = new MatrixEffectMove(appearDyn);
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// enable all effects used in this Transition. Called by reflection from the parent class.
+// Matrix Effects do not have to be enabled.
+
+  @SuppressWarnings("unused")
+  static void enable()
+    {
+
+    }
+  }
+
diff --git a/src/main/java/org/distorted/magic/RubikCube.java b/src/main/java/org/distorted/magic/RubikCube.java
index 1949ba68..0bba5ff2 100644
--- a/src/main/java/org/distorted/magic/RubikCube.java
+++ b/src/main/java/org/distorted/magic/RubikCube.java
@@ -31,9 +31,9 @@ import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.effect.VertexEffectSink;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedNode;
-import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.mesh.MeshCubes;
+import org.distorted.library.mesh.MeshQuad;
 import org.distorted.library.message.EffectListener;
 import org.distorted.library.type.Dynamic1D;
 import org.distorted.library.type.Static1D;
@@ -42,7 +42,7 @@ import org.distorted.library.type.Static4D;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-public class RubikCube
+public class RubikCube extends DistortedNode
 {
     private static final int POST_ROTATION_MILLISEC = 500;
     private static final int TEXTURE_SIZE = 100;
@@ -60,25 +60,33 @@ public class RubikCube
     private Static3D[][][] mCurrentPosition;
     private MatrixEffectRotate[][][] mRotateEffect;
     private Static1D mRotationAngleStatic, mRotationAngleMiddle, mRotationAngleFinal;
-    private Static3D mMove, mScale;
+    private Static3D mMove, mScale, mNodeMove, mNodeScale;
     private DistortedTexture mTexture;
     private DistortedEffects mEffectsListeningForNow;
 
     private int mRotAxis, mRotRow;
     private int mSize;
 
+    private DistortedTexture mNodeTexture;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    RubikCube(int size, Static4D quatC, Static4D quatA)
+    RubikCube(int size, Static4D quatC, Static4D quatA, DistortedTexture texture, MeshQuad mesh, DistortedEffects effects)
       {
+      super(texture,effects,mesh);
+
+      mNodeTexture = texture;
+
       mSize = size;
 
       mRotationAngleStatic = new Static1D(0);
       mRotationAngleMiddle = new Static1D(0);
       mRotationAngleFinal  = new Static1D(0);
 
-      mMove = new Static3D(0,0,0);
-      mScale= new Static3D(1,1,1);
+      mMove     = new Static3D(0,0,0);
+      mScale    = new Static3D(1,1,1);
+      mNodeMove = new Static3D(0,0,0);
+      mNodeScale= new Static3D(1,1,1);
 
       mRotAxis= RubikSurfaceView.VECTX;
       mTexture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
@@ -103,6 +111,12 @@ public class RubikCube
       MatrixEffectQuaternion quatCEffect = new MatrixEffectQuaternion(quatC, center);
       MatrixEffectQuaternion quatAEffect = new MatrixEffectQuaternion(quatA, center);
 
+      MatrixEffectMove       nodeMoveEffect  = new MatrixEffectMove(mNodeMove);
+      MatrixEffectScale      nodeScaleEffect = new MatrixEffectScale(mNodeScale);
+
+      effects.apply(nodeMoveEffect);
+      effects.apply(nodeScaleEffect);
+
       // 3x2 bitmap = 6 squares:
       //
       // RED     GREEN   BLUE
@@ -157,13 +171,17 @@ public class RubikCube
               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]) );
+
+              mNodes[x][y][z] = new DistortedNode(mTexture,mEffects[x][y][z],mCubes[x][y][z]);
+
+              attach(mNodes[x][y][z]);
               }
             }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    public void attachToScreen(DistortedScreen screen)
+    public void apply(Effect effect)
       {
       for(int x=0; x<mSize; x++)
         for(int y=0; y<mSize; y++)
@@ -171,15 +189,14 @@ public class RubikCube
             {
             if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
               {
-              mNodes[x][y][z] = new DistortedNode(mTexture,mEffects[x][y][z],mCubes[x][y][z]);
-              screen.attach(mNodes[x][y][z]);
+              mEffects[x][y][z].apply(effect);
               }
             }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    public void apply(Effect effect)
+    public void apply(Effect effect, int position)
       {
       for(int x=0; x<mSize; x++)
         for(int y=0; y<mSize; y++)
@@ -187,7 +204,22 @@ public class RubikCube
             {
             if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
               {
-              mEffects[x][y][z].apply(effect);
+              mEffects[x][y][z].apply(effect, position);
+              }
+            }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void remove(long effectID)
+      {
+      for(int x=0; x<mSize; x++)
+        for(int y=0; y<mSize; y++)
+          for(int z=0; z<mSize; z++)
+            {
+            if( x==0 || x==mSize-1 || y==0 || y==mSize-1 || z==0 || z==mSize-1 )
+              {
+              mEffects[x][y][z].abortById(effectID);
               }
             }
       }
@@ -454,9 +486,27 @@ public class RubikCube
 
    void recomputeScaleFactor(int screenWidth, int screenHeight, float size)
      {
-     float scaleFactor = size/(TEXTURE_SIZE*mSize);
-
-     mMove.set( (screenWidth-scaleFactor*TEXTURE_SIZE)/2 , (screenHeight-scaleFactor*TEXTURE_SIZE)/2 , -scaleFactor*TEXTURE_SIZE/2 );
+     int texW = mNodeTexture.getWidth();
+     int texH = mNodeTexture.getHeight();
+
+     if( (float)texH/texW > (float)screenHeight/screenWidth )
+       {
+       int w = (screenHeight*texW)/texH;
+       float factor = (float)screenHeight/texH;
+       mNodeMove.set((screenWidth-w)*0.5f ,0, 0);
+       mNodeScale.set(factor,factor,factor);
+       }
+     else
+       {
+       int h = (screenWidth*texH)/texW;
+       float factor = (float)screenWidth/texW;
+       mNodeMove.set(0,(screenHeight-h)*0.5f,0);
+       mNodeScale.set(factor,factor,factor);
+       }
+
+     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 );
      mScale.set(scaleFactor,scaleFactor,scaleFactor);
      }
 
diff --git a/src/main/java/org/distorted/magic/RubikRenderer.java b/src/main/java/org/distorted/magic/RubikRenderer.java
index 94672c7a..0cd09a31 100644
--- a/src/main/java/org/distorted/magic/RubikRenderer.java
+++ b/src/main/java/org/distorted/magic/RubikRenderer.java
@@ -23,8 +23,11 @@ import android.opengl.GLSurfaceView;
 
 import org.distorted.effect.TransitionEffect;
 import org.distorted.library.effect.VertexEffectSink;
+import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedLibrary;
 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.message.EffectMessage;
 import org.distorted.library.type.Static4D;
@@ -34,10 +37,11 @@ import javax.microedition.khronos.opengles.GL10;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
+public class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
 {
     private static final float CUBE_SCREEN_RATIO = 0.5f;
     private static final float CAMERA_DISTANCE   = 0.6f;  // 0.6 of the length of max(scrHeight,scrWidth)
+    public  static final int TEXTURE_SIZE = 600;
 
     private RubikSurfaceView mView;
     private DistortedScreen mScreen;
@@ -52,6 +56,8 @@ class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
 
     private int mScreenWidth, mScreenHeight;
 
+    private MeshQuad mMesh;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     RubikRenderer(RubikSurfaceView v)
@@ -79,6 +85,8 @@ class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
 
       mCanRotate = true;
       mCanDrag   = true;
+
+      mMesh= new MeshQuad();
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -123,9 +131,8 @@ class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
 
         try
           {
-          TransitionEffect effect = TransitionEffect.createEffect(TransitionEffect.Type.DISAPPEAR);
-          mTransitionEffectID = effect.prepare(this);
-          effect.start(mScreen,mOldCube,mNewCube);
+          TransitionEffect effect = TransitionEffect.create(TransitionEffect.Type.EMPTY);
+          mTransitionEffectID = effect.start(mScreen,mOldCube,mNewCube,this);
           }
         catch(Exception ex)
           {
@@ -149,6 +156,8 @@ class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
        {
        mCanRotate = true;
        mCanDrag   = true;
+       mNewCube.remove(mTransitionEffectID);
+       mNewCube.deregisterForMessages(this);
        }
      }
 
@@ -176,7 +185,7 @@ class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
       {
       mNewCube.createTexture();
       mScreen.detachAll();
-      mNewCube.attachToScreen(mScreen);
+      mScreen.attach(mNewCube);
 
       VertexEffectSink.enable();
       TransitionEffect.enableEffects();
@@ -225,7 +234,10 @@ class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
        if( mOldCube!=null ) mOldCube.releaseResources();
        mOldCube = mNewCube;
 
-       mNewCube = new RubikCube(newSize, mQuatCurrent, mQuatAccumulated);
+       DistortedTexture texture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
+       DistortedEffects effects = new DistortedEffects();
+
+       mNewCube = new RubikCube(newSize, mQuatCurrent, mQuatAccumulated, texture, mMesh, effects);
        mNewCube.createTexture();
 
        if( mScreenWidth!=0 )
