commit 71c7624f5cefb7f1422be99a40581b49c9498437
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sat Jun 13 01:33:39 2020 +0100

    Progress with MeshFile

diff --git a/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java b/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
index 2dc6ad2..6efb570 100644
--- a/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
+++ b/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
@@ -22,19 +22,46 @@ package org.distorted.examples.meshfile;
 import android.app.Activity;
 import android.opengl.GLSurfaceView;
 import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
 
 import org.distorted.examples.R;
 import org.distorted.library.main.DistortedLibrary;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-public class MeshFileActivity extends Activity
+public class MeshFileActivity extends Activity implements AdapterView.OnItemSelectedListener
 {
+    private String mName;
+    private String[] mNames = new String[] { "deferredjob",
+                                             "meshjoin"   ,
+                                             "predeform"  ,
+                                             "singlemesh" ,
+                                             "cube2"      ,
+                                             "cube3"      ,
+                                             "cube4"      ,
+                                             "cube5"      ,
+                                             "pyra3"      ,
+                                             "pyra4"      ,
+                                             "pyra5"
+                                           };
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
     @Override
     protected void onCreate(Bundle icicle) 
       {
       super.onCreate(icicle);
       setContentView(R.layout.meshfilelayout);
+
+      Spinner meshSpinner  = findViewById(R.id.meshfileSpinner);
+      meshSpinner.setOnItemSelectedListener(this);
+
+      ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, mNames);
+      adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+      meshSpinner.setAdapter(adapterBitmap);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -66,4 +93,30 @@ public class MeshFileActivity extends Activity
       DistortedLibrary.onDestroy();
       super.onDestroy();
       }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void Open(View v)
