commit 7198e5c9ae23ca83dc2180252fa4162d5f4fe98e
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Thu Aug 13 23:00:31 2020 +0100

    Progress with the MeshFile app.

diff --git a/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java b/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
index 6114581..e2a1820 100644
--- a/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
+++ b/src/main/java/org/distorted/examples/meshfile/MeshFileActivity.java
@@ -25,6 +25,8 @@ import android.os.Bundle;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.LinearLayout;
 import android.widget.SeekBar;
 import android.widget.Spinner;
 import android.widget.TextView;
@@ -34,8 +36,11 @@ import org.distorted.library.main.DistortedLibrary;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-public class MeshFileActivity extends Activity implements AdapterView.OnItemSelectedListener, SeekBar.OnSeekBarChangeListener
+public class MeshFileActivity extends Activity implements AdapterView.OnItemSelectedListener,
+                                                          SeekBar.OnSeekBarChangeListener,
+                                                          View.OnClickListener
 {
+    private LinearLayout mLayout;
     private int mResource;
     private String[] mNames = new String[] { "deferredjob",
                                              "meshjoin"   ,
@@ -67,6 +72,8 @@ public class MeshFileActivity extends Activity implements AdapterView.OnItemSele
       SeekBar barB = findViewById(R.id.meshfileScale);
       barB.setOnSeekBarChangeListener(this);
       barB.setProgress(50);
+
+      mLayout = findViewById(R.id.meshfileComponentLayout);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -121,6 +128,36 @@ public class MeshFileActivity extends Activity implements AdapterView.OnItemSele
       byt.setText( String.format("%d", bytes   ) );
       ver.setText( String.format("%d", vertices) );
       tim.setText( String.format("%d", time    ) );
+
+      mLayout.removeAllViews();
+
+      int effComponentNum = renderer.getEffComponentNum();
+
+      for(int i=0; i<effComponentNum; i++)
+        {
+        View compView = createComponentView(renderer,i);
+        mLayout.addView(compView);
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private View createComponentView(MeshFileRenderer renderer, int component)
+      {
+      View view = getLayoutInflater().inflate(R.layout.meshfilecomponent, null);
+
+      TextView id = view.findViewById(R.id.meshfileComponentID);
+      id.setText(String.valueOf(component));
+
+      int endIndex = renderer.getEndEffIndex(component);
+      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);
+
+      return view;
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -151,6 +188,16 @@ public class MeshFileActivity extends Activity implements AdapterView.OnItemSele
       {
       }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+  @Override
+  public void onClick(View v)
+    {
+    int id = v.getId();
+
+    android.util.Log.e("act", "clicked: "+id);
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     public void onProgressChanged(SeekBar bar, int progress, boolean fromUser)
diff --git a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
index c737f80..1cfa0bf 100644
--- a/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
+++ b/src/main/java/org/distorted/examples/meshfile/MeshFileRenderer.java
@@ -33,7 +33,6 @@ import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedLibrary;
 import org.distorted.library.main.DistortedScreen;
 import org.distorted.library.main.DistortedTexture;
-import org.distorted.library.mesh.MeshBase;
 import org.distorted.library.mesh.MeshFile;
 import org.distorted.library.type.DynamicQuat;
 import org.distorted.library.type.Static3D;
@@ -58,9 +57,8 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
     private DistortedEffects mEffects;
     private Static3D mScale;
     private long mTime;
-    private int mBytes;
-    private int mVertices;
     private float mCurrentScale;
+    private MeshFile mMesh;
 
     Static4D mQuat1, mQuat2;
     int mScreenMin;
@@ -155,13 +153,13 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
       mTexture.setTexture( createTexture(resourceID) );
 
       long t1 = System.currentTimeMillis();
-      MeshBase mesh = createMesh(resourceID);
+      createMesh(resourceID);
       long t2 = System.currentTimeMillis();
 
       mTime = t2-t1;
 
       mScreen.detachAll();
-      mScreen.attach(mTexture,mEffects,mesh);
+      mScreen.attach(mTexture,mEffects,mMesh);
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -298,16 +296,13 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-    private MeshBase createMesh(int resourceID)
+    private void createMesh(int resourceID)
       {
       Context con = mView.getContext();
       Resources res = con.getResources();
       InputStream is = res.openRawResource(resourceID);
       DataInputStream dos = new DataInputStream(is);
-      MeshFile mesh = new MeshFile(dos);
-
-      mBytes = mesh.getNumBytes();
-      mVertices = mesh.getNumVertices();
+      mMesh = new MeshFile(dos);
 
       try
         {
@@ -317,8 +312,6 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
         {
         android.util.Log.e("MeshFile", "Error closing InputStream: "+e.toString());
         }
-
-      return mesh;
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -332,13 +325,41 @@ class MeshFileRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Excep
 
     int getBytes()
       {
-      return mBytes;
+      return mMesh.getNumBytes();
       }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
     int getVertices()
       {
-      return mVertices;
+      return mMesh.getNumVertices();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    int getEndEffIndex(int component)
+      {
+      return mMesh.getLastVertexEff(component);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    int getEndTexIndex(int component)
+      {
+      return mMesh.getLastVertexTex(component);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    int getEffComponentNum()
+      {
+      return mMesh.numEffComponents();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    int getTexComponentNum()
+      {
+      return mMesh.numTexComponents();
       }
 }
diff --git a/src/main/res/layout/meshfilecomponent.xml b/src/main/res/layout/meshfilecomponent.xml
new file mode 100644
index 0000000..1548db6
--- /dev/null
+++ b/src/main/res/layout/meshfilecomponent.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+     android:layout_width="match_parent"
+     android:layout_height="match_parent"
+     android:orientation="horizontal">
+
+     <TextView
+          android:id="@+id/meshfileComponentID"
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:layout_marginEnd="5dp"
+          android:layout_marginStart="5dp"
+          android:layout_marginTop="5dp"
+          android:layout_weight="1"/>
+
+     <TextView
+          android:id="@+id/meshfileComponentText"
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:layout_marginEnd="5dp"
+          android:layout_marginStart="5dp"
+          android:layout_marginTop="5dp"
+          android:layout_weight="1"/>
+
+     <Button
+          android:id="@+id/meshfileComponentDisappear"
+          android:text="@string/disappear"
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:layout_weight="0.2"
+          android:layout_marginEnd="5dp"
+          android:layout_marginStart="10dp"
+          android:layout_marginTop="5dp"/>
+</LinearLayout>
diff --git a/src/main/res/layout/meshfilelayout.xml b/src/main/res/layout/meshfilelayout.xml
index 68308d3..161fce4 100644
--- a/src/main/res/layout/meshfilelayout.xml
+++ b/src/main/res/layout/meshfilelayout.xml
@@ -94,4 +94,40 @@
 
     </LinearLayout>
 
+    <View
+        android:layout_height="4dip"
+        android:background="#777777"
+        android:layout_width="match_parent"
+        />
+
+    <TextView
+          android:text="@string/effComponents"
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:gravity="center"
+          android:layout_marginEnd="5dp"
+          android:layout_marginStart="5dp"
+          android:layout_marginTop="5dp"/>
+
+    <View
+        android:layout_height="4dip"
+        android:background="#777777"
+        android:layout_width="match_parent"
+        />
+
+    <ScrollView
+        android:id="@+id/meshfileScrollView"
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="0.5">
+
+        <LinearLayout
+            android:id="@+id/meshfileComponentLayout"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical" >
+        </LinearLayout>
+
+    </ScrollView>
+
 </LinearLayout>
\ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 6cbf5a2..87b8b99 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -90,6 +90,9 @@
     <string name="open">Open</string>
     <string name="vertices">Vert</string>
     <string name="time">Time</string>
+    <string name="disappear">Disappear</string>
+    <string name="appear">Appear</string>
+    <string name="effComponents">Effect Components</string>
 
     <string name="quality0">Highest</string>
     <string name="quality1">High</string>
