Browse Source

more comments for the gl classes

Fabio Arnold 10 years ago
parent
commit
0868f9c3a3

+ 10 - 4
src/de/tudarmstadt/informatik/hostage/ui2/fragment/opengl/AnimatedMesh.java

@@ -59,10 +59,6 @@ public class AnimatedMesh {
 				currentFrame = currentAction.numFrames - 1;
 	}
 	
-	public boolean isActionReversed() {
-		return reverseAction;
-	}
-	
 	public boolean isActionDone() {
 		if (currentAction == null)
 			return false;
@@ -73,6 +69,7 @@ public class AnimatedMesh {
 	}
 	
 	private class Bone {
+		@SuppressWarnings("unused")
 		public String name; // 15 bytes
 		public int parentIndex; // 1 byte
 		public float[] invBindPose; // 64 bytes
@@ -121,6 +118,7 @@ public class AnimatedMesh {
 	}
 	
 	private class Track {
+		@SuppressWarnings("unused")
 		public int boneIndex;
 		public ArrayList<JointPose> poses;
 		
@@ -142,6 +140,7 @@ public class AnimatedMesh {
 	private class JointPose {
 		public Quaternion rotation;
 		public float[] translation;
+		@SuppressWarnings("unused")
 		float scale;
 		
 		public static final int kSize = 32;
@@ -280,6 +279,9 @@ public class AnimatedMesh {
 	
 	private boolean halfFramerate = false;
 
+	/**
+	 * animate the mesh for one frame
+	 */
 	public void tick() {
 		// empty pose
 		ArrayList<JointPose> pose = new ArrayList<JointPose>();
@@ -324,6 +326,10 @@ public class AnimatedMesh {
 		}
 	}
 	
+	/**
+	 * draws the mesh
+	 * @param program the currently bound shader program
+	 */
 	public void draw(int program) {
 		GLES20.glUniformMatrix4fv(GLES20.glGetUniformLocation(program, "boneMatrices"), bones.size(), false, matrices, 0);
 		

+ 7 - 4
src/de/tudarmstadt/informatik/hostage/ui2/fragment/opengl/ThreatIndicatorGLRenderer.java

@@ -168,6 +168,8 @@ public class ThreatIndicatorGLRenderer implements Renderer {
 			if (nextThreatLevel != targetThreatLevel) {
 				targetThreatLevel = nextThreatLevel;
 				threatLevelTransition = 0.0f;
+				
+				// HACK!!! reverses the sleep animation to create smooth transition into other states
 				if (currentThreatLevel == kThreatLevelNotMonitoring)
 					androidMesh.startAction("sleep", false, true);
 			}
@@ -183,10 +185,11 @@ public class ThreatIndicatorGLRenderer implements Renderer {
 		int textureUniformLoc = GLES20.glGetUniformLocation(program, "texture");
 		int mvpUniformLoc = GLES20.glGetUniformLocation(program, "mvp");
 
+		//  animate color
 		final float[] whiteColor = {1.0f, 1.0f, 1.0f, 1.0f};
 		final float[] greyColor = {0.5f, 0.5f, 0.5f, 1.0f};
 		final float[] redColor = {2.0f, 0.4f, 0.2f, 1.0f};
-		final float[] yellowColor = {1.2f * 255.0f / 166.0f, 1.2f * 255.0f / 200.0f, 0.0f, 1.0f};
+		final float[] yellowColor = {1.1f * 255.0f / 166.0f, 1.2f * 255.0f / 200.0f, 0.0f, 1.0f};
 		
 		float[] currentColor = whiteColor;
 		float blink = 0.5f + 0.5f * (float)Math.sin(12.0 * animTime);
@@ -217,13 +220,13 @@ public class ThreatIndicatorGLRenderer implements Renderer {
 			currentColor = mixColor(threatLevelTransition, currentColor, targetColor);
 		}
 		GLES20.glUniform4fv(colorUniformLoc, 1, currentColor, 0);
-		
 		GLES20.glUniform1i(textureUniformLoc, 0);
 		
+		// animate camera
 		Matrix.setIdentityM(modelview, 0);
 		if (currentThreatLevel == kThreatLevelPersistentThreat || targetThreatLevel == kThreatLevelPersistentThreat) {
 			float delta = 1.0f;
-			if (threatLevelTransition < 0.4f) {
+			if (threatLevelTransition < 0.4f) { // animate only during the first 40% of the transition
 				delta = threatLevelTransition / 0.4f;
 				delta = -2.0f * delta * delta * delta + 3.0f * delta * delta; // ease in/out
 			}
@@ -237,12 +240,12 @@ public class ThreatIndicatorGLRenderer implements Renderer {
 			Matrix.rotateM(modelview, 0, -85.0f, 1.0f, 0.0f, 0.0f);
 		}
 		Matrix.multiplyMM(mvp, 0, projection, 0, modelview, 0);
-		
 		GLES20.glUniformMatrix4fv(mvpUniformLoc, 1, false, mvp, 0);
 		
 		GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, androidTexture);
 		androidMesh.draw(program);
 		
+		// restore color
 		GLES20.glUniform4fv(colorUniformLoc, 1, whiteColor, 0);
 
 		if (currentThreatLevel == kThreatLevelPersistentThreat || targetThreatLevel == kThreatLevelPersistentThreat) {