commit 2bf60c29dea83d5e577e7ac526e4808b9719ac36
Author: Leszek Koltunski <leszek@distorted.org>
Date:   Sun Jun 26 23:45:57 2016 +0100

    Progress with vertex3D

diff --git a/src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java b/src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java
index 7a98a30..9bf7485 100644
--- a/src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java
+++ b/src/main/java/org/distorted/examples/vertex3d/Vertex3DRenderer.java
@@ -55,6 +55,7 @@ class Vertex3DRenderer implements GLSurfaceView.Renderer
     private GLSurfaceView mView;
     private static DistortedObject mObject;
     private DistortedBitmap mCenter;
+    private int mCols;
 
     private int mObjWidth, mObjHeight;
 
@@ -63,11 +64,11 @@ class Vertex3DRenderer implements GLSurfaceView.Renderer
     private static EffectNames[] order;
 
     private static Dynamic2D mCenterInter;
-    private static Dynamic3D mDeformInter, mDistortInter;
+    private static Dynamic3D mDeformInter, mDistortInter, mMoveInter;
     private static Dynamic1D mSinkInter, mSwirlInter;
 
     private static Static2D mCenterPoint;
-    private static Static3D mDeformPoint, mDistortPoint;
+    private static Static3D mDeformPoint, mDistortPoint, mMovePoint;
     private static Static1D mSinkPoint, mSwirlPoint;
 
     Static4D mQuat1, mQuat2;
@@ -106,6 +107,7 @@ class Vertex3DRenderer implements GLSurfaceView.Renderer
     public static void setCenter(float x, float y)
       {
       mCenterPoint.set(x,y);
+      mMovePoint.set(x,y,0);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -140,7 +142,9 @@ class Vertex3DRenderer implements GLSurfaceView.Renderer
       {
       mView = v;
 
-      mObject = new DistortedCubes( Vertex3DActivity.getCols(), Vertex3DActivity.getShape(), SIZE);
+      mCols = Vertex3DActivity.getCols();
+
+      mObject = new DistortedCubes( mCols, Vertex3DActivity.getShape(), SIZE);
       //mObject = new DistortedBitmap( SIZE, SIZE, 10);
       mCenter = new DistortedBitmap(SIZE, SIZE, 1);
 
@@ -148,6 +152,7 @@ class Vertex3DRenderer implements GLSurfaceView.Renderer
       mObjHeight= mObject.getHeight();
 
       mCenterPoint = new Static2D(0,0);
+      mMovePoint   = new Static3D(0,0,0);
       mDeformPoint = new Static3D(0,0,0);
       mDistortPoint= new Static3D(1,1,1);
       mSwirlPoint  = new Static1D(0);
@@ -156,10 +161,12 @@ class Vertex3DRenderer implements GLSurfaceView.Renderer
       mCenterInter  = new Dynamic2D();
       mDeformInter  = new Dynamic3D();
       mDistortInter = new Dynamic3D();
+      mMoveInter    = new Dynamic3D();
       mSwirlInter   = new Dynamic1D();
       mSinkInter    = new Dynamic1D();
 
       mCenterInter.add(mCenterPoint);
+      mMoveInter.add(mMovePoint);
       mDeformInter.add(mDeformPoint);
       mDistortInter.add(mDistortPoint);
       mSwirlInter.add(mSwirlPoint);
@@ -197,30 +204,35 @@ class Vertex3DRenderer implements GLSurfaceView.Renderer
       mObject.abortEffects(EffectTypes.MATRIX);
       mCenter.abortEffects(EffectTypes.MATRIX);
 
-      float factor;
+      float factorObj;
 
       if( width*mObjHeight > height*mObjWidth ) // screen is more 'horizontal' than the Object
         {
-        factor = (0.7f*height)/mObjHeight;
+        factorObj = (0.7f*height)/mObjHeight;
         }
       else
         {
-        factor = (0.7f*width)/mObjWidth;
+        factorObj = (0.7f*width)/mObjWidth;
         }
 
-      Static3D center = new Static3D(mObjWidth/2,mObjHeight/2, 0);
+      Static3D rotateObj = new Static3D(mObjWidth/2,mObjHeight/2, 0);
+
+      mObject.move( new Static3D( (width-factorObj*mObjWidth)/2 , (height-factorObj*mObjHeight)/2 , 0) );
+      mObject.scale(factorObj);
+      mObject.quaternion(mQuatInt1, rotateObj);
+      mObject.quaternion(mQuatInt2, rotateObj);
 
-      mObject.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0) );
-      mObject.scale(factor);
-      mObject.quaternion(mQuatInt1, center);
-      mObject.quaternion(mQuatInt2, center);
+      int centerSize = mCenter.getWidth();
+      Static3D rotateCen = new Static3D(width/2,height/2, 0);
 
-      factor *= 0.5f;
+      float factorCen = (float)(mCols*SIZE) / (5*centerSize);  // make the 'center' bitmap 1/5 of the Object's width
 
-      mCenter.move( new Static3D( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 10) );
-      mCenter.scale(factor);
-      mCenter.quaternion(mQuatInt1, center);
-      mCenter.quaternion(mQuatInt2, center);
+      mCenter.quaternion(mQuatInt1, rotateCen);
+      mCenter.quaternion(mQuatInt2, rotateCen);
+      mCenter.move( new Static3D( (width -factorCen*centerSize-factorObj*mObjWidth )/2 ,
+                                  (height-factorCen*centerSize-factorObj*mObjHeight)/2 , 10) );
+      mCenter.move(mMoveInter);
+      mCenter.scale(factorCen);
 
       setVertexEffects();
 
