commit 0df17fad7ecb90a8d0346ae0064766d61e6ff7cc
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Tue Jun 21 14:02:11 2016 +0100

    - Javadoc for EffectNames
    - make Matrix effects consistent with the rest (center of effect as last parameter!)
    - bugfix for yesterday's bugfix (we only want to send 'EFFECT_REMOVED' messages if it was really the Application that called 'abortAll' and not when we are cleaning up everything)

diff --git a/src/main/java/org/distorted/library/DistortedObject.java b/src/main/java/org/distorted/library/DistortedObject.java
index a196662..058a10d 100644
--- a/src/main/java/org/distorted/library/DistortedObject.java
+++ b/src/main/java/org/distorted/library/DistortedObject.java
@@ -171,9 +171,9 @@ public abstract class DistortedObject
    
   void releasePriv()
     {
-    if( matrixCloned  ==false) mM.abortAll();
-    if( vertexCloned  ==false) mV.abortAll();
-    if( fragmentCloned==false) mF.abortAll();
+    if( matrixCloned  ==false) mM.abortAll(false);
+    if( vertexCloned  ==false) mV.abortAll(false);
+    if( fragmentCloned==false) mF.abortAll(false);
 
     mBmp          = null;
     mGrid         = null;
@@ -374,7 +374,7 @@ public abstract class DistortedObject
  */
   public int abortAllEffects()
       {
-      return mM.abortAll() + mV.abortAll() + mF.abortAll();
+      return mM.abortAll(true) + mV.abortAll(true) + mF.abortAll(true);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -388,9 +388,9 @@ public abstract class DistortedObject
     {
     switch(type)
       {
-      case MATRIX  : return mM.abortAll();
-      case VERTEX  : return mV.abortAll();
-      case FRAGMENT: return mF.abortAll();
+      case MATRIX  : return mM.abortAll(true);
+      case VERTEX  : return mV.abortAll(true);
+      case FRAGMENT: return mF.abortAll(true);
       default      : return 0;
       }
     }
@@ -498,14 +498,14 @@ public abstract class DistortedObject
  * Rotates the Object by 'angle' degrees around the center.
  * Static axis of rotation is given by the last parameter.
  *
- * @param center Coordinates of the Point we are rotating around.
  * @param angle  Angle that we want to rotate the Object to. Unit: degrees
  * @param axis   Axis of rotation
+ * @param center Coordinates of the Point we are rotating around.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long rotate(Data3D center, Data1D angle, Static3D axis)
+  public long rotate(Data1D angle, Static3D axis, Data3D center )
     {   
-    return mM.add(EffectNames.ROTATE, center, angle, axis);
+    return mM.add(EffectNames.ROTATE, angle, axis, center);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -513,39 +513,39 @@ public abstract class DistortedObject
  * Rotates the Object by 'angle' degrees around the center.
  * Here both angle and axis can dynamically change.
  *
- * @param center    Coordinates of the Point we are rotating around.
  * @param angleaxis Combined 4-tuple representing the (angle,axisX,axisY,axisZ).
+ * @param center    Coordinates of the Point we are rotating around.
  * @return          ID of the effect added, or -1 if we failed to add one.
  */
-  public long rotate(Data3D center, Data4D angleaxis)
+  public long rotate(Data4D angleaxis, Data3D center)
     {
-    return mM.add(EffectNames.ROTATE, center, angleaxis);
+    return mM.add(EffectNames.ROTATE, angleaxis, center);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Rotates the Object by quaternion.
- *   
- * @param center     Coordinates of the Point we are rotating around.
+ *
  * @param quaternion The quaternion describing the rotation.
+ * @param center     Coordinates of the Point we are rotating around.
  * @return           ID of the effect added, or -1 if we failed to add one.
  */
-  public long quaternion(Data3D center, Data4D quaternion)
+  public long quaternion(Data4D quaternion, Data3D center )
     {
-    return mM.add(EffectNames.QUATERNION,center,quaternion);
+    return mM.add(EffectNames.QUATERNION,quaternion,center);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Shears the Object.
  *
- * @param center  Center of shearing, i.e. the point which stays unmoved.
  * @param shear   The 3-tuple of shear factors.
+ * @param center  Center of shearing, i.e. the point which stays unmoved.
  * @return        ID of the effect added, or -1 if we failed to add one.
  */
-  public long shear(Data3D center, Data3D shear)
+  public long shear(Data3D shear, Data3D center)
     {
-    return mM.add(EffectNames.SHEAR, center, shear);
+    return mM.add(EffectNames.SHEAR, shear, center);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/EffectMessageSender.java b/src/main/java/org/distorted/library/EffectMessageSender.java
index 8965188..5676c8c 100644
--- a/src/main/java/org/distorted/library/EffectMessageSender.java
+++ b/src/main/java/org/distorted/library/EffectMessageSender.java
@@ -116,8 +116,11 @@ final class EffectMessageSender extends Thread
         
   static void newMessage(EffectListener l, EffectMessage m, long id, int name, long bmpID, String str)
     {
-    Message msg = mThis.new Message(l,m,id,name,bmpID,str);
-    mList.add(msg);   
+    if( mThis!=null )
+      {
+      Message msg = mThis.new Message(l,m,id,name,bmpID,str);
+      mList.add(msg);
+      }
     }
   }
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/EffectNames.java b/src/main/java/org/distorted/library/EffectNames.java
index 10bf377..037b2f9 100644
--- a/src/main/java/org/distorted/library/EffectNames.java
+++ b/src/main/java/org/distorted/library/EffectNames.java
@@ -22,38 +22,168 @@ package org.distorted.library;
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Names of Effects one can apply to DistortedObjects.
+ * <p>
+ * Effect's 'unity' is a set of values which
  */
 public enum EffectNames
   {
   // EFFECT NAME /////// EFFECT TYPE ////////////// UNITY /////////////////////////
-   
+
+  /////////////////////////////////////////////////////////////////////////////////
+  // MATRIX EFFECTS.
+  // Always 7 Uniforms: 4 per-effect interpolated values + 3 dimensional center.
+ /**
+   * Rotate the whole Object around a center point (in angle-axis notation).
+   * <p>
+   * 7 Uniforms: (angle,axisX,axisY,axisZ,centerX,centerY,centerZ)
+   * Unity: angle==0
+   */
   ROTATE           ( EffectTypes.MATRIX  ,   new float[] {0.0f}           ),
-  QUATERNION       ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} ),      // quaternion is a unity iff its axis (x,y,z) is (0,0,0)
+ /**
+   * Rotate the whole Object around a center point (in quaternion notation).
+   * <p>
+   * 7 Uniforms: (quatX,quatY,quatZ,quatW,centerX,centerY,centerZ)
+   * Unity: (quatX,quatY,quatZ) = (0,0,0)
+   */
+  QUATERNION       ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} ),
+ /**
+   * Move the whole Object by a vector.
+   * <p>
+   * 7 Uniforms: (vectorX,vectorY,vectorZ,UNUSED,UNUSED,UNUSED,UNUSED)
+   * Unity: (vectorX,vectorY,vectorZ) = (0,0,0)
+   */
   MOVE             ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} ),
