commit dd19d6e01593268777bd5806eb4f1ab69108e243
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sat May 23 19:53:29 2020 +0100

    Some progress with 'MeshJoin' app.

diff --git a/src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java b/src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java
index 159cab7..ffec0f3 100644
--- a/src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java
+++ b/src/main/java/org/distorted/examples/meshjoin/MeshJoinRenderer.java
@@ -24,8 +24,12 @@ import android.graphics.Canvas;
 import android.graphics.Paint;
 import android.opengl.GLSurfaceView;
 
+import org.distorted.library.effect.EffectType;
 import org.distorted.library.effect.MatrixEffectQuaternion;
 import org.distorted.library.effect.MatrixEffectScale;
+import org.distorted.library.effect.VertexEffectMove;
+import org.distorted.library.effect.VertexEffectRotate;
+import org.distorted.library.effect.VertexEffectScale;
 import org.distorted.library.effect.VertexEffectSink;
 import org.distorted.library.main.DistortedEffects;
 import org.distorted.library.main.DistortedLibrary;
@@ -100,7 +104,7 @@ class MeshJoinRenderer implements GLSurfaceView.Renderer
     public void onSurfaceChanged(GL10 glUnused, int width, int height) 
       {
       final float SCALE = 0.7f;
-      mScreenMin = width<height ? width:height;
+      mScreenMin = Math.min(width, height);
       float factor = SCALE*mScreenMin;
       mScale.set(factor,factor,factor);
       mScreen.resize(width, height);
@@ -118,7 +122,7 @@ class MeshJoinRenderer implements GLSurfaceView.Renderer
       mScreen.detachAll();
       mScreen.attach(mTexture,mEffects,mMesh);
 
-      VertexEffectSink.enable();
+      DistortedLibrary.setMax(EffectType.VERTEX, 7);
 
       try
         {
@@ -185,42 +189,52 @@ class MeshJoinRenderer implements GLSurfaceView.Renderer
       final float angleFaces = (float)((180/Math.PI)*(2*Math.asin(SQ3/3))); // angle between two faces of a tetrahedron
       final int MESHES=4;
 
+      int association = 1;
       MeshBase[] meshes = new MeshTriangles[MESHES];
-      for(int i=0; i<MESHES; i++) meshes[i] = new MeshTriangles(10);
-/*
-      MatrixEffect[] effects0 = new MatrixEffect[3];
-      effects0[0] = new MatrixEffectScale( new Static3D(1,SQ3/2,1) );
-      effects0[1] = new MatrixEffectRotate( new Static1D(90), new Static3D(1,0,0), new Static3D(0,0,0) );
-      effects0[2] = new MatrixEffectMove( new Static3D(0,-SQ3*SQ2/12,SQ3/12) );
-
-      meshes[0].apply(effects0);
-
-      Static1D angle = new Static1D(angleFaces);
-      Static3D axis  = new Static3D(-1,0,0);
-      Static3D center= new Static3D(0,-SQ3*SQ2/12,-SQ3/6);
-
-      MatrixEffect[] effects1 = new MatrixEffect[5];
-      effects1[0] = effects0[0];
-      effects1[1] = effects0[1];
-      effects1[2] = effects0[2];
-      effects1[3] = new MatrixEffectRotate( new Static1D(180), new Static3D(0,0,1), center );
-      effects1[4] = new MatrixEffectRotate( angle, axis, center );
-      meshes[1].apply(effects1);
-
-      axis.set(0.5f,0,-SQ3/2);
-      center.set2(SQ3/3);
-      meshes[2].apply(effects1);
-
-      axis.set2(SQ3/2);
-      meshes[3].apply(effects1);
-*/
-      Static4D[] textureMaps = new Static4D[MESHES];
 
-      for(int i=0; i<MESHES; i++) textureMaps[i] = new Static4D(i*0.25f,0.0f,0.25f,1.0f);
+      for(int i=0; i<MESHES; i++)
+        {
+        meshes[i] = new MeshTriangles(10);
+        meshes[i].setEffectAssociation(0,association);
+        association <<= 1;
+        }
 
+      Static4D[] textureMaps = new Static4D[MESHES];
+      for(int i=0; i<MESHES; i++) textureMaps[i] = new Static4D(i*0.25f,0.0f,0.25f,1.0f);
       MeshBase result = new MeshJoined(meshes);
       result.setTextureMap(textureMaps);
 
+      Static1D angle  = new Static1D(angleFaces);
+      Static3D axis1  = new Static3D(  -1, 0,      0);
+      Static3D axis2  = new Static3D(0.5f, 0, -SQ3/2);
+      Static3D axis3  = new Static3D(0.5f, 0, +SQ3/2);
+      Static3D center1= new Static3D(0,-SQ3*SQ2/12,-SQ3/6);
+      Static3D center2= new Static3D(0,-SQ3*SQ2/12,+SQ3/3);
+
+      VertexEffectScale  effect1 = new VertexEffectScale ( new Static3D(1,SQ3/2,1) );
+      VertexEffectRotate effect2 = new VertexEffectRotate( new Static1D(90), new Static3D(1,0,0), new Static3D(0,0,0) );
+      VertexEffectMove   effect3 = new VertexEffectMove  ( new Static3D(0,-SQ3*SQ2/12,SQ3/12) );
+      VertexEffectRotate effect4 = new VertexEffectRotate( new Static1D(180), new Static3D(0,0,1), center1 );
+      VertexEffectRotate effect5 = new VertexEffectRotate( angle, axis1, center1 );
+      VertexEffectRotate effect6 = new VertexEffectRotate( angle, axis2, center2 );
+      VertexEffectRotate effect7 = new VertexEffectRotate( angle, axis3, center2 );
+
+      effect1.setMeshAssociation(15);  // apply to all 4 meshes
+      effect2.setMeshAssociation(15);  // apply to all 4 meshes
+      effect3.setMeshAssociation(15);  // apply to all 4 meshes
+      effect4.setMeshAssociation(14);  // apply to mesh[1], [2] and [3]
+      effect5.setMeshAssociation( 2);  // apply only to mesh[1]
+      effect6.setMeshAssociation( 0);  // apply onlt to mesh[2]
+      effect7.setMeshAssociation( 0);  // apply only to mesh[3]
+
+      result.apply(effect1);
+      result.apply(effect2);
+      result.apply(effect3);
+      result.apply(effect4);
+      result.apply(effect5);
+      result.apply(effect6);
+      result.apply(effect7);
+
       return result;
       }
 }
