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、支持任意模型,记忆和密码绝不离开设备。
feat(ball): a livelier Andee, simpler hands, and an expressions screen
booboosui7937dcf71d2b
diff --git a/CLAUDE.md b/CLAUDE.mdindex e43dc2b..924487f 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -176,16 +176,23 @@ Fallbacks all land on the pre-existing behaviour rather than on nothing: no markA `Face` row is a set of continuous dials every look interprets; a wink, a fist under the chin and a star are not dials. So each `Mood` also has a `Pose` (`POSES`), and **only a look with `BallLook.gestures = true` reads it** — today that is `ANDEE`. A look without the flag sees `Pose.NONE` for every mood, which is the whole reason the pig, the imp and the rest are untouched by any of this: five moods were added (`WINK`, `WAVE`, `PROTECT`, `CELEBRATE`, `REST`) and on those looks each is just the plain face on its `FACE` row.- **Everything in a pose is a target that `EmotionState` tweens toward.** A hand that is not showing is *placed* at its new spot and then grown; it slides only once visible (`tweenHand`), because sliding from wherever it was dragged a half-grown hand across the face. Props pop in with an overshoot (`pop`). `arcFlip` is the one value that flips instead of tweening.-- **A hand is a palm and five blobs, and `fist` walks between two arrangements of the same blobs** (fingers along the top → knuckles at the front, thumb out → across). One continuous parameter between two shapes is what lets a hand close instead of swap. Parented to `root`, unlike the ledge paws (`drawHands`), which hold still while the body slips; the two never show together because pose hands and props are scaled by `1 − cling`.+- **A hand is a round palm, a thumb, and two fingers — and the number is the result of attempts, not a taste.** Five blobs turned into a lumpy knot at eighty dp; a bare ball with a stick in it (a "cat's mitt", tried because it is the cutest hand there is) read as a candied haw on a skewer, because on this ball a hand always sits beside the head and a single stub has nothing to say. Two fingers read as a hand, and nobody counts them. Each finger is **one capsule** (`fingerPart`: base anchor, length, angle) — two stacked ellipsoids per finger looked like beads. **The finger angle is the whole gesture**: `7°` and long is a wave, folded flat on the palm is a fist (`fist`). Parented to `root`, unlike the ledge paws (`drawHands`), which hold still while the body slips; the two never show together because pose hands and props are scaled by `1 − cling`.+- **No pose holds up a V, a pointing finger or a thumb, and that is a result.** All three were built for the wink and each misread at eighty dp: the V became a lump, the pointer — a lone finger standing beside the face — read as the rude one (it was also, briefly, the SEARCHING pose), and a thumbs-up built from the same capsules was a single vertical stick, i.e. the same finger again, and a shorter fatter version was a sideways blob. Three shapes that can't be told apart from the one you were avoiding at this size are not three options. The wink carries a puffy heart (`PROP_HEART`) instead, and SEARCHING is a fist tapping. If you try a hand gesture again, shoot it at `dp 168` before believing it.- **Hands sit at least `HAND_MIN_Z` deep.** A hand set out past the silhouette used to sit at z 0.12 and its inner half was hidden by the body it reached across — which hid the pointing finger on the wink.- **`lidCut` is signed.** Positive slices the top of each eye (a second mesh, swapped at 0.5) and rolls it inward; negative slices nothing and rolls the *other* way, the worried slant. The sad moods need it because their `Face.brow` rolls the eyes the angry way.-- **A look whose face sits low needs `clingLift`.** The ledge cuts the ball at its equator, and Andee's eyes are below it, so it used to hang there as a faceless blue dome. The lift is per-look; the default 0.055 is what everyone else has always had.-- **`WAVE` and `WINK` are also idle fidgets**, borrowing the pose channels for their length, and the fidget picker skips them on a look without gestures (a slot spent on nothing reads as the ball freezing).+- **A look whose face sits low needs `clingLift`.** The ledge cuts the ball at its equator, and Andee's eyes were below it, so it used to hang there as a faceless blue dome. The lift is per-look; the default 0.055 is what everyone else has always had. Andee's is 0.09 since its eyes moved up (below).+- **Andee's eyes sit above the middle of the sphere (`eyeY` +0.09, `mouthY` −0.185), which is *not* where the reference picture puts them (−0.03).** The picture's head is oblate and the ball is round, so copying its offsets left 1.7 eye-diameters of blank forehead against the picture's 1.4, and once the horns were raised it read as a face stuck on the bottom of a dome. Eyes, mouth, cheeks and the sleep bubble moved together; if you move one, move them all.+- **An idle Andee has a life, and the list of faces it may wear is defined by what is left out.** In `resolveMood`, only for a look with `gestures`, only while `holdingBase == CALM` and the ball has been quiet for 8 s: every 7–16 s it wears one of `IDLE_FACES` for a few seconds (HAPPY, CURIOUS, WINK, WAVE), never the same one twice running. **SPEAKING, LISTENING, THINKING, SEARCHING and HOLDING are excluded because each says what the device is *doing* — an idle ball with its listening face is a lie the user acts on, by talking into a mic that is off — and ANXIOUS/CONCERNED/TENSE/FAILED/PROTECT read as an alarm, SUCCESS/CELEBRATE as a finished task. REST is excluded too: it is SLEEPING without the bubble, and it turned up fifteen seconds after a wake-up and read as the ball going back to sleep.** Any real activity ends the face at once. (This replaced the `WAVE`/`WINK` body *actions*, which were the same idea done twice; the fidget pool is body-only again.) The face is applied to `effective`, **not** to `holdingBase`, because `idleFor` is derived from `holdingBase == CALM` and swapping it earlier would make the ball think it had stopped being idle.+- **Andee naps, it does not stay asleep.** Past `SLEEP_AFTER_SECONDS` it sleeps `NAP_MIN..MAX` (25–50 s), then wakes — done by moving `idleFor` back below the sleep line by `AWAKE_MIN..MAX` (40–90 s), which keeps every gate that already reads `idleFor` (the fidgets, the stroll, `dozing`) right with no second flag, and the existing wake-up HOP fires for free. Other looks keep the old sleep-until-touched rule. **The lab activity's CALM runs this same logic**, so a screenshot taken more than ~12 s after launch may be an idle face rather than a calm one; restart the app (`am force-stop`) for a clean clock.- **There is no open mouth, and that is a removal, not an omission.** A flat half-disc with a tongue was built for the laughing moods and cross-faded with the thin smile; for the ~0.15 s of the fade both were drawn, and the smile is a tube with depth while the disc is flat, so one poked through the other on every change into or out of a happy face. Fixing it means sequencing the two so they never overlap, which on a fade that short is a blink. The mouth is one mesh, a line, and speech opens it by taller and rounder (`mouthScaleY`), as it always did. Do not bring the disc back without a transition that cannot show both.- **`smileRoll` is 0 for Andee.** The default turns the mouth 0.9 rad per unit of `Face.smile`, which is what makes a deep smile lopsided; on a line mouth that read as a sneer at HAPPY (≈35°) and CELEBRATE (≈44°). A look that wants a symmetric grin sets it to 0.- **A gesture look hides the round eye once the arc has taken over** (`arc ≥ ARC_EYE_AT`). Its big eyes otherwise leave the last tenth of the round eye as a dark sliver under every `^ ^`.+- **The horns are jelly, and they say the mood.** Two springs in `EmotionState.tick` (after `rotZ`), gated on `BallLook.hornWobble > 0`: `hornSway` is driven by the *acceleration* of the body's turn and roll, `hornLean` by a hop's vertical acceleration and settles on `Pose.hornLean` (negative stands them up — curious, listening, celebrating; positive flops them — sad, tired, failed). Accelerations are second differences and noisy; the soft spring (`HORN_K` 110, `HORN_C` 7, damping ratio ≈ ⅓) is the low-pass that makes them usable, so don't stiffen it. A sway is a screen direction (`tilt + sway·side`), a lean is outward on both horns (`tilt + lean`) — the left horn is the right one mirrored.+- **The horn tip is a per-vertex fade, so it needs its own program.** `hornTipColor`/`hornTipMix` switch `drawHorns` onto `HORN_VS/FS`, which is the shell shader plus the mesh's v coordinate. Blue and peach mixed half-and-half is a dull lilac, so the mix runs to 0.9 over the last 40%; a lower number looks like a bruise.-To see any mood without the accessibility service, a debug build carries `debug/BallLabActivity`: `adb shell am start -n net.kuafuai.andee/.debug.BallLabActivity --es mood WINK --es look andee --es bg light --ei dp 420` and then `screencap`. `dp 168` is the real folded size and is the one a face has to survive; `--ez working true --ez ledge true` shows the hanging pose. It lives in `src/debug`, so release never carries it.+To see any mood without the accessibility service, a debug build carries `debug/BallLabActivity`: `adb shell am start -n net.kuafuai.andee/.debug.BallLabActivity --es mood WINK --es look andee --es bg light --ei dp 420` and then `screencap`. `dp 168` is the real folded size and is the one a face has to survive; `--ez working true --ez ledge true` shows the hanging pose. It lives in `src/debug`, so release never carries it. **It runs in the same process as the service and writes the same global look** (`BallLooks.requestByName`, not saved), so launching it with `--es look X` while the settings card is open silently changes what the card's preview draws and leaves its chips and caption — which come from the saved look — disagreeing with it. That looked like a bug in the card and was not. Leave `look` off when the real UI is up.++`ui/ExpressionsUi` is the settings card that shows every look and every expression (settings → 形象与表情). It holds a ball of its own, because the corner ball is driven by the voice pipeline and would overwrite a picked expression the moment anything was said. A look chip is saved on tap (the same write as swiping the ball); an expression chip changes only that card's ball and is never saved. The expression grid is as tall as its chips need — a fixed 190 dp cut the top row in half and made people scroll to reach 睡着.### Meeting recorderdiff --git a/app/src/debug/java/net/kuafuai/andee/debug/BallLabActivity.kt b/app/src/debug/java/net/kuafuai/andee/debug/BallLabActivity.ktindex 40154cc..3a5780e 100644--- a/app/src/debug/java/net/kuafuai/andee/debug/BallLabActivity.kt+++ b/app/src/debug/java/net/kuafuai/andee/debug/BallLabActivity.kt@@ -36,6 +36,8 @@ class BallLabActivity : Activity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)+ // Long captures (the idle life takes minutes) must not end on a dark screen.+ window.addFlags(android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)root = FrameLayout(this)label = TextView(this).apply {setTextSize(TypedValue.COMPLEX_UNIT_SP, 18f)diff --git a/app/src/main/java/net/kuafuai/andee/ui/ExpressionsUi.kt b/app/src/main/java/net/kuafuai/andee/ui/ExpressionsUi.ktnew file mode 100644index 0000000..824100c--- /dev/null+++ b/app/src/main/java/net/kuafuai/andee/ui/ExpressionsUi.kt@@ -0,0 +1,334 @@+package net.kuafuai.andee.ui++import android.annotation.SuppressLint+import android.content.Context+import android.graphics.Color+import android.graphics.PixelFormat+import android.view.Gravity+import android.view.View+import android.view.WindowManager+import android.widget.FrameLayout+import android.widget.HorizontalScrollView+import android.widget.LinearLayout+import android.widget.ScrollView+import android.widget.TextView+import net.kuafuai.andee.R+import net.kuafuai.andee.config.VoiceConfig+import net.kuafuai.andee.i18n.AppLocale+import net.kuafuai.andee.ui.ball.BallLooks+import net.kuafuai.andee.ui.ball.EmotionBallTextureView+import net.kuafuai.andee.ui.ball.Mood++/**+ * Every character and every expression, to look at and to choose.+ *+ * The card holds a ball of its own — a second [EmotionBallTextureView], not the+ * one in the corner — and two rows of chips under it: who (the six looks) and how+ * it feels (the expressions). Tapping a look makes it the ball's look for real,+ * the same write the swipe makes; tapping an expression only changes what *this*+ * card's ball is wearing, and nothing else is touched, so it is safe to poke at+ * every one of them.+ *+ * **Why a second ball and not the real one.** The real ball is a window of its own+ * behind this card and is driven by the voice pipeline: it is about to go+ * SPEAKING or LISTENING the moment anything happens, and an expression the user+ * picked would be overwritten mid-look. This ball belongs to the card, and the+ * card's chips are the only thing that tells it what to wear.+ *+ * It does mean two GL contexts for as long as the card is up. Both are one small+ * view each, and the cost is paid only while this screen is open.+ *+ * Like [WakeEnrollUi] — which it is built on — it stays `FLAG_NOT_FOCUSABLE` and+ * does not touch [OwnCard]: nothing here takes text, so it never needs to be the+ * active window.+ */+class ExpressionsUi(+ private val context: Context,+ private val onDismiss: () -> Unit = {},+) {++ private val wm: WindowManager =+ context.getSystemService(Context.WINDOW_SERVICE) as WindowManager++ private var root: View? = null+ private var preview: EmotionBallTextureView? = null+ private var caption: TextView? = null+ private var frosted = false+ private var lctx: Context = context++ /** Which expression chip is lit. Null until the user picks one. */+ private var pickedMood: Mood = Mood.CALM+ private val moodChips = LinkedHashMap<Mood, TextView>()+ private val lookChips = ArrayList<TextView>()++ fun show() {+ if (root != null) return+ val p = WindowManager.LayoutParams(+ cardWidth(), WindowManager.LayoutParams.WRAP_CONTENT,+ WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,+ WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,+ PixelFormat.TRANSLUCENT,+ ).apply { gravity = Gravity.CENTER }+ frosted = Glass.frost(context, wm, p)+ val v = build()+ runCatching {+ v.hideFromAccessibility()+ wm.addView(v, p)+ root = v+ Glass.enter(v)+ }+ }++ fun hide() {+ val v = root ?: return+ root = null+ preview = null+ Glass.exit(v) {+ runCatching { wm.removeView(v) }+ onDismiss()+ }+ }++ // ---- Build ----++ @SuppressLint("SetTextI18n")+ private fun build(): View {+ lctx = AppLocale.wrap(context)+ val card = LinearLayout(context).apply {+ orientation = LinearLayout.VERTICAL+ setPadding(dp(22), dp(20), dp(22), dp(16))+ background = Glass.card(context, dp(28), frosted)+ clipToOutline = true+ }++ card.addView(TextView(context).apply {+ text = lctx.getString(R.string.expr_title)+ textSize = Glass.Type.HEADLINE+ setTextColor(Color.parseColor(Glass.TITLE))+ })++ // The stage. Square and fixed, so the card does not change height when a+ // look with taller horns or a raised hand is chosen.+ val side = dp(STAGE_DP)+ val stage = FrameLayout(context).apply {+ background = Glass.well(context, dp(22))+ }+ val ball = EmotionBallTextureView(context)+ preview = ball+ stage.addView(ball, FrameLayout.LayoutParams(side, side, Gravity.CENTER))+ card.addView(+ stage,+ LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, side + dp(8)).apply {+ topMargin = dp(12)+ },+ )++ caption = TextView(context).apply {+ textSize = Glass.Type.CAPTION+ setTextColor(Color.parseColor(Glass.SECONDARY))+ gravity = Gravity.CENTER+ setPadding(0, dp(8), 0, dp(6))+ }+ card.addView(caption)++ // ---- Who ----+ card.addView(heading(lctx.getString(R.string.expr_section_look)))+ card.addView(chipRow {+ for (look in BallLooks.ALL) {+ val chip = chip(lctx.getString(look.labelRes)) { pickLook(look.name) }+ lookChips.add(chip)+ addView(chip, chipParams())+ }+ })++ // ---- How it feels ----+ card.addView(heading(lctx.getString(R.string.expr_section_mood)))+ val grid = ScrollView(context).apply { isVerticalScrollBarEnabled = false }+ val wrap = LinearLayout(context).apply { orientation = LinearLayout.VERTICAL }+ var row: LinearLayout? = null+ MOODS.forEachIndexed { i, m ->+ if (i % PER_ROW == 0) {+ row = LinearLayout(context).apply { orientation = LinearLayout.HORIZONTAL }+ wrap.addView(+ row,+ LinearLayout.LayoutParams(+ LinearLayout.LayoutParams.MATCH_PARENT,+ LinearLayout.LayoutParams.WRAP_CONTENT,+ ).apply { topMargin = dp(6) },+ )+ }+ val chip = chip(lctx.getString(labelOf(m))) { pickMood(m) }+ moodChips[m] = chip+ row!!.addView(+ chip,+ LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f).apply {+ marginStart = dp(3); marginEnd = dp(3)+ },+ )+ }+ grid.addView(wrap)+ // As tall as the chips need, so all nineteen are on screen and nobody has to+ // scroll to find 睡着 — it was a fixed 190 dp, five rows do not fit in that,+ // and the top row came up half cut off. Capped at a third of the screen so a+ // landscape phone still gets a card it can see the footer of; only there does+ // it scroll.+ wrap.measure(+ View.MeasureSpec.makeMeasureSpec(cardWidth() - dp(44), View.MeasureSpec.EXACTLY),+ View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),+ )+ val screenH = wm.currentWindowMetrics.bounds.height()+ val gridH = minOf(wrap.measuredHeight, (screenH * 0.34f).toInt())+ card.addView(+ grid,+ LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, gridH),+ )++ // ---- Footer ----+ val footer = LinearLayout(context).apply {+ orientation = LinearLayout.HORIZONTAL+ gravity = Gravity.END+ }+ footer.addView(button(lctx.getString(R.string.wake_close)) { hide() })+ card.addView(+ footer,+ LinearLayout.LayoutParams(+ LinearLayout.LayoutParams.MATCH_PARENT,+ LinearLayout.LayoutParams.WRAP_CONTENT,+ ).apply { topMargin = dp(14) },+ )++ // Start on whichever look the ball is actually wearing, so opening the card+ // shows what the user already has rather than a different character.+ BallLooks.requestByName(VoiceConfig.ballLook(context))+ refresh()+ return card+ }++ // ---- Behaviour ----++ private fun pickLook(name: String) {+ // The same write the swipe makes (FloatingWindowUi.stepBallLook): the look is+ // saved the instant it is chosen, so the corner ball follows and a restart+ // keeps it. Reading the saved name back is what the real ball does on its+ // next frame — nothing else needs telling.+ BallLooks.requestByName(name)+ VoiceConfig.save(context, mapOf("ball" to name))+ refresh()+ }++ private fun pickMood(m: Mood) {+ pickedMood = m+ refresh()+ }++ /** Push the card's choices onto its ball and repaint the chips. */+ private fun refresh() {+ preview?.setMood(pickedMood)+ preview?.setListening(pickedMood == Mood.LISTENING)+ val look = BallLooks.requestedLook+ lookChips.forEachIndexed { i, chip -> light(chip, BallLooks.ALL[i] === look) }+ for ((m, chip) in moodChips) light(chip, m == pickedMood)+ caption?.text = lctx.getString(+ R.string.expr_caption,+ lctx.getString(look.labelRes),+ lctx.getString(labelOf(pickedMood)),+ )+ }++ // ---- Widgets ----++ private fun heading(text: String) = TextView(context).apply {+ this.text = text+ textSize = Glass.Type.CAPTION+ setTextColor(Color.parseColor(Glass.SECONDARY))+ setPadding(dp(2), dp(10), 0, dp(2))+ }++ private fun chipRow(fill: LinearLayout.() -> Unit): View {+ val row = LinearLayout(context).apply { orientation = LinearLayout.HORIZONTAL }+ row.fill()+ return HorizontalScrollView(context).apply {+ isHorizontalScrollBarEnabled = false+ addView(row)+ }+ }++ private fun chipParams() = LinearLayout.LayoutParams(+ LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT,+ ).apply { marginEnd = dp(6); topMargin = dp(4) }++ private fun chip(label: String, onClick: () -> Unit): TextView = TextView(context).apply {+ text = label+ textSize = Glass.Type.CAPTION+ gravity = Gravity.CENTER+ setPadding(dp(12), dp(9), dp(12), dp(9))+ isClickable = true+ Glass.pressable(this)+ setOnClickListener { onClick() }+ }++ /** A lit chip is the tinted pane; an unlit one is the plain panel. */+ private fun light(chip: TextView, on: Boolean) {+ chip.background =+ if (on) Glass.tinted(context, dp(18)) else Glass.panel(context, dp(18))+ chip.setTextColor(Color.parseColor(if (on) Glass.TITLE else Glass.LABEL))+ }++ private fun button(label: String, onClick: () -> Unit): TextView = TextView(context).apply {+ text = label+ textSize = Glass.Type.BODY+ setTextColor(Color.parseColor(Glass.LABEL))+ gravity = Gravity.CENTER+ background = Glass.panel(context, dp(20))+ setPadding(dp(22), dp(11), dp(22), dp(11))+ isClickable = true+ Glass.pressable(this)+ setOnClickListener { onClick() }+ }++ private fun cardWidth(): Int =+ minOf(dp(460), (wm.currentWindowMetrics.bounds.width() * 0.94f).toInt())++ private fun dp(v: Int): Int = Glass.dp(context, v)++ private companion object {+ const val STAGE_DP = 220+ const val PER_ROW = 4++ /**+ * Every expression worth looking at, in the order a person would try them:+ * the everyday ones, then the gestures, then what it does while it works.+ * SPEAKING is here because its mouth is the one thing a still frame cannot+ * show — it moves on its own when picked.+ */+ val MOODS = listOf(+ Mood.CALM, Mood.HAPPY, Mood.CURIOUS, Mood.WINK,+ Mood.WAVE, Mood.CELEBRATE, Mood.PROTECT, Mood.REST,+ Mood.THINKING, Mood.LISTENING, Mood.SPEAKING, Mood.SEARCHING,+ Mood.TENSE, Mood.ANXIOUS, Mood.CONCERNED, Mood.FAILED,+ Mood.SUCCESS, Mood.HOLDING, Mood.SLEEPING,+ )++ fun labelOf(m: Mood): Int = when (m) {+ Mood.CALM -> R.string.expr_calm+ Mood.HAPPY -> R.string.expr_happy+ Mood.CURIOUS -> R.string.expr_curious+ Mood.TENSE -> R.string.expr_tense+ Mood.ANXIOUS -> R.string.expr_anxious+ Mood.CONCERNED -> R.string.expr_concerned+ Mood.WINK -> R.string.expr_wink+ Mood.WAVE -> R.string.expr_wave+ Mood.PROTECT -> R.string.expr_protect+ Mood.CELEBRATE -> R.string.expr_celebrate+ Mood.REST -> R.string.expr_rest+ Mood.LISTENING -> R.string.expr_listening+ Mood.HOLDING -> R.string.expr_holding+ Mood.THINKING -> R.string.expr_thinking+ Mood.SPEAKING -> R.string.expr_speaking+ Mood.SEARCHING -> R.string.expr_searching+ Mood.SUCCESS -> R.string.expr_success+ Mood.FAILED -> R.string.expr_failed+ Mood.SLEEPING -> R.string.expr_sleeping+ }+ }+}diff --git a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.ktindex 724e2ce..8f44587 100644--- a/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt+++ b/app/src/main/java/net/kuafuai/andee/ui/SettingsUi.kt@@ -360,6 +360,7 @@ class SettingsUi(// the credentials it can spend. 大脑 stays first because it is the one// setting that changes what the rest of the card means.brainSection(form)+ expressionsSection(form)wakeSection(form)notebookSection(form)notifySection(form)@@ -691,6 +692,30 @@ class SettingsUi(applyThinking(thinking, false)}+ /**+ * The door to [ExpressionsUi]. Nothing is edited here — the card it opens is+ * where a look is picked and where every expression can be tried — so the+ * section is a sentence and one button, like [vaultSection]'s door, and the+ * look picked inside is saved the moment it is picked rather than on 保存.+ */+ private fun expressionsSection(form: LinearLayout) {+ val panel = group(form, lctx.getString(R.string.settings_section_expr))+ panel.addView(+ TextView(context).apply {+ text = lctx.getString(R.string.settings_expr_note)+ textSize = Glass.Type.CAPTION+ setTextColor(Color.parseColor(Glass.LABEL))+ setLineSpacing(dp(3).toFloat(), 1f)+ },+ rowParams(0),+ )+ val row = LinearLayout(context).apply { orientation = LinearLayout.HORIZONTAL }+ row.addView(button(lctx.getString(R.string.settings_expr_open), filled = false) {+ ExpressionsUi(context).show()+ })+ panel.addView(row, rowParams(dp(12)))+ }+/*** The wake phrase is taught by saying it, not by typing it. It lives here* rather than on the ball because it is a once-per-device chore — seediff --git a/app/src/main/java/net/kuafuai/andee/ui/ball/BallLook.kt b/app/src/main/java/net/kuafuai/andee/ui/ball/BallLook.ktindex 4607e4f..7c4ae84 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@@ -367,6 +367,27 @@ class BallLook(*/val hornShade: Float = 0f,+ /**+ * A second colour the horn fades into over its last stretch, and how much of it.+ * 0 = the horn is one colour, which is every look but one.+ *+ * Per-vertex rather than a second mesh: the fade is along the horn's own length+ * (the mesh's v coordinate), so it follows the curl and the sway for free. It is+ * the cheapest way to make a horn read as *soft* — a one-colour blue horn is a+ * piece of the body, a horn whose tip blushes is something with blood in it.+ */+ val hornTipColor: FloatArray = EMPTY,+ val hornTipMix: Float = 0f,++ /**+ * 0 = the horns are rigid. Above that they hang off the body on a spring, like+ * jelly: a wiggle or a turn of the head sends them swinging the other way and+ * they ring for a moment before they settle, and the mood sets where they rest+ * (see [Pose.hornLean] — perked up when curious, flopped when sad). The number+ * scales how hard the body's motion drives them; 1 is a visible but gentle sway.+ */+ val hornWobble: Float = 0f,+// ---- Second catchlight ----/*** A second, smaller highlight low and to the right of the eye — the one that@@ -1004,9 +1025,12 @@ val BAJIE = BallLook(** * **Eyes** are 173 px across on a 693 px head: [eyeRadius] 0.175, centres* ±161 px from the middle, so [eyeX] 0.338 (the first pass had 0.262 — close-set- * eyes are a different face). They sit a hair *below* the middle of the head,- * [eyeY] −0.03, which is the baby proportion the picture is made of: a big- * forehead and the whole face in the lower half. The eye is round, so+ * eyes are a different face). They were first put a hair *below* the middle of the+ * head, [eyeY] −0.03, the picture's own baby proportion — but the picture's head+ * is oblate and ours is a sphere, so that left a dome of blank forehead, and once+ * the horns were raised it read as a face stuck on the bottom of a ball. They are+ * now at +0.09 (and [mouthY] at −0.185, same gap), which gives the picture's 1.4+ * eye-diameters of forehead instead of 1.7. The eye is round, so* [eyeCyl] is almost nothing.* * **Two catchlights.** A big one up and left ([glintR] 0.038, at the offset* [drawEyeContents] already uses for every look) and a small light-blue one low@@ -1062,12 +1086,17 @@ val ANDEE = BallLook(bodyScale = 0.870f,faceZ = 0.876f,eyeX = 0.338f,- eyeY = -0.030f,+ // Raised 0.12 from the picture's own −0.03, after the horns were raised twice:+ // with horns that tall the sphere read as a forehead dome with a face stuck on+ // the bottom of it — 1.7 eye-diameters of blank above the eyes against the+ // picture's 1.4. Eyes, mouth, cheeks and the sleep bubble all moved together so+ // the face is the same face, one notch higher.+ eyeY = 0.090f,eyeRadius = 0.175f,eyeCyl = 0.012f,mouthR = 0.136f,mouthTube = 0.024f,- mouthY = -0.305f,+ mouthY = -0.185f,mouthThick = 0.140f,eyeColor = floatArrayOf(0.030f, 0.065f, 0.230f),pupilR = 0f,@@ -1075,7 +1104,9 @@ val ANDEE = BallLook(glint2R = 0.034f,glint2Color = floatArrayOf(0.45f, 0.70f, 1.00f),gestures = true,- clingLift = 0.17f,+ // 0.09 now, from 0.17: the eyes already sit 0.12 higher, so the same lift would+ // put them well clear of the ledge and leave the peeking ball with no forehead.+ clingLift = 0.09f,smileRoll = 0f,mouthInk = floatArrayOf(0.025f, 0.045f, 0.140f),arcScale = 1.5f,@@ -1084,7 +1115,7 @@ val ANDEE = BallLook(rimTintMix = 0.55f,// Light droplet on a mid-dark body, the same side of the split as [BEAR].bubbleX = 0.085f,- bubbleY = -0.030f,+ bubbleY = 0.090f,bubbleR = 0.085f,bubbleColor = floatArrayOf(0.88f, 0.93f, 1.00f),bubblePow = 3.0f,@@ -1097,7 +1128,7 @@ val ANDEE = BallLook(blushBlendNormal = true,blushSize = 0.40f,blushX = 0.440f,- blushY = -0.110f,+ blushY = 0.010f,// A light rim, like the imp's and bear's: a dark outline on a mid-dark body// is a smudge.rimDark = false,@@ -1105,18 +1136,30 @@ val ANDEE = BallLook(rimPow = 4.4f,labelRes = R.string.ball_look_andee,- // See the class note: fitted to the picture's horn (base at 0.407), then lifted- // 0.07 on request so the horns stand clear of the head.- // Base buried at (0.413, 0.477) so only the curl shows.- hornH = 0.452f,- hornR = 0.255f,- hornX = 0.413f,- hornY = 0.477f,+ // See the class note: fitted to the picture's horn, then raised twice on request+ // — the second time (0.477 → 0.53, tilt 50 → 38, bend −80 → −62, a longer horn)+ // makes them stand more upright as well as higher: the tip goes from y 0.89 to+ // about 1.02 and the sweep sideways shrinks. Base buried at (0.40, 0.53) so only+ // the curl shows.+ // The tip blushes toward the coral of the rim and the props. Blue and peach+ // mixed half and half is a dull lilac, so it goes nearly all the way (0.9) over+ // the last ~40% of the horn: the very end is peach, and only the short stretch+ // between is the in-between colour.+ hornH = 0.520f,+ hornR = 0.290f,+ hornX = 0.400f,+ hornY = 0.530f,hornZ = 0.450f,- hornTilt = 50f,- hornBend = -80f,+ hornTilt = 38f,+ hornBend = -62f,hornTaper = 0.9f,hornShade = 1.00f,+ hornTipColor = floatArrayOf(1.00f, 0.70f, 0.58f),+ hornTipMix = 0.90f,+ // 1.5 rather than 1: measured on the device, a wiggle at 1 moves the horns about+ // 10 px against the eyes on a 420 dp ball, which is about 3° and at the real+ // 168 dp size is a pixel and a half — present, and not visible.+ hornWobble = 1.5f,)/**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.ktindex 265ca9f..4a4a2e5 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@@ -160,6 +160,20 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {private var idleFor = 0fprivate var lastEffective = Mood.CALM+ // ---- Idle life, for a look with gestures; see the block in [resolveMood] ----+ private var idleFace = Mood.CALM+ private var lastIdleFace: Mood? = null++ /** How much longer the current idle face is held. */+ private var idleFaceLeft = 0f++ /** How long until the next one; counts down only while idle. */+ private var idleFaceIn = IDLE_FACE_FIRST_SECONDS++ /** How long this nap has lasted, and how long it will. */+ private var napFor = 0f+ private var napLen = NAP_MIN_SECONDS+// ---- Idle fidgets ----/** Countdown to the next fidget; only ticks while calm, awake, unheld. */private var fidgetIn = FIDGET_AFTER_SECONDS@@ -193,6 +207,7 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {// ---- Shaders ----private lateinit var shellShader: Shader+ private lateinit var hornShader: Shaderprivate lateinit var rimShader: Shaderprivate lateinit var coreShader: Shaderprivate lateinit var flowShader: Shader@@ -312,6 +327,9 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {/** One blob, instanced eight times into two paws. See [drawHands]. */private lateinit var handMesh: Mesh+ /** A capsule along +Y for fingers: unit radius, straight section of 2·[CAPSULE_HALF] radii. See [fingerPart]. */+ private lateinit var fingerMesh: Mesh+/** One blob per pupil and per glint — see [drawDot]. */private lateinit var dotMesh: Mesh@@ -319,6 +337,7 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {private lateinit var starMesh: Meshprivate lateinit var shieldMesh: Meshprivate lateinit var dropMesh: Mesh+ private lateinit var heartMesh: Mesh/** Scratch: a hand part's model matrix, built on top of the hand's own. */private val partM = FloatArray(16)@@ -414,6 +433,7 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {GLES20.glEnable(GLES20.GL_BLEND)shellShader = Shader(SHELL_VS, SHELL_FS)+ hornShader = Shader(HORN_VS, HORN_FS)rimShader = Shader(RIM_VS, RIM_FS)coreShader = Shader(CORE_VS, CORE_FS)flowShader = Shader(FLOW_VS, FLOW_FS)@@ -439,6 +459,7 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {// subdiv 2 is already smooth and subdiv 4 is 16x the triangles for// nothing. It gets drawn eight times a frame.handMesh = IcoSphere.build(2)+ fingerMesh = Capsule.build(1f, CAPSULE_HALF * 2f, 6, 14)// Pupils and glints. Same unit blob as a paw part, and the same order of// cost: four of them a frame, each about 4 dp wide on screen.dotMesh = IcoSphere.build(2)@@ -446,6 +467,7 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {starMesh = Puff.build(Puff.roundStar(5, 0.54f, 1.3f), 0.55f)shieldMesh = Puff.build(Puff.shield(), 0.42f, rings = 5)dropMesh = Puff.build(Puff.drop(), 0.60f)+ heartMesh = Puff.build(Puff.heart(), 0.55f)heads = PointsBuffer(DUST_COUNT)tails = PointsBuffer(DUST_COUNT * TRAIL_COUNT)@@ -631,7 +653,7 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {r -= wif (r <= 0) { pick = a; break }}- } while (pick == lastFidget || (!LOOK.gestures && (pick == Action.WAVE || pick == Action.WINK)))+ } while (pick == lastFidget)lastFidget = pickstate.trigger(pick)fidgetIn = FIDGET_MIN_SECONDS +@@ -644,8 +666,73 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {fidgetIn = FIDGET_AFTER_SECONDS}+ // ---- A look with gestures lives while it is idle ----+ // Two things, both off for every other look (their sleep is the sleep they+ // always had, and their idle face is CALM):+ //+ // * It wakes itself. Sleeping for good was the old rule — a ball that+ // dozed off at 150 s stayed asleep until someone touched it, which on a+ // tablet on a desk is most of the day. Now it sleeps for [NAP_MIN]..[NAP_MAX]+ // seconds, wakes (the HOP below is the stretch), stays up for+ // [AWAKE_MIN]..[AWAKE_MAX], and dozes again. Waking is done by moving+ // `idleFor` back below the sleep line, which keeps every gate that already+ // reads it — the fidgets, the stroll, `dozing` — correct with no second+ // flag to forget.+ // * It changes face. See [IDLE_FACES] for what may be worn and, more to the+ // point, what may not.+ if (LOOK.gestures && idleFor > SLEEP_AFTER_SECONDS && overlayMood == null) {+ napFor += dt+ if (napFor >= napLen) {+ napFor = 0f+ napLen = NAP_MIN_SECONDS + fidgetRandom.nextFloat() * (NAP_MAX_SECONDS - NAP_MIN_SECONDS)+ idleFor = SLEEP_AFTER_SECONDS -+ (AWAKE_MIN_SECONDS + fidgetRandom.nextFloat() * (AWAKE_MAX_SECONDS - AWAKE_MIN_SECONDS))+ // Wake up in a good mood: the first face comes soon rather than a+ // full gap later.+ idleFaceIn = IDLE_FACE_FIRST_SECONDS+ }+ } else {+ napFor = 0f+ }++ var idleBase = holdingBase+ if (LOOK.gestures && holdingBase == Mood.CALM && overlayMood == null &&+ idleFor > IDLE_FACE_AFTER_SECONDS && idleFor <= SLEEP_AFTER_SECONDS+ ) {+ if (idleFaceLeft > 0f) {+ idleFaceLeft -= dt+ idleBase = idleFace+ } else {+ idleFaceIn -= dt+ if (idleFaceIn <= 0f) {+ // Weighted pick, never the same face twice running — a repeat+ // reads as a stuck loop. Same shape as the fidget pick above.+ var pick: IdleFace+ do {+ var r = fidgetRandom.nextFloat() * IDLE_FACES.sumOf { it.weight.toDouble() }+ pick = IDLE_FACES.first()+ for (f in IDLE_FACES) {+ r -= f.weight+ if (r <= 0) { pick = f; break }+ }+ } while (pick.mood == lastIdleFace)+ lastIdleFace = pick.mood+ idleFace = pick.mood+ idleFaceLeft = pick.holdMin + fidgetRandom.nextFloat() * (pick.holdMax - pick.holdMin)+ idleFaceIn = IDLE_FACE_GAP_MIN_SECONDS ++ fidgetRandom.nextFloat() * (IDLE_FACE_GAP_MAX_SECONDS - IDLE_FACE_GAP_MIN_SECONDS)+ idleBase = idleFace+ }+ }+ } else {+ // Anything real — speech, a task, a card, sleep — ends the face at once+ // and sends the next one back to the start of its wait.+ idleFaceLeft = 0f+ idleFaceIn = IDLE_FACE_FIRST_SECONDS+ }+val effective = overlayMood- ?: if (idleFor > SLEEP_AFTER_SECONDS) Mood.SLEEPING else holdingBase+ ?: if (idleFor > SLEEP_AFTER_SECONDS) Mood.SLEEPING else idleBase// Waking up is worth a hop. Nothing else in here triggers an action on// a mood change — a mood is a resting state, and animating every// transition would make the ball twitch its way through a conversation.@@ -777,23 +864,53 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {*/private fun drawHorns() {val horn = meshes.horn ?: return- if (LOOK.hornShade > 0f) {+ val color = if (LOOK.hornShade > 0f) {for (i in 0..2) hornColor[i] = bodyColor[i] * LOOK.hornShade- useShellWith(hornColor)- } else {- useShellWith(LOOK.hornColor)- }+ hornColor+ } else LOOK.hornColor+ // A horn with a tip colour needs the per-vertex shader; every other horn+ // goes through the shell shader exactly as it always has.+ val tipped = LOOK.hornTipMix > 0f+ if (tipped) useHornWith(color) else useShellWith(color)for (side in -1..1 step 2) {+ // The look's tilt, plus where the mood has set the horns to rest and the+ // spring's swing. Tilt is *outward* for both horns (the left one is the+ // right one mirrored), so a lean applies to them alike, but a sway is a+ // direction on the screen and so enters with opposite signs.+ val tilt = LOOK.hornTilt + state.hornLean + state.hornSway * sidecomposeModelFromRoot {if (side < 0) Matrix.scaleM(local, 0, -1f, 1f, 1f)Matrix.translateM(local, 0, LOOK.hornX, LOOK.hornY, LOOK.hornZ)// Negative Z rotation tips +Y toward +X, i.e. outward.- Matrix.rotateM(local, 0, -LOOK.hornTilt, 0f, 0f, 1f)+ Matrix.rotateM(local, 0, -tilt, 0f, 0f, 1f)}- drawShellPart(horn)+ if (tipped) drawHornPart(horn) else drawShellPart(horn)}}+ /**+ * [useShellWith], for the horn shader: the same material and a second colour the+ * horn fades into near its tip. See [BallLook.hornTipMix].+ */+ private fun useHornWith(color: FloatArray) {+ hornShader.use()+ GLES20.glUniform3fv(hornShader.uniform("uColor"), 1, color, 0)+ GLES20.glUniform3fv(hornShader.uniform("uTip"), 1, LOOK.hornTipColor, 0)+ GLES20.glUniform1f(hornShader.uniform("uTipMix"), LOOK.hornTipMix)+ GLES20.glUniform1f(hornShader.uniform("uGrad"), LOOK.bodyGrad)+ GLES20.glUniform1f(hornShader.uniform("uAmb"), LOOK.bodyAmb)+ GLES20.glUniform1f(hornShader.uniform("uDiff"), LOOK.bodyDiff)+ GLES20.glUniform1f(hornShader.uniform("uGloss"), LOOK.bodyGloss)+ GLES20.glUniform1f(hornShader.uniform("uAlpha"), 1f)+ }++ private fun drawHornPart(mesh: Mesh) {+ GLES20.glUniformMatrix4fv(hornShader.uniform("uMVP"), 1, false, mvp, 0)+ GLES20.glUniformMatrix4fv(hornShader.uniform("uMV"), 1, false, mv, 0)+ mesh.bind(hornShader.attrib("aPos"), hornShader.attrib("aNormal"), hornShader.attrib("aUV"))+ mesh.draw()+ }+/*** A pair of ears. Nothing if the look has no [BallLook.earH].*@@ -1715,18 +1832,27 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {}/**- * The gesture hands, for a look with [BallLook.gestures]: two lit, puffy gloves- * parented to the body, so they breathe, hop and lean with it — unlike- * [drawHands], whose paws hold still on the ledge while the body slips.- *- * Drawn after the face so they sit over the body, and lit with the body's own- * material so they read as part of the same plush animal instead of stickers- * on it. Each is a palm and five blobs; [EmotionState.HandRender.fist] walks- * the fingers from a row along the top (an open mitten) down to a row of- * knuckles at the front with the thumb across them (a fist), and- * [EmotionState.HandRender.point] stretches the finger on the body side out.- * One continuous parameter between two shapes is what lets a hand *close*- * rather than swap.+ * The gesture hands, for a look with [BallLook.gestures]: two plump mitts parented+ * to the body, so they breathe, hop and lean with it — unlike [drawHands], whose+ * paws hold still on the ledge while the body slips.+ *+ * **A hand is a round palm, a thumb, and at most two fingers.** Two, because+ * five blobs turned into a lumpy knot at eighty dp and a bare ball with a stick+ * in it read as a candied haw on a skewer; a fat palm with a pair of short+ * chubby fingers is a V sign, a wave and a point at once, and nobody counts.+ *+ * Everything a hand does is a change of arrangement of the same few shapes, by+ * the numbers in [EmotionState.HandRender]:+ * * `fist` 0→1: open, the palm is tall with the thumb out and the two fingers+ * spread upward; closed, the palm is a tighter ball with the fingers folded+ * down over its front like two knuckles and the thumb across them.+ *+ * There is no pointing, peace-sign or thumbs-up pose, and that is a result: each+ * was built for the wink and each misread at this size — two fingers as a V that+ * turned into a lump, one finger as the rude one, a thumb as the same finger+ * again. The wink carries a heart instead ([PROP_HEART]).+ *+ * Drawn after the face so they sit over the body, in the body's own material.*/private fun drawGestureHands() {if (!LOOK.gestures) return@@ -1742,9 +1868,8 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {val sc = h.s.coerceAtMost(1.2f) * HAND_SCALEval r2 = LOOK.bodyScale * LOOK.bodyScale - h.x * h.x - h.y * h.y// On the surface where there is one, and never behind the ball: a hand set- // out past the silhouette used to sit at z 0.12, and its inner half — the- // half with the pointing finger on it — was hidden by the body it was- // reaching across.+ // out past the silhouette used to sit at z 0.12, and its inner half was+ // hidden by the body it was reaching across.val z = max(sqrt(max(r2, 0f)) + 0.05f, HAND_MIN_Z)val swing = h.waveAmt * sin(state.clock * 9f) * 24fval bob = h.jig * (1f - h.waveAmt) * sin(state.clock * 7f) * 0.035f@@ -1756,44 +1881,35 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {}System.arraycopy(model, 0, handM, 0, 16)val f = h.fist- val p = h.point-- // Palm.- handPart(0f, 0f, 0f, 0.175f, 0.155f, 0.118f)-- // Three fingers: along the top when open, folded down to knuckles when closed.- // Open they are long and spaced a full finger-width apart; at the first pass's- // 0.088 spacing the three overlapped into one lumpy blob and a waving hand- // read as a fist.- for (n in -1..1) {- val ox = n * 0.104f- val oy = 0.175f + (if (n == 0) 0.05f else 0f)- val cx = n * 0.075f- var x = ox + (cx - ox) * f- var y = oy + (0.075f - oy) * f- var zf = 0.02f + (0.098f - 0.02f) * f- var rx = 0.054f + (0.077f - 0.054f) * f- var ry = 0.108f + (0.070f - 0.108f) * f- var rz = 0.07f + (0.078f - 0.07f) * f- if (n == -1 && p > 0.01f) {- // The finger on the body side straightens out and up. Long enough- // to clear the fist by more than its own width: at 0.145 it was a- // bump on the knuckles and nobody could tell it was pointing.- x += (-0.09f - x) * p- y += (0.30f - y) * p- zf += (0.07f - zf) * p- rx += (0.056f - rx) * p- ry += (0.185f - ry) * p- rz += (0.060f - rz) * p- }- handPart(x, y, zf, rx, ry, rz)- }- // Thumb: out to the side when open, across the front of the fingers when closed.+ // Palm: tall and wide when open, a tighter ball when closed.+ val pw = 0.185f + (0.165f - 0.185f) * f+ val ph = 0.185f + (0.160f - 0.185f) * f+ handPart(0f, 0f, 0f, pw, ph, 0.150f)++ // Thumb: out to the side when open, across the front when closed.handPart(- 0.165f + (0.02f - 0.165f) * f, -0.01f + (-0.03f - -0.01f) * f, 0.03f + (0.135f - 0.03f) * f,- 0.055f + (0.085f - 0.055f) * f, 0.082f + (0.05f - 0.082f) * f, 0.06f,+ 0.170f + (0.050f - 0.170f) * f,+ 0.020f + (-0.040f - 0.020f) * f,+ 0.050f + (0.150f - 0.050f) * f,+ 0.080f + (0.090f - 0.080f) * f,+ 0.095f + (0.070f - 0.095f) * f,+ 0.085f,)++ // Two fingers, each one capsule. They start at the top of the palm and lean+ // out by an angle: nearly parallel and short is a wave, folded flat on the+ // palm is a fist.+ val fr = 0.056f+ for (n in 0..1) {+ val dir = if (n == 0) -1f else 1f+ val ang = dir * 7f * (1f - f)+ val ax = dir * 0.065f+ val ay = 0.120f + (0.030f - 0.120f) * f+ val az = 0.040f + (0.120f - 0.040f) * f+ val len = 0.290f - 0.180f * f+ fingerPart(ax, ay, az, len, fr, ang)+ }}/** One part of a gesture hand: [handM] with a translate and a scale on it. */@@ -1806,6 +1922,30 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {drawShellPart(handMesh)}+ /**+ * A finger: one capsule, [len] long tip to base and [r] thick, growing up from+ * ([bx], [by], [bz]) in the hand's own plane and leaning [angle] degrees off+ * vertical (positive toward +X).+ *+ * Placed by its base and an angle, so a V sign is two calls with two angles+ * instead of a pile of hand-tuned offsets, and drawn as a single mesh so there is+ * no seam for the eye to read as a row of beads — which is exactly what two+ * stacked ellipsoids per finger looked like.+ */+ private fun fingerPart(bx: Float, by: Float, bz: Float, len: Float, r: Float, angle: Float) {+ System.arraycopy(handM, 0, partM, 0, 16)+ Matrix.translateM(partM, 0, bx, by, bz)+ Matrix.rotateM(partM, 0, -angle, 0f, 0f, 1f)+ // The capsule is centred on its origin: lift it so its base cap sits on the+ // anchor, then stretch y so the whole thing is [len] tall.+ Matrix.translateM(partM, 0, 0f, len / 2f - r, 0f)+ val sy = len / (r * (2f + 2f * CAPSULE_HALF))+ Matrix.scaleM(partM, 0, r, r * sy, r)+ Matrix.multiplyMM(mv, 0, view, 0, partM, 0)+ Matrix.multiplyMM(mvp, 0, proj, 0, mv, 0)+ drawShellPart(fingerMesh)+ }+/*** Stars, motion strokes, the shield and the sweat bead — everything a pose* puts *around* the ball rather than on it.@@ -1835,7 +1975,16 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {}}if (pr[PROP_SPARK_L] > 0.03f) strokes(SPARK_L, pop(pr[PROP_SPARK_L]), t)- if (pr[PROP_SPARK_R] > 0.03f) strokes(SPARK_R, pop(pr[PROP_SPARK_R]), t + 1.3f)+ if (pr[PROP_HEART] > 0.03f) {+ // Floats up and down on its own beat and sways a little, which is most of+ // what makes a still shape read as being *given* to you.+ val k = pop(pr[PROP_HEART])+ val bob = sin(t * 3.1f) * 0.03f+ propDraw(+ heartMesh, 1.02f, 0.46f + bob, 0.55f,+ 0.175f * k, 0.175f * k, 0.175f * k, 10f * sin(t * 2.2f), HEART_COLOR,+ )+ }if (pr[PROP_SPARK_TOP] > 0.03f) strokes(SPARK_TOP, pop(pr[PROP_SPARK_TOP]), t + 2.1f)if (pr[PROP_SHIELD] > 0.03f) {val k = pop(pr[PROP_SHIELD])@@ -2047,19 +2196,23 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {/** The gesture hands are a touch lighter than the body: they face the light. */private const val HAND_SHADE = 1.05f+ /** Half the straight section of the finger capsule, in radii. */+ private const val CAPSULE_HALF = 0.9f+/*** How big a gesture hand is drawn, as a multiple of the geometry in* [drawGestureHand]. Measured off the sketches: a hand is about a quarter of* the head's width, and the first pass drew them at about a seventh — they* read as mittens on a doll rather than as part of the character.*/- private const val HAND_SCALE = 1.65f+ private const val HAND_SCALE = 1.35f/** The shallowest a gesture hand sits: in front of the body's own edge. See [drawGestureHand]. */private const val HAND_MIN_Z = 0.46fprivate val CORAL = floatArrayOf(1.0f, 0.50f, 0.40f)private val CORAL_LIGHT = floatArrayOf(1.0f, 0.68f, 0.56f)+ private val HEART_COLOR = floatArrayOf(1.0f, 0.40f, 0.52f)private val STAR_COLOR = floatArrayOf(1.0f, 0.66f, 0.36f)private val DROP_COLOR = floatArrayOf(0.62f, 0.84f, 1.0f)@@ -2069,7 +2222,6 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {/** Motion strokes as `x, y, roll` triples — a fan from the waving hand, a pair off the pointing one, a burst on top. */private val SPARK_L = floatArrayOf(-0.78f, 0.50f, 35f, -1.04f, 0.36f, 62f, -1.22f, 0.10f, 88f)- private val SPARK_R = floatArrayOf(1.08f, 0.12f, -60f, 0.98f, 0.36f, -32f)private val SPARK_TOP = floatArrayOf(0f, 1.15f, 0f, -0.28f, 1.08f, 35f, 0.28f, 1.08f, -35f)/** Camera distance on +Z, looking at the origin. */@@ -2260,6 +2412,27 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {private const val FIDGET_MIN_SECONDS = 20fprivate const val FIDGET_MAX_SECONDS = 50f+ // ---- Idle life, for a look with gestures ----+ //+ // Faces: nothing for the first IDLE_FACE_AFTER_SECONDS of quiet (the calm+ // face right after an answer *means* something — it is done), then one face+ // every GAP_MIN..GAP_MAX seconds, held for the face's own time. Seven to+ // sixteen seconds is the range where it reads as a ball with moods rather+ // than one flipping through a deck: shorter and it twitches, longer and+ // nobody ever catches one.+ private const val IDLE_FACE_AFTER_SECONDS = 8f+ private const val IDLE_FACE_FIRST_SECONDS = 4f+ private const val IDLE_FACE_GAP_MIN_SECONDS = 7f+ private const val IDLE_FACE_GAP_MAX_SECONDS = 16f++ // Naps: asleep for NAP_MIN..MAX, then up for AWAKE_MIN..MAX before it dozes+ // again. Long enough asleep that it is plainly a nap, short enough that a+ // person glancing at the tablet twice in a morning sees both.+ private const val NAP_MIN_SECONDS = 25f+ private const val NAP_MAX_SECONDS = 50f+ private const val AWAKE_MIN_SECONDS = 40f+ private const val AWAKE_MAX_SECONDS = 90f+// ---- Body: top-lit gradient + one specular dot + an edge lift ----private const val SHELL_VS = """uniform mat4 uMVP;@@ -2307,6 +2480,60 @@ class EmotionBallRenderer : GLSurfaceView.Renderer {}"""+ // ---- Horn: the shell shader with a colour that fades in toward the tip ----+ //+ // Identical lighting; the only addition is `vT`, the horn mesh's own v+ // coordinate (0 at the base, 1 at the tip), and the mix it drives. Kept as a+ // second program rather than a branch in the shell shader so the one that+ // draws the body, the hands and every other look's horns is not touched.+ private const val HORN_VS = """+ uniform mat4 uMVP;+ uniform mat4 uMV;+ attribute vec3 aPos;+ attribute vec3 aNormal;+ attribute vec2 aUV;+ varying vec3 vN;+ varying vec3 vP;+ varying float vT;+ void main() {+ vN = normalize(mat3(uMV) * aNormal);+ vec4 p = uMV * vec4(aPos, 1.0);+ vP = p.xyz;+ vT = aUV.y;+ gl_Position = uMVP * vec4(aPos, 1.0);+ }+ """+ private const val HORN_FS = """+ precision mediump float;+ uniform vec3 uColor;+ uniform vec3 uTip;+ uniform float uTipMix;+ uniform float uAlpha;+ uniform float uGrad;+ uniform float uAmb;+ uniform float uDiff;+ uniform float uGloss;+ varying vec3 vN;+ varying vec3 vP;+ varying float vT;+ void main() {+ vec3 n = normalize(vN);+ vec3 V = normalize(-vP);+ // The fade starts 40% from the tip and is smooth, so there is no band+ // where the colour changes.+ vec3 c = mix(uColor, uTip, smoothstep(0.60, 0.98, vT) * uTipMix);+ float vert = n.y * 0.5 + 0.5;+ vec3 base = c * mix(1.0, mix(0.70, 1.14, vert), uGrad);+ vec3 L = normalize(vec3(-0.48, 0.85, 0.20));+ float diff = max(0.0, dot(n, L));+ vec3 lit = base * (uAmb + uDiff * diff);+ vec3 H = normalize(L + V);+ float spec = pow(max(0.0, dot(n, H)), 90.0) * uGloss;+ float edge = pow(1.0 - max(0.0, dot(n, V)), 3.0) * uGloss * 0.26;+ gl_FragColor = vec4(lit + vec3(spec) + c * edge, uAlpha);+ }+ """+// ---- Rim + scan (direct port of RIM_VERT/FRAG) ----private const val RIM_VS = """uniform mat4 uMVP;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.ktindex f5d5405..123120a 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@@ -171,7 +171,6 @@ class EmotionState {var s = 0fvar roll = 0fvar fist = 0f- var point = 0fvar jig = 0fvar waveAmt = 0f}@@ -182,6 +181,22 @@ class EmotionState {/** Pop-in amount of each prop, 0..1; indexed by the `PROP_*` constants. */val prop = FloatArray(PROP_COUNT)+ // ---- Jelly horns: see the block after `rotZ` in [tick] ----+ /** Side-to-side swing, degrees, positive toward the viewer's right. */+ var hornSway = 0f; private set++ /** In-out lean, degrees on top of the look's own tilt: negative stands up, positive flops. */+ var hornLean = 0f; private set+ private var swayV = 0f+ private var leanV = 0f+ private var prevRotY = 0f+ private var prevRotZ = 0f+ private var prevHop = 0f+ private var prevVY = 0f+ private var prevVZ = 0f+ private var prevVH = 0f+ private var hornInit = false+// ---- Dust particles ----private class Particle(val sinPhi: Float, val cosPhi: Float,@@ -399,11 +414,6 @@ class EmotionState {sqx = contact * 0.07fsqy = contact * -0.09f}- // The hand and the closing eye are the [Pose] layer's — see the- // overrides above. What is left for the body is a small lean, which- // is all a look without gestures can do with either.- Action.WAVE -> actRotY = sin(p * 4f * PI.toFloat()) * 0.05f- Action.WINK -> actRotY = sin(p * PI.toFloat()) * 0.04fAction.NONE -> {}}if (p >= 1f) action = Action.NONE@@ -455,20 +465,9 @@ class EmotionState {clock = tval gestures = LOOK.gesturesval pose = if (gestures) POSES[mood] ?: Pose.NONE else Pose.NONE- var tWink = pose.wink- var tHandL = pose.handL- var tSparkL = pose.sparkL- // The two idle gestures borrow the channels for their length. A hand the- // mood already put out is left alone: waving over a fist at the chin- // would be two answers at once.- if (gestures && action == Action.WAVE) {- if (tHandL.s < 0.05f) tHandL = HAND_WAVE- tSparkL = 1f- }- if (gestures && action == Action.WINK) {- val ap = actionT / actionDur- if (ap > 0.12f && ap < 0.88f) tWink = 1f- }+ val tWink = pose.wink+ val tHandL = pose.handL+ val tSparkL = pose.sparkLval kg = min(1f, dt * 10f)wink += (tWink - wink) * kglookX += (pose.lookX - lookX) * kg@@ -483,7 +482,7 @@ class EmotionState {val away = 1f - cling.coerceIn(0f, 1f)prop[PROP_STARS] += (pose.stars * away - prop[PROP_STARS]) * kpprop[PROP_SPARK_L] += (tSparkL * away - prop[PROP_SPARK_L]) * kp- prop[PROP_SPARK_R] += (pose.sparkR * away - prop[PROP_SPARK_R]) * kp+ prop[PROP_HEART] += (pose.heart * away - prop[PROP_HEART]) * kpprop[PROP_SPARK_TOP] += (pose.sparkTop * away - prop[PROP_SPARK_TOP]) * kpprop[PROP_SHIELD] += (pose.shield * away - prop[PROP_SHIELD]) * kpprop[PROP_DROP] += (pose.drop * away - prop[PROP_DROP]) * kp@@ -504,6 +503,49 @@ class EmotionState {rotX = sin(t * 0.17f) * 0.06f + jy * 0.009f + actRotX + workBobrotZ = tilt + th * sin(t * 0.51f) * 0.09f - clingLean+ // ---- Jelly horns ----+ // Two springs, both driven by how the *body* is accelerating rather than by+ // where it is: a horn standing still on a still head has nothing to do, and+ // one that swings when the head turns and rings out afterwards is what makes+ // it look like it is made of the same stuff as the ball.+ //+ // * `hornSway` is the side-to-side one. A turn about the vertical axis+ // throws the horns the way the face is coming *from*, and a roll throws+ // them the other way, so the two enter with opposite signs; the roll has+ // the longer lever (the horns sit high), hence the 1.5.+ // * `hornLean` is the in-out one, and the only one with a resting place:+ // the mood's [Pose.hornLean]. A hop's vertical acceleration pushes on it+ // too, so they flatten on take-off and flick back up on landing.+ //+ // Accelerations are differences of differences and therefore noisy; the+ // spring is the low-pass that makes them usable, which is also why it is as+ // soft as it is. Looks without [BallLook.hornWobble] never enter.+ if (gestures && LOOK.hornWobble > 0f) {+ val h = dt.coerceIn(0.001f, 1f / 30f)+ val vY = (rotY - prevRotY) / h+ val vZ = (rotZ - prevRotZ) / h+ val vH = (hopY - prevHop) / h+ var aY = (vY - prevVY) / h+ var aZ = (vZ - prevVZ) / h+ var aH = (vH - prevVH) / h+ if (!hornInit) {+ // The first frame has no previous one; a difference against zero is+ // a kick the size of the whole pose.+ aY = 0f; aZ = 0f; aH = 0f+ hornInit = true+ }+ prevRotY = rotY; prevRotZ = rotZ; prevHop = hopY+ prevVY = vY; prevVZ = vZ; prevVH = vH+ val g = LOOK.hornWobble * HORN_DRIVE+ swayV += (g * (-aY + 1.5f * aZ) - HORN_K * hornSway - HORN_C * swayV) * h+ hornSway = (hornSway + swayV * h).coerceIn(-HORN_SWAY_MAX, HORN_SWAY_MAX)+ leanV += (g * aH + HORN_K * (pose.hornLean - hornLean) - HORN_C * leanV) * h+ hornLean = (hornLean + leanV * h).coerceIn(-HORN_LEAN_MAX, HORN_LEAN_MAX)+ } else {+ hornSway = 0f; hornLean = 0f; swayV = 0f; leanV = 0f+ hornInit = false+ }+// Rings group tumble. Small on purpose: the belt orientation in [RINGS]// is chosen to keep the rings edge-on and off the face, and a large// tumble swings them right back across it.@@ -621,14 +663,13 @@ class EmotionState {val wants = t.s > 0.02fif (wants) {if (h.s < 0.05f) {- h.x = t.x; h.y = t.y; h.roll = t.roll; h.fist = t.fist; h.point = t.point+ h.x = t.x; h.y = t.y; h.roll = t.roll; h.fist = t.fist} else {val k = min(1f, dt * 10f)h.x += (t.x - h.x) * kh.y += (t.y - h.y) * kh.roll += (t.roll - h.roll) * kh.fist += (t.fist - h.fist) * k- h.point += (t.point - h.point) * k}val kj = min(1f, dt * 6f)h.jig += (t.jig - h.jig) * kj@@ -684,6 +725,20 @@ class EmotionState {/** Degrees per radian, for the one place a look's angle meets the mood's. */const val DEG = 57.29578f+ /**+ * The horn springs. K is the stiffness (natural frequency √K ≈ 10 rad/s, so+ * about a swing and a half a second) and C the damping: 7 against a critical+ * 21 is a damping ratio of a third, which rings three or four times before it+ * settles — jelly, where critical damping would be a hinge and none would be+ * a pendulum. DRIVE is degrees of swing per rad/s² of body acceleration; a+ * wiggle (≈10 rad/s²) throws them about 11°.+ */+ const val HORN_K = 110f+ const val HORN_C = 7f+ const val HORN_DRIVE = 120f+ const val HORN_SWAY_MAX = 26f+ const val HORN_LEAN_MAX = 36f+/** One sag-and-haul cycle, seconds. */const val SLIP_SECONDS = 3.6fdiff --git a/app/src/main/java/net/kuafuai/andee/ui/ball/Mood.kt b/app/src/main/java/net/kuafuai/andee/ui/ball/Mood.ktindex 64a79a8..45c9f4a 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@@ -211,10 +211,6 @@ val FACE: Map<Mood, Face> = mapOf(enum class Action {NONE, HOP, NOD, SHAKE, POP, RECOIL,STRETCH, LOOK_AROUND, WIGGLE, BOUNCE,- // A raised hand, and one eye closing. Both borrow the face's [Pose] channels- // for their length, so on a look without gestures they are no-ops that still- // use up their idle slot — see [EmotionState.tick].- WAVE, WINK,}/**@@ -234,8 +230,6 @@ val ACTION_SECONDS = floatArrayOf(1.9f, // LOOK_AROUND1.1f, // WIGGLE0.9f, // BOUNCE- 1.7f, // WAVE- 0.9f, // WINK)/**@@ -243,6 +237,11 @@ val ACTION_SECONDS = floatArrayOf(* here (not from every [Action]) when the idle fidget timer fires. Body-only* on purpose: the face stays CALM throughout, so nothing in here can be* mistaken for a response, a failure or a speaker being active.+ *+ * (A look with [BallLook.gestures] also changes *face* while idle, on its own+ * clock — see [IDLE_FACES]. The two are independent and may overlap, which is+ * what makes the ball look like it is in the middle of something rather than+ * running a playlist.)*/val IDLE_ACTIONS: List<Pair<Action, Float>> = listOf(Action.STRETCH to 1.0f,@@ -250,8 +249,35 @@ val IDLE_ACTIONS: List<Pair<Action, Float>> = listOf(Action.WIGGLE to 1.0f,Action.BOUNCE to 0.7f,Action.HOP to 0.5f,- Action.WAVE to 0.8f,- Action.WINK to 0.8f,+)++/**+ * The faces an idle ball may wear for a few seconds, with weights and how long to+ * hold each. **The list is deliberately short, and it is defined by what is left+ * out**: a face that reports a state of the *device* cannot be worn for no reason.+ *+ * - SPEAKING, LISTENING, THINKING, SEARCHING and HOLDING each say what the ball is+ * doing (talking, with the mic open, working, waiting on a question) — wearing+ * one at idle is a lie the user acts on, by speaking into a mic that is off.+ * - ANXIOUS, CONCERNED, TENSE, FAILED and PROTECT read as an alarm or an error.+ * - SUCCESS and CELEBRATE read as a task having finished.+ * - **REST and SLEEPING look alike** — squashed, eyes shut, hands on the belly; the+ * snot bubble is all that tells them apart. REST was in this list and the+ * capture showed why it cannot be: it surfaced fifteen seconds after Andee woke+ * from a nap and read as the ball going straight back to sleep, which is+ * exactly what the naps were changed to stop. Drowsiness belongs to the nap.+ *+ * What is left are the faces that report nothing but a mood: pleased, nosey, a+ * wink, a wave hello. WINK and WAVE are short because a gesture held for four+ * seconds is a pose, not a gesture.+ */+class IdleFace(val mood: Mood, val weight: Float, val holdMin: Float, val holdMax: Float)++val IDLE_FACES: List<IdleFace> = listOf(+ IdleFace(Mood.HAPPY, 1.3f, 2.6f, 4.0f),+ IdleFace(Mood.CURIOUS, 1.0f, 2.8f, 4.5f),+ IdleFace(Mood.WINK, 1.0f, 1.6f, 2.2f),+ IdleFace(Mood.WAVE, 0.8f, 1.8f, 2.6f),)/**diff --git a/app/src/main/java/net/kuafuai/andee/ui/ball/Pose.kt b/app/src/main/java/net/kuafuai/andee/ui/ball/Pose.ktindex 3975ca5..8e319e7 100644--- a/app/src/main/java/net/kuafuai/andee/ui/ball/Pose.kt+++ b/app/src/main/java/net/kuafuai/andee/ui/ball/Pose.kt@@ -24,8 +24,6 @@ class HandPose(val roll: Float = 0f,/** 0 = open mitten, 1 = fist. */val fist: Float = 0f,- /** 1 = the finger on the body side is out. */- val point: Float = 0f,/** Idle motion: a swing of the wrist if [wave], otherwise a small vertical bob. */val jig: Float = 0f,val wave: Boolean = false,@@ -59,11 +57,20 @@ class Pose(/** Resting body squash on top of breathing. Negative Y flattens, positive X widens. */val sqx: Float = 0f,val sqy: Float = 0f,+ /**+ * Where the horns rest, in degrees from their usual lean: **negative stands them+ * up, positive lets them flop outward.** The spring in [EmotionState] settles+ * on it, which is why a mood change makes them spring rather than snap. Perked+ * for curious, listening and celebrating; flopped for sad, tired and failed —+ * the one part of the head that can show a mood while the face is looking away.+ */+ val hornLean: Float = 0f,val handL: HandPose = HAND_OFF_L,val handR: HandPose = HAND_OFF_R,val stars: Float = 0f,val sparkL: Float = 0f,- val sparkR: Float = 0f,+ /** A small heart floating beside the face. */+ val heart: Float = 0f,val sparkTop: Float = 0f,val shield: Float = 0f,val drop: Float = 0f,@@ -77,7 +84,7 @@ class Pose(const val PROP_STARS = 0const val PROP_SPARK_L = 1-const val PROP_SPARK_R = 2+const val PROP_HEART = 2const val PROP_SPARK_TOP = 3const val PROP_SHIELD = 4const val PROP_DROP = 5@@ -86,8 +93,8 @@ const val PROP_COUNT = 6val HAND_OFF_L = HandPose(-0.62f, -0.15f, 0f)val HAND_OFF_R = HandPose(0.62f, -0.15f, 0f)-/** The wave a [Action.WAVE] fidget borrows, whatever mood is showing. */-val HAND_WAVE = HandPose(-1.18f, -0.22f, 1f, roll = -10f, jig = 1f, wave = true)+/** The wave [Mood.WAVE] raises: a left hand up at the side, swinging. */+val HAND_WAVE = HandPose(-0.96f, 0.05f, 1f, roll = -10f, jig = 1f, wave = true)/*** The poses. The numbers were read off the reference sketches (wink, wave, think,@@ -99,62 +106,64 @@ val HAND_WAVE = HandPose(-1.18f, -0.22f, 1f, roll = -10f, jig = 1f, wave = true)val POSES: Map<Mood, Pose> = mapOf(Mood.CALM to Pose(),- // Open-mouthed and pleased, with a little burst above the head. No hands: a- // happy face is the one that most needs its face visible.- Mood.HAPPY to Pose(sparkTop = 1f),+ // A pleased face with a little burst above the head. No hands: a happy face is+ // the one that most needs its face visible.+ Mood.HAPPY to Pose(sparkTop = 1f, hornLean = -8f),- // Eyes up and to one side, as if something is on the shelf above you.- Mood.CURIOUS to Pose(lookX = 0.6f, lookY = 0.6f),+ // Eyes up and to one side, as if something is on the shelf above you, and the+ // horns stand straight up to listen to it.+ Mood.CURIOUS to Pose(lookX = 0.6f, lookY = 0.6f, hornLean = -18f),- // Annoyed rather than hurt: the lids come down, and nothing else moves.- Mood.TENSE to Pose(lidCut = 0.8f),+ // Annoyed rather than hurt: the lids come down, the horns lie back a little.+ Mood.TENSE to Pose(lidCut = 0.8f, hornLean = 10f),// Fists drawn in at the chest, a bead of sweat, and the shiver the Face row// already supplies.Mood.ANXIOUS to Pose(- drop = 1f, lookY = 0.1f, lidCut = -1f,+ drop = 1f, lookY = 0.1f, lidCut = -1f, hornLean = 14f,handL = HandPose(-0.24f, -0.46f, 0.8f, roll = 25f, fist = 1f, jig = 0.12f),handR = HandPose(0.24f, -0.46f, 0.8f, roll = -25f, fist = 1f, jig = 0.12f),),// Hands folded low, eyes cast a little down: sorry, and about to say so.Mood.CONCERNED to Pose(- lookY = -0.2f, lidCut = -1f,+ lookY = -0.2f, lidCut = -1f, hornLean = 18f,handL = HandPose(-0.17f, -0.64f, 0.85f, roll = 30f, fist = 0.4f),handR = HandPose(0.17f, -0.64f, 0.85f, roll = -30f, fist = 0.4f),),- // wink.webp — a closed eye, an open laughing mouth, a finger pointing at you.- Mood.WINK to Pose(- wink = 1f, sparkR = 1f,- handR = HandPose(0.80f, -0.52f, 0.95f, roll = 40f, fist = 1f, point = 1f, jig = 0.4f),- ),+ // wink.webp — a closed eye and a heart floating beside the cheek. The reference+ // has a pointing hand; four hands were tried here (a V, a pointing finger, a+ // thumbs up, a fat thumb) and every one misread at eighty dp — the pointer as the+ // rude finger — so the wink carries a heart, which cannot be misread.+ Mood.WINK to Pose(wink = 1f, heart = 1f, hornLean = -6f),// wave.webp — a hand up at the side, swinging, with its motion lines.- Mood.WAVE to Pose(sparkL = 1f, handL = HAND_WAVE),+ Mood.WAVE to Pose(sparkL = 1f, handL = HAND_WAVE, hornLean = -10f),// protect.webp — brows set, a fist at the ready and a shield held out.Mood.PROTECT to Pose(- lidCut = 1f, shield = 1f,+ lidCut = 1f, shield = 1f, hornLean = -8f,handL = HandPose(-0.84f, -0.50f, 1f, roll = 20f, fist = 1f),),- // celebrate.webp — both fists in the air, stars, an open grin.+ // celebrate.webp — both fists in the air, stars, a grin; the horns spring.Mood.CELEBRATE to Pose(- stars = 1f, sparkTop = 1f,+ stars = 1f, sparkTop = 1f, hornLean = -16f,handL = HandPose(-1.12f, 0.0f, 1f, roll = 18f, fist = 1f, jig = 1f),handR = HandPose(1.12f, 0.0f, 1f, roll = -18f, fist = 1f, jig = 1f),),- // rest.webp — squashed down, eyes shut, both hands on the belly.+ // rest.webp — squashed down, eyes shut, both hands on the belly, horns slack.Mood.REST to Pose(- sqx = 0.08f, sqy = -0.13f, arcFlip = true,+ sqx = 0.08f, sqy = -0.13f, arcFlip = true, hornLean = 24f,handL = HandPose(-0.47f, -0.50f, 0.9f, roll = 20f, fist = 0.2f),handR = HandPose(0.55f, -0.46f, 0.9f, roll = -20f, fist = 0.2f),),- // A hand cupped behind the ear: the mic is open.+ // A hand cupped behind the ear: the mic is open, and the horns are up too.Mood.LISTENING to Pose(+ hornLean = -16f,handL = HandPose(-0.98f, 0.10f, 0.95f, roll = -25f, fist = 0f),),@@ -166,7 +175,7 @@ val POSES: Map<Mood, Pose> = mapOf(// think.webp — eyes up and to the side, a fist under the chin.Mood.THINKING to Pose(- lookX = 0.5f, lookY = 0.9f,+ lookX = 0.5f, lookY = 0.9f, hornLean = -8f,handL = HandPose(-0.04f, -0.66f, 1f, roll = 25f, fist = 1f),),@@ -175,23 +184,25 @@ val POSES: Map<Mood, Pose> = mapOf(// being listened to.Mood.SPEAKING to Pose(),- // Driving an app: one finger out, tapping at the glass.+ // Driving an app: a fist at the glass, tapping. It was one finger out, and a+ // single finger standing up beside the face read as the rude one — two fingers+ // leaned 35° overlap into a lone vertical bar. A fist has no such reading.Mood.SEARCHING to Pose(- lookY = -0.15f,- handR = HandPose(0.80f, -0.40f, 0.9f, roll = 35f, fist = 1f, point = 1f, jig = 0.7f),+ lookY = -0.15f, hornLean = -4f,+ handR = HandPose(0.80f, -0.40f, 0.9f, roll = 15f, fist = 1f, jig = 0.9f),),Mood.SUCCESS to Pose(- stars = 1f, sparkTop = 1f,+ stars = 1f, sparkTop = 1f, hornLean = -16f,handL = HandPose(-1.0f, 0.0f, 1f, roll = 18f, fist = 1f, jig = 1f),handR = HandPose(1.0f, 0.0f, 1f, roll = -18f, fist = 1f, jig = 1f),),- // Eyes down, a bead of sweat, slumped.- Mood.FAILED to Pose(lookY = -0.5f, lidCut = -1.2f, drop = 1f, sqy = -0.05f),+ // Eyes down, a bead of sweat, slumped, horns flopped.+ Mood.FAILED to Pose(lookY = -0.5f, lidCut = -1.2f, drop = 1f, sqy = -0.05f, hornLean = 24f),Mood.SLEEPING to Pose(- sqx = 0.08f, sqy = -0.13f, arcFlip = true,+ sqx = 0.08f, sqy = -0.13f, arcFlip = true, hornLean = 24f,handL = HandPose(-0.47f, -0.50f, 0.9f, roll = 20f, fist = 0.2f),handR = HandPose(0.55f, -0.46f, 0.9f, roll = -20f, fist = 0.2f),),diff --git a/app/src/main/java/net/kuafuai/andee/ui/ball/gl/Puff.kt b/app/src/main/java/net/kuafuai/andee/ui/ball/gl/Puff.ktindex b4c2aaf..46bd813 100644--- a/app/src/main/java/net/kuafuai/andee/ui/ball/gl/Puff.kt+++ b/app/src/main/java/net/kuafuai/andee/ui/ball/gl/Puff.kt@@ -119,6 +119,24 @@ object Puff {return chaikin(pts, 2)}+ /**+ * A heart, point down. The classic parametric curve, scaled to about unit+ * height and shifted down so the origin sits inside it: it is star-shaped about+ * a point a little below the cleft and not about the cleft itself, which is the+ * only reason [build]'s fan can fill it.+ */+ fun heart(samples: Int = 64): FloatArray {+ val out = FloatArray(samples * 2)+ for (i in 0 until samples) {+ val t = i.toFloat() / samples * 2f * PI.toFloat()+ val x = 16f * sin(t).pow(3)+ val y = 13f * cos(t) - 5f * cos(2f * t) - 2f * cos(3f * t) - cos(4f * t)+ out[2 * i] = x / 17f+ out[2 * i + 1] = y / 17f - 0.10f+ }+ return out+ }+/** A teardrop, tip up. Centred a little low so the origin is inside the belly. */fun drop(samples: Int = 28): FloatArray {val half = ArrayList<Float>()diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xmlindex 3a5624a..dc7ea29 100644--- a/app/src/main/res/values-en/strings.xml+++ b/app/src/main/res/values-en/strings.xml@@ -522,4 +522,32 @@<string name="ball_look_bear">Bear</string><string name="ball_look_imp">Imp</string>+ <!-- The expressions screen: the entry in settings, and the card that shows them all -->+ <string name="settings_section_expr">Looks & expressions</string>+ <string name="settings_expr_note">See every character and every expression; tap one to switch.</string>+ <string name="settings_expr_open">Open</string>+ <string name="expr_title">Looks & expressions</string>+ <string name="expr_section_look">Look</string>+ <string name="expr_section_mood">Expression</string>+ <string name="expr_caption">%1$s · %2$s</string>+ <string name="expr_calm">Calm</string>+ <string name="expr_happy">Happy</string>+ <string name="expr_curious">Curious</string>+ <string name="expr_tense">Angry</string>+ <string name="expr_anxious">Nervous</string>+ <string name="expr_concerned">Worried</string>+ <string name="expr_wink">Wink</string>+ <string name="expr_wave">Wave</string>+ <string name="expr_protect">Guard</string>+ <string name="expr_celebrate">Celebrate</string>+ <string name="expr_rest">Rest</string>+ <string name="expr_listening">Listening</string>+ <string name="expr_holding">Waiting</string>+ <string name="expr_thinking">Thinking</string>+ <string name="expr_speaking">Speaking</string>+ <string name="expr_searching">Working</string>+ <string name="expr_success">Success</string>+ <string name="expr_failed">Failed</string>+ <string name="expr_sleeping">Asleep</string>+</resources>diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xmlindex 4061d51..ef2a3db 100644--- a/app/src/main/res/values/strings.xml+++ b/app/src/main/res/values/strings.xml@@ -602,4 +602,32 @@<string name="ball_look_bear">憨憨熊</string><string name="ball_look_imp">小恶魔</string>+ <!-- 表情页:设置里"表情"一节的入口,以及那张看所有表情的卡片 -->+ <string name="settings_section_expr">形象与表情</string>+ <string name="settings_expr_note">看看每个形象和每个表情,点一下就换。</string>+ <string name="settings_expr_open">打开</string>+ <string name="expr_title">形象与表情</string>+ <string name="expr_section_look">形象</string>+ <string name="expr_section_mood">表情</string>+ <string name="expr_caption">%1$s · %2$s</string>+ <string name="expr_calm">平静</string>+ <string name="expr_happy">开心</string>+ <string name="expr_curious">好奇</string>+ <string name="expr_tense">生气</string>+ <string name="expr_anxious">紧张</string>+ <string name="expr_concerned">担心</string>+ <string name="expr_wink">眨眼</string>+ <string name="expr_wave">挥手</string>+ <string name="expr_protect">守护</string>+ <string name="expr_celebrate">庆祝</string>+ <string name="expr_rest">休息</string>+ <string name="expr_listening">在听</string>+ <string name="expr_holding">等你选</string>+ <string name="expr_thinking">思考</string>+ <string name="expr_speaking">说话</string>+ <string name="expr_searching">干活</string>+ <string name="expr_success">成功</string>+ <string name="expr_failed">失败</string>+ <string name="expr_sleeping">睡着</string>+</resources>