+ /**
+   * Scale the whole Object independently in all 3 dimensions.
+   * <p>
+   * 7 Uniforms: (scaleX,scaleY,scaleZ,UNUSED,UNUSED,UNUSED,UNUSED)
+   * Unity: (scaleX,scaleY,scaleZ) = (1,1,1)
+   */
   SCALE            ( EffectTypes.MATRIX  ,   new float[] {1.0f,1.0f,1.0f} ),
+ /**
+   * Shear the whole Object in 3 dimensions around a center point.
+   * <p>
+   * 7 Uniforms: (shearX,shearY,shearZ,UNUSED,centerX,centerY,centerZ)
+   * Unity:  (shearX,shearY,shearZ) = (0,0,0)
+   */
   SHEAR            ( EffectTypes.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} ),
   // add new Matrix effects here...
-  
+
+ /////////////////////////////////////////////////////////////////////////////////
+ // VERTEX EFFECTS
+ // Always 9 Uniforms: 3 per-effect interpolated values, 4-dimensional Region,
+ // 2-dimensional center of the effect.
+ /**
+   * Apply a 3D vector of force to area around a point on the surface of the Object.
+   * <p>
+   * 9 Uniforms: (forceX,forceY,forceZ,regionX,regionY,regionRX,regionRY,centerX,centerY)
+   * Unity: (forceX,forceY,forceZ) = (0,0,0)
+   */
   DISTORT          ( EffectTypes.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} ),      // keep this the first VERT effect (reason: getType)
