Skip to content

armgit / andee

Public Imported from GitHub
0

Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。

fix(ball): make thinking read as thinking, and give rabbit and bear dark sleeping eyes

booboosui783c0f01c7ed
diff --git a/app/src/main/java/net/kuafuai/andee/ui/ball/BallLook.kt b/app/src/main/java/net/kuafuai/andee/ui/ball/BallLook.kt
index 5b690a4..ef2aa31 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/ball/BallLook.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/ball/BallLook.kt
@@ -220,6 +220,18 @@ class BallLook(
*/
val pupilAspect: Float = 1f,
+ /**
+ * Colour of the `^ ^` closed eye, when it should not be [eyeColor]. Null = use
+ * [eyeColor], which is every look but two.
+ *
+ * Exists because "white eyes" is two different things. Awake, a white eye is
+ * a white *shape* with a dark pupil in it. Asleep the shape is gone and what
+ * is left is the line — and a white line on a dark body is a harsh slash with
+ * no pupil to give it a reason, which is what the rabbit and the bear were
+ * drawing. A dark line there is a lid, not a mark.
+ */
+ val sleepEyeColor: FloatArray? = null,
+
// ---- Eye cut ----
//
// The glare, taken out of the eye's own geometry instead of drawn next to
@@ -1479,6 +1491,9 @@ val RABBIT = BallLook(
// look and the imp. A slit ([pupilAspect]) is a predator; this animal is
// prey that thinks it is in charge, which is most of the joke.
eyeColor = floatArrayOf(1f, 1f, 1f),
+ // Asleep the white shape is gone and only the line is left; a white line on
+ // a white body is invisible and a dark one is a lid. See [sleepEyeColor].
+ sleepEyeColor = floatArrayOf(0.17f, 0.13f, 0.20f),
pupilR = 0.092f,
glintR = 0.030f,
bubbleX = 0.085f,
@@ -1767,6 +1782,9 @@ val BEAR = BallLook(
// and the eye rules in this file say a dark ball reads its features light on
// dark. A bead eye here would be a hole.
eyeColor = floatArrayOf(1f, 1f, 1f),
+ // Asleep the eye is a line, not a white shape with a pupil in it, and a white
+ // line on a brown body is a harsh slash. A dark brown one is a closed lid.
+ sleepEyeColor = floatArrayOf(0.10f, 0.06f, 0.04f),
// Low and wide, and it has to clear the muzzle: the snout's lower edge is at
// −0.165 − 0.150 = −0.315, so a mouth at −0.395 sits just under the shelf
// rather than on it. Drawn thick, because at this size a hairline under a
diff --git a/app/src/main/java/net/kuafuai/andee/ui/ball/EmotionBallRenderer.kt b/app/src/main/java/net/kuafuai/andee/ui/ball/EmotionBallRenderer.kt
index 2a6f618..01caad0 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/ball/EmotionBallRenderer.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/ball/EmotionBallRenderer.kt
@@ -322,6 +322,9 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {
/** Scratch for [drawBody]'s mood tint — per-frame, so never allocated. */
private val bodyColor = FloatArray(3)
+ /** Scratch for the `^ ^` eye colour while it fades to [BallLook.sleepEyeColor]. */
+ private val arcColor = FloatArray(3)
+
/** Scratch for the pupil colour, which is a dark relative of the mood. */
private val pupilColor = FloatArray(3)
@@ -947,7 +950,20 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {
// while the lab showed dark ones, because the lab sets this colour
// per element. A uniform with no attribute is shared state; the
// only safe rule in this pass is that every draw sets its own.
- GLES20.glUniform3fv(solidShader.uniform("uColor"), 1, LOOK.eyeColor, 0)
+ val sleepEye = LOOK.sleepEyeColor
+ if (sleepEye != null) {
+ // `bubble` is the one smoothed value that only SLEEPING drives, so
+ // it doubles as "how asleep is it" — and being smoothed, the line
+ // fades from the awake colour to the dark one as the ball nods off
+ // instead of snapping. HAPPY and SUCCESS draw the same `^ ^` and
+ // must keep the look's own colour, which is why this is not keyed
+ // on the arc.
+ val k = state.bubble.coerceIn(0f, 1f)
+ for (i in 0..2) arcColor[i] = LOOK.eyeColor[i] + (sleepEye[i] - LOOK.eyeColor[i]) * k
+ GLES20.glUniform3fv(solidShader.uniform("uColor"), 1, arcColor, 0)
+ } else {
+ GLES20.glUniform3fv(solidShader.uniform("uColor"), 1, LOOK.eyeColor, 0)
+ }
val h = arc * state.lid
setLocalFromFace(
state.eyeLX, state.eyeLY - EYE_ARC_DROP,
@@ -1458,12 +1474,29 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {
* and slightly to its left, so that is the side it lands on. Getting this
* wrong is not subtle — a glint on the wrong side reads as the ball having
* looked away.
+ *
+ * **Where the contents sit has to follow the eye when it squints.** The eye
+ * squashes about its lower edge ([EYE_LID_PIVOT]): its centre sinks by
+ * `PIVOT·(1 − s)` and its height becomes `s` of normal. The dots keep
+ * `pivotY = 0` (see [drawDot]) and used to be placed from the *unsquashed*
+ * centre, so on a squinted eye — THINKING is 0.4 — they were left behind,
+ * above the sliver they belong to. Measured in the lab: on `cream` the
+ * catchlight floated over the slit as a loose white dash, and on `imp` the
+ * pupil sat on the top edge of the white with the white showing underneath,
+ * which is exactly an eye rolled up. Blinks did the same thing for a few
+ * frames.
+ *
+ * Only for `lidScale < 1`. A widened eye (LISTENING 1.6) also grows from the
+ * hinge and its contents are also off-centre, but those faces were tuned
+ * with the dots where they are and nobody has asked for them to move.
*/
private fun drawEyeContents(cx: Float, cy: Float, rotZ: Float, lidScale: Float) {
+ val follow = min(lidScale, 1f)
+ val sink = EYE_LID_PIVOT * (1f - follow)
val pr = LOOK.pupilR
if (pr > 0f) {
drawDot(
- cx - pr * 0.12f, cy - pr * 0.20f, rotZ, lidScale,
+ cx - pr * 0.12f, cy + sink - pr * 0.20f * follow, rotZ, lidScale,
pr, eyeFrontZ, pupilColor, LOOK.pupilAspect,
)
}
@@ -1476,12 +1509,13 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {
// pupil barely moves off the centre of a bare eye.
if (pr > 0f) {
drawDot(
- cx - pr * 0.34f, cy + pr * 0.26f, rotZ, lidScale,
+ cx - pr * 0.34f, cy + sink + pr * 0.26f * follow, rotZ, lidScale,
gr, eyeFrontZ + GLINT_Z_STEP, WHITE,
)
} else {
drawDot(
- cx - LOOK.eyeRadius * 0.36f, cy + LOOK.eyeRadius * 0.40f, rotZ, lidScale,
+ cx - LOOK.eyeRadius * 0.36f, cy + sink + LOOK.eyeRadius * 0.40f * follow,
+ rotZ, lidScale,
gr, eyeFrontZ + GLINT_Z_STEP, WHITE,
)
}
@@ -1631,6 +1665,21 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {
}
rimSphere.bind(rimShader.attrib("aPos"), rimShader.attrib("aNormal"))
rimSphere.draw()
+ // A dark-outline look has no glow of its own, so thinking used to be
+ // invisible on it once the face stopped changing. Lay one on top, after
+ // the contour so the contour is not tinted, and only while thinking.
+ // Additive: faint over a white app, which is the cost of choosing a glow
+ // over a pulsing outline — the outline's own alpha is capped, see
+ // [RIM_DARK_CAP].
+ if (LOOK.rimDark && state.thinkGlow > 0.01f) {
+ GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE)
+ GLES20.glUniform3fv(rimShader.uniform("uColor"), 1, state.nowColor, 0)
+ GLES20.glUniform1f(rimShader.uniform("uIntensity"), state.thinkGlow * LOOK.rimGain)
+ GLES20.glUniform1f(rimShader.uniform("uCap"), 1f)
+ GLES20.glUniform1f(rimShader.uniform("uPow"), THINK_GLOW_POW)
+ GLES20.glUniform1f(rimShader.uniform("uScan"), state.think * THINK_GLOW_SCAN)
+ rimSphere.draw()
+ }
}
private fun drawCore() {
@@ -1734,6 +1783,12 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {
*/
private const val RIM_DARK_CAP = 0.82f
+ /** Falloff of the thinking glow on a dark-outline look; the glow looks use 3.6–5.0. */
+ private const val THINK_GLOW_POW = 4.0f
+
+ /** Scan-band strength at full think, matching `scan = … + th * 0.5` for the glow looks. */
+ private const val THINK_GLOW_SCAN = 0.5f
+
// ---- Pupils ----
//
// A dark relative of the mood colour rather than a fixed black, so the
diff --git a/app/src/main/java/net/kuafuai/andee/ui/ball/EmotionState.kt b/app/src/main/java/net/kuafuai/andee/ui/ball/EmotionState.kt
index 5912268..a268ab1 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/ball/EmotionState.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/ball/EmotionState.kt
@@ -122,6 +122,14 @@ class EmotionState {
var scan = 0f; private set
var rimIntensity = 0.9f; private set
+ /**
+ * Additive glow laid over a look's dark outline while thinking; 0 otherwise.
+ * Only the looks with `rimDark` read it — the others already get this from
+ * [rimIntensity] — which is why it is its own field and not a term in that
+ * one: on a dark-outline look `rimIntensity` is ignored by design.
+ */
+ var thinkGlow = 0f; private set
+
// ---- Core ----
var coreScale = 0.42f; private set
var coreAlpha = 0.16f; private set
@@ -235,10 +243,17 @@ class EmotionState {
listen += ((if (listening) 1f else 0f) - listen) * min(1f, dt * 3.4f)
busy = if (listening) 0.9f else th
- // Gaze — eye drift while thinking. Three incommensurate low-freq sines
- // so there's no recognizable period.
- val gaze = th * (sin(t * 0.9f) + sin(t * 1.31f) * 0.5f)
- val gazeY = th * (sin(t * 0.73f) * 0.6f + sin(t * 1.07f) * 0.35f)
+ // Gaze — eye drift while thinking, left and right only. Two incommensurate
+ // low-freq sines so there's no recognizable period. Twice the speed it
+ // had: the face no longer squints or furrows, so this drift is most of
+ // what tells "thinking" from "resting".
+ //
+ // There used to be a vertical term too (`gazeY`, 0.73 and 1.07 rad/s against
+ // this one's 0.9 and 1.31). Two near-equal frequencies on two axes is an
+ // orbit, not a drift: summed over a minute the eyes went round about nine
+ // times, both ways, with the horizontal swing at about one eye radius. On
+ // screen that is the eyes rolling. One axis cannot loop.
+ val gaze = th * (sin(t * 1.8f) + sin(t * 2.62f) * 0.5f)
// Jitter — tense/anxious shake, two incommensurate high-freq sines
val jx = (sin(t * 23.7f) + sin(t * 37.1f) * 0.6f) * jitter
@@ -407,7 +422,7 @@ class EmotionState {
// rather than disappearing into the bob.
val workBob = cling * sin(t * 3.4f) * 0.04f
rotY = sin(t * 0.22f) * 0.12f + jx * 0.012f + gaze * 0.09f + actRotY
- rotX = sin(t * 0.17f) * 0.06f + jy * 0.009f - gazeY * 0.05f + actRotX + workBob
+ rotX = sin(t * 0.17f) * 0.06f + jy * 0.009f + actRotX + workBob
rotZ = tilt + th * sin(t * 0.51f) * 0.09f - clingLean
// Rings group tumble. Small on purpose: the belt orientation in [RINGS]
@@ -445,6 +460,10 @@ class EmotionState {
val listenBeat = listen * (0.5f + sin(t * 4.2f) * 0.5f)
rimIntensity = 0.85f + open * 0.7f + listen * 0.45f + listenBeat * 0.95f +
thinkBeat * 0.55f + sin(t * want.pulse * 2f) * 0.05f
+ // Same beat as above, but a floor under it: the glow is the *only* sign of
+ // thinking on a look whose face no longer changes, so it has to stay
+ // visible between beats rather than going out each time.
+ thinkGlow = th * 0.45f + thinkBeat * 0.55f
// Core — small pulse plus a slower "beat" that only exists while thinking
val beat = th * (0.5f + sin(t * 2.6f) * 0.5f)
@@ -467,8 +486,8 @@ class EmotionState {
// ball that happens to be low on screen and one looking up at you from
// under a ledge. Without it the face aims into the bezel.
val peek = cling * (0.055f + grip * 0.02f)
- eyeLY = LOOK.eyeY - browL * 0.06f + gazeY * 0.05f + peek
- eyeRY = LOOK.eyeY - browR * 0.06f + gazeY * 0.05f + peek
+ eyeLY = LOOK.eyeY - browL * 0.06f + peek
+ eyeRY = LOOK.eyeY - browR * 0.06f + peek
eyeLX = -LOOK.eyeX + jx * 0.014f + gaze * 0.075f
eyeRX = LOOK.eyeX + jx * 0.014f + gaze * 0.075f
// Eye roll. Two terms, and they are on the same axis on purpose:
diff --git a/app/src/main/java/net/kuafuai/andee/ui/ball/Mood.kt b/app/src/main/java/net/kuafuai/andee/ui/ball/Mood.kt
index 86f407c..45fd4d2 100644
--- a/app/src/main/java/net/kuafuai/andee/ui/ball/Mood.kt
+++ b/app/src/main/java/net/kuafuai/andee/ui/ball/Mood.kt
@@ -109,9 +109,8 @@ val FACE: Map<Mood, Face> = mapOf(
// unmistakable from across a desk — and unmistakable from CALM, which it
// used to differ from only by a shade of pale blue and a taller eye.
//
- // The tilt is *negative* where THINKING's is positive: both states cock the
- // head, so the only way for either to stay readable is for them to cock it
- // opposite ways.
+ // The tilt is *negative*: this is the one mood that cocks its head, so
+ // nothing else competes for the pose.
Mood.LISTENING to Face(
rgb(0x7dd3fc), 1.6f, -0.14f, 0.28f, 1.7f, -0.13f, 0f, 0f,
blush = 0.46f, breath = 0.055f, gape = 0.12f,
@@ -122,12 +121,15 @@ val FACE: Map<Mood, Face> = mapOf(
rgb(0xfacc15), 0.92f, 0.48f, -0.18f, 0.72f, 0f, 0f, 0f,
blush = 0.3f, breath = 0.018f,
),
- // The opposite read: eyes squeezed to a slot, brows down and uneven, head
- // cocked. Deliberately slow and deep rather than fast — fast squinting is
- // agitation, and this ball is meant to look like it's working the problem.
+ // The resting face, in the mood's own colour. It used to be the opposite of
+ // CALM — eyes squeezed to a slot, brows down and uneven, head cocked — and
+ // on the tablet that read as straining or stuck rather than as thinking.
+ // What says "thinking" now is not the face but what moves around it: the
+ // eyes' quick left-right drift ([EmotionState] `gaze`) and the rim, core and
+ // scan light that swell with `think`, none of which come from this row.
Mood.THINKING to Face(
- rgb(0xc084fc), 0.4f, 0.32f, 0.04f, 1.15f, 0.15f, 0.08f, 0f,
- blush = 0.3f, breath = 0.042f,
+ rgb(0xc084fc), 1f, 0f, 0.26f, 1f, 0f, 0f, 0f,
+ blush = 0.38f,
),
Mood.SPEAKING to Face(
rgb(0x9db4ff), 1.05f, 0f, 0.32f, 1.5f, 0f, 0f, 0f,