commit e4c556f9714698bb3687ee30aa970bdb0bd55c0a
Author: leszek <leszek@koltunski.pl>
Date:   Wed Dec 11 18:48:12 2024 +0100

    new app 'TwoComponents' : apply a postprocessing effect to only part of a Mesh (a single vertex component)

diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index dae205b..92e44ef 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -63,6 +63,6 @@
         <activity android:name=".meshfile.MeshFileActivity"/>
         <activity android:name=".flatblur.FlatBlurActivity"/>
         <activity android:name=".flatblur2.FlatBlur2Activity"/>
-        <activity android:name=".polymesh.PolymeshActivity"/>
+        <activity android:name=".twocomponents.TwoComponentsActivity"/>
     </application>
 </manifest>
diff --git a/src/main/java/org/distorted/examples/TableOfContents.java b/src/main/java/org/distorted/examples/TableOfContents.java
index faecff7..ee98419 100644
--- a/src/main/java/org/distorted/examples/TableOfContents.java
+++ b/src/main/java/org/distorted/examples/TableOfContents.java
@@ -59,6 +59,7 @@ import org.distorted.examples.generic.GenericActivity;
 import org.distorted.examples.surfaceview.SurfaceViewActivity;
 import org.distorted.examples.save.SaveActivity;
 import org.distorted.examples.flag.FlagActivity;
+import org.distorted.examples.twocomponents.TwoComponentsActivity;
 import org.distorted.examples.wind.WindActivity;
 import org.distorted.examples.aroundtheworld.AroundTheWorldActivity;
 import org.distorted.examples.mirror.MirrorActivity;
@@ -129,6 +130,7 @@ public class TableOfContents extends ListActivity
     SINGLEMESH        (R.drawable.icon_example_singlemesh      , R.string.example_singlemesh           , R.string.example_singlemesh_subtitle           ,            SingleMeshActivity.class),
     FLATBLUR2         (R.drawable.icon_example_flatblur        , R.string.example_flatblur         , R.string.example_flatblur_subtitle         , FlatBlur2Activity.class ),
     MESHFILE          (R.drawable.icon_example_meshfile        , R.string.example_meshfile           , R.string.example_meshfile_subtitle           ,            MeshFileActivity.class),
+    TWOCOMPONENTS     (R.drawable.icon_example_wip             , R.string.example_twocomponents           , R.string.example_twocomponents_subtitle           ,            TwoComponentsActivity.class),
     ;
 
     final int icon, title, subtitle;
diff --git a/src/main/java/org/distorted/examples/deferredjob/DeferredJobRenderer.java b/src/main/java/org/distorted/examples/deferredjob/DeferredJobRenderer.java
index d2efa7a..5dfd6f6 100644
--- a/src/main/java/org/distorted/examples/deferredjob/DeferredJobRenderer.java
+++ b/src/main/java/org/distorted/examples/deferredjob/DeferredJobRenderer.java
@@ -76,10 +76,6 @@ class DeferredJobRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Li
       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);
 
diff --git a/src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java b/src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java
index c3b4f43..f9dacd3 100644
--- a/src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java
+++ b/src/main/java/org/distorted/examples/singlemesh/SingleMeshRenderer.java
@@ -206,6 +206,7 @@ class SingleMeshRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Lib
 
       VertexEffectRotate.enable();
       VertexEffectDisappear.enable();
+      PostprocessEffectGlow.enable();
 
       DistortedLibrary.onSurfaceCreated(this);
       }
@@ -411,7 +412,7 @@ class SingleMeshRenderer implements GLSurfaceView.Renderer, DistortedLibrary.Lib
 
       for(int i=0; i<NUM_CUBITS; i++)
         {
-        cubits[i] = cubits[NUM_CUBITS-1].copy(true);
+        if( i<NUM_CUBITS-1 ) cubits[i] = cubits[NUM_CUBITS-1].copy(true);
         cubits[i].apply( new MatrixEffectMove(CUBIT_MOVES[i]), 1,0);
         cubits[i].setTextureMap(TEXTURE_MAP[i],0);
         }
