commit fce25d0438c7b4f0a423a8943d0a269e4d9dfada
Author: leszek <leszek@koltunski.pl>
Date:   Wed Apr 26 00:06:57 2017 +0100

    Revert "Progress with the last 2 Apps: Effects3D and Wind (not done yet)"
    
    This reverts commit 752c6b57bb227292e6c28438b955fcb892f7acc6.

diff --git a/src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java b/src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java
index 8da600d..e25a7d0 100644
--- a/src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java
+++ b/src/main/java/org/distorted/examples/effects3d/Effects3DEffect.java
@@ -131,24 +131,16 @@ class Effects3DEffect implements SeekBar.OnSeekBarChangeListener
                               float sinAnorm = (float)Math.sin(qa/2)/len;
                               mSta4.set(sinAnorm*qx,sinAnorm*qy,sinAnorm*qz, cosA);
                               break;
-      case MOVE             : float s  = 0.04f;
-                              float xm = (mInter[0]-50)*s;
-                              float ym = (mInter[1]-50)*s;
-                              float zm = (mInter[2]-50)*s;
+      case MOVE             : float sw = mAct.get().getScreenWidth()/50.0f;
+                              float sh = mAct.get().getScreenWidth()/50.0f;
+                              float xm = (mInter[0]-50)*sw;
+                              float ym = (mInter[1]-50)*sh;
+                              float zm = (mInter[2]-50)*(sw+sh)/2;
                               mSta3.set(xm,ym,zm);
                               break;
-      case SCALE            : double coeff = Math.PI / 100;
-
-                              if( mInter[0]<=  0 ) mInter[0]= 1;
-                              if( mInter[0]>=100 ) mInter[0]=99;
-                              if( mInter[1]<=  0 ) mInter[1]= 1;
-                              if( mInter[1]>=100 ) mInter[1]=99;
-                              if( mInter[2]<=  0 ) mInter[2]= 1;
-                              if( mInter[2]>=100 ) mInter[2]=99;
-
-                              float xs = (float)Math.tan((mInter[0]-50)*coeff);
-                              float ys = (float)Math.tan((mInter[1]-50)*coeff);
-                              float zs = (float)Math.tan((mInter[2]-50)*coeff);
+      case SCALE            : float xs = (mInter[0]>50 ? 0.18f : 0.018f)*(mInter[0]-50) + 1;
+                              float ys = (mInter[1]>50 ? 0.18f : 0.018f)*(mInter[1]-50) + 1;
+                              float zs = (mInter[2]>50 ? 0.18f : 0.018f)*(mInter[2]-50) + 1;
                               mSta3.set(xs,ys,zs);
                               break;
       case SHEAR            : float xsh = (mInter[0]-50)/25.0f;
@@ -213,16 +205,7 @@ class Effects3DEffect implements SeekBar.OnSeekBarChangeListener
       case 1: mInter[0] = 50;
       }
 
-    if( mName==EffectNames.ROTATE || mName==EffectNames.QUATERNION )
-      {
-      mInter[1]= 100;
-      }
-    if( mName==EffectNames.SCALE )
-      {
-      mInter[0]= 75;
-      mInter[1]= 75;
-      mInter[2]= 75;
-      }
+    if( mName==EffectNames.ROTATE || mName==EffectNames.QUATERNION ) mInter[1]= 100;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -278,9 +261,11 @@ class Effects3DEffect implements SeekBar.OnSeekBarChangeListener
 
   private void fillCenterStatics()
     {
-    float x = (mInterCenter[0]-50)*0.02f;
-    float y = (mInterCenter[1]-50)*0.02f;
-    float z = (mInterCenter[2]-50)*0.02f;
+    Effects3DActivity act = mAct.get();
+
+    float x = (mInterCenter[0]*0.012f - 0.1f)*act.getWidth();
+    float y = (mInterCenter[1]*0.012f - 0.1f)*act.getHeight();
+    float z = (mInterCenter[2]*0.012f - 0.1f)*act.getDepth();
 
     mCenterSta.set(x,y,z);
     }
