Index: /issm/trunk-jpl/src/android/ISSM/src/com/example/issm/ISSM.java
===================================================================
--- /issm/trunk-jpl/src/android/ISSM/src/com/example/issm/ISSM.java	(revision 14248)
+++ /issm/trunk-jpl/src/android/ISSM/src/com/example/issm/ISSM.java	(revision 14249)
@@ -252,5 +252,5 @@
     	mGLView = new MyGLSurfaceView(this, buff, size, colorMap);
     	frame.addView(mGLView);
-    	frame.addView(colorBar);
+    	//frame.addView(colorBar);
     }
 //------------------------------------------------------------------------------------
Index: /issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MyGLRenderer.java
===================================================================
--- /issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MyGLRenderer.java	(revision 14248)
+++ /issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MyGLRenderer.java	(revision 14249)
@@ -30,5 +30,14 @@
 {
 	public volatile float mAngle;
-	
+	public volatile float mAngleX; /* NEW STUFF*/
+	public volatile float mAngleY;
+	
+	
+    private FloatBuffer[] triangleVert;
+	
+	private float[][] mScaleMatrix;  // scaling /* NEW STUFF*/
+	private float[][] mRotXMatrix;	 // rotation x 
+	private float[][] mRotYMatrix;	 // rotation x
+
 	/**
 	 * Store the model matrix. This matrix is used to move models from object space (where each model can be thought
@@ -52,6 +61,4 @@
 	private int mMatrixHandle;
 	
-    private FloatBuffer[] triangleVert;
-    
     private float[][] triangleData2DArr;
     
@@ -78,8 +85,21 @@
     private final int mColorDataSize = 4;	
 
+	// scaling /* NEW STUFF*/
+	float scaleX = 1.0f;
+	float scaleY = 1.0f;
+	float scaleZ = 1.0f;
+
+	public float eyeX;
+	public float eyeY;
+	public float eyeZ;
+	
     public MyGLRenderer(float[][] vertices)
     {	
     	triangleData2DArr = new float[vertices.length][21];
+ 
     	triangleVert = new FloatBuffer[vertices.length];
+    	mScaleMatrix  = new float[triangleVert.length][16];  // scaling  /* NEW STUFF*/
+    	mRotXMatrix  = new float[triangleVert.length][16];	 // rotation x
+    	mRotYMatrix  = new float[triangleVert.length][16];	 // rotation x
     	
     	for (int i = 0; i < vertices.length; i++)
@@ -88,5 +108,5 @@
     			triangleData2DArr[i][j] = vertices[i][j]; 
     	}
-	    		
+	    
 	    // initialize vertex byte buffer for shape coordinates
     	for (int i = 0; i < vertices.length; i++)
@@ -98,13 +118,30 @@
     }
     
