agent (cont.)

+1:18
  • read_file{"Path":"~/work/lowmarch/art/cast/cast.py"}

    input

    {
      "Path": "~/work/lowmarch/art/cast/cast.py"
    }

    result, 465 lines

    Showing lines 1-464 of 464
    1: """Lowmarch test cast on the VRoid base: model, hair donor, shape controls and colours.
    2: 
    3: Models live outside the repo (see docs/vroid.md); paths are relative to LOWMARCH_VROID.
    4: Palette chars: hair A-E (dark->light), eyes r s t (dark->light), coat K L M P (dark->light).
    5: """
    6: # common enemies share an army palette: the enemy's dark red cloth, worn leather, dull steel
    7: MOB_COLORS = dict(A="#2a2420", B="#4a3a30", C="#6e5644", D="#92785e", E="#b89c7e",
    8:                   r="#2a1a12", s="#5a4630", t="#8a7050", K="#3a1418", L="#5e2026", M="#7e2a30", P="#a84848")
    9: MOB_PAINT = dict(signature="#7b3026", doublet="#3a3330", heraldry="#d8cfc0", leather="#5a3e2a", boot="#3e2c22",
    10:                  glove="#4a3426", steel="#9aa0aa", gold="#a88a4a", hair="#4a3a2e", motif="#d8cfc0",
    11:                  padding="#8a7a62", cloth="#4a4038", wood=dict(kind="leather", base="#6a4a30"),
    12:                  mail=dict(kind="steel", base="#8a909a"), fur=dict(kind="leather", base="#6a5444"), linen="#b8ad94",
    13:                  grain=dict(signature=0.03, padding=0.03, fur=0.10))
    14: 
    15: # generic units vary in hair, eyes and skin (palette letters: hair A-E dark to light, eyes r s t)
    16: HAIRS = {"brown": ("#2a1d14", "#4a3424", "#6e5038", "#94704e", "#c09a74"),
    17:          "black": ("#141418", "#24242c", "#383844", "#50505e", "#76768a"),
    18:          "blond": ("#6b4a1e", "#a8782e", "#d4a648", "#ecd07a", "#fbf0c0"),
    19:          "red": ("#3a140c", "#6a2414", "#9a3a1e", "#c45a30", "#e8905a"),
    20:          "grey": ("#3a3a3e", "#5e5e64", "#85858c", "#aeaeb4", "#d8d8dc"),
    21:          "auburn": ("#2e1610", "#52281a", "#7a3e26", "#a05a3a", "#c88a62"),
    22:          "blue": ("#1d2a52", "#2c4a8a", "#3f74c0", "#63a3e0", "#a6d8f6")}
    23: EYES = {"brown": ("#2a1a12", "#5a3a1c", "#9a7040"), "blue": ("#1a2a4a", "#3a6ab0", "#8ac0ec"),
    24:         "green": ("#12321e", "#2e8a4e", "#9edcae"), "grey": ("#2a2e34", "#5a6470", "#a0aab4"),
    25:         "amber": ("#3a2410", "#8a5a20", "#d8a050")}
    26: SKINS = {"light": None, "fair": "#f4dccb", "tan": "#e3bf9c", "olive": "#d6b08a", "brown": "#b08060",
    27:          "dark": "#8a5e44", "pale": "#f6e6e2",           # the mobs' older tones, kept as they were
    28:          # the skin range (2026-10-30): the lit colour of each tone; tools/export_glb.py skin_ramp derives its shade
    29:          # and deep shade. People, light to deep, undertones in the names:
    30:          "porcelain": "#f9e8e1", "ivory": "#f8e1d5", "peach": "#f4d3bd", "sand": "#e7c3a0", "honey": "#d9aa7d",
    31:          "olive_mid": "#c8a881", "amber": "#c18b5e", "caramel": "#a87047", "chestnut": "#8b5638", "umber": "#6e4129",
    32:          "mahogany": "#5a3122", "ebony": "#432a1f",
    33:          # fantasy
    34:          "drow_ash": "#6d6888", "drow_slate": "#4a4560", "ashen": "#b8b5ad", "orc": "#7e9659", "orc_deep": "#566c3e",
    35:          "sea": "#6f97c3", "infernal": "#b25648"}
    36: 
    37: 
    38: POLEARMS = ("soldier", "soldier_f")                     # classes that hold their weapon in both hands
    39: 
    40: 
    41: def mob(model, label, costume, build, face, hair="brown", eyes="brown", skin="light", hair_from=None, hair_trim=None,
    42:         beard=None, paint=None, mh=None, hair_style=None, qt=None, mass=None, cage=None, group=None, **shape):
    43:     """A common-enemy cast entry: a base body, a class costume (tools/mobs.py), a build and a face
    44:     (tools/gear.py presets), hair, eye and skin colours, optional facial hair."""
    45:     import gear
    46:     h, e = HAIRS[hair], EYES[eyes]
    47:     colors = dict(MOB_COLORS, A=h[0], B=h[1], C=h[2], D=h[3], E=h[4], r=e[0], s=e[1], t=e[2])
    48:     pnt = dict(MOB_PAINT, hair=h[2])
    49:     if SKINS[skin]:
    50:         pnt["skin"] = SKINS[skin]
    51:     pnt.update(paint or {})
    52:     shape.setdefault("hands", 1.22)
    53:     out = dict(model=model, hair=hair_from, label=label, costume=f"mob_{costume}", shape=gear.shape(build, face, **shape),
    54:                colors=colors, paint=pnt)
    55:     if costume in POLEARMS:                      # both hands on the weapon (tools/clips.py polearm)
    56:         out["stance"] = "polearm"
    57:     if hair_trim is not None:
    58:         out["hair_trim"] = hair_trim
    59:     if beard:
    60:         out["beard"] = beard
    61:     if mh:                                       # a MakeHuman body (tools/makehuman.py): its own build; the face
    62:         shape.setdefault("curl", 28.0)           # preset needs a VRoid head; relaxed hands, not paddles
    63:         out.update(mh=mh, shape=gear.shape("average", face, **shape) if mh.get("head") else dict(shape))
    64:     if group:                                    # a section of a long roster's character list (the viewer)
    65:         out["group"] = group
    66:     if mass:                                     # a VRoid model with MakeHuman's muscle and weight (tools/mass.py)
    67:         out["mass"] = mass
    68:     if cage:                                     # a VRoid model reshaped whole, its own head kept (tools/cage.py)
    69:         out["cage"] = cage
    70:     if qt:                                       # a Quaternius body (tools/quaternius.py, base spike): its own head
    71:         shape.setdefault("curl", 28.0)
    72:         out.update(qt=qt, shape=dict(shape))
    73:     if hair_style:
    74:         out["hair_style"] = hair_style
    75:     return out
    76: 
    77: 
    78: # MakeHuman bodies (test, 2026-10-08/09): macro sliders 0..1 (g: 0 female 1 male; age 0.5 = 25 years,
    79: # 1 = 90; muscle, weight, height, proportions) and named targets -1..1. The head is a VRoid model's
    80: # (head=..., tools/makehuman.py graft()), so the face stays anime and the face presets (gear.FACES) work.
    81: MH_HEAD = "base_male/Base_Male.vrm"
    82: MH_YOUTH = dict(macro=dict(g=1.0, age=0.38, muscle=0.25, weight=0.45, height=0.45, proportions=0.5),
    83:                 targets={"torso/torso-vshape": -0.35, "torso/torso-scale-horiz": -0.2}, head=MH_HEAD, head_scale=1.08)
    84: MH_VETERAN = dict(macro=dict(g=1.0, age=0.78, muscle=0.60, weight=0.78, height=0.40, proportions=0.35),
    85:                   targets={"neck/neck-scale-horiz": 0.4}, head=MH_HEAD)
    86: MH_BRUTE = dict(macro=dict(g=1.0, age=0.62, muscle=1.0, weight=0.85, height=0.72, proportions=0.6),
    87:                 targets={"neck/neck-scale-horiz": 0.9, "torso/torso-vshape": 0.6}, head=MH_HEAD, head_scale=1.12)
    88: # women soldiers (body workshop, 2026-10-09): VRoid's CC0 female head
    89: MH_HEAD_F = "base_female/Base_Female.vrm"
    90: MH_F_YOUTH = dict(macro=dict(g=0.0, age=0.40, muscle=0.40, weight=0.45, height=0.45, proportions=0.5), head=MH_HEAD_F)
    91: MH_F_VETERAN = dict(macro=dict(g=0.0, age=0.76, muscle=0.55, weight=0.70, height=0.40, proportions=0.40), head=MH_HEAD_F)
    92: MH_F_STRONG = dict(macro=dict(g=0.0, age=0.55, muscle=0.85, weight=0.55, height=0.70, proportions=0.6),
    93:                    targets={"neck/neck-scale-horiz": 0.4}, head=MH_HEAD_F, head_scale=1.05)
    94: 
    95: # ---- base spike (2026-10-09): the same soldier kit on other bases, judged against MakeHuman + VRoid head ----
    96: # MakeHuman's own head pushed toward anime with its face targets (bigger, lower eyes; small nose and
    97: # mouth; a narrower chin), rounded face normals (anime shading) and heavier drawn lines
    98: MH_ANIME_FACE = {"eyes/l-eye-scale": 1.0, "eyes/l-eye-height2": 0.8, "eyes/l-eye-trans": -0.3,
    99:                  "nose/nose-scale-vert": -0.7, "nose/nose-scale-horiz": -0.6, "nose/nose-scale-depth": -0.8,
    100:                  "nose/nose-point-width": -0.6, "nose/nose-volume": -0.6, "mouth/mouth-scale-horiz": -0.5,
    101:                  "mouth/mouth-upperlip-volume": -0.6, "mouth/mouth-lowerlip-volume": -0.6, "chin/chin-width": -0.4,
    102:                  "chin/chin-prominent": -0.3, "l-cheek/l-cheek-volume": -0.4, "eyebrows/eyebrows-trans": 0.3}
    103: MH_ANIME_DRAW = dict(face_round=0.75, iris_deg=62, lid_w=1.7, brow_w=1.3)
    104: QT_M = dict(file="Superhero_Male_FullBody.gltf", tex="T_Superhero_Male_Ligh.png")
    105: QT_F = dict(file="Superhero_Female_FullBody.gltf", tex="T_Superhero_Female_Light_BaseColor.png")
    106: 
    107: 
    108: # MakeHuman's mass for VRoid bodies (tools/mass.py): its macros plus its regional muscle and fat targets
    109: # ('l-' names apply to both sides)
    110: MASS_MUSCULAR = dict(base="lowmarch_bodies/base_masc.vrm", muscle=1.0, weight=0.75, gain=2.6, torso_gain=0.5, targets={
    111:     "arms/l-upperarm-muscle": 1.0, "arms/l-upperarm-shoulder-muscle": 1.0, "arms/l-lowerarm-muscle": 0.8,
    112:     "legs/l-upperleg-muscle": 0.8, "legs/l-lowerleg-muscle": 0.6, "torso/torso-muscle-pectoral": 0.8,
    113:     "torso/torso-muscle-dorsi": 1.0, "torso/torso-vshape": 0.6, "neck/neck-scale-horiz": 1.0, "neck/neck-scale-depth": 0.6})
    114: MASS_HEAVY = dict(base="lowmarch_bodies/base_masc.vrm", muscle=0.6, weight=1.0, gain=2.6, torso_gain=0.7, targets={
    115:     "stomach/stomach-pregnant": 0.6, "arms/l-upperarm-fat": 1.0, "arms/l-lowerarm-fat": 0.6, "legs/l-upperleg-fat": 1.0,
    116:     "legs/l-lowerleg-fat": 0.5, "torso/torso-scale-depth": 0.6, "hip/hip-scale-horiz": 0.4, "neck/neck-scale-horiz": 0.8})
    117: 
    118: 
    119: def _anime(spec, **face):
    120:     """A MakeHuman spec with its own head, pushed toward anime (MH_ANIME_FACE plus extra face targets)."""
    121:     out = {k: v for k, v in spec.items() if k not in ("head", "head_scale")}
    122:     out["targets"] = {**spec.get("targets", {}), **MH_ANIME_FACE, **face}
    123:     out.update(MH_ANIME_DRAW)
    124:     return out
    125: 
    126: 
    127: # ---- the armory (2026-10-09): bodies to assemble characters from, T-posed in plain underwear. From 2026-10-12 it
    128: # holds one line: VRoid's own base, its head kept, shaped by a MakeHuman reference body (tools/cage.py). Each
    129: # reference is fitted to its archetype (docs/proportions.md) and to real people of its height and waist
    130: # (tools/anthro.py), and is never shown itself
    131: def _mhb(g, age, muscle, weight, height, proportions=0.5, targets=None):
    132:     return dict(macro=dict(g=g, age=age, muscle=muscle, weight=weight, height=height, proportions=proportions),
    133:                 targets=dict(targets or {}), head=MH_HEAD if g else MH_HEAD_F)
    134: 
    135: 
    136: # the heavy archetype's widths were measured on armoured figures: on a bare heavy body they made shoulders no
    137: # real person of that height and waist has (the heavy man's 54 cm across the acromions against 42.5, 2026-10-10),
    138: # so the heavy man and woman take their shoulders and hips from MakeHuman's own weight, and their waists from
    139: # real people: at the 80th to 97th percentile of US adults their height (tools/anthro.py BUILD). The brute keeps
    140: # the widths, and his big hands and feet: he is drawn past real people on purpose
    141: _HEAVY_SKIP = ("shoulder_hd", "hip_hd", "waist_hd")
    142: # the game's heroic man and sexy woman (2026-10-12): MakeHuman's idealised proportions (its proportions macro at
    143: # 1), over the adult archetype's long legs, with a figure from tools/anthro.py (FIGURES) and widths of their own:
    144: # his shoulders broad over a narrow waist (2.1 to 2.25 head heights: at 2.33 his shoulder joints stood wider than
    145: # any real man's; at 1.95 to 2.2 he read as the strong man stretched, his V only from the waist, Fable), about
    146: # 1.9 m so the brute keeps the height, her hips full. Her waist is held by its girth among real women (FIGURES), not its width in head
    147: # heights: a narrower width fought the girth
    148: ARMORY_REFS = {     # name: (archetype (docs/proportions.md), MakeHuman spec, fit options)
    149:     "ref_m_lean": ("young", _mhb(1.0, 0.40, 0.35, 0.30, 0.60), {}),
    150:     "ref_m_average": ("generic", _mhb(1.0, 0.50, 0.50, 0.50, 0.50), {}),
    151:     "ref_m_strong": ("adult", _mhb(1.0, 0.50, 0.85, 0.55, 0.60, targets={"torso/torso-vshape": 0.4}), {}),
    152:     "ref_m_heroic": ("adult", _mhb(1.0, 0.50, 0.75, 0.45, 0.57, proportions=1.0, targets={"torso/torso-vshape": 0.6}),
    153:                      dict(figure="heroic", ranges=dict(shoulder_hd=(2.1, 2.25), waist_hd=(1.1, 1.3), hip_hd=(1.35, 1.6)))),
    154:     "ref_m_heavy": ("heavy", _mhb(1.0, 0.60, 0.50, 1.00, 0.50), dict(skip=_HEAVY_SKIP)),
    155:     "ref_m_brute": ("heavy", MH_BRUTE, dict(skip=("hip_hd", "waist_hd", "hand_p", "foot_p"))),
    156:     "ref_m_old": ("generic", _mhb(1.0, 0.90, 0.40, 0.55, 0.40, proportions=0.35), {}),
    157:     "ref_m_youth": ("young", MH_YOUTH, {}),
    158:     "ref_f_slender": ("young", _mhb(0.0, 0.40, 0.35, 0.30, 0.60), {}),
    159:     "ref_f_average": ("generic", _mhb(0.0, 0.50, 0.50, 0.50, 0.50), {}),
    160:     "ref_f_strong": ("adult", MH_F_STRONG, {}),
    161:     "ref_f_sexy": ("adult", _mhb(0.0, 0.45, 0.50, 0.50, 0.70, proportions=1.0),
    162:                    dict(figure="sexy", ranges=dict(hip_hd=(1.6, 1.9)))),
    163:     "ref_f_heavy": ("heavy", _mhb(0.0, 0.60, 0.50, 1.00, 0.45), dict(skip=_HEAVY_SKIP)),
    164:     "ref_f_old": ("generic", _mhb(0.0, 0.90, 0.40, 0.55, 0.40, proportions=0.35), {}),
    165: }
    166: 
    167: # The smoothed pull gives width but not mass, and smoothing takes muscle tone: masses are added as forms on the skin
    168: # (tools/cage.py, metres). The brute's are big: deltoid caps wider than the arm, a trapezius rising into the neck,
    169: # pecs, lats, biceps, forearms, calves
    170: CAGE_BRUTE_FORMS = [
    171:     dict(gate=("{s}_UpperArm", "{s}_Shoulder"), at=("{s}_UpperArm", 0.12), face=(1, 0.7, 0), size=(0.07, 0.07, 0.08), h=0.035),
    172:     dict(gate=("C_UpperChest", "{s}_Shoulder", "C_Neck"), at=("{s}_Shoulder", 0.4), face=(0.2, 1, 0), size=(0.07, 0.05, 0.07),
    173:          h=0.045),
    174:     dict(gate=("C_UpperChest", "C_Chest", "Bust1", "Bust2"), at=("C_UpperChest", 0.2), off=(0.08, -0.02, 0), face=(0, 0, 1),
    175:          size=(0.07, 0.05, 0.06), h=0.025),
    176:     dict(gate=("C_Chest", "C_UpperChest", "C_Spine"), at=("C_Chest", 0.5), off=(0.12, 0, 0), face=(1, 0, -0.4),
    177:          size=(0.05, 0.09, 0.07), h=0.025),
    178:     dict(gate=("{s}_UpperArm",), at=("{s}_UpperArm", 0.55), face=(0, 0.3, 1), size=(0.06, 0.04, 0.05), h=0.015),
    179:     dict(gate=("{s}_LowerArm",), at=("{s}_LowerArm", 0.25), face=(0, 1, 0.3), size=(0.06, 0.04, 0.05), h=0.012),
    180:     dict(gate=("{s}_LowerLeg",), at=("{s}_LowerLeg", 0.3), face=(0.3, 0, -1), size=(0.04, 0.07, 0.05), h=0.02)]
    181: 
    182: 
    183: def _muscle(k, trap=1.0, lats=1.0, delts=1.0):
    184:     """The brute's forms at k of their height (the trapezius, lats and deltoids scaled again by trap, lats, delts)."""
    185:     out = []
    186:     for f in CAGE_BRUTE_FORMS:
    187:         g = dict(f, h=round(f["h"] * k, 4))
    188:         if "C_Neck" in f["gate"]:
    189:             g["h"] = round(g["h"] * trap, 4)
    190:         if "C_Spine" in f["gate"]:
    191:             g["h"] = round(g["h"] * lats, 4)
    192:         if f["gate"] == ("{s}_UpperArm", "{s}_Shoulder"):
    193:             g["h"] = round(g["h"] * delts, 4)
    194:         out.append(g)
    195:     return out
    196: 
    197: 
    198: # a heavy man is big, not only fat: shoulders with some bulk (his arms come from his reference since it's fitted to
    199: # real heavy men's, 2026-10-10: an upper-arm form on top put them past everyone's)
    200: CAGE_HEAVY_FORMS = [
    201:     dict(gate=("{s}_UpperArm", "{s}_Shoulder"), at=("{s}_UpperArm", 0.12), face=(1, 0.7, 0), size=(0.07, 0.07, 0.08), h=0.02),
    202:     dict(gate=("C_UpperChest", "{s}_Shoulder", "C_Neck"), at=("{s}_Shoulder", 0.4), face=(0.2, 1, 0), size=(0.07, 0.05, 0.07),
    203:          h=0.025)]
    204: # the strong man is an athlete: the brute's masses at about two thirds. The heroic man's are a little less, the
    205: # trapezius lower (a clean line from the neck), the lats fuller (the V under the arms) and the deltoids rounder
    206: CAGE_STRONG_FORMS = _muscle(0.65)
    207: CAGE_HEROIC_FORMS = _muscle(0.6, trap=0.6, lats=1.4, delts=1.3)
    208: # women (2026-10-10): VRoid's feminine base over the MakeHuman women. The strong one gets mild shoulder, arm and calf
    209: # forms, since the smoothing takes her muscle tone
    210: CAGE_STRONG_F_FORMS = [
    211:     dict(gate=("{s}_UpperArm", "{s}_Shoulder"), at=("{s}_UpperArm", 0.12), face=(1, 0.7, 0), size=(0.06, 0.06, 0.07), h=0.016),
    212:     dict(gate=("C_UpperChest", "{s}_Shoulder", "C_Neck"), at=("{s}_Shoulder", 0.4), face=(0.2, 1, 0), size=(0.06, 0.04, 0.06),
    213:          h=0.015),
    214:     dict(gate=("{s}_UpperArm",), at=("{s}_UpperArm", 0.55), face=(0, 0.3, 1), size=(0.05, 0.035, 0.045), h=0.008),
    215:     dict(gate=("{s}_LowerLeg",), at=("{s}_LowerLeg", 0.3), face=(0.3, 0, -1), size=(0.035, 0.06, 0.045), h=0.012)]
    216: # VRoid's breasts are a hemisphere each, set close, upper pole as full as the lower (Fable, 2026-10-10): each woman's
    217: # are reshaped after the wrap (tools/cage.py bust_shape): opened at the cleavage, set a little lower, the upper pole
    218: # sloped back (a fuller lower pole). The sexy and heavy women's are grown mostly by inflating them along the skin
    219: # (2026-10-12): scaled up from VRoid's narrow base they stood out as balls glued on, with a crease round the rim.
    220: # The inflation sits low (a teardrop, not a dome), and the heavy woman's falls outward, as her reference's does
    221: CAGE_HEAVY_F_FORMS = [
    222:     dict(gate=("{s}_UpperArm", "{s}_Shoulder"), at=("{s}_UpperArm", 0.12), face=(1, 0.7, 0), size=(0.06, 0.06, 0.07), h=0.012)]
    223: _MASC, _FEM = "lowmarch_bodies/base_masc.vrm", "lowmarch_bodies/base_fem.vrm"
    224: # ranges the armory's checks hold a body to beyond its reference's: the strong and heroic men's deltoid forms widen
    225: # their shoulders over a skeleton fitted to 2.2 head heights (every man's T-posed shoulders read past real men's
    226: # breadth across the deltoids, the average man's too; theirs are the broadest on purpose)
    227: CHECK_RANGES = {"arm_m_strong": dict(shoulder_hd=(1.7, 2.35)), "arm_m_heroic": dict(shoulder_hd=(2.0, 2.4))}
    228: # heads (2026-10-13, tools/heads.py): each body wears a VRoid sample's face, or a blend of samples' faces (the first
    229: # gives the eye drawing), chosen by look. They are left as VRoid built them, with light touches at most: fitted to
    230: # the face ratios of the study's paintings (by lengthening the lower face, enlarging the eyes) they read too sharp
    231: # from the side and the average man too wide (the user, 2026-10-13). The ratios are reported against the face's
    232: # archetype. What a face does at rest (a frown, half-closed eyes) and age lines are drawn when the figure is built
    233: # (PORTRAIT), not in the file
    234: def _head(archetype, sculpt=None, hair=None, face=None, makeup=False, **mix):
    235:     """A head: a sample's face or a blend (mix: letter -> weight), or a face designed in VRoid Studio's own editor
    236:     (face: a VRM under LOWMARCH_VROID, faces/, exported by tools/winvroid; makeup keeps its lips and shadow)."""
    237:     sample = [[face, 1.0]] if face else [[f"avatarsample_{k}", w] for k, w in mix.items()]   # in order: the first
    238:                                                                                                 # gives the eyes
    239:     out = dict(sample=sample, sculpt=sculpt or {}, archetype=archetype)
    240:     if hair:
    241:         out["hair"] = f"avatarsample_{hair}"
    242:     if makeup:
    243:         out["makeup"] = True
    244:     return out
    245: 
    246: 
    247: # hair (2026-10-13): a VRoid sample's hairstyle per body (tools/heads.py: warped onto our head, with its springs),
    248: # chosen by archetype; its colour (HAIR_COLOURS, the cast's palettes) and the eyes' (EYE_COLOURS) are the body's own,
    249: # since the renderers recolour both
    250: HEADS = {
    251:     "arm_m_lean": _head("young", hair="z", z=1),
    252:     "arm_m_average": _head("generic", hair="l", p=0.5, z=0.5),
    253:     "arm_m_strong": _head("adult", hair="c", c=0.6, t=0.4),
    254:     "arm_m_heroic": _head("adult", hair="r", r=0.6, v=0.4),
    255:     "arm_m_heavy": _head("heavy", dict(cheek=0.4), hair="x", x=1),
    256:     "arm_m_brute": _head("heavy", dict(jaw=0.8, brow_ridge=0.8), hair="t", t=0.6, x=0.4),
    257:     "arm_m_old": _head("adult", dict(brow_ridge=0.8, nose=0.6), hair="n", v=0.6, t=0.4),
    258:     "arm_m_youth": _head("young", hair="g", z=0.4, g=0.6),
    259:     "arm_f_slender": _head("young", hair="j", j=1),
    260:     "arm_f_average": _head("generic", hair="a", a=1),
    261:     "arm_f_strong": _head("adult", hair="s", u=1),
    262:     "arm_f_sexy": _head("adult", hair="u", q=1),        # (faces/face_sexy.vrm, made in VRoid's editor 2026-10-13 from
    263:                                                         # its preset 11, read cuter than this, not sultrier: kept aside)
    264:     "arm_f_heavy": _head("generic", dict(cheek=0.4), hair="y", s=0.6, e=0.4),
    265:     "arm_f_old": _head("adult", hair="w", m=1),
    266: }
    267: HAIR_COLOURS = {"arm_m_lean": "black", "arm_m_average": "brown", "arm_m_strong": "black", "arm_m_heroic": "auburn",
    268:                 "arm_m_heavy": "brown", "arm_m_brute": "black", "arm_m_old": "grey", "arm_m_youth": "blond",
    269:                 "arm_f_slender": "blond", "arm_f_average": "brown", "arm_f_strong": "red", "arm_f_sexy": "black",
    270:                 "arm_f_heavy": "auburn", "arm_f_old": "grey"}
    271: EYE_COLOURS = {"arm_m_heroic": "blue", "arm_f_sexy": "green", "arm_f_slender": "blue", "arm_m_old": "grey",
    272:                "arm_f_old": "grey", "arm_m_youth": "amber"}
    273: PORTRAIT = {    # at rest and age lines: name -> shape extras (tools/vroid_portrait.py)
    274:     "arm_m_strong": dict(rest={"Fcl_BRW_Angry": 0.4}),
    275:     "arm_m_heroic": dict(rest={"Fcl_BRW_Angry": 0.25}),
    276:     "arm_m_brute": dict(rest={"Fcl_EYE_Close": 0.28, "Fcl_BRW_Angry": 0.75}),
    277:     # fangs: his teeth have sample V's two fangs (they show in an open mouth); fangs=0 files them away (owner's call)
    278:     "arm_m_old": dict(age_lines=0.8, blush=0.0, fangs=1.0, rest={"Fcl_EYE_Angry": 0.4, "Fcl_EYE_Close": 0.25,
    279:                                                                   "Fcl_BRW_Angry": 0.5, "Fcl_MTH_Down": 0.3}),
    280:     "arm_f_old": dict(age_lines=0.6, blush=0.3, rest={"Fcl_EYE_Close": 0.22, "Fcl_MTH_Down": 0.2}),
    281:     "arm_f_strong": dict(rest={"Fcl_BRW_Angry": 0.2}),
    282: }
    283: ARMORY = {      # name: (label, sex, its reference, cage spec beyond base and ref)
    284:     "arm_m_lean": ("Man, lean", "m", "ref_m_lean", dict(relax=4)),
    285:     "arm_m_average": ("Man, average", "m", "ref_m_average", dict(relax=4)),
    286:     "arm_m_strong": ("Man, strong", "m", "ref_m_strong", dict(relax=4, forms=CAGE_STRONG_FORMS)),
    287:     "arm_m_heroic": ("Man, heroic", "m", "ref_m_heroic", dict(relax=4, forms=CAGE_HEROIC_FORMS)),
    288:     "arm_m_heavy": ("Man, heavy", "m", "ref_m_heavy", dict(relax=4, forms=CAGE_HEAVY_FORMS)),
    289:     "arm_m_brute": ("Man, brute", "m", "ref_m_brute", dict(wrap_sigma=(0.02, 0.035), relax=4, forms=CAGE_BRUTE_FORMS)),
    290:     "arm_m_old": ("Man, old", "m", "ref_m_old", dict(relax=4)),
    291:     "arm_m_youth": ("Man, youth", "m", "ref_m_youth", dict(relax=4)),
    292:     "arm_f_slender": ("Woman, slender", "f", "ref_f_slender", dict(relax=4, bust_shape=dict(spread=0.008, drop=0.005, flat=0.25))),
    293:     "arm_f_average": ("Woman, average", "f", "ref_f_average", dict(relax=4, bust_shape=dict(spread=0.005, drop=0.008, flat=0.3))),
    294:     "arm_f_strong": ("Woman, strong", "f", "ref_f_strong", dict(relax=4, bust=0.1, forms=CAGE_STRONG_F_FORMS,
    295:                                                                   bust_shape=dict(spread=0.006, drop=0.006, flat=0.35))),
    296:     "arm_f_sexy": ("Woman, sexy", "f", "ref_f_sexy", dict(relax=4, bust=0.2, bust_shape=dict(scale=0.3, inflate=0.025, low=0.02, drop=0.025,
    297:                                                                                                spread=0.006, flat=0.4))),
    298:     "arm_f_heavy": ("Woman, heavy", "f", "ref_f_heavy", dict(relax=4, bust=0.3, forms=CAGE_HEAVY_F_FORMS,
    299:                                                                bust_shape=dict(scale=0.2, inflate=0.025, low=0.025, splay=0.015,
    300:                                                                                drop=0.03, spread=0.006, flat=0.45, base=0.1))),
    301:     "arm_f_old": ("Woman, old", "f", "ref_f_old", dict(relax=4, bust_shape=dict(spread=0.006, drop=0.015, flat=0.4))),
    302: }
    303: 
    304: CAST = {
    305:     "aldric": dict(  # young lord
    306:         model="hairsample_male/HairSample_Male.vrm", hair="sakurada_fumiriya/Sakurada Fumiriya.vrm",
    307:         # heroic proportions after the study's lord: about 7.4 heads (smaller head, longer legs), broad
    308:         # shoulders and chest over a narrower waist, thicker neck and limbs
    309:         shape=dict(eye=1.14, head=0.93, neck=1.14, chest=1.10, shoulders=1.28, arms=1.10, torso=1.06,
    310:                    legs=1.06, leg_len=1.05, hands=1.06),
    311:         colors=dict(A="#1d2a52", B="#2c4a8a", C="#3f74c0", D="#63a3e0", E="#a6d8f6",
    312:                     r="#21183a", s="#3b6ab0", t="#86c0ec", K="#4a2030", L="#7a2e3c", M="#a8444e", P="#d8747a",
    313:                     U="#161a38", V="#26305e", W="#3c4c8e", X="#6a7cc4"),
    314:         costume="lord",
    315:         # painted renderer: one signature cloth hue, neutral steel and brown leather (Unicorn Overlord
    316:         # study: two or three hues at most; gold only for royalty and only as small accents)
    317:         paint=dict(signature="#7d1e2c", doublet="#2a2d3d", heraldry="#dfe2e8", leather="#5f3e2b", boot="#4a3326",
    318:                    glove="#5f3e2b", steel="#a6adbb", gold="#b08b3f", hair="#3c6db3")),
    319:     "elaine": dict(  # knight-princess, swordswoman (the user's brief: a blonde swordswoman like Saber)
    320:         # the sample's hair cards are all dropped (hair_trim < 0): her hair is built by tools/hair.py
    321:         model="hairsample_female/HairSample_Female.vrm", hair=None, hair_trim=-1,
    322:         shape=dict(head=0.95, leg_len=1.04, shoulder_w=0.008, rest={"Fcl_BRW_Angry": 0.35}),
    323:         colors=dict(A="#6b4a1e", B="#a8782e", C="#d4a648", D="#ecd07a", E="#fbf0c0",
    324:                     r="#12321e", s="#2e8a4e", t="#9edcae", K="#18224f", L="#24398a", M="#3556b8", P="#6f8fe0",
    325:                     Q="#0f111b", R="#1b1e2c", S="#2a2e42", T="#41465e"),
    326:         costume="knight_dress",
    327:         paint=dict(signature="#2a4aa6", doublet="#1d2133", heraldry="#eef0f5", leather="#5a3d2b", boot="#4a3326",
    328:                    glove="#5a3d2b", steel="#b7bfcc", gold="#c9a34a", hair="#e2bf62", grain=dict(signature=0.015))),
    329:     # benchmark only, NOT FOR THE GAME (Saber is Type-Moon's): a fidelity test of the outline-plate kit on
    330:     # Elaine's base. The game's characters are original designs.
    331:     "saber": dict(
    332:         model="hairsample_female/HairSample_Female.vrm", hair=None, hair_trim=0.12,
    333:         shape=dict(head=0.95, leg_len=1.04, shoulder_w=0.008, rest={"Fcl_BRW_Angry": 0.35}),
    334:         colors=dict(A="#6b4a1e", B="#a8782e", C="#d4a648", D="#ecd07a", E="#fbf0c0",
    335:                     r="#12321e", s="#2e8a4e", t="#9edcae", K="#18224f", L="#24398a", M="#3556b8", P="#6f8fe0",
    336:                     Q="#0f111b", R="#1b1e2c", S="#2a2e42", T="#41465e"),
    337:         costume="saber_study",
    338:         # colours sampled from the study (royal blue dress, violet front panel, warm light steel)
    339:         paint=dict(signature="#2e5ba6", doublet="#1a1c26", heraldry="#f4f0e6", leather="#2a2326", boot="#3a3032",
    340:                    glove="#221d20", steel="#eceef2", gold="#d9b46a", hair="#ebc985", motif="#3a44a2",
    341:                    violet="#4440a0", ribbon="#5a58a8", grain=dict(signature=0.012, violet=0.012))),
    342:     # ---- common enemies (tools/mobs.py): a class costume on a base, a build and a face (tools/gear.py) ----
    343:     "mob_soldier": mob("base_male/Base_Male.vrm", "Soldier", "soldier", "average", "young", hair="brown", eyes="brown"),
    344:     "mob_mh_youth": mob(None, "MH youth", "soldier", "average", "young", hair="brown", eyes="brown", mh=MH_YOUTH),
    345:     "mob_mh_veteran": mob(None, "MH veteran", "soldier", "average", "veteran", hair="grey", eyes="grey", skin="tan",
    346:                           mh=MH_VETERAN, beard="short"),
    347:     "mob_mh_brute": mob(None, "MH brute", "soldier", "average", "brute", hair="red", eyes="blue", skin="fair",
    348:                         mh=MH_BRUTE, beard=("full", 0.06), age_lines=0.4, iris=0.88, blush=0.3,
    349:                         rest={"Fcl_EYE_Angry": 0.35}),
    350:     "mob_mh_f_youth": mob(None, "MH woman, young", "soldier_f", "average", "young", hair="black", eyes="amber", skin="brown",
    351:                           mh=MH_F_YOUTH),
    352:     "mob_mh_f_veteran": mob(None, "MH woman, veteran", "soldier_f", "average", "stern", hair="grey", eyes="grey",
    353:                             mh=MH_F_VETERAN, age_lines=0.5, iris=0.84, blush=0.0, mouth=1.05,
    354:                             rest={"Fcl_EYE_Angry": 0.45, "Fcl_EYE_Close": 0.1, "Fcl_EYE_Joy": 0.18, "Fcl_BRW_Angry": 0.45,
    355:                                   "Fcl_MTH_Down": 0.25}),
    356:     "mob_mh_f_strong": mob(None, "MH woman, strong", "soldier_f", "average", "plain", hair="red", eyes="green", skin="fair",
    357:                            mh=MH_F_STRONG),
    358:     "spk_mh_vroid_m": mob(None, "Man: MakeHuman + VRoid head", "soldier", "average", "young", hair="brown", eyes="brown",
    359:                           mh=MH_YOUTH, group="Round 1 · bases"),
    360:     "spk_mh_anime_m": mob(None, "Man: MakeHuman, own head", "soldier", "average", "young", hair="brown", eyes="brown",
    361:                           mh=_anime(MH_YOUTH), hair_style="crop", group="Round 1 · bases"),
    362:     "spk_qt_m": mob(None, "Man: Quaternius", "soldier", "average", "young", hair="brown", eyes="brown",
    363:                     qt=QT_M, hair_style="crop", group="Round 1 · bases"),
    364:     "spk_mh_vroid_f": mob(None, "Woman: MakeHuman + VRoid head", "soldier_f", "average", "young", hair="black", eyes="amber",
    365:                           skin="brown", mh=MH_F_YOUTH, group="Round 1 · bases"),
    366:     "spk_mh_anime_f": mob(None, "Woman: MakeHuman, own head", "soldier_f", "average", "young", hair="black", eyes="amber",
    367:                           skin="brown", mh=_anime(MH_F_YOUTH, **{"chin/chin-width": -0.7}), hair_style="crop", group="Round 1 · bases"),
    368:     "spk_qt_f": mob(None, "Woman: Quaternius", "soldier_f", "average", "young", hair="black", eyes="amber",
    369:                     skin="brown", qt=QT_F, hair_style="crop", group="Round 1 · bases"),
    370:     "spk_mh_sample_a_f": mob(None, "Woman: MakeHuman + VRoid sample A head", "soldier_f", "average", "young", hair="black",
    371:                              eyes="amber", skin="brown", mh=dict(MH_F_YOUTH, head="samples_2_14/avatarsample_a/AvatarSample_A.vrm"), group="Round 2 · VRoid"),
    372:     # bodies made in VRoid Studio by the Windows driver, exported without its clothes (they cut the skin they cover)
    373:     "spk_vroid_broad": mob("lowmarch_bodies/vroid_broad_v2.vrm", "Man: VRoid Studio, broad", "soldier", "average", "young",
    374:                            hair="brown", eyes="brown", group="Round 2 · VRoid"),
    375:     "spk_vroid_stocky": mob("lowmarch_bodies/vroid_stocky_v2.vrm", "Man: VRoid Studio, stocky", "soldier", "average", "young",
    376:                             hair="brown", eyes="brown", group="Round 2 · VRoid"),
    377:     # VRoid's Base_Male with MakeHuman's muscle and weight carried across (tools/mass.py), beside it unchanged
    378:     # and beside the MakeHuman brute whose mass they borrow
    379:     "spk_vroid_plain": mob("base_male/Base_Male.vrm", "Man: VRoid Base_Male", "soldier", "average", "young",
    380:                            hair="brown", eyes="brown", group="Round 2 · VRoid"),
    381:     "spk_vroid_muscular": mob("base_male/Base_Male.vrm", "Man: VRoid + MakeHuman muscle", "soldier", "average", "young",
    382:                               hair="brown", eyes="brown", mass=MASS_MUSCULAR, group="Round 2 · VRoid"),
    383:     "spk_vroid_heavy": mob("base_male/Base_Male.vrm", "Man: VRoid + MakeHuman weight", "soldier", "average", "young",
    384:                            hair="brown", eyes="brown", mass=MASS_HEAVY, group="Round 2 · VRoid"),
    385:     "spk_mh_brute": mob(None, "Man: MakeHuman brute + VRoid head", "soldier", "average", "brute", hair="red", eyes="blue",
    386:                         skin="fair", mh=MH_BRUTE, beard=("full", 0.06), age_lines=0.4, iris=0.88, blush=0.3,
    387:                         rest={"Fcl_EYE_Angry": 0.35}, group="Round 2 · VRoid"),
    388:     "spk_mh_anime_teen": mob(None, "MakeHuman own head, 15", "soldier", "average", "young", hair="blond", eyes="blue",
    389:                              skin="fair", mh=_anime(dict(macro=dict(g=1.0, age=0.30, muscle=0.35, weight=0.4,
    390:                                                                     height=0.4, proportions=0.5))),
    391:                              hair_style="crop", group="Round 1 · bases"),
    392:     "spk_mh_anime_old": mob(None, "MakeHuman own head, 70", "soldier", "average", "young", hair="grey", eyes="grey",
    393:                             skin="tan", mh=_anime(dict(macro=dict(g=1.0, age=0.85, muscle=0.5, weight=0.6,
    394:                                                                   height=0.45, proportions=0.4))),
    395:                             hair_style="crop", beard="short", group="Round 1 · bases"),
    396:     "mob_fighter": mob("hairsample_male/HairSample_Male.vrm", "Fighter", "fighter", "athletic", "veteran", hair="black",
    397:                        eyes="grey", skin="tan", hair_from="base_male/Base_Male.vrm", beard="short"),
    398:     "mob_hoplite": mob("base_male/Base_Male.vrm", "Hoplite", "hoplite", "stocky", "stern", hair="red", eyes="blue",
    399:                        skin="fair", beard="full", height=1.09, chest=1.16, arms=1.16),

    65 more lines not shown.

  • read_file{"Path":"~/work/lowmarch/tools/session/frame.py"}

    input

    {
      "Path": "~/work/lowmarch/tools/session/frame.py"
    }

    result, 78 lines

    Showing lines 1-77 of 77
    1: """Shoot the first-session frame (docs/handbook.md): review/frame/index.html, headless, one PNG per option in the spec.
    2: 
    3:   python3 tools/session/frame.py SPEC.json OUT_DIR      writes OUT_DIR/<label>.png and OUT_DIR/frame_info.json
    4:   python3 tools/session/frame.py --info FIGURE          prints the figure's height and landmarks, for placing blocks
    5: 
    6: The figure comes from the built armory site (review/out/armory/site/<figure>.glb.json). Nothing is rebuilt, so a new
    7: option costs a few seconds. CHROMIUM picks the browser (default /snap/bin/chromium); the page loads three.js from a CDN.
    8: """
    9: import base64
    10: import json
    11: import os
    12: import re
    13: import shutil
    14: import socket
    15: import subprocess
    16: import sys
    17: import tempfile
    18: import time
    19: 
    20: ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
    21: SITE = os.environ.get("LOWMARCH_FRAME_SITE", os.path.join(ROOT, "review", "out", "armory", "site"))
    22: PAGE = os.path.join(ROOT, "review", "frame", "index.html")
    23: CHROMIUM = os.environ.get("CHROMIUM", "/snap/bin/chromium")
    24: 
    25: 
    26: def shoot(spec):
    27:     figure = spec["figure"]
    28:     src = os.path.join(SITE, f"{figure}.glb.json")
    29:     if not os.path.exists(src):
    30:         sys.exit(f"no {src}: build the armory first (handbook, How to run)")
    31:     # snap Chromium can't read outside home, and the site must hold page, spec and figure together
    32:     work = tempfile.mkdtemp(prefix="lowmarch-frame-", dir=os.path.expanduser("~/.cache"))
    33:     try:
    34:         shutil.copy(PAGE, os.path.join(work, "index.html"))
    35:         os.symlink(src, os.path.join(work, f"{figure}.glb.json"))
    36:         json.dump(spec, open(os.path.join(work, "spec.json"), "w"))
    37:         s = socket.socket()
    38:         s.bind(("127.0.0.1", 0))
    39:         port = s.getsockname()[1]
    40:         s.close()
    41:         server = subprocess.Popen([sys.executable, "-m", "http.server", str(port), "--bind", "127.0.0.1", "--directory", work],
    42:                                   stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
    43:         try:
    44:             time.sleep(0.4)
    45:             r = subprocess.run([CHROMIUM, "--headless=new", "--use-angle=swiftshader", "--enable-unsafe-swiftshader",
    46:                                 "--ignore-gpu-blocklist", "--window-size=1280,900", "--virtual-time-budget=120000",
    47:                                 "--dump-dom", f"http://127.0.0.1:{port}/index.html?spec=spec.json"],
    48:                                capture_output=True, text=True, timeout=300)
    49:         finally:
    50:             server.terminate()
    51:     finally:
    52:         shutil.rmtree(work, ignore_errors=True)
    53:     m = re.search(r'id="out"[^>]*>(\{.*?\})</textarea>', r.stdout, re.S)
    54:     if not m:
    55:         sys.exit("the frame page gave no result:\n" + r.stderr[-1500:])
    56:     return json.loads(m.group(1).replace("&quot;", '"').replace("&amp;", "&"))
    57: 
    58: 
    59: def main():
    60:     if len(sys.argv) == 3 and sys.argv[1] == "--info":
    61:         res = shoot({"figure": sys.argv[2]})
    62:         print(json.dumps({k: res[k] for k in ("height", "box", "landmarks")}, indent=1))
    63:         return
    64:     if len(sys.argv) != 3:
    65:         sys.exit(__doc__)
    66:     t0 = time.time()
    67:     spec = json.load(open(sys.argv[1]))
    68:     res = shoot(spec)
    69:     os.makedirs(sys.argv[2], exist_ok=True)
    70:     for label, data in res["shots"].items():
    71:         open(os.path.join(sys.argv[2], f"{label}.png"), "wb").write(base64.b64decode(data.split(",", 1)[1]))
    72:     json.dump({k: res[k] for k in ("height", "box", "landmarks")}, open(os.path.join(sys.argv[2], "frame_info.json"), "w"), indent=1)
    73:     print(f"{len(res['shots'])} image(s) in {sys.argv[2]}, {time.time() - t0:.0f}s, figure {res['height']} m")
    74: 
    75: 
    76: if __name__ == "__main__":
    77:     main()
  • read_file{"Path":"~/work/lowmarch/tools/session/smoke_spec.json"}

    input

    {
      "Path": "~/work/lowmarch/tools/session/smoke_spec.json"
    }

    result, 108 lines

    Showing lines 1-106 of 106
    1: {
    2:  "_note": "A test of the kit only, not a design: grey figure, placeholder blocks. tools/session/smoke.sh uses it.",
    3:  "figure": "arm_f_slender",
    4:  "frame": {
    5:   "w": 960,
    6:   "h": 540,
    7:   "camera": {
    8:    "kind": "ortho",
    9:    "yaw": 25,
    10:    "pitch": 4,
    11:    "figure_h": 0.55,
    12:    "figure_x": 0.5
    13:   }
    14:  },
    15:  "look": {
    16:   "hide": []
    17:  },
    18:  "options": [
    19:   {
    20:    "label": "A"
    21:   },
    22:   {
    23:    "label": "B",
    24:    "look": {
    25:     "hide": [
    26:      "hair"
    27:     ]
    28:    },
    29:    "blocks": [
    30:     {
    31:      "kind": "ball",
    32:      "at": "J_Bip_C_Head",
    33:      "c": [
    34:       0,
    35:       0.1,
    36:       -0.01
    37:      ],
    38:      "r": [
    39:       0.115,
    40:       0.115,
    41:       0.125
    42:      ],
    43:      "colour": "#55555e",
    44:      "shade": "#3e3e46"
    45:     },
    46:     {
    47:      "kind": "tube",
    48:      "at": "J_Bip_C_Head",
    49:      "points": [
    50:       [
    51:        0.07,
    52:        0.12,
    53:        0.09
    54:       ],
    55:       [
    56:        0.1,
    57:        0.0,
    58:        0.08
    59:       ],
    60:       [
    61:        0.11,
    62:        -0.14,
    63:        0.03
    64:       ]
    65:      ],
    66:      "radii": [
    67:       0.03,
    68:       0.035,
    69:       0.002
    70:      ],
    71:      "flat": 0.4,
    72:      "colour": "#55555e",
    73:      "shade": "#3e3e46"
    74:     },
    75:     {
    76:      "kind": "loft",
    77:      "at": "J_Bip_C_Hips",
    78:      "rings": [
    79:       {
    80:        "y": 0.05,
    81:        "rx": 0.13,
    82:        "rz": 0.1
    83:       },
    84:       {
    85:        "y": -0.45,
    86:        "rx": 0.3,
    87:        "rz": 0.26
    88:       }
    89:      ],
    90:      "colour": "#8f8f98",
    91:      "shade": "#6c6c76"
    92:     }
    93:    ]
    94:   },
    95:   {
    96:    "label": "C",
    97:    "look": {
    98:     "threshold": 0.55,
    99:     "features": true,
    100:     "skin": "#d9cfc7",
    101:     "shade": "#a58f86",
    102:     "outline": 0.003
    103:    }
    104:   }
    105:  ]
    106: }
    (no newline at end of file)