@@ -298,9 +283,9 @@ class Effects3DEffect implements SeekBar.OnSeekBarChangeListener
 
   private void setCenterText()
     {
-    float f0 = ((int)(mCenterSta.getX()*100))/100.0f;
-    float f1 = ((int)(mCenterSta.getY()*100))/100.0f;
-    float f2 = ((int)(mCenterSta.getZ()*100))/100.0f;
+    int f0 = (int)mCenterSta.getX();
+    int f1 = (int)mCenterSta.getY();
+    int f2 = (int)mCenterSta.getZ();
 
     mTextCenter.setText("center ("+f0+","+f1+","+f2+")");
     }
diff --git a/src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java b/src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
index e92575b..51ea6f0 100644
--- a/src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
+++ b/src/main/java/org/distorted/examples/effects3d/Effects3DRenderer.java
@@ -173,30 +173,12 @@ class Effects3DRenderer implements GLSurfaceView.Renderer
     public void onSurfaceChanged(GL10 glUnused, int width, int height)
       {
       mScreenMin = width<height ? width:height;
-      Static3D centerRot = new Static3D(0,0,0);
-
-      //// BACKGROUND ////////////
-      // quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() )
-      float distToScreen = height/(2.0f*(float)Math.tan(FOV*Math.PI/360));
-      float distToFar    = distToScreen*(2-NEAR);
-      float factor       = distToFar / distToScreen;
-      mBackgroundEffects.abortEffects(EffectTypes.MATRIX);
-      mBackgroundEffects.move(new Static3D( 0, 0, -(distToFar-distToScreen)/width ) );
-      mBackgroundEffects.scale(new Static3D(factor,factor,1.0f) );
-
-      //// OBJECT //////////////
-      float qObj= ((float)width/height)*((float)mObjHeight/mObjWidth);
-      float sObj= 0.8f;
 
       mObjectEffects.abortEffects(EffectTypes.MATRIX);
-      mObjectEffects.quaternion(mQuatInt1, centerRot);
-      mObjectEffects.quaternion(mQuatInt2, centerRot);
-      mObjectEffects.scale(  qObj<1 ? (new Static3D(sObj,sObj*qObj,sObj)) : (new Static3D(sObj/qObj,sObj,sObj/qObj)) );
-
-
-
+      mBackgroundEffects.abortEffects(EffectTypes.MATRIX);
+      mCenterEffects.abortEffects(EffectTypes.MATRIX);
+      mRegionEffects.abortEffects(EffectTypes.MATRIX);
 
-      /*
       float factorCen;
       int centerSize = mCenterTexture.getWidth();
       int regionSize = mRegionTexture.getWidth();
@@ -218,24 +200,23 @@ class Effects3DRenderer implements GLSurfaceView.Renderer
 
       mFactorReg = 2*mFactorObj*act.getRegionR()/regionSize;
       mRegionScalePoint.set(mFactorReg,mFactorReg,mFactorReg);
-      */
 
+      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
 
-      //// CENTER //////////////
-      float qCen= ((float)width/height);
-      float sCen= 0.1f;
+      mObjectEffects.move( new Static3D( (width-mFactorObj*mObjWidth)/2 , (height-mFactorObj*mObjHeight)/2 , 0) );
+      mObjectEffects.scale(mFactorObj);
+      mObjectEffects.quaternion(mQuatInt1, rotateObj);
+      mObjectEffects.quaternion(mQuatInt2, rotateObj);
 
-      mCenterEffects.abortEffects(EffectTypes.MATRIX);
-      /*
-      mCenterEffects.quaternion(mQuatInt1, centerRot);
-      mCenterEffects.quaternion(mQuatInt2, centerRot);
-      mCenterEffects.move( new Static3D(0,0,0.5f) );
+      Static3D rotateCen = new Static3D(width/2,height/2, 0);
+
+      mCenterEffects.quaternion(mQuatInt1, rotateCen);
+      mCenterEffects.quaternion(mQuatInt2, rotateCen);
+
+      mCenterEffects.move( new Static3D( (width -factorCen*centerSize-mFactorObj*mObjWidth )/2 ,
+                                  (height-factorCen*centerSize-mFactorObj*mObjHeight)/2 , mFactorObj*mObjDepth/2+10) );
       mCenterEffects.move(mCenterInter);
-      mCenterEffects.scale(qObj<1 ? (new Static3D(sCen,sCen*qCen,sCen)) : (new Static3D(sCen/qCen,sCen,sCen/qCen)));
-      */
-/*
-      //// REGION //////////////
-      mRegionEffects.abortEffects(EffectTypes.MATRIX);
+      mCenterEffects.scale(factorCen);
 
       mRegionEffects.quaternion(mQuatInt1, rotateCen);
       mRegionEffects.quaternion(mQuatInt2, rotateCen);
@@ -246,7 +227,15 @@ class Effects3DRenderer implements GLSurfaceView.Renderer
       mRegionEffects.move(mRegionInter);
       mRegionEffects.scale(mRegionScaleInter);
       mRegionEffects.move( new Static3D( -regionSize/2 , -regionSize/2 , 0) );
-      */
+
+      int backgroundSize = mBackgroundTexture.getWidth();
+      float factorBackX = ((float)width)/backgroundSize;
+      float factorBackY = ((float)height)/backgroundSize;
+
+      // quite tricky: move the background exactly to the FAR plane! (see DistortedOutputSurface.setProjection() )
+      mBackgroundEffects.move(new Static3D( -width/2, -height/2, -height*(1.0f-NEAR)/(2.0f*(float)Math.tan(FOV*Math.PI/360))) );
+      mBackgroundEffects.scale(new Static3D(2*factorBackX, 2*factorBackY, 1.0f) );
+
       mScreen.resize(width, height);
       }
 