+ /**
+   * Deform the whole Object by applying a 2D vector of force to a center point.
+   * <p>
+   * 9 Uniforms: (forceX,forceY,UNUSED,UNUSED,UNUSED,UNUSED,UNUSED,centerX,centerY)
+   * Unity: (forceX,forceY) = (0,0)
+   */
   DEFORM           ( EffectTypes.VERTEX  ,   new float[] {0.0f,0.0f}      ),
+ /**
+   * Pull (or push away) all points around a center point to (from) it.
+   * <p>
+   * 9 Uniforms: (sinkFactor,UNUSED,UNUSED,regionX,regionY,regionRX,regionRY,centerX,centerY)
+   * Unity: sinkFactor = 1
+   */
   SINK             ( EffectTypes.VERTEX  ,   new float[] {1.0f}           ),
+ /**
+   * Smoothly rotate a limited area around a center point.
+   * <p>
+   * 9 Uniforms: (swirlAngle,UNUSED,UNUSED,regionX,regionY,regionRX,regionRY,centerX,centerY)
+   * Unity: swirlAngle = 0
+   */
   SWIRL            ( EffectTypes.VERTEX  ,   new float[] {0.0f}           ),
-  WAVE             ( EffectTypes.VERTEX  ,   new float[] {0.0f}           ),
   // add new Vertex Effects here...
-  
+
+ /////////////////////////////////////////////////////////////////////////////////
+ // FRAGMENT EFFECTS
+ // Always 8 Uniforms: 4-per effect interpolated values, 4 dimensional Region.
+ /**
+   * Create square-shaped macroblocks.
+   * <p>
+   * 8 Uniforms: (macroblockSize,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
+   * Unity: macroblockSize = 1
+   */
   MACROBLOCK       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),      // keep this the first FRAG effect (reason: getType)
+ /**
+   * Make a given Region (partially) transparent.
+   * <p>
+   * 8 Uniforms: (transparencyLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
+   * Unity: transparencyLevel = 1
+   */
   ALPHA            ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+ /**
+   * Make a given Region (partially) transparent.
+   * Effect smoothly fades towards the edges of the region.
+   * <p>
+   * 8 Uniforms: (transparencyLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
+   * Unity: transparencyLevel = 1
+   */
   SMOOTH_ALPHA     ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+ /**
+   * Blend current color in the texture with a given color.
+   * <p>
+   * 8 Uniforms: (blendLevel,colorR,colorG,colorB, regionX, regionY, regionRX, regionRY)
+   * Unity: blendLevel = 0
+   */
   CHROMA           ( EffectTypes.FRAGMENT,   new float[] {0.0f}           ),
+ /**
+   * Smoothly blend current color in the texture with a given color.
+   * <p>
+   * 8 Uniforms: (blendLevel,colorR,colorG,colorB, regionX, regionY, regionRX, regionRY)
+   * Unity: blendLevel = 0
+   */
   SMOOTH_CHROMA    ( EffectTypes.FRAGMENT,   new float[] {0.0f}           ),
