commit 1b059065ccebe80e573a5157b8f50c76db8e4603
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Tue Mar 3 10:03:42 2020 +0000

    Correct the Rubik app for the recent changes to the library's Node.

diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
index cca3d17..3e7d397 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
@@ -161,9 +161,9 @@ public class EffectQueuePostprocess extends EffectQueue
     MeshBase mesh = node.getMesh();
     DistortedEffects effects = node.getEffects();
 
-    float halfW = mesh.getStretchX() / 2.0f;
-    float halfH = mesh.getStretchY() / 2.0f;
-    float halfZ = mesh.getStretchZ() / 2.0f;
+    float halfW = mesh.getBoundingX();
+    float halfH = mesh.getBoundingY();
+    float halfZ = mesh.getBoundingZ();
 
     int width   = buffer.getWidth();
     int height  = buffer.getHeight();
diff --git a/src/main/java/org/distorted/library/main/DistortedLibrary.java b/src/main/java/org/distorted/library/main/DistortedLibrary.java
index 986a20f..ab0af3e 100644
--- a/src/main/java/org/distorted/library/main/DistortedLibrary.java
+++ b/src/main/java/org/distorted/library/main/DistortedLibrary.java
@@ -441,9 +441,9 @@ public class DistortedLibrary
     GLES31.glUniform1ui(DistortedLibrary.mMainOITNumRecordsH, (int)(DistortedLibrary.mBufferSize*surface.mWidth*surface.mHeight) );
     mesh.bindVertexAttribs(DistortedLibrary.mMainOITProgram);
 
-    float halfX       = mesh.getStretchX() / 2.0f;
-    float halfY       = mesh.getStretchY() / 2.0f;
-    float halfZ       = mesh.getStretchZ() / 2.0f;
+    float halfX       = mesh.getBoundingX();
+    float halfY       = mesh.getBoundingY();
+    float halfZ       = mesh.getBoundingZ();
     float inflate     = mesh.getInflate();
     float distance    = surface.mDistance;
     float mipmap      = surface.mMipmap;
@@ -473,9 +473,9 @@ public class DistortedLibrary
     GLES31.glUniform1i(DistortedLibrary.mMainTextureH, 0);
     mesh.bindVertexAttribs(DistortedLibrary.mMainProgram);
 
-    float halfX       = mesh.getStretchX() / 2.0f;
-    float halfY       = mesh.getStretchY() / 2.0f;
-    float halfZ       = mesh.getStretchZ() / 2.0f;
+    float halfX       = mesh.getBoundingX();
+    float halfY       = mesh.getBoundingY();
+    float halfZ       = mesh.getBoundingZ();
     float inflate     = mesh.getInflate();
     float distance    = surface.mDistance;
     float mipmap      = surface.mMipmap;
diff --git a/src/main/java/org/distorted/library/main/DistortedScreen.java b/src/main/java/org/distorted/library/main/DistortedScreen.java
index 9c90382..3e2c71c 100644
--- a/src/main/java/org/distorted/library/main/DistortedScreen.java
+++ b/src/main/java/org/distorted/library/main/DistortedScreen.java
@@ -27,6 +27,7 @@ import android.graphics.Paint;
 import android.opengl.GLES31;
 
 import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.effect.MatrixEffectScale;
 import org.distorted.library.mesh.MeshQuad;
 import org.distorted.library.type.Static3D;
 
@@ -166,7 +167,7 @@ public class DistortedScreen extends DistortedFramebuffer
       fpsTexture.setTexture(fpsBitmap);
       fpsCanvas = new Canvas(fpsBitmap);
       fpsEffects = new DistortedEffects();
-      fpsMesh.setStretch(FPS_W,FPS_H,0);
+      fpsEffects.apply( new MatrixEffectScale( new Static3D(FPS_W,FPS_H,1) ) );
       fpsEffects.apply(mMoveEffect);
 
       mPaint = new Paint();
diff --git a/src/main/java/org/distorted/library/mesh/MeshBase.java b/src/main/java/org/distorted/library/mesh/MeshBase.java
index e75f268..629e2ec 100644
--- a/src/main/java/org/distorted/library/mesh/MeshBase.java
+++ b/src/main/java/org/distorted/library/mesh/MeshBase.java
@@ -68,7 +68,7 @@ public abstract class MeshBase
    private int mNumVertices;
    private float[] mVertAttribs;      // packed: PosX,PosY,PosZ, NorX,NorY,NorZ, InfX,InfY,InfZ, TexS,TexT
    private float mInflate;
