|
@@ -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) {
|