+      {
+      MeshFileSurfaceView view = this.findViewById(R.id.meshfileSurfaceView);
+      MeshFileRenderer renderer = view.getRenderer();
+
+      renderer.open(mName);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
+      {
+      if( parent.getId()==R.id.meshfileSpinner )
+        {
+        mName = mNames[pos];
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onNothingSelected(AdapterView<?> parent)
+      {
+      }
 }
diff --git a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
index 07b0552..7f8c588 100644
--- a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
+++ b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
@@ -52,66 +52,12 @@ import javax.microedition.khronos.opengles.GL10;
 
 class MeshFileRenderer implements GLSurfaceView.Renderer
 {
-    private static final float DIST = 0.5f;
-
-    private static Static3D[] AXIS = new Static3D[]
-         {
-           new Static3D(1,0,0),
-           new Static3D(0,1,0),
-           new Static3D(0,0,1)
-         };
-
-    private static final int[] FACE_COLORS = new int[]
-         {
-           0xffffff00, 0xffffffff,   // (right-YELLOW) (left  -WHITE)
-           0xff0000ff, 0xff00ff00,   // (top  -BLUE  ) (bottom-GREEN)
-           0xffff0000, 0xffb5651d    // (front-RED   ) (back  -BROWN)
-         };
-
-    private static final int NUM_FACES = FACE_COLORS.length;
-
-    private static final Static4D RIG_MAP = new Static4D(0.0f/(NUM_FACES+1),0.0f,1.0f/(NUM_FACES+1),1.0f);
-    private static final Static4D LEF_MAP = new Static4D(1.0f/(NUM_FACES+1),0.0f,1.0f/(NUM_FACES+1),1.0f);
-    private static final Static4D TOP_MAP = new Static4D(2.0f/(NUM_FACES+1),0.0f,1.0f/(NUM_FACES+1),1.0f);
-    private static final Static4D BOT_MAP = new Static4D(3.0f/(NUM_FACES+1),0.0f,1.0f/(NUM_FACES+1),1.0f);
-    private static final Static4D FRO_MAP = new Static4D(4.0f/(NUM_FACES+1),0.0f,1.0f/(NUM_FACES+1),1.0f);
-    private static final Static4D BAC_MAP = new Static4D(5.0f/(NUM_FACES+1),0.0f,1.0f/(NUM_FACES+1),1.0f);
-    private static final Static4D INT_MAP = new Static4D(6.0f/(NUM_FACES+1),0.0f,1.0f/(NUM_FACES+1),1.0f);
-
-    private static final Static4D[][] TEXTURE_MAP = new Static4D[][]
-         {
-             {  INT_MAP, LEF_MAP, INT_MAP, BOT_MAP, INT_MAP, BAC_MAP },
-             {  INT_MAP, LEF_MAP, INT_MAP, BOT_MAP, FRO_MAP, INT_MAP },
-             {  INT_MAP, LEF_MAP, TOP_MAP, INT_MAP, INT_MAP, BAC_MAP },
-             {  INT_MAP, LEF_MAP, TOP_MAP, INT_MAP, FRO_MAP, INT_MAP },
-             {  RIG_MAP, INT_MAP, INT_MAP, BOT_MAP, INT_MAP, BAC_MAP },
-             {  RIG_MAP, INT_MAP, INT_MAP, BOT_MAP, FRO_MAP, INT_MAP },
-             {  RIG_MAP, INT_MAP, TOP_MAP, INT_MAP, INT_MAP, BAC_MAP },
-             {  RIG_MAP, INT_MAP, TOP_MAP, INT_MAP, FRO_MAP, INT_MAP }
-         };
-
-    private static final Static3D[] CUBIT_MOVES = new Static3D[]
-         {
-           new Static3D(-DIST,-DIST,-DIST),
-           new Static3D(-DIST,-DIST,+DIST),
-           new Static3D(-DIST,+DIST,-DIST),
-           new Static3D(-DIST,+DIST,+DIST),
-           new Static3D(+DIST,-DIST,-DIST),
-           new Static3D(+DIST,-DIST,+DIST),
-           new Static3D(+DIST,+DIST,-DIST),
-           new Static3D(+DIST,+DIST,+DIST),
-         };
-
     private GLSurfaceView mView;
     private DistortedTexture mTexture;
     private DistortedScreen mScreen;
     private DistortedEffects mEffects;
     private Static3D mScale;
     private MeshBase mMesh;
-    private VertexEffectRotate mRotate;
-    private Dynamic1D mAngleDyn;
-    private Static1D mAngle;
-    private Static3D mAxis;
 
     Static4D mQuat1, mQuat2;
     int mScreenMin;
@@ -125,10 +71,6 @@ class MeshFileRenderer implements GLSurfaceView.Renderer
       mScale= new Static3D(1,1,1);
       Static3D center=new Static3D(0,0,0);
 
-      Dynamic1D sink = new Dynamic1D(5000,0.0f);
-      sink.add( new Static1D(0.5f) );
-      sink.add( new Static1D(2.0f) );
-
       mQuat1 = new Static4D(0,0,0,1);
       mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
 
@@ -138,17 +80,7 @@ class MeshFileRenderer implements GLSurfaceView.Renderer
       quatInt1.add(mQuat1);
       quatInt2.add(mQuat2);
 
-      mAngle = new Static1D(0);
-      mAxis  = new Static3D(1,0,0);
-
-      mAngleDyn = new Dynamic1D(2000,0.5f);
-      mAngleDyn.add(new Static1D(0));
-      mAngleDyn.add( mAngle );
-
-      mRotate = new VertexEffectRotate( mAngleDyn, mAxis, new Static3D(0,0,0) );
-
       mEffects = new DistortedEffects();
-      mEffects.apply( mRotate );
       mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
       mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
       mEffects.apply( new MatrixEffectScale(mScale));
@@ -179,15 +111,6 @@ class MeshFileRenderer implements GLSurfaceView.Renderer
     public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
       {
       if( mTexture==null ) mTexture = new DistortedTexture();
-      mTexture.setTexture( createTexture() );
-
-      if( mMesh==null ) mMesh = createMesh();
-
-      mScreen.detachAll();
-      mScreen.attach(mTexture,mEffects,mMesh);
-
-      DistortedLibrary.setMax(EffectType.VERTEX, 15);
-      VertexEffectRotate.enable();
 
       try
         {
@@ -195,183 +118,36 @@ class MeshFileRenderer implements GLSurfaceView.Renderer
         }
       catch(Exception ex)
         {
-        android.util.Log.e("DeferredJob", ex.getMessage() );
+        android.util.Log.e("MeshFile", ex.getMessage() );
         }
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    void apply(int andAssoc, int axisIndex)
-      {
-      mRotate.setMeshAssociation(andAssoc,-1);
-
-      mAngle.set(360);
-
-      mAxis.set0(AXIS[axisIndex].get0());
-      mAxis.set1(AXIS[axisIndex].get1());
-      mAxis.set2(AXIS[axisIndex].get2());
-
-      mAngleDyn.resetToBeginning();
-      }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-    private Bitmap createTexture()
+    void open(String name)
       {
-      final int NUM_FACES = 6;
-      final int TEXTURE_HEIGHT = 200;
-      final int INTERIOR_COLOR = 0xff000000;
-      final float R = TEXTURE_HEIGHT*0.10f;
-      final float M = TEXTURE_HEIGHT*0.05f;
-
-      Bitmap bitmap;
-      Paint paint = new Paint();
-      bitmap = Bitmap.createBitmap( (NUM_FACES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, Bitmap.Config.ARGB_8888);
-      Canvas canvas = new Canvas(bitmap);
+      mTexture.setTexture( createTexture(name) );
+      mMesh = createMesh(name);
 
-      paint.setAntiAlias(true);
-      paint.setTextAlign(Paint.Align.CENTER);
-      paint.setStyle(Paint.Style.FILL);
-
-      paint.setColor(INTERIOR_COLOR);
-      canvas.drawRect(0, 0, (NUM_FACES+1)*TEXTURE_HEIGHT, TEXTURE_HEIGHT, paint);
-
-      for(int i=0; i<NUM_FACES; i++)
-        {
-        paint.setColor(FACE_COLORS[i]);
-        canvas.drawRoundRect( i*TEXTURE_HEIGHT+M, M, (i+1)*TEXTURE_HEIGHT-M, TEXTURE_HEIGHT-M, R, R, paint);
-        }
-
-      return bitmap;
+      mScreen.detachAll();
+      mScreen.attach(mTexture,mEffects,mMesh);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-     MeshBase createCubitMesh()
+    private Bitmap createTexture(String name)
       {
-      final int MESHES=6;
-      int association = 1;
-      MeshBase[] meshes = new MeshRectangles[MESHES];
-      meshes[0] = new MeshRectangles(10,10);
-      meshes[0].setEffectAssociation(0,association,0);
-
-      for(int i=1; i<MESHES; i++)
-        {
-        association <<=1;
-        meshes[i] = meshes[0].copy(true);
-        meshes[i].setEffectAssociation(0,association,0);
-        }
-
-      MeshBase mesh = new MeshJoined(meshes);
-
-      Static3D axisY   = new Static3D(0,1,0);
-      Static3D axisX   = new Static3D(1,0,0);
-      Static3D center  = new Static3D(0,0,0);
-      Static1D angle90 = new Static1D(90);
-      Static1D angle180= new Static1D(180);
-      Static1D angle270= new Static1D(270);
-
-      float d1 = 1.0f;
-      float d2 =-0.05f;
-      float d3 = 0.12f;
-
-      Static3D dCen0 = new Static3D( d1*(+0.5f), d1*(+0.5f), d1*(+0.5f) );
-      Static3D dCen1 = new Static3D( d1*(+0.5f), d1*(+0.5f), d1*(-0.5f) );
-      Static3D dCen2 = new Static3D( d1*(+0.5f), d1*(-0.5f), d1*(+0.5f) );
-      Static3D dCen3 = new Static3D( d1*(+0.5f), d1*(-0.5f), d1*(-0.5f) );
-      Static3D dCen4 = new Static3D( d1*(-0.5f), d1*(+0.5f), d1*(+0.5f) );
-      Static3D dCen5 = new Static3D( d1*(-0.5f), d1*(+0.5f), d1*(-0.5f) );
-      Static3D dCen6 = new Static3D( d1*(-0.5f), d1*(-0.5f), d1*(+0.5f) );
-      Static3D dCen7 = new Static3D( d1*(-0.5f), d1*(-0.5f), d1*(-0.5f) );
-
-      Static3D dVec0 = new Static3D( d2*(+0.5f), d2*(+0.5f), d2*(+0.5f) );
-      Static3D dVec1 = new Static3D( d2*(+0.5f), d2*(+0.5f), d2*(-0.5f) );
-      Static3D dVec2 = new Static3D( d2*(+0.5f), d2*(-0.5f), d2*(+0.5f) );
-      Static3D dVec3 = new Static3D( d2*(+0.5f), d2*(-0.5f), d2*(-0.5f) );
-      Static3D dVec4 = new Static3D( d2*(-0.5f), d2*(+0.5f), d2*(+0.5f) );
-      Static3D dVec5 = new Static3D( d2*(-0.5f), d2*(+0.5f), d2*(-0.5f) );
-      Static3D dVec6 = new Static3D( d2*(-0.5f), d2*(-0.5f), d2*(+0.5f) );
-      Static3D dVec7 = new Static3D( d2*(-0.5f), d2*(-0.5f), d2*(-0.5f) );
-
-      Static4D dReg  = new Static4D(0,0,0,d3);
-      Static1D dRad  = new Static1D(1);
-
-      VertexEffectMove   effect0 = new VertexEffectMove(new Static3D(0,0,+0.5f));
-      effect0.setMeshAssociation(63,-1);  // all 6 sides
-      VertexEffectRotate effect1 = new VertexEffectRotate( angle180, axisX, center );
-      effect1.setMeshAssociation(32,-1);  // back
-      VertexEffectRotate effect2 = new VertexEffectRotate( angle90 , axisX, center );
-      effect2.setMeshAssociation( 8,-1);  // bottom
-      VertexEffectRotate effect3 = new VertexEffectRotate( angle270, axisX, center );
-      effect3.setMeshAssociation( 4,-1);  // top
-      VertexEffectRotate effect4 = new VertexEffectRotate( angle270, axisY, center );
-      effect4.setMeshAssociation( 2,-1);  // left
-      VertexEffectRotate effect5 = new VertexEffectRotate( angle90 , axisY, center );
-      effect5.setMeshAssociation( 1,-1);  // right
+      // TODO
 
-      VertexEffectDeform effect6 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
-      VertexEffectDeform effect7 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
-      VertexEffectDeform effect8 = new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
-      VertexEffectDeform effect9 = new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
-      VertexEffectDeform effect10= new VertexEffectDeform(dVec4, dRad, dCen4, dReg);
-      VertexEffectDeform effect11= new VertexEffectDeform(dVec5, dRad, dCen5, dReg);
-      VertexEffectDeform effect12= new VertexEffectDeform(dVec6, dRad, dCen6, dReg);
-      VertexEffectDeform effect13= new VertexEffectDeform(dVec7, dRad, dCen7, dReg);
-
-      VertexEffectSink effect14= new VertexEffectSink( new Static1D(1.5f), center, new Static4D(0,0,0,0.72f) );
-
-      mesh.apply(effect0);
-      mesh.apply(effect1);
-      mesh.apply(effect2);
-      mesh.apply(effect3);
-      mesh.apply(effect4);
-      mesh.apply(effect5);
-      mesh.apply(effect6);
-      mesh.apply(effect7);
-      mesh.apply(effect8);
-      mesh.apply(effect9);
-      mesh.apply(effect10);
-      mesh.apply(effect11);
-      mesh.apply(effect12);
-      mesh.apply(effect13);
-      mesh.apply(effect14);
-
-      mesh.mergeEffComponents();
-
-      return mesh;
+      return null;
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    private MeshBase createMesh()
+    private MeshBase createMesh(String name)
       {
-      final int NUM_CUBITS = CUBIT_MOVES.length;
-      MeshBase[] cubits = new MeshBase[NUM_CUBITS];
-
-      cubits[NUM_CUBITS-1] = createCubitMesh();   // NUM_CUBITS-1 (or anything non-zero!)
-
-      for(int i=0; i<NUM_CUBITS-1; i++)
-        {
-        cubits[i] = cubits[NUM_CUBITS-1].copy(true);
-        }
-
-      for(int i=0; i<NUM_CUBITS; i++)
-        {
-        cubits[i].apply( new MatrixEffectMove(CUBIT_MOVES[i]), 1,0);
-        cubits[i].setTextureMap(TEXTURE_MAP[i],0);
-        }
-
-      MeshBase result = new MeshJoined(cubits);
-
-      result.setEffectAssociation( 0, (1<<4) + (1<<2) + 1, 0);
-      result.setEffectAssociation( 1, (1<<4) + (1<<2) + 2, 0);
-      result.setEffectAssociation( 2, (1<<4) + (2<<2) + 1, 0);
-      result.setEffectAssociation( 3, (1<<4) + (2<<2) + 2, 0);
-      result.setEffectAssociation( 4, (2<<4) + (1<<2) + 1, 0);
-      result.setEffectAssociation( 5, (2<<4) + (1<<2) + 2, 0);
-      result.setEffectAssociation( 6, (2<<4) + (2<<2) + 1, 0);
-      result.setEffectAssociation( 7, (2<<4) + (2<<2) + 2, 0);
+      // TODO
 
-      return result;
+      return null;
       }
 }
diff --git a/src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java b/src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java
index 7ce695c..e557a88 100644
--- a/src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java
+++ b/src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java
@@ -125,10 +125,6 @@ class SingleMeshRenderer implements GLSurfaceView.Renderer
       mScale= new Static3D(1,1,1);
       Static3D center=new Static3D(0,0,0);
 
-      Dynamic1D sink = new Dynamic1D(5000,0.0f);
-      sink.add( new Static1D(0.5f) );
-      sink.add( new Static1D(2.0f) );
-
       mQuat1 = new Static4D(0,0,0,1);
       mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
 