diff --git a/src/main/java/org/distorted/examples/twocomponents/TwoComponentsActivity.java b/src/main/java/org/distorted/examples/twocomponents/TwoComponentsActivity.java
new file mode 100644
index 0000000..d62af28
--- /dev/null
+++ b/src/main/java/org/distorted/examples/twocomponents/TwoComponentsActivity.java
@@ -0,0 +1,99 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2024 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.twocomponents;
+
+import android.app.Activity;
+import android.opengl.GLSurfaceView;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.CheckBox;
+
+import org.distorted.examples.R;
+import org.distorted.library.main.DistortedLibrary;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+public class TwoComponentsActivity extends Activity
+{
+    @Override
+    protected void onCreate(Bundle icicle) 
+      {
+      super.onCreate(icicle);
+      DistortedLibrary.onCreate();
+      setContentView(R.layout.twocomponentslayout);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override
+    protected void onPause() 
+      {
+      super.onPause();
+      GLSurfaceView view = this.findViewById(R.id.twocomponentsSurfaceView);
+      view.onPause();
+      DistortedLibrary.onPause();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override
+    protected void onResume() 
+      {
+      super.onResume();
+      GLSurfaceView view = this.findViewById(R.id.twocomponentsSurfaceView);
+      view.onResume();
+      }
+    
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    @Override
+    protected void onDestroy() 
+      {
+      DistortedLibrary.onDestroy();
+      super.onDestroy();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onClick(View view)
+      {
+      Button butt = (Button)view;
+      int id = butt.getId();
+      TwoComponentsSurfaceView v = findViewById(R.id.twocomponentsSurfaceView);
+      TwoComponentsRenderer r = v.getRenderer();
+
+      if( id == R.id.twocomponentsButton0 ) r.apply(0);
+      if( id == R.id.twocomponentsButton1 ) r.apply(1);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void onVisible(View view)
+      {
+      CheckBox check = (CheckBox)view;
+      int id = check.getId();
+      TwoComponentsSurfaceView v = findViewById(R.id.twocomponentsSurfaceView);
+      TwoComponentsRenderer r = v.getRenderer();
+
+      if( id == R.id.twocomponentsCheckBox0 ) r.visible(true);
+      if( id == R.id.twocomponentsCheckBox1 ) r.visible(false);
+      }
+}
diff --git a/src/main/java/org/distorted/examples/twocomponents/TwoComponentsRenderer.java b/src/main/java/org/distorted/examples/twocomponents/TwoComponentsRenderer.java
new file mode 100644
index 0000000..ca38301
--- /dev/null
+++ b/src/main/java/org/distorted/examples/twocomponents/TwoComponentsRenderer.java
@@ -0,0 +1,310 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2024 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.twocomponents;
+
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.opengl.GLSurfaceView;
+
+import org.distorted.library.effect.MatrixEffectMove;
+import org.distorted.library.effect.MatrixEffectQuaternion;
+import org.distorted.library.effect.MatrixEffectScale;
+import org.distorted.library.effect.PostprocessEffectGlow;
+import org.distorted.library.effect.VertexEffectDisappear;
+import org.distorted.library.effect.VertexEffectMove;
+import org.distorted.library.effect.VertexEffectRotate;
+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.MeshJoined;
+import org.distorted.library.mesh.MeshTriangle;
+import org.distorted.library.type.Dynamic1D;
+import org.distorted.library.type.DynamicQuat;
+import org.distorted.library.type.Static1D;
+import org.distorted.library.type.Static2D;
+import org.distorted.library.type.Static3D;
+import org.distorted.library.type.Static4D;
+
+import java.io.InputStream;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class TwoComponentsRenderer implements GLSurfaceView.Renderer, DistortedLibrary.LibraryUser
+{
+    private final int[] FACE_COLORS = new int[] { 0xffffff00, 0xff00ff00, 0xff0000ff, 0xffff0000 };
+
+    private final Resources mResources;
+    private final DistortedScreen mScreen;
+    private final DistortedEffects mEffects;
+    private final Static3D mScale;
+    private final VertexEffectRotate mRotate;
+    private final VertexEffectDisappear mDisappear;
+    private final Dynamic1D mAngleDyn;
+    private final Static1D mAngle;
+
+    private DistortedTexture mTexture;
+    private MeshBase mMesh;
+    private boolean mInvisibleLeft, mInvisibleRight;
+
+    Static4D mQuat1, mQuat2;
+    int mScreenMin;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    TwoComponentsRenderer(GLSurfaceView v)
+      {
+      mResources = v.getResources();
+
+      mScreen = new DistortedScreen();
+      mScale= new Static3D(1,1,1);
+      Static3D center=new Static3D(0,0,0);
+
+      mQuat1 = new Static4D(0,0,0,1);
+      mQuat2 = new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f);
+
+      DynamicQuat quatInt1 = new DynamicQuat(0,0.5f);
+      DynamicQuat quatInt2 = new DynamicQuat(0,0.5f);
+
+      quatInt1.add(mQuat1);
+      quatInt2.add(mQuat2);
+
+      mAngle = new Static1D(0);
+
+      mAngleDyn = new Dynamic1D(2000,0.5f);
+      mAngleDyn.add(new Static1D(0));
+      mAngleDyn.add( mAngle );
+
+      mRotate = new VertexEffectRotate( mAngleDyn, new Static3D(1,0,0), new Static3D(0,0,0) );
+
+      mDisappear = new VertexEffectDisappear();
+      mDisappear.setMeshAssociation(0,-1);
+
+      final float HALO_TO_RADIUS = 0.2f;
+      Static2D haloRadius= new Static2D(25*HALO_TO_RADIUS,25);
+      Static4D color     = new Static4D(1.0f,0.0f,0.0f,0.5f); // half-transparent red
+
+      PostprocessEffectGlow glow = new PostprocessEffectGlow(haloRadius,color);
+
+      mEffects = new DistortedEffects();
+      mEffects.apply( mDisappear );
+      mEffects.apply( mRotate );
+      mEffects.apply( new MatrixEffectQuaternion(quatInt2, center) );
+      mEffects.apply( new MatrixEffectQuaternion(quatInt1, center) );
+      mEffects.apply( new MatrixEffectScale(mScale));
+      mEffects.apply(glow);
+
+      mScreen.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+   
+    public void onDrawFrame(GL10 glUnused) 
+      {
+      mScreen.render( System.currentTimeMillis() );
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    public void onSurfaceChanged(GL10 glUnused, int width, int height) 
+      {
+      final float SCALE = 0.4f;
+      mScreenMin = Math.min(width, height);
+      float factor = SCALE*mScreenMin;
+      mScale.set(factor,factor,factor);
+      mScreen.resize(width, height);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+    
+    public void onSurfaceCreated(GL10 glUnused, EGLConfig config) 
+      {
+      if( mTexture==null ) mTexture = new DistortedTexture();
+      mTexture.setTexture( createTexture() );
+
+      if( mMesh==null ) mMesh = createMesh(1);  // has to be <=FACE_COLORS.length;
+
+      mScreen.detachAll();
+      mScreen.attach(mTexture,mEffects,mMesh);
+
+      VertexEffectRotate.enable();
+      VertexEffectDisappear.enable();
+      PostprocessEffectGlow.enable();
+
+      DistortedLibrary.onSurfaceCreated(this);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    void apply(int number)
+      {
+      mRotate.setMeshAssociation(0,number);
+      mAngle.set(360);
+      mAngleDyn.resetToBeginning();
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    void visible(boolean left)
+      {
+      if( left )
+        {
+        mInvisibleLeft = !mInvisibleLeft;
+        mDisappear.setMeshAssociation(0, mInvisibleLeft ? 0 : -1 );
+        }
+      else
+        {
+        mInvisibleRight= !mInvisibleRight;
+        mDisappear.setMeshAssociation(0, mInvisibleRight ? 1 : -1 );
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private MeshBase createMesh(int numMeshes)
+      {
+      MeshBase[] meshes = new MeshTriangle[numMeshes];
+      VertexEffectMove[] moveEffect = new VertexEffectMove[numMeshes];
+
+      meshes[0] = new MeshTriangle(1);
+      meshes[0].setEffectAssociation(0,1,0);
+
+      for(int i=1; i<numMeshes; i++)
+        {
+        meshes[i] = meshes[0].copy(true);
+        meshes[i].setEffectAssociation(0,1,i);
+        }
+
+      Static4D[] textureMaps = new Static4D[numMeshes];
+
+      for(int i=0; i<numMeshes; i++)
+        {
+        textureMaps[i] = new Static4D(i*0.25f,0.0f,0.25f,1.0f);
+        }
+
+      MeshBase[] tmp = new MeshBase[2];
+
+      tmp[0] = new MeshJoined(meshes);
+
+      for(int i=0; i<numMeshes; i++)
+        {
+        Static3D mv = new Static3D(0,0, numMeshes>1 ? (0.5f-i/(numMeshes-1.0f)) : 0 );
+        moveEffect[i] = new VertexEffectMove(mv);
+        moveEffect[i].setMeshAssociation(0,i);
+        tmp[0].apply(moveEffect[i]);
+        }
+
+      tmp[1] = tmp[0].copy(true);
+
+      tmp[0].mergeEffComponents();
+      tmp[1].mergeEffComponents();
+
+      tmp[0].setEffectAssociation(0,0,0); // set the equAssoc of the 0th (the only) component to 0
+      tmp[1].setEffectAssociation(0,0,1); // set the equAssoc of the 0th (the only) component to 1
+
+      MeshBase combined = new MeshJoined(tmp);
+
+      MatrixEffectMove moveL = new MatrixEffectMove( new Static3D(-0.6f,0,0) );
+      MatrixEffectMove moveR = new MatrixEffectMove( new Static3D(+0.6f,0,0) );
+
+      combined.apply(moveL,0,0);
+      combined.apply(moveR,0,1);
+
+      combined.setTextureMap(textureMaps,0);
+      combined.setTextureMap(textureMaps,numMeshes);
+
+      combined.setComponentCenter(0,-0.6f,0,0);
+      combined.setComponentCenter(1,+0.6f,0,0);
+
+      return combined;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private Bitmap createTexture()
+      {
+      final int FACES=FACE_COLORS.length;
+      int SIZE = 200;
+      float STROKE = 0.05f*SIZE;
+      float OFF = STROKE/2 -1;
+      float OFF2 = 0.5f*SIZE + OFF;
+      float HEIGHT = SIZE - OFF;
+      float RADIUS = SIZE/12.0f;
+      float ARC1_H = 0.2f*SIZE;
+      float ARC1_W = SIZE*0.5f;
+      float ARC2_W = 0.153f*SIZE;
+      float ARC2_H = 0.905f*SIZE;
+      float ARC3_W = SIZE-ARC2_W;
+
+      Bitmap result = Bitmap.createBitmap(FACES*SIZE,SIZE, Bitmap.Config.ARGB_8888);
+      Canvas canvas = new Canvas(result);
+      Paint paint = new Paint();
+      paint.setAntiAlias(true);
+      paint.setStrokeWidth(STROKE);
+
+      for(int i=0; i<FACES; i++)
+        {
+        paint.setColor(FACE_COLORS[i]);
+        paint.setStyle(Paint.Style.FILL);
+
+        canvas.drawRect(i*SIZE,0,(i+1)*SIZE,SIZE,paint);
+
+        paint.setColor(0xff000000);
+        paint.setStyle(Paint.Style.STROKE);
+
+        canvas.drawLine(           i*SIZE, HEIGHT,  SIZE       +i*SIZE, HEIGHT, paint);
+        canvas.drawLine(      OFF +i*SIZE,   SIZE,       OFF2  +i*SIZE,      0, paint);
+        canvas.drawLine((SIZE-OFF)+i*SIZE,   SIZE, (SIZE-OFF2) +i*SIZE,      0, paint);
+
+        canvas.drawArc( ARC1_W-RADIUS+i*SIZE, ARC1_H-RADIUS, ARC1_W+RADIUS+i*SIZE, ARC1_H+RADIUS, 225, 90, false, paint);
+        canvas.drawArc( ARC2_W-RADIUS+i*SIZE, ARC2_H-RADIUS, ARC2_W+RADIUS+i*SIZE, ARC2_H+RADIUS, 105, 90, false, paint);
+        canvas.drawArc( ARC3_W-RADIUS+i*SIZE, ARC2_H-RADIUS, ARC3_W+RADIUS+i*SIZE, ARC2_H+RADIUS, 345, 90, false, paint);
+        }
+
+      return result;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void distortedException(Exception ex)
+      {
+      android.util.Log.e("TwoComponents", ex.getMessage() );
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public InputStream localFile(int fileID)
+      {
+      return mResources.openRawResource(fileID);
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public void logMessage(String message)
+      {
+      android.util.Log.e("TwoComponents", message );
+      }
+}
diff --git a/src/main/java/org/distorted/examples/twocomponents/TwoComponentsSurfaceView.java b/src/main/java/org/distorted/examples/twocomponents/TwoComponentsSurfaceView.java
new file mode 100644
index 0000000..a61cae2
--- /dev/null
+++ b/src/main/java/org/distorted/examples/twocomponents/TwoComponentsSurfaceView.java
@@ -0,0 +1,149 @@
+///////////////////////////////////////////////////////////////////////////////////////////////////
+// Copyright 2024 Leszek Koltunski                                                               //
+//                                                                                               //
+// This file is part of Distorted.                                                               //
+//                                                                                               //
+// Distorted is free software: you can redistribute it and/or modify                             //
+// it under the terms of the GNU General Public License as published by                          //
+// the Free Software Foundation, either version 2 of the License, or                             //
+// (at your option) any later version.                                                           //
+//                                                                                               //
+// Distorted is distributed in the hope that it will be useful,                                  //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
+// GNU General Public License for more details.                                                  //
+//                                                                                               //
+// You should have received a copy of the GNU General Public License                             //
+// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+package org.distorted.examples.twocomponents;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.pm.ConfigurationInfo;
+import android.opengl.GLSurfaceView;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+class TwoComponentsSurfaceView extends GLSurfaceView
+{
+    private final static int DIRECTION_SENSITIVITY=  12;
+    private int mX, mY;
+    private TwoComponentsRenderer mRenderer;
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public TwoComponentsSurfaceView(Context context, AttributeSet attrs)
+      {
+      super(context,attrs);
+
+      mX = -1;
+      mY = -1;
+
+      if(!isInEditMode())
+        {
+        mRenderer = new TwoComponentsRenderer(this);
+        final ActivityManager activityManager     = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+        final ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
+        setEGLContextClientVersion( (configurationInfo.reqGlEsVersion>>16) >= 3 ? 3:2 );
+        setRenderer(mRenderer);
+        }
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    public TwoComponentsRenderer getRenderer()
+      {
+      return mRenderer;
+      }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    private void resetQuats()
+      {
+      float qx = mRenderer.mQuat1.get0();
+      float qy = mRenderer.mQuat1.get1();
+      float qz = mRenderer.mQuat1.get2();
+      float qw = mRenderer.mQuat1.get3();
+
+      float rx = mRenderer.mQuat2.get0();
+      float ry = mRenderer.mQuat2.get1();
+      float rz = mRenderer.mQuat2.get2();
+      float rw = mRenderer.mQuat2.get3();
+
+       // This is quaternion multiplication. (tx,ty,tz,tw)
+       // is now equal to (qx,qy,qz,qw)*(rx,ry,rz,rw)
+       float tx = rw*qx - rz*qy + ry*qz + rx*qw;
+       float ty = rw*qy + rz*qx + ry*qw - rx*qz;
+       float tz = rw*qz + rz*qw - ry*qx + rx*qy;
+       float tw = rw*qw - rz*qz - ry*qy - rx*qx;
+
+       // The point of this is so that there are always
+       // exactly 2 quaternions: Quat1 representing the rotation
+       // accumulating only since the last screen touch, and Quat2
+       // which remembers the combined effect of all previous
+       // swipes.
+       // We cannot be accumulating an ever-growing list of quaternions
+       // and add a new one every time user swipes the screen - there
+       // is a limited number of slots in the EffectQueueMatrix!
+       mRenderer.mQuat1.set(0f, 0f, 0f, 1f);
+       mRenderer.mQuat2.set(tx, ty, tz, tw);
+       }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+    @Override public boolean onTouchEvent(MotionEvent event) 
+      {
+      int action = event.getAction();
+      int x = (int)event.getX();
+      int y = (int)event.getY();
+           
+      switch(action)
+         {
+         case MotionEvent.ACTION_DOWN: mX = x;
+                                       mY = y;
+                                       break;
+                                       
+         case MotionEvent.ACTION_MOVE: if( mX>=0 && mY>= 0 )
+                                         {
+                                         float px = mY-y;
+                                         float py = mX-x;
+                                         float pz = 0;
+                                         float plen = (float)Math.sqrt(px*px + py*py + pz*pz);
+                                         
+                                         if( plen>0 )
+                                           {
+                                           px /= plen;
+                                           py /= plen;
+                                           pz /= plen;
+
+                                           float cosA = (float)Math.cos(plen*3.14f/mRenderer.mScreenMin);
+                                           float sinA = (float)Math.sqrt(1-cosA*cosA);
+                                         
+                                           mRenderer.mQuat1.set(px*sinA, py*sinA, pz*sinA, cosA);
+                                           }
+                                         }
+
+                                       if( (mX-x)*(mX-x) + (mY-y)*(mY-y) > mRenderer.mScreenMin*mRenderer.mScreenMin/(DIRECTION_SENSITIVITY*DIRECTION_SENSITIVITY) )
+                                         {
+                                         mX = x;
+                                         mY = y;
+                                         resetQuats();
+                                         }
+
+                                       break;
+                                       
+         case MotionEvent.ACTION_UP  : mX = -1;
+                                       mY = -1;
+                                       resetQuats();
+                                       break;
+         }
+             
+      return true;
+      }
+         
+}
+
diff --git a/src/main/res/layout/twocomponentslayout.xml b/src/main/res/layout/twocomponentslayout.xml
new file mode 100644
index 0000000..ed63a2e
--- /dev/null
+++ b/src/main/res/layout/twocomponentslayout.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:orientation="vertical" >
+
+    <org.distorted.examples.twocomponents.TwoComponentsSurfaceView
+        android:id="@+id/twocomponentsSurfaceView"
+        android:layout_width="fill_parent"
+        android:layout_height="0dp"
+        android:layout_weight="1" />
+
+    <LinearLayout
+        android:orientation="horizontal"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+        <Button
+            android:id="@+id/twocomponentsButton0"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:text="@string/rotate_left"
+            android:onClick="onClick"
+            android:layout_weight="1"/>
+        <CheckBox
+            android:id="@+id/twocomponentsCheckBox0"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:text=""
+            android:onClick="onVisible"
+            android:layout_weight="1"
+            android:checked="false"/>
+        <Button
+            android:id="@+id/twocomponentsButton1"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:text="@string/rotate_right"
+            android:onClick="onClick"
+            android:layout_weight="1"/>
+        <CheckBox
+            android:id="@+id/twocomponentsCheckBox1"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:text=""
+            android:onClick="onVisible"
+            android:layout_weight="1"
+            android:checked="false"/>
+
+    </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 634e6a0..9bda1a6 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -217,8 +217,8 @@
     <string name="example_meshfile_subtitle">Explore Distorted\'s own Mesh format, dmesh. Open .dmesh files and explore their contents.</string>
     <string name="example_flatblur">Flat Blur</string>
     <string name="example_flatblur_subtitle">Unit test to see two partially obstructing flat objects, one of them blurred.</string>
-    <string name="example_polymesh">Polygon Mesh</string>
-    <string name="example_polymesh_subtitle">Test to be able to generate various polygon meshes with different parameters.</string>
+    <string name="example_twocomponents">Glow Part of Mesh</string>
+    <string name="example_twocomponents_subtitle">Attempt to apply a postprocess effect, GLOW, to only one vertex subcomponent of a Mesh.</string>
 
     <string name="example_movingeffects_toast">Click on \'RESET\' and define your path by touching the screen. Then click on one of the effects and see it move along your path.</string>
     <string name="example_rotate_toast">Rotate the scene by swiping the screen</string>