+ /**
+   * Change brightness level of a given Region.
+   * <p>
+   * 8 Uniforms: (brightnessLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
+   * Unity: brightnessLevel = 1
+   */
   BRIGHTNESS       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+ /**
+   * Smoothly change brightness level of a given Region.
+   * <p>
+   * 8 Uniforms: (brightnessLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
+   * Unity: brightnessLevel = 1
+   */
   SMOOTH_BRIGHTNESS( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+ /**
+   * Change saturation level of a given Region.
+   * <p>
+   * 8 Uniforms: (saturationLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
+   * Unity: saturationLevel = 1
+   */
   SATURATION       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+ /**
+   * Smoothly change saturation level of a given Region.
+   * <p>
+   * 8 Uniforms: (saturationLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
+   * Unity: saturationLevel = 1
+   */
   SMOOTH_SATURATION( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
+ /**
+   * Change contrast level of a given Region.
+   * <p>
+   * 8 Uniforms: (contrastLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
+   * Unity: contrastLevel = 1
+   */
   CONTRAST         ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
-  SMOOTH_CONTRAST  ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
-  HUE              ( EffectTypes.FRAGMENT,   new float[] {0.0f}           ),
-  SMOOTH_HUE       ( EffectTypes.FRAGMENT,   new float[] {0.0f}           );
+ /**
+   * Smoothly change contrast level of a given Region.
+   * <p>
+   * 8 Uniforms: (contrastLevel,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
+   * Unity: contrastLevel = 1
+   */
+  SMOOTH_CONTRAST  ( EffectTypes.FRAGMENT,   new float[] {1.0f}           );
   // add new Fragment effects here...
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/main/java/org/distorted/library/EffectQueue.java b/src/main/java/org/distorted/library/EffectQueue.java
index 95f71e9..87f7729 100644
--- a/src/main/java/org/distorted/library/EffectQueue.java
+++ b/src/main/java/org/distorted/library/EffectQueue.java
@@ -195,8 +195,10 @@ abstract class EffectQueue
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-  
-  synchronized int abortAll()
+// we do want to notify Listeners if they called 'abortAll' themselves but don't want to notify
+// them if it is the library itself which is releasing resources.
+
+  synchronized int abortAll(boolean notify)
     {
     int ret = mNumEffects;
     long removedID;
@@ -208,16 +210,19 @@ abstract class EffectQueue
       mInter[1][i] = null;
       mInter[2][i] = null;
 
-      removedID = mID[i];
-      removedType= mType[i];
-
-      for(int j=0; j<mNumListeners; j++)
-        EffectMessageSender.newMessage( mListeners.elementAt(j),
-                                        EffectMessage.EFFECT_REMOVED,
-                                        (removedID<<EffectTypes.LENGTH)+EffectNames.getType(removedType).type,
-                                        removedType,
-                                        mBitmapID,
-                                        null);
+      if( notify )
+        {
+        removedID = mID[i];
+        removedType= mType[i];
+
+        for(int j=0; j<mNumListeners; j++)
+          EffectMessageSender.newMessage( mListeners.elementAt(j),
+                                          EffectMessage.EFFECT_REMOVED,
+                                          (removedID<<EffectTypes.LENGTH)+EffectNames.getType(removedType).type,
+                                          removedType,
+                                          mBitmapID,
+                                          null);
+        }
       }
 
     mNumEffects= 0;
diff --git a/src/main/java/org/distorted/library/EffectQueueMatrix.java b/src/main/java/org/distorted/library/EffectQueueMatrix.java
index e7a8b9c..5504189 100644
--- a/src/main/java/org/distorted/library/EffectQueueMatrix.java
+++ b/src/main/java/org/distorted/library/EffectQueueMatrix.java
@@ -105,7 +105,7 @@ class EffectQueueMatrix extends EffectQueue
    
     for(int i=0; i<mNumEffects; i++)
       {
-      if( mInter[0][i]!=null && mInter[0][i].interpolateMain(mUniforms ,NUM_UNIFORMS*i+3, mCurrentDuration[i], step) )
+      if( mInter[0][i]!=null && mInter[0][i].interpolateMain(mUniforms ,NUM_UNIFORMS*i, mCurrentDuration[i], step) )
         {
         for(int j=0; j<mNumListeners; j++)
           EffectMessageSender.newMessage( mListeners.elementAt(j),
@@ -115,7 +115,7 @@ class EffectQueueMatrix extends EffectQueue
                                           mBitmapID,
                                           null);
 
-        if( EffectNames.isUnity(mType[i], mUniforms, NUM_UNIFORMS*i+3) )
+        if( EffectNames.isUnity(mType[i], mUniforms, NUM_UNIFORMS*i) )
           {
           remove(i);
           i--;
@@ -125,7 +125,7 @@ class EffectQueueMatrix extends EffectQueue
 
       if( mInter[1][i]!=null )
         {
-        mInter[1][i].interpolateMain(mUniforms, NUM_UNIFORMS*i, mCurrentDuration[i]);
+        mInter[1][i].interpolateMain(mUniforms, NUM_UNIFORMS*i+4, mCurrentDuration[i]);
         }
 
       mCurrentDuration[i] += step;
@@ -161,50 +161,50 @@ class EffectQueueMatrix extends EffectQueue
       {
       if (mType[i] == EffectNames.ROTATE.ordinal() )
         {
-        x = mUniforms[NUM_UNIFORMS*i  ];
-        y = mUniforms[NUM_UNIFORMS*i+1];
-        z = mUniforms[NUM_UNIFORMS*i+2];
+        x = mUniforms[NUM_UNIFORMS*i+4];
+        y = mUniforms[NUM_UNIFORMS*i+5];
+        z = mUniforms[NUM_UNIFORMS*i+6];
 
         Matrix.translateM(viewMatrix, 0, x,-y, z); 
-        Matrix.rotateM( viewMatrix, 0, mUniforms[NUM_UNIFORMS*i+3], mUniforms[NUM_UNIFORMS*i+4], mUniforms[NUM_UNIFORMS*i+5], mUniforms[NUM_UNIFORMS*i+6]);  
+        Matrix.rotateM( viewMatrix, 0, mUniforms[NUM_UNIFORMS*i], mUniforms[NUM_UNIFORMS*i+1], mUniforms[NUM_UNIFORMS*i+2], mUniforms[NUM_UNIFORMS*i+3]);
         Matrix.translateM(viewMatrix, 0,-x, y,-z);  
         }
       else if(mType[i] == EffectNames.QUATERNION.ordinal() )
         {
-        x = mUniforms[NUM_UNIFORMS*i  ];
-        y = mUniforms[NUM_UNIFORMS*i+1];
-        z = mUniforms[NUM_UNIFORMS*i+2];
+        x = mUniforms[NUM_UNIFORMS*i+4];
+        y = mUniforms[NUM_UNIFORMS*i+5];
+        z = mUniforms[NUM_UNIFORMS*i+6];
      	
         Matrix.translateM(viewMatrix, 0, x,-y, z); 
-        multiplyByQuat(viewMatrix, mUniforms[NUM_UNIFORMS*i+3], mUniforms[NUM_UNIFORMS*i+4], mUniforms[NUM_UNIFORMS*i+5], mUniforms[NUM_UNIFORMS*i+6]);
+        multiplyByQuat(viewMatrix, mUniforms[NUM_UNIFORMS*i], mUniforms[NUM_UNIFORMS*i+1], mUniforms[NUM_UNIFORMS*i+2], mUniforms[NUM_UNIFORMS*i+3]);
         Matrix.translateM(viewMatrix, 0,-x, y,-z);  
         }
       else if(mType[i] == EffectNames.MOVE.ordinal() )
         {
-        sx = mUniforms[NUM_UNIFORMS*i+3];   
-        sy = mUniforms[NUM_UNIFORMS*i+4];   
-        sz = mUniforms[NUM_UNIFORMS*i+5];   
+        sx = mUniforms[NUM_UNIFORMS*i  ];
+        sy = mUniforms[NUM_UNIFORMS*i+1];
+        sz = mUniforms[NUM_UNIFORMS*i+2];
         
         Matrix.translateM(viewMatrix, 0, sx,-sy, sz);   
         }
       else if(mType[i] == EffectNames.SCALE.ordinal() )
         {
-        sx = mUniforms[NUM_UNIFORMS*i+3];   
-        sy = mUniforms[NUM_UNIFORMS*i+4];   
-        sz = mUniforms[NUM_UNIFORMS*i+5];   
+        sx = mUniforms[NUM_UNIFORMS*i  ];
+        sy = mUniforms[NUM_UNIFORMS*i+1];
+        sz = mUniforms[NUM_UNIFORMS*i+2];
 
         Matrix.scaleM(viewMatrix, 0, sx, sy, sz);  
         }
       else if(mType[i] == EffectNames.SHEAR.ordinal() )
         {
-        x  = mUniforms[NUM_UNIFORMS*i  ];
-        y  = mUniforms[NUM_UNIFORMS*i+1];
-        z  = mUniforms[NUM_UNIFORMS*i+2];
-        
-        sx = mUniforms[NUM_UNIFORMS*i+3];   
-        sy = mUniforms[NUM_UNIFORMS*i+4];   
-        sz = mUniforms[NUM_UNIFORMS*i+5];   
-        
+        sx = mUniforms[NUM_UNIFORMS*i  ];
+        sy = mUniforms[NUM_UNIFORMS*i+1];
+        sz = mUniforms[NUM_UNIFORMS*i+2];
+
+        x  = mUniforms[NUM_UNIFORMS*i+4];
+        y  = mUniforms[NUM_UNIFORMS*i+5];
+        z  = mUniforms[NUM_UNIFORMS*i+6];
+
         Matrix.translateM(viewMatrix, 0, x,-y, z); 
       
         viewMatrix[4] += sx*viewMatrix[0]; // Multiply viewMatrix by 1 x 0 0 , i.e. X-shear. TODO: change this so it is symmetric w respect to all the axis.
@@ -260,9 +260,9 @@ class EffectQueueMatrix extends EffectQueue
       else if( vector instanceof Static3D )
         {
         mInter[0][mNumEffects] = null;
-        mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static3D)vector).getX();
-        mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)vector).getY();
-        mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)vector).getZ();
+        mUniforms[NUM_UNIFORMS*mNumEffects  ] = ((Static3D)vector).getX();
+        mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)vector).getY();
+        mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)vector).getZ();
         }
       else return -1;
 