diff --git a/src/main/java/org/distorted/examples/wind/WindRenderer.java b/src/main/java/org/distorted/examples/wind/WindRenderer.java
index c122216..e9881f4 100644
--- a/src/main/java/org/distorted/examples/wind/WindRenderer.java
+++ b/src/main/java/org/distorted/examples/wind/WindRenderer.java
@@ -21,6 +21,7 @@ package org.distorted.examples.wind;
 
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.opengl.GLES30;
 import android.opengl.GLSurfaceView;
 
 import org.distorted.examples.R;
@@ -84,22 +85,22 @@ class WindRenderer implements GLSurfaceView.Renderer
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-
+    
    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
       {
-      float q= ((float)width/height)*((float)mObjHeight/mObjWidth);
-      float scale = 0.5f;
+      mEffects.abortAllEffects();
+
+      float factor = ( (float)(width<height? width:height) )/(mObjHeight + 1.4f*mObjWidth);
+
+      mEffects.move( new Static3D( factor*mObjHeight*0.58f , factor*mObjHeight*0.08f , 0) );
+      mEffects.scale(factor);
+
       Static1D angle = new Static1D(-45);
       Static3D axis  = new Static3D(0,0,1);
-      Static3D center= new Static3D( -scale/2,0,0 );
-      Static3D move  = new Static3D( 0,((float)width/height)*(1-scale/2)-0.5f,0 );
-
-      mEffects.abortAllEffects();
-      //mEffects.move( move );
-      //mEffects.rotate(angle, axis, center);
-      //mManager.apply(mEffects,mWind);
-      mEffects.scale(q<1 ? (new Static3D(scale,scale*q,scale)) : (new Static3D(scale/q,scale,scale/q)));
+      Static3D center= new Static3D(0,mObjHeight/2,0);
 
+      mEffects.rotate(angle, axis, center);
+      mManager.apply(mEffects,mWind);
       mScreen.resize(width, height);
       }
 
