commit 5974d2aeb2f858c54ff02b9b3edec884d663d577
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed Feb 26 15:52:02 2020 +0000

    Move the 'pre-multiply mesh before applying any effects' thing from [(Xsize of texture, Ysize of texture) x Mesh's zFactor] to Effects.setStretch(sx,sy,sz)

diff --git a/src/main/java/org/distorted/effect/scramble/ScrambleEffectRotations.java b/src/main/java/org/distorted/effect/scramble/ScrambleEffectRotations.java
index 69376074..bc5c26eb 100644
--- a/src/main/java/org/distorted/effect/scramble/ScrambleEffectRotations.java
+++ b/src/main/java/org/distorted/effect/scramble/ScrambleEffectRotations.java
@@ -30,7 +30,7 @@ import org.distorted.library.type.Static4D;
 
 import java.util.Random;
 
-import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
+import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -78,7 +78,7 @@ public class ScrambleEffectRotations extends ScrambleEffect
 
     mCubeEffects[0] = new MatrixEffectQuaternion(dq, new Static3D(0,0,0));
 
-    float Z = TEXTURE_SIZE/3;
+    float Z = NODE_MESH_SIZE /3;
 
     Dynamic3D d0 = new Dynamic3D(duration, 0.5f);
     d0.setMode(Dynamic.MODE_PATH);
diff --git a/src/main/java/org/distorted/effect/sizechange/SizeChangeEffectRound.java b/src/main/java/org/distorted/effect/sizechange/SizeChangeEffectRound.java
index 20206edf..893fc979 100644
--- a/src/main/java/org/distorted/effect/sizechange/SizeChangeEffectRound.java
+++ b/src/main/java/org/distorted/effect/sizechange/SizeChangeEffectRound.java
@@ -26,7 +26,7 @@ import org.distorted.library.type.Dynamic;
 import org.distorted.library.type.Dynamic3D;
 import org.distorted.library.type.Static3D;
 
-import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
+import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -34,7 +34,7 @@ class SizeChangeEffectRound extends SizeChangeEffect
   {
   public int createEffectsPhase0(int duration)
     {
-    float X = TEXTURE_SIZE/3;
+    float X = NODE_MESH_SIZE /3;
 
     mCubeEffectPosition[0] = new int[] {6,7};
     mCubeEffects[0]        = new Effect[mCubeEffectPosition[0].length];
@@ -58,7 +58,7 @@ class SizeChangeEffectRound extends SizeChangeEffect
 
   public int createEffectsPhase1(int duration)
     {
-    float X = TEXTURE_SIZE/3;
+    float X = NODE_MESH_SIZE /3;
 
     mCubeEffectPosition[1] = new int[] {6,7};
     mCubeEffects[1]        = new Effect[mCubeEffectPosition[1].length];
diff --git a/src/main/java/org/distorted/effect/win/WinEffectGlow.java b/src/main/java/org/distorted/effect/win/WinEffectGlow.java
index 7aa6f4b6..5c266f09 100644
--- a/src/main/java/org/distorted/effect/win/WinEffectGlow.java
+++ b/src/main/java/org/distorted/effect/win/WinEffectGlow.java
@@ -28,7 +28,7 @@ import org.distorted.library.type.Static1D;
 import org.distorted.library.type.Static3D;
 import org.distorted.library.type.Static4D;
 
-import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
+import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -63,7 +63,7 @@ public class WinEffectGlow extends WinEffect
     degreeDyn.add(new Static1D(2.5f));
     degreeDyn.add(new Static1D(1.0f));
 
-    float centerPoint = TEXTURE_SIZE*0.5f;
+    float centerPoint = NODE_MESH_SIZE *0.5f;
     Static3D center = new Static3D(centerPoint,centerPoint,centerPoint);
 
     mNodeEffects[1] = new VertexEffectSink(degreeDyn,center);
diff --git a/src/main/java/org/distorted/magic/RubikRenderer.java b/src/main/java/org/distorted/magic/RubikRenderer.java
index 619cae13..acab24bb 100644
--- a/src/main/java/org/distorted/magic/RubikRenderer.java
+++ b/src/main/java/org/distorted/magic/RubikRenderer.java
@@ -40,7 +40,7 @@ import javax.microedition.khronos.opengles.GL10;
 public class RubikRenderer implements GLSurfaceView.Renderer, EffectListener
 {
     static final float CAMERA_DISTANCE = 0.6f;  // 0.6 of the length of min(scrHeight,scrWidth)
-    public static final int TEXTURE_SIZE = 600;
+    public static final int NODE_MESH_SIZE = 600;
 
     private RubikSurfaceView mView;
     private DistortedScreen mScreen;
diff --git a/src/main/java/org/distorted/object/Cubit.java b/src/main/java/org/distorted/object/Cubit.java
index 63ecea5a..4879eb6a 100644
--- a/src/main/java/org/distorted/object/Cubit.java
+++ b/src/main/java/org/distorted/object/Cubit.java
@@ -160,8 +160,7 @@ class Cubit
     float z = position.get2();
 
     float nc = parent.mSize*0.5f;
-    int TS = RubikObject.TEXTURE_SIZE;
-    Static3D vector = new Static3D(TS*(x-nc), TS*(y-nc), TS*(z-nc));
+    Static3D vector = new Static3D(x-nc, y-nc, z-nc);
 
     mParent          = parent;
     mMesh            = mesh;
@@ -172,7 +171,7 @@ class Cubit
     mCurrentPosition = position;
     mRotateEffect    = new MatrixEffectRotate(mRotationAngle, mRotationAxis, matrCenter);
 
-    mEffect = new DistortedEffects();
+    mEffect = new DistortedEffects(1);
     mEffect.apply(mParent.mSinkEffect);
     mEffect.apply( new MatrixEffectMove(vector) );
     mEffect.apply( new MatrixEffectQuaternion(mQuatScramble, matrCenter));
diff --git a/src/main/java/org/distorted/object/RubikObject.java b/src/main/java/org/distorted/object/RubikObject.java
index a70a6231..a9d64ef4 100644
--- a/src/main/java/org/distorted/object/RubikObject.java
+++ b/src/main/java/org/distorted/object/RubikObject.java
@@ -42,7 +42,6 @@ import org.distorted.library.type.Static4D;
 public abstract class RubikObject extends DistortedNode
   {
   static final float OBJECT_SCREEN_RATIO = 0.5f;
-  static final int TEXTURE_SIZE = 100;
   final float[] LEGAL_QUATS;
 
   private static final int POST_ROTATION_MILLISEC = 500;
@@ -51,7 +50,6 @@ public abstract class RubikObject extends DistortedNode
   private Static3D mRotAxis;
   private Static3D mMove, mScale, mNodeMove, mNodeScale;
   private Static4D mQuatAccumulated;
-  private DistortedTexture mNodeTexture;
   private Cubit[] mCubits;
 
   int mSize;
@@ -74,7 +72,6 @@ public abstract class RubikObject extends DistortedNode
     LEGAL_QUATS = getLegalQuats();
     NUM_CUBITS  = getNumCubits(size);
 
-    mNodeTexture = texture;
     mSize = size;
 
     mRotationAngleStatic = new Static1D(0);
@@ -88,9 +85,9 @@ public abstract class RubikObject extends DistortedNode
 
     mQuatAccumulated = quatAcc;
 
-    Static3D sinkCenter = new Static3D(TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f);
+    Static3D sinkCenter = new Static3D(0.5f,0.5f,0.5f);
     Static3D matrCenter = new Static3D(0,0,0);
-    Static4D region = new Static4D(0,0,0, TEXTURE_SIZE*0.72f);
+    Static4D region = new Static4D(0,0,0,0.72f);
 
     mSinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), sinkCenter, region );
     mMoveEffect = new MatrixEffectMove(mMove);
@@ -105,7 +102,7 @@ public abstract class RubikObject extends DistortedNode
     effects.apply(nodeMoveEffect);
 
     mCubits = new Cubit[NUM_CUBITS];
-    mTexture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
+    mTexture = new DistortedTexture();
 
     int vertices = (int)(24.0f/mSize + 2.0f);
     int[][] positions = getCubitPositions(size);
@@ -172,27 +169,27 @@ public abstract class RubikObject extends DistortedNode
 
   public void recomputeScaleFactor(int screenWidth, int screenHeight)
     {
-    int texW = mNodeTexture.getWidth();
-    int texH = mNodeTexture.getHeight();
+    int sizeX = getEffects().getStartchX();
+    int sizeY = getEffects().getStartchY();
 
-    if( (float)texH/texW > (float)screenHeight/screenWidth )
+    if( (float)sizeY/sizeX > (float)screenHeight/screenWidth )
       {
-      int w = (screenHeight*texW)/texH;
-      float factor = (float)screenHeight/texH;
+      int w = (screenHeight*sizeX)/sizeY;
+      float factor = (float)screenHeight/sizeY;
       mNodeMove.set((screenWidth-w)*0.5f ,0, 0);
       mNodeScale.set(factor,factor,factor);
       }
     else
       {
-      int h = (screenWidth*texH)/texW;
-      float factor = (float)screenWidth/texW;
+      int h = (screenWidth*sizeY)/sizeX;
+      float factor = (float)screenWidth/sizeX;
       mNodeMove.set(0,(screenHeight-h)*0.5f,0);
       mNodeScale.set(factor,factor,factor);
       }
 
-    float scaleFactor = (OBJECT_SCREEN_RATIO*texW/(TEXTURE_SIZE*mSize));
+    float scaleFactor = (OBJECT_SCREEN_RATIO*sizeX/mSize);
 
-    mMove.set( texW*0.5f , texH*0.5f , 0.0f );
+    mMove.set( sizeX*0.5f , sizeY*0.5f , 0.0f );
     mScale.set(scaleFactor,scaleFactor,scaleFactor);
     }
 
diff --git a/src/main/java/org/distorted/object/RubikObjectList.java b/src/main/java/org/distorted/object/RubikObjectList.java
index a56f6d10..8a05c31c 100644
--- a/src/main/java/org/distorted/object/RubikObjectList.java
+++ b/src/main/java/org/distorted/object/RubikObjectList.java
@@ -25,7 +25,7 @@ import org.distorted.library.mesh.MeshRectangles;
 import org.distorted.library.type.Static4D;
 import org.distorted.magic.R;
 
-import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
+import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -84,8 +84,8 @@ public enum RubikObjectList
 
   public RubikObject create(Static4D quatCur, Static4D quatAcc)
     {
-    DistortedTexture texture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
-    DistortedEffects effects = new DistortedEffects();
+    DistortedTexture texture = new DistortedTexture();
+    DistortedEffects effects = new DistortedEffects(NODE_MESH_SIZE,NODE_MESH_SIZE,0);
     MeshRectangles mesh      = new MeshRectangles(20,20);   // mesh of the node, not of the cubits
 
     return new RubikCube(mObjectSize, quatCur, quatAcc, texture, mesh, effects);