-   private float mStretchX, mStretchY, mStretchZ;
+   private float mBoundingX, mBoundingY, mBoundingZ;
 
    private class Component
      {
@@ -100,11 +100,11 @@ public abstract class MeshBase
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-   MeshBase(float sx, float sy, float sz)
+   MeshBase(float bx, float by, float bz)
      {
-     mStretchX = sx;
-     mStretchY = sy;
-     mStretchZ = sz;
+     mBoundingX = bx/2;
+     mBoundingY = by/2;
+     mBoundingZ = bz/2;
 
      mShowNormals = false;
      mInflate     = 0.0f;
@@ -120,9 +120,9 @@ public abstract class MeshBase
 
    MeshBase(MeshBase original)
      {
-     mStretchX = original.mStretchX;
-     mStretchY = original.mStretchY;
-     mStretchZ = original.mStretchZ;
+     mBoundingX = original.mBoundingX;
+     mBoundingY = original.mBoundingY;
+     mBoundingZ = original.mBoundingZ;
 
      mShowNormals = original.mShowNormals;
      mInflate     = original.mInflate;
@@ -183,40 +183,33 @@ public abstract class MeshBase
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
- * Sets the stretch parameters. Coordinates of all vertices will be first pre-multiplied by those.
- */
-  public void setStretch(int sx, int sy, int sz)
-    {
-    mStretchX = sx;
-    mStretchY = sy;
-    mStretchZ = sz;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * X coordinates of all vertices will be first pre-multiplied by this parameter.
+ * Each mesh has its 'bounding box' - return half of its X-length.
+ * <p>
+ * In case of all 'simple' Meshes, the bounding box is always 1x1x1 (Sphere, Cubes) or 1x1x0
+ * (Rectangles, Triangles, Quad - i.e. all 'flat' Meshes). But this can be something else in case of
+ * MeshComponent.
  */
-  public float getStretchX()
+   public float getBoundingX()
     {
-    return mStretchX;
+    return mBoundingX;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
- * Y coordinates of all vertices will be first pre-multiplied by this parameter.
+ * Each mesh has its 'bounding box' - return half of its Y-length.
  */
-  public float getStretchY()
+   public float getBoundingY()
     {
-    return mStretchY;
+    return mBoundingY;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
- * Z coordinates of all vertices will be first pre-multiplied by this parameter.
+ * Each mesh has its 'bounding box' - return half of its Z-length.
  */
-  public float getStretchZ()
+   public float getBoundingZ()
     {
-    return mStretchZ;
+    return mBoundingZ;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -352,9 +345,6 @@ public abstract class MeshBase
          mVertAttribs[index+POS_ATTRIB+1] = tmp[1]*x + tmp[5]*y + tmp[ 9]*z + tmp[13];
          mVertAttribs[index+POS_ATTRIB+2] = tmp[2]*x + tmp[6]*y + tmp[10]*z + tmp[14];
 
-//android.util.Log.e("mesh", "vert BEFORE: ("+x+","+y+","+z+")");
-//android.util.Log.e("mesh", "vert AFTER: ("+mVertAttribs[index+POS_ATTRIB  ]+","+mVertAttribs[index+POS_ATTRIB+1]+","+mVertAttribs[index+POS_ATTRIB+2]+")");
-
          x = mVertAttribs[index+NOR_ATTRIB  ];
          y = mVertAttribs[index+NOR_ATTRIB+1];
          z = mVertAttribs[index+NOR_ATTRIB+2];
@@ -484,6 +474,32 @@ public abstract class MeshBase
 
        }
      }
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+   public void setStretch(int sx, int sy, int sz)
+     {
+     mBoundingX = sx/2.0f;
+     mBoundingY = sy/2.0f;
+     mBoundingZ = sz/2.0f;
+     }
+
+   public float getStretchX()
+    {
+    return mBoundingX*2;
+    }
+   public float getStretchY()
+    {
+    return mBoundingY*2;
+    }
+   public float getStretchZ()
+    {
+    return mBoundingZ*2;
+    }
+
+
    }
 
 