@@ -275,31 +275,31 @@ class EffectQueueMatrix extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // rotate - static axis
 
-  synchronized long add(EffectNames eln, Data3D center, Data1D angle, Static3D axis)
+  synchronized long add(EffectNames eln, Data1D angle, Static3D axis, Data3D center)
     {
     if( mMax[INDEX]>mNumEffects )
       {
-           if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center;
-      else if( center instanceof Static3D )
-        {
-        mInter[1][mNumEffects] = null;
-        mUniforms[NUM_UNIFORMS*mNumEffects  ] = ((Static3D)center).getX();
-        mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)center).getY();
-        mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)center).getZ();
-        }
-      else return -1;
-
            if( angle instanceof Dynamic1D) mInter[0][mNumEffects] = (Dynamic1D)angle;
       else if( angle instanceof Static1D)
         {
         mInter[0][mNumEffects] = null;
-        mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static1D)angle).getX();
+        mUniforms[NUM_UNIFORMS*mNumEffects] = ((Static1D)angle).getX();
         }
       else return -1;
 
-      mUniforms[NUM_UNIFORMS*mNumEffects+4] = axis.getX();
-      mUniforms[NUM_UNIFORMS*mNumEffects+5] = axis.getY();
-      mUniforms[NUM_UNIFORMS*mNumEffects+6] = axis.getZ();
+      mUniforms[NUM_UNIFORMS*mNumEffects+1] = axis.getX();
+      mUniforms[NUM_UNIFORMS*mNumEffects+2] = axis.getY();
+      mUniforms[NUM_UNIFORMS*mNumEffects+3] = axis.getZ();
+
+      if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center;
+      else if( center instanceof Static3D )
+        {
+        mInter[1][mNumEffects] = null;
+        mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)center).getX();
+        mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getY();
+        mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static3D)center).getZ();
+        }
+      else return -1;
 
       return addBase(eln);
       }
