commit 1833b023ff63119fba1bf4adfb8b11b53c5bf74e
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu Jan 3 11:07:27 2019 +0000

    Progress with the Earth app.

diff --git a/src/main/java/org/distorted/examples/earth/EarthRenderer.java b/src/main/java/org/distorted/examples/earth/EarthRenderer.java
index 28ac71b..f26ded6 100644
--- a/src/main/java/org/distorted/examples/earth/EarthRenderer.java
+++ b/src/main/java/org/distorted/examples/earth/EarthRenderer.java
@@ -47,6 +47,7 @@ import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedTexture;
 import org.distorted.library.mesh.MeshBase;
 import org.distorted.library.mesh.MeshSphere;
+import org.distorted.library.type.Dynamic3D;
 import org.distorted.library.type.DynamicQuat;
 import org.distorted.library.type.Static1D;
 import org.distorted.library.type.Static3D;
@@ -68,7 +69,7 @@ class EarthRenderer implements GLSurfaceView.Renderer
     private static final float FOV     = 30.0f;
     private static final float NEAR    =  0.1f;
     private static final int   MAX_EFF =    20;
-
+    private static final float SCALE   = 1.10f;
 
     private GLSurfaceView mView;
     private DistortedTexture mTexture;
@@ -76,30 +77,39 @@ class EarthRenderer implements GLSurfaceView.Renderer
     private MeshBase mMesh;
     private DistortedScreen mScreen;
     private int mObjWidth, mObjHeight, mObjDepth;
-    private Static3D mMove, mScale, mCenter;
+    private Static3D mMove, mScaleFactor, mCenter;
+    private Dynamic3D mScale;
 
-    Static4D mQuat1, mQuat2;
-    int mScreenMin;
+    private int mScrWidth, mScrHeight;
+    private float mLevel;
 
     private Static3D mColor;
     private Static3D mRegionF;
     private Static1D mStrength;
 
+    Static4D mQuat1, mQuat2;
+    int mScreenMin;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     EarthRenderer(GLSurfaceView v)
       {
       mView = v;
 
+      mLevel = SCALE;
+
       DistortedEffects.setMax(EffectType.VERTEX  , MAX_EFF);
       DistortedEffects.setMax(EffectType.FRAGMENT, MAX_EFF);
 
-      mStrength = new Static1D(0.5f);
-      mColor    = new Static3D(255,0,0);
-      mRegionF  = new Static3D(RADIUS,RADIUS,RADIUS);
-      mMove     = new Static3D(0,0,0);
-      mScale    = new Static3D(1,1,1);
-      mCenter   = new Static3D(0,0,0);
+      mScale      = new Dynamic3D(0,0.5f);
+      mStrength   = new Static1D(0.5f);
+      mColor      = new Static3D(255,0,0);
+      mRegionF    = new Static3D(RADIUS,RADIUS,RADIUS);
+      mMove       = new Static3D(0,0,0);
+      mScaleFactor= new Static3D(1,1,1);
+      mCenter     = new Static3D(0,0,0);
+
+      mScale.add(mScaleFactor);
 
       mMesh     = new MeshSphere(LEVEL);
       mTexture  = new DistortedTexture(SIZE,SIZE);
@@ -138,12 +148,12 @@ class EarthRenderer implements GLSurfaceView.Renderer
     
     public void onSurfaceChanged(GL10 glUnused, int width, int height) 
       {
-      final float SCALE = 1.10f;
+      mScrWidth = width;
+      mScrHeight= height;
+      mScreenMin= width<height ? width:height;
+
+      adjustFactor();
 
-      mScreenMin = width<height ? width:height;
-      float factor = ( width*mObjHeight > height*mObjWidth ) ? (SCALE*height)/mObjHeight :  (SCALE*width)/mObjWidth;
-      mMove.set( (width-factor*mObjWidth)/2 , (height-factor*mObjHeight)/2 , 0);
-      mScale.set(factor,factor,factor);
       mCenter.set( (float)mObjWidth/2, (float)mObjHeight/2, (float)mObjDepth/2 );
       mScreen.resize(width, height);
       }
@@ -152,8 +162,25 @@ class EarthRenderer implements GLSurfaceView.Renderer
 
     void setLevel(int level)
       {
-      float inflateLevel = (level-50)/50.0f;
-      mMesh.setInflate(inflateLevel);
+      float N=3.0f;
+
+      // MAP: 0--> SCALE/N   50-->SCALE   100->SCALE*N
+      mLevel = SCALE* (1.0f+  (level>=50 ? N-1 : (N-1)/N) * (level-50)/50.0f);
+
+      adjustFactor();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private void adjustFactor()
+      {
+      float xW = (float)mScrWidth /mObjWidth;
+      float xH = (float)mScrHeight/mObjHeight;
+
+      float factor = xW>xH ? mLevel*xH : mLevel*xW;
+
+      mMove.set( (mScrWidth-factor*mObjWidth)/2 , (mScrHeight-factor*mObjHeight)/2 , 0);
+      mScaleFactor.set(factor,factor,factor);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
