commit fa6c352d97698bac2e125e57a7df6e0fab4730c0
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Mon Nov 14 22:00:16 2016 +0000

    Complete moving center to 3D.

diff --git a/src/main/java/org/distorted/library/DistortedObject.java b/src/main/java/org/distorted/library/DistortedObject.java
index ea05c04..86c00c7 100644
--- a/src/main/java/org/distorted/library/DistortedObject.java
+++ b/src/main/java/org/distorted/library/DistortedObject.java
@@ -723,11 +723,11 @@ public abstract class DistortedObject
  *
  * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
  *               currently being dragged with.
- * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
+ * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @param region Region that masks the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long distort(Data3D vector, Data2D center, Data4D region)
+  public long distort(Data3D vector, Data3D center, Data4D region)
     {  
     return mV.add(EffectNames.DISTORT, vector, center, region);
     }
@@ -738,10 +738,10 @@ public abstract class DistortedObject
  *
  * @param vector 3-dimensional Vector which represents the force the Center of the Effect is
  *               currently being dragged with.
- * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
+ * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long distort(Data3D vector, Data2D center)
+  public long distort(Data3D vector, Data3D center)
     {
     return mV.add(EffectNames.DISTORT, vector, center, null);
     }
@@ -752,10 +752,10 @@ public abstract class DistortedObject
  * a (possibly changing in time) point on the Object.
  *     
  * @param vector Vector of force that deforms the shape of the whole Object.
- * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
+ * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long deform(Data3D vector, Data2D center)
+  public long deform(Data3D vector, Data3D center)
     {  
     return mV.add(EffectNames.DEFORM, vector, center, null);
     }
@@ -766,11 +766,11 @@ public abstract class DistortedObject
  * away from the center (degree<=1)
  *
  * @param sink   The current degree of the Effect.
- * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
+ * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @param region Region that masks the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long sink(Data1D sink, Data2D center, Data4D region)
+  public long sink(Data1D sink, Data3D center, Data4D region)
     {
     return mV.add(EffectNames.SINK, sink, center, region);
     }
@@ -781,10 +781,10 @@ public abstract class DistortedObject
  * away from the center (degree<=1)
  *
  * @param sink   The current degree of the Effect.
- * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
+ * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long sink(Data1D sink, Data2D center)
+  public long sink(Data1D sink, Data3D center)
     {
     return mV.add(EffectNames.SINK, sink, center);
     }
@@ -794,11 +794,11 @@ public abstract class DistortedObject
  * Rotate part of the Object around the Center of the Effect by a certain angle.
  *
  * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
- * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
+ * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @param region Region that masks the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long swirl(Data1D swirl, Data2D center, Data4D region)
+  public long swirl(Data1D swirl, Data3D center, Data4D region)
     {    
     return mV.add(EffectNames.SWIRL, swirl, center, region);
     }
@@ -808,10 +808,10 @@ public abstract class DistortedObject
  * Rotate the whole Object around the Center of the Effect by a certain angle.
  *
  * @param swirl  The angle of Swirl (in degrees). Positive values swirl clockwise.
- * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
+ * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long swirl(Data1D swirl, Data2D center)
+  public long swirl(Data1D swirl, Data3D center)
     {
     return mV.add(EffectNames.SWIRL, swirl, center);
     }
@@ -842,10 +842,10 @@ public abstract class DistortedObject
  *               Example3: if Alpha = 0 and Beta = 45, then V=(sqrt(2)/2, -sqrt(2)/2, 0) and the wave
  *               is entirely 'horizontal' and moves point (x,y,0) in direction V by whatever is the
  *               value if sin at this point.
- * @param center 2-dimensional Data that, at any given time, returns the Center of the Effect.
+ * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long wave(Data5D wave, Data2D center)
+  public long wave(Data5D wave, Data3D center)
     {
     return mV.add(EffectNames.WAVE, wave, center, null);
     }