+	public void changeScale(float scale) /* NEW STUFF*/
+	{
+		if (scaleX * scale > 3.0f) return;
+		  scaleX *= scale; scaleY *= scale; scaleZ *= scale;
+		
+		//scaleX += scale;scaleY += scale;scaleZ += scale;
+		//scaleX = scale;scaleY = scale;scaleZ = scale;
+		//scaleX /= 100;scaleY /= 100;scaleZ /= 100;
+	}
+
+	public void defaultScale() 
+	{
+		scaleX = 1f;
+		scaleY = 1f;
+		scaleZ = 1f;
+	}
+	
     public void onSurfaceCreated(GL10 unused, EGLConfig config) 
     {
         // Set the background frame color
-        GLES20.glClearColor(0.0f, 0.8f, 1.0f, 1.0f);
+        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
         
 		// Position the eye behind the origin.
-		final float eyeX = 0.0f;
-		final float eyeY = 0.0f;
-		final float eyeZ = 1.5f;
+		eyeX = 0.0f;
+		eyeY = 0.0f;
+		eyeZ = 1.5f;
 
 		// We are looking toward the distance
@@ -123,6 +160,8 @@
 		mViewMatrix = new float[triangleVert.length][16];
 		
+		
 		for (int i = 0; i < triangleVert.length; i++)
 			Matrix.setLookAtM(mViewMatrix[i], 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);
+			//Matrix.setLookAtM(mVMatrix[i], 0, 0, 0, -5.0f, 0.0f, 0f, 0f, 0f, 1.0f, 0.0f);
         
 		final String vertexShader =
@@ -134,4 +173,5 @@
 			  + "{                              \n"
 			  + "   v_Color = a_Color;          \n"		// Pass the color through to the fragment shader. 
+			  
 			  											// It will be interpolated across the triangle.
 			  + "   gl_Position = u_MVPMatrix   \n" 	// gl_Position is a special variable used to store the final position.
@@ -197,5 +237,5 @@
 		GLES20.glBindAttribLocation(mProgram, 0, "a_Position");
 		GLES20.glBindAttribLocation(mProgram, 1, "a_Color");
-
+		
 		// Link the two shaders together into a program.
 		GLES20.glLinkProgram(mProgram);
@@ -214,5 +254,5 @@
 		for (int i = 0; i < triangleVert.length; i++)
 		{
-			mMatrixHandle = GLES20.glGetUniformLocation(mProgram, "u_MVPMatrix");        
+			mMatrixHandle = GLES20.glGetUniformLocation(mProgram, "u_MVPMatrix");       
 	        mPositionHandle = GLES20.glGetAttribLocation(mProgram, "a_Position");
 	        mColorHandle = GLES20.glGetAttribLocation(mProgram, "a_Color");
@@ -222,5 +262,4 @@
         GLES20.glUseProgram(mProgram);
     }
-    
     public void onSurfaceChanged(GL10 unused, int width, int height) 
     {
@@ -236,5 +275,4 @@
 		for (int i = 0; i < triangleVert.length; i++)
 			Matrix.frustumM(mProjectionMatrix[i], 0, -ratio*0.7f, ratio*1.0f, 0.0f, 1.0f, 1.0f, 14f);
-		//Matrix.frustumM(m, offset, left, right, bottom, top, near, far)
     }
     
@@ -247,5 +285,16 @@
         // Draw the triangle facing straight on.
     	for (int i = 0; i < triangleVert.length; i++)
-    		Matrix.setIdentityM(mModelMatrix[i], 0);
+    	{
+    		//Matrix.setIdentityM(mModelMatrix[i], 0); /* NEW STUFF*/
+    		Matrix.setIdentityM(mScaleMatrix[i], 0);
+    		Matrix.scaleM(mScaleMatrix[i], 0, scaleX, scaleY, scaleZ);
+    		
+    		// Rotation along x
+    		Matrix.setRotateM(mRotXMatrix[i], 0, this.mAngleY, -1.0f, 0.0f, 0.0f);
+    		Matrix.setRotateM(mRotYMatrix[i], 0, this.mAngleX, 0.0f, 1.0f, 0.0f); /* NEW STUFF*/
+    		
+    		Matrix.setLookAtM(mViewMatrix[i], 0, eyeX, eyeY, eyeZ, 0.0f, 0.0f, -5.0f, 0.0f, 1.0f, 0.0f); 
+    	
+    	}
     		
     	mMVPMatrix = new float[triangleVert.length][16];
@@ -273,5 +322,10 @@
 	        GLES20.glEnableVertexAttribArray(mColorHandle);
 	        
-	        //Matrix.setRotateM(mModelMatrix[i], 0, mAngle, 0, 0, -1.0f);
+	        Matrix.setRotateM(mRotXMatrix[i], 0, this.mAngleY, -1.0f, 0.0f, 0.0f); /* NEW STUFF*/
+    		Matrix.setRotateM(mRotYMatrix[i], 0, this.mAngleX, 0.0f, 1.0f, 0.0f);
+
+    		float tempMatrix[][] = new float[triangleVert.length][16]; /* NEW STUFF*/
+    		Matrix.multiplyMM(tempMatrix[i], 0, mRotYMatrix[i], 0, mRotXMatrix[i], 0);
+    		Matrix.multiplyMM(mModelMatrix[i], 0, mScaleMatrix[i], 0, tempMatrix[i], 0);
 
 			// This multiplies the view matrix by the model matrix, and stores the result in the MVP matrix
@@ -283,6 +337,6 @@
 	        Matrix.multiplyMM(mMVPMatrix[i], 0, mProjectionMatrix[i], 0, mMVPMatrix[i], 0);
 	        
-	        GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMVPMatrix[i], 0);
-	        
+	        GLES20.glUniformMatrix4fv(mMatrixHandle, 1, false, mMVPMatrix[i], 0);   
+
 	        // Draw the triangle
 	        GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