@@ -310,29 +310,29 @@ class EffectQueueMatrix extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // quaternion or rotate - dynamic axis
 
-  synchronized long add(EffectNames eln, Data3D center, Data4D data)
+  synchronized long add(EffectNames eln, Data4D data, Data3D center)
     {
     if( mMax[INDEX]>mNumEffects )
       {
-           if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center;
-      else if( center instanceof Static3D )
-        {
-        mInter[1][mNumEffects] = null;
-        mUniforms[NUM_UNIFORMS*mNumEffects  ] = ((Static3D)center).getX();
-        mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)center).getY();
-        mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)center).getZ();
-        }
-      else return -1;
-
            if( data instanceof Dynamic4D  ) mInter[0][mNumEffects] = (Dynamic4D)data;
       else if( data instanceof DynamicQuat) mInter[0][mNumEffects] = (DynamicQuat)data;
       else if( data instanceof Static4D   )
         {
         mInter[0][mNumEffects] = null;
-        mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static4D)data).getX();
-        mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static4D)data).getY();
-        mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static4D)data).getZ();
-        mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static4D)data).getW();
+        mUniforms[NUM_UNIFORMS*mNumEffects  ] = ((Static4D)data).getX();
+        mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static4D)data).getY();
+        mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static4D)data).getZ();
+        mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static4D)data).getW();
+        }
+      else return -1;
+
+      if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center;
+      else if( center instanceof Static3D )
+        {
+        mInter[1][mNumEffects] = null;
+        mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)center).getX();
+        mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getY();
+        mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static3D)center).getZ();
         }
       else return -1;
 