@@ -855,11 +855,11 @@ public abstract class DistortedObject
  * Directional, sinusoidal wave effect.
  *
  * @param wave   see {@link DistortedObject#wave(Data5D,Data2D)}
- * @param center see {@link DistortedObject#wave(Data5D,Data2D)}
+ * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @param region Region that masks the Effect.
  * @return       ID of the effect added, or -1 if we failed to add one.
  */
-  public long wave(Data5D wave, Data2D center, Data4D region)
+  public long wave(Data5D wave, Data3D center, Data4D region)
     {
     return mV.add(EffectNames.WAVE, wave, center, region);
     }
diff --git a/src/main/java/org/distorted/library/EffectNames.java b/src/main/java/org/distorted/library/EffectNames.java
index 3d70f95..43d00f9 100644
--- a/src/main/java/org/distorted/library/EffectNames.java
+++ b/src/main/java/org/distorted/library/EffectNames.java
@@ -53,7 +53,7 @@ public enum EffectNames
    * <p>
    * Unity: angle==0
    */
-  ROTATE           ( EffectTypes.MATRIX  ,   new float[] {0.0f}           , 1, false, true ),
+  ROTATE           ( EffectTypes.MATRIX  ,   new float[] {0.0f}           , 4, false, true ),
  /**
    * Rotate the whole Object around a center point (in quaternion notation).
    * <p>
diff --git a/src/main/java/org/distorted/library/EffectQueueVertex.java b/src/main/java/org/distorted/library/EffectQueueVertex.java
index 8f0ac99..f8734ae 100644
--- a/src/main/java/org/distorted/library/EffectQueueVertex.java
+++ b/src/main/java/org/distorted/library/EffectQueueVertex.java
@@ -23,17 +23,14 @@ import android.opengl.GLES20;
 
 import org.distorted.library.message.EffectMessage;
 import org.distorted.library.type.Data1D;
-import org.distorted.library.type.Data2D;
 import org.distorted.library.type.Data3D;
 import org.distorted.library.type.Data4D;
 import org.distorted.library.type.Data5D;
 import org.distorted.library.type.Dynamic1D;
-import org.distorted.library.type.Dynamic2D;
 import org.distorted.library.type.Dynamic3D;
 import org.distorted.library.type.Dynamic4D;
 import org.distorted.library.type.Dynamic5D;
 import org.distorted.library.type.Static1D;
-import org.distorted.library.type.Static2D;
 import org.distorted.library.type.Static3D;
 import org.distorted.library.type.Static4D;
 import org.distorted.library.type.Static5D;
@@ -109,10 +106,11 @@ class EffectQueueVertex extends EffectQueue
 
       if( mInter[2][i]!=null )  // center
         {
-        mInter[2][i].interpolateMain(mUniforms, NUM_UNIFORMS*i+6, mCurrentDuration[i], step);
+        mInter[2][i].interpolateMain(mUniforms, NUM_UNIFORMS*i+5, mCurrentDuration[i], step);
 
-        mUniforms[NUM_UNIFORMS*i+6] = mUniforms[NUM_UNIFORMS*i+6]-mObjHalfX;
-        mUniforms[NUM_UNIFORMS*i+7] =-mUniforms[NUM_UNIFORMS*i+7]+mObjHalfY;
+        mUniforms[NUM_UNIFORMS*i+5] = mUniforms[NUM_UNIFORMS*i+5]-mObjHalfX;
+        mUniforms[NUM_UNIFORMS*i+6] =-mUniforms[NUM_UNIFORMS*i+6]+mObjHalfY;
+        mUniforms[NUM_UNIFORMS*i+7] = mUniforms[NUM_UNIFORMS*i+7]-mObjHalfZ;
         }
 
       mCurrentDuration[i] += step;
@@ -187,7 +185,7 @@ class EffectQueueVertex extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // wave
 
-  synchronized long add(EffectNames eln, Data5D data, Data2D center, Data4D region)
+  synchronized long add(EffectNames eln, Data5D data, Data3D center, Data4D region)
     {
     if( mMax[INDEX]>mNumEffects )
       {
@@ -218,7 +216,7 @@ class EffectQueueVertex extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // deform,distort
 
-  synchronized long add(EffectNames eln, Data3D data, Data2D center, Data4D region)
+  synchronized long add(EffectNames eln, Data3D data, Data3D center, Data4D region)
     {
     if( mMax[INDEX]>mNumEffects )
       {
@@ -247,7 +245,7 @@ class EffectQueueVertex extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // sink, swirl
 
-  synchronized long add(EffectNames eln, Data1D data, Data2D center, Data4D region)
+  synchronized long add(EffectNames eln, Data1D data, Data3D center, Data4D region)
     {
     if( mMax[INDEX]>mNumEffects )
       {
@@ -272,7 +270,7 @@ class EffectQueueVertex extends EffectQueue
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // sink, swirl
 
-  synchronized long add(EffectNames eln, Data1D data, Data2D center)
+  synchronized long add(EffectNames eln, Data1D data, Data3D center)
     {
     if( mMax[INDEX]>mNumEffects )
       {
@@ -296,7 +294,7 @@ class EffectQueueVertex extends EffectQueue
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
   
-  private long addPriv(EffectNames eln, Data2D center, Data4D region)
+  private long addPriv(EffectNames eln, Data3D center, Data4D region)
     {
     if( region!=null )
       {
@@ -327,15 +325,16 @@ class EffectQueueVertex extends EffectQueue
       mInter[1][mNumEffects] = null;
       }
 
-    if( center instanceof Dynamic2D)
+    if( center instanceof Dynamic3D)
       {
-      mInter[2][mNumEffects] = (Dynamic2D)center;
+      mInter[2][mNumEffects] = (Dynamic3D)center;
       }
-    else if( center instanceof Static2D)
+    else if( center instanceof Static3D)
       {
       mInter[2][mNumEffects] = null;
-      mUniforms[NUM_UNIFORMS*mNumEffects+6] = ((Static2D)center).getX()-mObjHalfX;
-      mUniforms[NUM_UNIFORMS*mNumEffects+7] =-((Static2D)center).getY()+mObjHalfY;
+      mUniforms[NUM_UNIFORMS*mNumEffects+5] = ((Static3D)center).getX()-mObjHalfX;
+      mUniforms[NUM_UNIFORMS*mNumEffects+6] =-((Static3D)center).getY()+mObjHalfY;
+      mUniforms[NUM_UNIFORMS*mNumEffects+7] = ((Static3D)center).getZ()-mObjHalfZ;
       }
 
     long ret= addBase(eln);
diff --git a/src/main/res/raw/main_vertex_shader.glsl b/src/main/res/raw/main_vertex_shader.glsl
index 1c97a5d..09c950d 100644
--- a/src/main/res/raw/main_vertex_shader.glsl
+++ b/src/main/res/raw/main_vertex_shader.glsl
@@ -208,7 +208,7 @@ void restrictZ(inout float v)
   
 void deform(in int effect, inout vec4 v)
   {
-  vec2 center = vUniforms[effect+1].zw;
+  vec2 center = vUniforms[effect+1].yz;
   vec2 force = vUniforms[effect].xy;    // force = vec(MM')
   vec2 vert_vec, horz_vec; 
   vec2 signXY = sign(center-v.xy);
@@ -286,7 +286,7 @@ void deform(in int effect, inout vec4 v)
         
 void distort(in int effect, inout vec4 v, inout vec4 n)
   {
-  vec2 center = vUniforms[effect+1].zw;
+  vec2 center = vUniforms[effect+1].yz;
   vec2 ps = center-v.xy;
   vec3 force = vUniforms[effect].xyz;
   float d = degree(vUniforms[effect+2],center,ps);
@@ -314,7 +314,7 @@ void distort(in int effect, inout vec4 v, inout vec4 n)
  
 void sink(in int effect,inout vec4 v)
   {
-  vec2 center = vUniforms[effect+1].zw;
+  vec2 center = vUniforms[effect+1].yz;
   vec2 ps = center-v.xy;
   float h = vUniforms[effect].x;
   float t = degree(vUniforms[effect+2],center,ps) * (1.0-h)/max(1.0,h);
@@ -331,7 +331,7 @@ void sink(in int effect,inout vec4 v)
 
 void swirl(in int effect, inout vec4 v)
   {
-  vec2 center  = vUniforms[effect+1].zw;
+  vec2 center  = vUniforms[effect+1].yz;
   vec2 PS = center-v.xy;
   vec4 SO = vUniforms[effect+2];
   float d1_circle = degree_region(SO,PS);
@@ -416,7 +416,7 @@ void swirl(in int effect, inout vec4 v)
 
 void wave(in int effect, inout vec4 v, inout vec4 n)
   {
-  vec2 center     = vUniforms[effect+1].zw;
+  vec2 center     = vUniforms[effect+1].yz;
   float amplitude = vUniforms[effect  ].x;
   float length    = vUniforms[effect  ].y;
 