Index: /issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MyGLSurfaceView.java
===================================================================
--- /issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MyGLSurfaceView.java	(revision 14248)
+++ /issm/trunk-jpl/src/android/ISSM/src/com/example/issm/MyGLSurfaceView.java	(revision 14249)
@@ -6,4 +6,5 @@
 import android.content.Context;
 import android.opengl.GLSurfaceView;
+import android.util.FloatMath;
 import android.view.MotionEvent;
 
@@ -17,4 +18,10 @@
 	final int firstVelocity = 9; 
 	ColorMap colorMap;
+	
+	// pinch to zoom
+	float oldDist = 100.0f;
+	float newDist;
+	
+	int mode = 0;
     public MyGLSurfaceView(Context context, DoubleBuffer db, int size, ColorMap colorMap) 
     {
@@ -152,36 +159,71 @@
     
     private float mPreviousY;
+ // touch events
+ 	private final int NONE = 0;
+ 	private final int DRAG = 0;
+ 	private final int ZOOM = 0;
     @Override
-    public boolean onTouchEvent(MotionEvent e) {
-        // MotionEvent reports input details from the touch screen
-        // and other input controls. In this case, you are only
-        // interested in events where the touch position changed.
-
-        float x = e.getX();
-        float y = e.getY();
-
-        switch (e.getAction()) {
-            case MotionEvent.ACTION_MOVE:
-
-                float dx = x - mPreviousX;
-                float dy = y - mPreviousY;
-
-                // reverse direction of rotation above the mid-line
-                if (y > getHeight() / 2) {
-                  dx = dx * -1 ;
-                }
-
-                // reverse direction of rotation to left of the mid-line
-                if (x < getWidth() / 2) {
-                  dy = dy * -1 ;
-                }
-
-                mRend.mAngle += (dx + dy) * TOUCH_SCALE_FACTOR;  // = 180.0f / 320
-                requestRender();
-        }
-
-        mPreviousX = x;
-        mPreviousY = y;
-        return true;
-    }
+    public boolean onTouchEvent(MotionEvent e) /* NEW STUFF*/
+	{
+		float x = e.getX();
+		float y = e.getY();
+		switch (e.getAction()) {
+			case MotionEvent.ACTION_DOWN:			// one touch: drag
+		      mode = DRAG;
+		      //mRend.eyeX = e.getX();
+		      //mRend.eyeY = e.getY;
+		      break;
+		      
+			case MotionEvent.ACTION_POINTER_DOWN:	// two touches: zoom
+				oldDist = spacing(e);
+				if (oldDist > 10.0f) 
+					mode = ZOOM; // zoom
+				break;
+				
+			case MotionEvent.ACTION_UP:		// no mode
+				mode = NONE;
+				oldDist = 100.0f;
+				break;
+				
+			case MotionEvent.ACTION_POINTER_UP:		// no mode
+				mode = NONE;
+				oldDist = 100.0f;
+				break;
+				
+			case MotionEvent.ACTION_MOVE:						// rotation
+				if (e.getPointerCount() > 1 && mode == ZOOM) 
+				{
+					newDist = spacing(e);
+					if (newDist > 10.0f) {
+						float scale = newDist/oldDist; // scale
+						
+						// scale in the renderer
+						mRend.changeScale(scale);
+						oldDist = newDist;
+					}
+				}
+				else if (mode == DRAG)
+				{
+					float dx = x - mPreviousX;
+					float dy = y - mPreviousY;
+					
+					mRend.mAngleX += dx * TOUCH_SCALE_FACTOR;
+					mRend.mAngleY += dy * TOUCH_SCALE_FACTOR;
+
+					requestRender();
+				}
+				break;
+		}
+		mPreviousX = x;
+		mPreviousY = y;
+		return true;
+	}
+	
+	private float spacing(MotionEvent event) /* NEW STUFF*/
+	{
+		float x = event.getX(0) - event.getX(1);
+		float y = event.getY(0) - event.getY(1);
+		return FloatMath.sqrt(x * x + y * y);
+	}
 }
+