@@ -345,27 +345,27 @@ class EffectQueueMatrix extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // shear
 
-  synchronized long add(EffectNames eln, Data3D center, Data3D shear)
+  synchronized long add(EffectNames eln, Data3D shear, Data3D center)
     {
     if( mMax[INDEX]>mNumEffects )
       {
-           if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center;
-      else if( center instanceof Static3D )
+           if( shear instanceof Dynamic3D) mInter[0][mNumEffects] = (Dynamic3D)shear;
+      else if( shear instanceof Static3D )
         {
-        mInter[1][mNumEffects] = null;
-        mUniforms[NUM_UNIFORMS*mNumEffects  ] = ((Static3D)center).getX();
-        mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)center).getY();
-        mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)center).getZ();
+        mInter[0][mNumEffects] = null;
+        mUniforms[NUM_UNIFORMS*mNumEffects  ] = ((Static3D)shear).getX();
+        mUniforms[NUM_UNIFORMS*mNumEffects+1] = ((Static3D)shear).getY();
+        mUniforms[NUM_UNIFORMS*mNumEffects+2] = ((Static3D)shear).getZ();
         }
       else return -1;
 
-           if( shear instanceof Dynamic3D) mInter[0][mNumEffects] = (Dynamic3D)shear;
-      else if( shear instanceof Static3D )
+      if( center instanceof Dynamic3D) mInter[1][mNumEffects] = (Dynamic3D)center;
+      else if( center instanceof Static3D )
         {
-        mInter[0][mNumEffects] = null;
-        mUniforms[NUM_UNIFORMS*mNumEffects+3] = ((Static3D)shear).getX();
-        mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)shear).getY();
-        mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)shear).getZ();
+        mInter[1][mNumEffects] = null;
+        mUniforms[NUM_UNIFORMS*mNumEffects+4] = ((Static3D)center).getX();
+        mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getY();
+        mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static3D)center).getZ();
         }
       else return -1;
 
diff --git a/src/main/res/raw/main_vertex_shader.glsl b/src/main/res/raw/main_vertex_shader.glsl
index ffba582..2be84f3 100644
--- a/src/main/res/raw/main_vertex_shader.glsl
+++ b/src/main/res/raw/main_vertex_shader.glsl
@@ -289,15 +289,6 @@ void swirl(in int effect, inout vec4 P)
   P.xy += min(d1_circle,d1_bitmap)*(PS - PS2/(1.0-d2));        // if d2=1 (i.e P=S) we should have P unchanged. How to do it?
   }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-// Wave
-//
-
-void wave(in int effect, inout vec4 P)
-  {
-
-  }
-
 //////////////////////////////////////////////////////////////////////////////////////////////
 // Clamp v.z to (-u_Depth,u_Depth) with the following function:
 // define h to be, say, 0.7; let H=u_Depth
@@ -332,14 +323,12 @@ void main()
     //  case DEFORM : deform(3*i,v)   ; break;
     //  case SINK   : sink(3*i,v)     ; break;
     //  case SWIRL  : swirl(3*i,v)    ; break;
-    //  case WAVE   : wave(3*i,v)     ; break;
     //  }
         
          if( vType[i]==DISTORT) distort(3*i,v,n);
     else if( vType[i]==DEFORM ) deform(3*i,v);
     else if( vType[i]==SINK   ) sink(3*i,v);
     else if( vType[i]==SWIRL  ) swirl(3*i,v);
-    else if( vType[i]==WAVE   ) wave(3*i,v);   
     }
  
   restrict(v.z);  
