commit 39b925d5751e9dc05cea18cb47d6799b0a943088
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu Aug 13 23:40:53 2020 +0100

    Progress with the MeshFile app: disappear works now.

diff --git a/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java b/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
index e2a1820..f684146 100644
--- a/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
+++ b/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
@@ -33,6 +33,7 @@ import android.widget.TextView;
 
 import org.distorted.examples.R;
 import org.distorted.library.main.DistortedLibrary;
+import org.distorted.library.mesh.MeshFile;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
@@ -40,6 +41,8 @@ public class MeshFileActivity extends Activity implements AdapterView.OnItemSele
                                                           SeekBar.OnSeekBarChangeListener,
                                                           View.OnClickListener
 {
+    private static final int OFFSET = 100000;
+
     private LinearLayout mLayout;
     private int mResource;
     private String[] mNames = new String[] { "deferredjob",
@@ -153,9 +156,13 @@ public class MeshFileActivity extends Activity implements AdapterView.OnItemSele
       TextView index = view.findViewById(R.id.meshfileComponentText);
       index.setText(String.valueOf(endIndex));
 
-      Button butt = view.findViewById(R.id.meshfileComponentDisappear);
-      butt.setId(component);
-      butt.setOnClickListener(this);
+      Button disappear = view.findViewById(R.id.meshfileComponentDisappear);
+      disappear.setId(component);
+      disappear.setOnClickListener(this);
+
+      Button appear = view.findViewById(R.id.meshfileComponentAppear);
+      appear.setId(component+OFFSET);
+      appear.setOnClickListener(this);
 
       return view;
       }
@@ -190,13 +197,26 @@ public class MeshFileActivity extends Activity implements AdapterView.OnItemSele
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  @Override
-  public void onClick(View v)
-    {
-    int id = v.getId();
+    @Override
+    public void onClick(View v)
+      {
+      int id = v.getId();
+
+      MeshFileSurfaceView view = findViewById(R.id.meshfileSurfaceView);
+      MeshFileRenderer renderer = view.getRenderer();
 
-    android.util.Log.e("act", "clicked: "+id);
-    }
+      MeshFile mesh = renderer.getMesh();
+
+      if( id>=OFFSET )
+        {
+        id -= OFFSET;
+        mesh.setEffectAssociation(id,0,id);
+        }
+      else
+        {
+        mesh.setEffectAssociation(id,1,id);
+        }
+      }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
index 1cfa0bf..ccaa93d 100644
--- a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
+++ b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
@@ -29,6 +29,7 @@ import android.opengl.GLSurfaceView;
 import org.distorted.examples.R;
 import org.distorted.library.effect.MatrixEffectQuaternion;
 import org.distorted.library.effect.MatrixEffectScale;
+import org.distorted.library.effect.VertexEffectDisappear;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedLibrary;
 import org.distorted.library.main.DistortedScreen;
@@ -83,11 +84,16 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
       quatInt1.add(mQuat1);
       quatInt2.add(mQuat2);
 
+      VertexEffectDisappear disappear = new VertexEffectDisappear();
+      disappear.setMeshAssociation(1,-1);
+
       mEffects = new DistortedEffects();
       mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
       mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
       mEffects.apply( new MatrixEffectScale(mScale));
 
+      mEffects.apply( disappear );
+
       mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
       mScreen.showFPS();
       }
@@ -115,6 +121,8 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
       {
       if( mTexture==null ) mTexture = new DistortedTexture();
 
+      VertexEffectDisappear.enable();
+
       DistortedLibrary.onCreate(mView.getContext(), this);
       }
 
@@ -304,6 +312,13 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
       DataInputStream dos = new DataInputStream(is);
       mMesh = new MeshFile(dos);
 
+      int numEff = mMesh.numEffComponents();
+
+      for(int i=0; i<numEff; i++)
+        {
+        mMesh.setEffectAssociation(i, 0, i);
+        }
+
       try
         {
         is.close();
@@ -314,6 +329,13 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
         }
       }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    MeshFile getMesh()
+      {
+      return mMesh;
+      }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     long getTime()
diff --git a/src/main/res/layout/meshfilecomponent.xml b/src/main/res/layout/meshfilecomponent.xml
index 1548db6..6e09211 100644
--- a/src/main/res/layout/meshfilecomponent.xml
+++ b/src/main/res/layout/meshfilecomponent.xml
@@ -22,6 +22,16 @@
           android:layout_marginTop="5dp"
           android:layout_weight="1"/>
 
+     <Button
+          android:id="@+id/meshfileComponentAppear"
+          android:text="@string/appear"
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:layout_weight="0.2"
+          android:layout_marginEnd="5dp"
+          android:layout_marginStart="5dp"
+          android:layout_marginTop="5dp"/>
+
      <Button
           android:id="@+id/meshfileComponentDisappear"
           android:text="@string/disappear"
@@ -29,6 +39,6 @@
           android:layout_height="wrap_content"
           android:layout_weight="0.2"
           android:layout_marginEnd="5dp"
-          android:layout_marginStart="10dp"
+          android:layout_marginStart="5dp"
           android:layout_marginTop="5dp"/>
 </LinearLayout>
