Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / library / avatar / src / main / assets / models / README.md
| 1 | # models/ |
| 2 | |
| 3 | Place the authored `base_upperbody.glb` here. Requirements (see `../../AGENTS.md` |
| 4 | "Base mesh asset"): |
| 5 | |
| 6 | - ~13–15 joints named per `joint_name()` (`root/spine/chest/neck/head`, |
| 7 | `clavicle_L/R`, `upperArm_L/R`, `forearm_L/R`, `hand_L/R`) |
| 8 | - `JOINTS_0` / `WEIGHTS_0` 4-weight skinning on the first mesh primitive |
| 9 | - Distinct `glasses` / `beard` / hair nodes for attachments |
| 10 | - 2K albedo honoring the skin `[0,.25]` / shirt `[.5,1]` UV split |
| 11 | - ≤65536 verts (tighter cap for grid cells) |
| 12 | |
| 13 | The `.glb` ships uncompressed (`noCompress` in `build.gradle.kts`) and is |
| 14 | handed to native as a detached fd by `YuuAvatarAssets`. Until it lands, the |
| 15 | engine renders the procedural fallback mesh. |
| 16 | |
| 17 | ## Packed-mesh node contract (v1) |
| 18 | |
| 19 | Mesh selection keys off node names — these spellings are the contract, used |
| 20 | verbatim (no case/format variants). `hairStyle` / `glassesStyle` / |
| 21 | `beardStyle` from `YuuFaceConfig` each select exactly one node per group per |
| 22 | frame; assembly = base body + selected attachments. |
| 23 | |
| 24 | - Hair: `hair_00`, `hair_01`, … `hair_11` — 12 nodes, ALL real, no hidden slot. |
| 25 | `hairStyle` 0..11 (`HAIR_STYLES = 12`) maps 1:1 onto `hair_00`..`hair_11`. |
| 26 | - Glasses: `glasses_01` … `glasses_06` — 6 nodes. Style 0 = hidden (editor |
| 27 | shows "None" at index 0); styles 1..6 map onto `glasses_01`..`glasses_06`. |
| 28 | - Beard: `beard_01` … `beard_05` — 5 nodes. Style 0 = hidden; styles 1..5 map |
| 29 | onto `beard_01`..`beard_05`. |
| 30 | |
| 31 | Attachment rules: |
| 32 | |
| 33 | - Every attachment parents to the Head joint (`head` per `joint_name()`). |
| 34 | - Skinning: parts that deform carry `JOINTS_0` / `WEIGHTS_0` 4-weight skinning |
| 35 | (weights normalized, remapped onto the UBO joint order); everything else is |
| 36 | rigid, bound 100% to Head — joints `[head, 0, 0, 0]`, weights `[1, 0, 0, 0]`, |
| 37 | the same convention as the procedural face decal quads in `mesh.rs`. |
| 38 | - One 2K albedo for the pack, honoring the skin `[0, .25]` / shirt `[.5, 1]` |
| 39 | UV split above (face decal UVs live in the atlas face block instead — see |
| 40 | next section). |
| 41 | - Budget: ≤65536 verts total assembled (base + selected attachments), per |
| 42 | `mesh_budgets()`. |
| 43 | |
| 44 | ## Face texture atlas layout (v1) |
| 45 | |
| 46 | Matches `atlas.rs` exactly (`ATLAS_SIZE = 256`; face block `[0, 128, 256, 256]` |
| 47 | = bottom half; skin-tone base fill everywhere so legacy skin UVs keep working): |
| 48 | |
| 49 | - Grid: `FACE_COLS = 12` x `FACE_ROWS = 4`. One cell = 256/12 x 128/4 px. |
| 50 | - Rows: 0 = eyes, 1 = brows, 2 = nose, 3 = mouth (`face_cell_uv(row, style)`; |
| 51 | row clamped to 0..3, column = `style mod 12`). |
| 52 | - Overlays: mole / wrinkle / blush share the SPARE BROW-ROW cells (row 1, |
| 53 | cols 8..11) via `overlay_cell_uv(style)` = row 1, col `8 + (style mod 4)` — |
| 54 | exactly the cells `generate_atlas` paints, so decal UVs and painted pixels |
| 55 | always agree. |
| 56 | - Only the SELECTED style cell per row is painted; unselected columns stay |
| 57 | skin. Colors (8 skin, 8 hair/brow, 5 eye, 4 mouth) are ARGB tints applied at |
| 58 | paint time, not separate atlas regions. |
| 59 | - The head face quad (`mesh.rs`: `FACE_Z = 0.145`, just proud of the skull |
| 60 | front at z = 0.14 so it never z-fights) carries 4 decal bands |
| 61 | (eyes / brows / nose / mouth) bound 100% to Head. Slider traits |
| 62 | (`eyeSpacing` / `eyeHeight` / `eyeSize`, `browHeight`, `noseHeight`, |
| 63 | `mouthSize` / `mouthHeight`) shift the band rects; style traits pick the |
| 64 | cell. Nonzero mole appends 1 cheek quad, wrinkle 1 forehead quad, blush 2 |
| 65 | cheek quads — all UV'd at the matching overlay cell. |
| 66 | |
| 67 | ## v1 pack manifest (data) |
| 68 | |
| 69 | `base_upperbody.glb` ships: |
| 70 | |
| 71 | - Mesh nodes: `hair_00`..`hair_11` (12), `glasses_01`..`glasses_06` (6), |
| 72 | `beard_01`..`beard_05` (5). Base body always assembled; one node per group |
| 73 | selected per frame (glasses/beard style 0 assembles none). |
| 74 | - Face regions: atlas rows for 12 eye / 8 brow / 8 nose / 12 mouth styles, |
| 75 | plus overlay cells (row 1, cols 8..11) for 4 mole / 4 wrinkle / 3 blush |
| 76 | styles. |
| 77 | - Face shape (8) is procedural — head-bone scale, no pack content. |
| 78 | - Colors are palette tints, not pack content. |
| 79 | |
| 80 | ### Const-vs-pack audit (`YuuFaceConfig` is source of truth — consts NOT changed) |
| 81 | |
| 82 | | Const | Value | Pack / atlas reality | Verdict | |
| 83 | |---|---|---|---| |
| 84 | | `FACE_SHAPES` | 8 | Procedural head-bone scale; no nodes or atlas cells | OK (pack-agnostic) | |
| 85 | | `HAIR_STYLES` | 12 | `hair_00`..`hair_11`, all real | MATCH | |
| 86 | | `EYE_STYLES` | 12 | Row 0, cols 0..11 | MATCH | |
| 87 | | `BROW_STYLES` | 8 | Row 1, cols 0..7 painted/selected | MISMATCH — atlas has 12 cols; cols 8..11 are overlay cells, never brow-selectable | |
| 88 | | `NOSE_STYLES` | 8 | Row 2, cols 0..7 painted/selected | MISMATCH — cols 8..11 exist but are never painted or selected | |
| 89 | | `MOUTH_STYLES` | 12 | Row 3, cols 0..11 | MATCH | |
| 90 | | `GLASSES_STYLES` | 6 | `glasses_01`..`glasses_06`; 0 = hidden | MATCH | |
| 91 | | `BEARD_STYLES` | 5 | `beard_01`..`beard_05`; 0 = hidden | MATCH | |
| 92 | | `MOLE_STYLES` | 4 | Styles 1..4 -> cols 9, 10, 11, 8; 0 = none | OK (note: style 4 wraps onto col 8) | |
| 93 | | `WRINKLE_STYLES` | 4 | Styles 1..4 -> cols 9, 10, 11, 8; 0 = none | OK (same wrap note) | |
| 94 | | `BLUSH_STYLES` | 3 | Styles 1..3 -> cols 9, 10, 11; 0 = none | OK (note: col 8 never used by blush) | |
| 95 | |
| 96 | Further mismatches / hazards (report only, no const changed): |
| 97 | |
| 98 | 1. Brow-row sharing: brow styles occupy row-1 cols 0..7 while mole/wrinkle/ |
| 99 | blush overlays occupy cols 8..11 — no conflict today, but bumping |
| 100 | `BROW_STYLES` past 8 would paint/select over the overlay cells (native |
| 101 | mods style by 12). That bump needs an atlas rework, not just editor |
| 102 | pagination. |
| 103 | 2. Stale comment in `atlas.rs`: `generate_atlas` docs say overlays paint on |
| 104 | "mouth-row spare cells", but the code and `overlay_cell_uv` both use the |
| 105 | brow row (row 1). Code is source of truth. |
| 106 | 3. Native indexing is lenient (`style mod 12`, negatives clamped to 0); the |
| 107 | real range gate is the editor `VariantGrid` counts — face parts `0..N-1`, |
| 108 | extras `0..N` with 0 = "None". |
| 109 | |
| 110 | ## Outfit / body-type / accessory extension path (recipe — implement nothing) |
| 111 | |
| 112 | To add a new axis (e.g. `outfitStyle`): |
| 113 | |
| 114 | 1. `YuuFaceConfig.kt`: add the field (e.g. `outfitStyle: Int = 0`) plus a |
| 115 | `XXX_STYLES` count const. Count rule: bare count if 0 is a real variant |
| 116 | (hair/eyes pattern); count + 1 grid with index 0 as "None" if 0 means |
| 117 | hidden (glasses/beard/extras pattern). |
| 118 | 2. `YuuEditorScreen.kt` `YuuDraft`: mirror the field — constructor param, |
| 119 | `mutableIntStateOf`, plus `toConfig()` and `from()` arms. |
| 120 | 3. `YuuEditorContract.kt` `YuuCategory`: add the entry (rail order = enum |
| 121 | order). |
| 122 | 4. `YuuEditorScreen.kt`: add an `XxxPanel(draft)` composable (`VariantGrid` + |
| 123 | `SectionLabel`), a `YuuCategory.Xxx -> XxxPanel(draft)` branch, a |
| 124 | `labelRes()` arm (`R.string.yuu_cat_xxx`), and a preview-stepper arm if the |
| 125 | axis has sliders. Give its `VariantGrid` cells a fresh |
| 126 | `YuuSurfaceIds.forVariant(panelBase, …)` base (Extras uses 6..10). |
| 127 | 5. Strings: add `yuu_cat_xxx` (plus section labels) to hub strings; "None" |
| 128 | reuses the shared `UiR.string.none`. |
| 129 | 6. Native: extend `YuuTraits` plus the node-select / atlas-row plumbing in the |
| 130 | Rust engine when mesh/art exists. New mesh nodes follow this README's |
| 131 | naming rules (`outfit_00..`, style-0 semantics declared up front). |
| 132 | |
| 133 | ## No `.glb` in this change |
| 134 | |
| 135 | This change is contract + manifest only — no `base_upperbody.glb` is added. |
| 136 | Art authors against the node contract (§ Packed-mesh node contract) and atlas |
| 137 | layout above separately; until the `.glb` lands, `YuuAvatarAssets` keeps the |
| 138 | best-effort handoff and the engine renders the procedural fallback mesh (face |
| 139 | decals included). |