A 3D model pipeline, pushed by Gemini 4 Carbon
agent
+38:28reasoning
The export_glb.py script hardcodes the "cape" attribute as "cloth" before checking the role, which suggests a possible override issue. This means the intended role-based assignment is bypassed, and all models are assigned the "cloth" kind. This explains why the cape is always cloth.
The initial assumption was that the "cape" attribute was consistently overwritten; however, the paint data structure was the source of the persistent "cloth" assignment, specifically linked to the pc["signature"] field rather than pc["cape"]. This indicates that the previous change for build_unit needed updating to assign distinct colors. Further inspection of the output reveals visual advantages with the contrasting indigo and crimson capes, supporting the decision to preserve these colors for distinct unit roles. Reviewing outfit.py at line 969 to confirm current values.
The boots definition in mobs._base lacks an exclusion applied in outfit.py, leading to potential z-fighting. Examining how excluding "ToeBase" from boots and/or adjusting vertex positions to tuck the toes could eliminate visual artifacts. Testing whether clean dark cavalier leather boots (role="boot", pad=0.015) provide a cleaner appearance than the current steel sabaton configuration.
read_file{"EndLine":50,"Path":"~/work/lowmarch/tools/mobs.py","StartLine":1}
input
{ "EndLine": 50, "Path": "~/work/lowmarch/tools/mobs.py", "StartLine": 1 }result, 51 lines
Showing lines 1-50 of 311 1: """Common enemy units: one costume per class, built from gear.py on any base body. Generic but detailed: 2: layered padding, mail and plate, riveted straps, an army colour on the cloth and shields (portrait 3: guide, lesson 15). Pair each with a build and a face from gear.BUILDS / gear.FACES in the cast. 4: """ 5: import numpy as np 6: 7: import outfit as O 8: import gear as G 9: from fitting import Surface, merge_surfaces 10: from vrm import bone_weight 11: 12: 13: def _base(fit, shirt="padding", legs="cloth", boots="boot", gloves="glove", knee=None, shirt_subdiv=0, boot_top=None): 14: """Under layers every class shares: a shirt with sleeves to the wrist, trousers, boots to below 15: the knee (or to boot_top: above the knee, they take the thigh too), gloves. Returns the pieces and 16: the shirt (what coats are fitted over).""" 17: B = fit.bone 18: nk, hips = B["J_Bip_C_Neck"], B["J_Bip_C_Hips"] 19: knee = B["J_Bip_L_LowerLeg"][1] if knee is None else knee 20: 21: def cuff(side): 22: a, h = B[f"J_Bip_{side}_LowerArm"], B[f"J_Bip_{side}_Hand"] 23: n = (h - a) / np.linalg.norm(h - a) 24: return n, n @ (h - n * 0.02) 25: torso = ("Spine", "Chest", "UpperChest", "Bust", "Shoulder", "UpperArm", "LowerArm", "Neck", "Hips") 26: # the neckline: a straight hem, lower at the throat than at the back of the neck (a level cut of 27: # whole triangles left a saw-tooth edge, and a big trapezius showed above it) 28: nh = np.array([0.0, 1.0, -0.3]) / np.linalg.norm([0.0, 1.0, -0.3]) 29: neckline = (nh, float(nh @ (nk + np.array([0.0, 0.012, 0.0])))) 30: s = O.wrap(fit, "shirt", shirt, torso, offset=0.006, exclude=("UpperLeg",), y_min=hips[1] - 0.04, 31: y_max=nk[1] + 0.05, cut=neckline, hems=[cuff("L"), cuff("R"), neckline], subdiv=shirt_subdiv) 32: t = O.wrap(fit, "trousers", legs, ("Hips", "UpperLeg", "LowerLeg"), offset=0.007, y_max=hips[1] + 0.02, subdiv=1) 33: top = knee - 0.07 if boot_top is None else boot_top 34: b = O.wrap(fit, "boots", boots, ("LowerLeg", "Foot", "ToeBase") + (("UpperLeg",) if top > knee else ()), offset=0.015, 35: y_max=top, subdiv=1, hems=[((0, 1, 0), top - 0.005)]) 36: g = O.wrap(fit, "gloves", gloves, ("Hand", "Thumb", "Index", "Middle", "Ring", "Little"), offset=0.003, min_w=0.3, smooth=4) 37: out = [p for p in (s, t, b, g) if p is not None] 38: for p, grp in zip(out, ("doublet", "trousers", "boots", "gloves")): 39: p["group"] = grp 40: return out, s, t, b 41: 42: 43: def underwear(fit, band=False): 44: """Plain shorts (and a chest band with band=True) for inspecting bare bodies (the armory page, built 45: in the T-pose): hips to mid-thigh, close to the skin.""" 46: B = fit.bone 47: hips, knee = B["J_Bip_C_Hips"][1], B["J_Bip_L_LowerLeg"][1] 48: lo, hi = (hips + knee) / 2 + 0.03, hips + 0.07 49: # all the skin between the hems but the arms' (they hang there in the fitting pose): taking only skin 50: # weighted to the hips, legs and spine left holes where MakeHuman weights it to the chest or elsewhereread_file{"EndLine":850,"Path":"~/work/lowmarch/tools/outfit.py","StartLine":780}
input
{ "EndLine": 850, "Path": "~/work/lowmarch/tools/outfit.py", "StartLine": 780 }result, 72 lines
Showing lines 780-850 of 1272 780: def shield(fit, name, side="L", radius=0.20, boss=0.045): 781: """A round wooden shield, painted with the house's arms, strapped to the forearm's outer side: 782: a shallow dome in the signature colour, a cream chevron, a steel rim and boss.""" 783: E, H = fit.bone[f"J_Bip_{side}_LowerArm"], fit.bone[f"J_Bip_{side}_Hand"] 784: ax = (H - E) / np.linalg.norm(H - E) 785: lat = np.array([-1.0 if side == "L" else 1.0, 0, 0.0]) 786: lat -= ax * (lat @ ax) 787: lat /= np.linalg.norm(lat) 788: centre = E + ax * np.linalg.norm(H - E) * 0.48 + lat * 0.075 789: up = -ax # the shield's top points up the arm (toward the elbow) 790: fw = np.cross(lat, up) 791: rows, seg, depth = 9, 48, 0.035 792: ph = np.linspace(0, 2 * math.pi, seg + 1) 793: P = np.zeros((seg + 1, rows, 3)) 794: for j, t in enumerate(np.linspace(0, 1, rows)): 795: P[:, j] = centre + lat * depth * (1 - t * t) + np.outer(radius * t * np.cos(ph), up) + np.outer(radius * t * np.sin(ph), fw) 796: pos, tri, outer = thick_grid(P, 0.010, outward_from=centre - lat * 0.2) 797: face = piece(name, "signature", pos, tri) 798: surf = lambda u, v: centre + lat * (depth * (1 - (u * u + v * v)) + 0.0012) + up * u * radius + fw * v * radius 799: nrm_at = lambda u, v: lat + (up * u + fw * v) * 2 * depth / radius 800: chev = [(-0.48, -0.62), (0.10, -0.02), (-0.48, 0.58)] if side == "L" else [(-0.48, 0.62), (0.10, 0.02), (-0.48, -0.58)] 801: line = [] 802: for (u0, v0), (u1, v1) in zip(chev[:-1], chev[1:]): 803: for t in np.linspace(0, 1, 12, endpoint=False): 804: line.append((u0 + (u1 - u0) * t, v0 + (v1 - v0) * t)) 805: line.append(chev[-1]) 806: pts = np.array([surf(u, v) for u, v in line]) 807: nr = np.array([nrm_at(u, v) for u, v in line]) 808: device = ribbon(f"{name}_device", "heraldry", pts, width=radius * 0.24, lift=0.0, normals=nr) 809: rim = pipe(f"{name}_rim", "steel", outer[:-1, -1], r=0.0065, seg=8, closed=True) 810: bs, _ = dome(f"{name}_boss", "steel", centre + lat * (depth - 0.004), lat, up, boss, 0.026, rows=7) 811: out = [face, device, rim, bs] 812: for pc in out: 813: fit.bind(pc, rigid=f"J_Bip_{side}_LowerArm") 814: pc["group"] = "shield" 815: return out 816: 817: 818: # ---- dress, hairdo ------------------------------------------------------------------------- 819: def closed_grid_mesh(P): 820: """(U, V, 3) grid whose U direction wraps around (a skirt) -> (pos, tri).""" 821: U, V = P.shape[:2] 822: idx = np.arange(U * V).reshape(U, V) 823: a, b = idx[:, :-1], np.roll(idx, -1, 0)[:, :-1] 824: c, d = np.roll(idx, -1, 0)[:, 1:], idx[:, 1:] 825: tri = np.concatenate([np.stack([a, b, c], -1).reshape(-1, 3), np.stack([a, c, d], -1).reshape(-1, 3)]) 826: return P.reshape(-1, 3), tri 827: 828: 829: def skirt(fit, name, role, under, collide, y_top, length, flare=0.26, seg=56, rows=20, folds=9, fold_depth=0.012, 830: clear=(0.004, 0.02)): 831: """A full skirt: a closed ring at the waist cast onto `under`, belling out to the hem, settled 832: by the cloth solve against the legs. Simulated in the viewer as closed cloth (no seam).""" 833: cz = fit.bone["J_Bip_C_Hips"][2] 834: o = np.array([0.0, y_top, cz]) 835: ang = np.linspace(0, 2 * math.pi, seg, endpoint=False) 836: rad = np.stack([np.sin(ang), np.zeros_like(ang), np.cos(ang)], 1) 837: top = [] 838: for d in rad: 839: r = under.cast(o, d, rmax=0.3, far=True) 840: top.append(o + d * ((0.13 if np.isnan(r) else r) + clear[0])) 841: top = np.array(top) 842: P = np.zeros((seg, rows, 3)) 843: for j, t in enumerate(np.linspace(0, 1, rows)): 844: bell = flare * (1 - (1 - t) ** 1.6) # flares fast below the hips, then falls 845: wave = fold_depth * t * np.sin(ang * folds + 0.4) 846: P[:, j] = top + rad * (bell + wave)[:, None] + np.array([0, -length * t, 0]) 847: pinned = np.zeros((seg, rows), bool) 848: pinned[:, 0] = True 849: P = drape(P, collide, clear[0] + (clear[1] - clear[0]) * np.linspace(0, 1, rows), pinned, steps=60, closed=True) 850: pos, tri = closed_grid_mesh(P)read_file{"EndLine":780,"Path":"~/work/lowmarch/tools/outfit.py","StartLine":710}
input
{ "EndLine": 780, "Path": "~/work/lowmarch/tools/outfit.py", "StartLine": 710 }result, 72 lines
Showing lines 710-780 of 1272 710: pc = piece(name, role, pos, tri, outward_from=o, axis=[0, 1, 0]) 711: fit.bind(pc, allow=("Hips", "UpperLeg"), fallback="J_Bip_C_Hips") 712: pc["grid"] = (seg, rows) 713: return pc, P 714: 715: 716: def mantle(fit, name, role, over, seg=64, rows=16, gap_deg=12, clear=(0.010, 0.016)): 717: """A hooded scarf (the study's lord wears one in his signature colour): a ring at the base of 718: the neck, open at the front where it is clasped, falling over the breastplate in front and 719: lower at the back, short at the sides so the spaulders stand over its edges. The hood lies 720: bunched behind the neck. `over` should not include the spaulders: they overhang the arm, and 721: a ray out of the neck that passes under one would pull the cloth into that gap.""" 722: nk = fit.bone["J_Bip_C_Neck"] 723: half = math.radians(180 - gap_deg / 2) 724: ang = np.linspace(-half, half, seg) # 0 = back (+z), +-pi = front 725: rad = np.stack([np.sin(ang), np.zeros_like(ang), np.cos(ang)], 1) 726: neck = Surface(fit.pos, fit.tris_for(("Neck", "UpperChest"), min_w=0.3)) 727: top = [] 728: for a, d in zip(ang, rad): 729: front = (1 - math.cos(a)) / 2 730: o = np.array([nk[0], nk[1] - 0.008 - 0.030 * front, nk[2]]) 731: r = neck.cast(o, d, rmax=0.2, far=False) 732: top.append(o + d * ((0.055 if np.isnan(r) else r) + 0.024)) 733: top = np.array(top) 734: back = np.clip(np.cos(ang), 0, 1) ** 2 735: frnt = np.clip(-np.cos(ang), 0, 1) ** 2 736: L = 0.035 + 0.105 * frnt + 0.135 * back # short at the sides: the spaulders sit over its edges 737: P = np.zeros((seg, rows, 3)) 738: for j, t in enumerate(np.linspace(0, 1, rows)): 739: P[:, j] = top + rad * (0.05 * min(1.0, t * 2.5)) + np.outer(L * t, [0, -1, 0]) 740: # start outside everything it covers (plate included): the cloth solve only pushes outward along 741: # the nearest face, so a mantle that starts inside the breastplate stays there 742: clr = clear[0] + (clear[1] - clear[0]) * np.linspace(0, 1, rows) 743: 744: def push_out(P): 745: """Move each vertex outside the outermost surface on a level ray from the neck axis.""" 746: for i in range(seg): 747: for j in range(rows): 748: o = np.array([nk[0], P[i, j, 1], nk[2]]) 749: d = P[i, j] - o 750: d[1] = 0 751: dist = np.linalg.norm(d) 752: d /= max(dist, 1e-9) 753: r = over.cast(o, d, rmax=0.30, far=True) 754: if not np.isnan(r) and dist < r + clr[j]: 755: P[i, j] = o + d * (r + clr[j]) + np.array([0, P[i, j, 1] - o[1], 0]) 756: return P 757: 758: P = push_out(P) 759: pinned = np.zeros((seg, rows), bool) 760: pinned[:, 0] = True 761: P = drape(P, over, clr, pinned, steps=110, bend=0.4) 762: for j, t in enumerate(np.linspace(0, 1, rows)): # soft folds toward the hem 763: P[:, j] += rad * (0.006 * t * np.sin(ang * 9 + 0.7))[:, None] 764: P = push_out(P) # and nothing pokes through after settling 765: pos, tri = grid_mesh(P) 766: pc = piece(name, role, pos, tri, outward_from=nk + [0, -0.25, 0], axis=[0, 1, 0]) 767: fit.bind(pc, allow=("Neck", "UpperChest", "Shoulder", "Chest"), fallback="J_Bip_C_UpperChest") 768: # the hood, folded down: a thick roll around the back half of the ring 769: k = np.where(np.abs(ang) < math.radians(105))[0] 770: lift = top[k] + rad[k] * 0.012 + np.array([0, 0.016, 0]) 771: hood = pipe(f"{name}_hood", role, lift, r=0.024, seg=10) 772: w = np.abs(ang[k]) / math.radians(105) # the roll thins toward the shoulders 773: hp = hood["pos"].reshape(len(k), 11, 3) 774: hp[:] = lift[:, None] + (hp - lift[:, None]) * (1 - 0.55 * w ** 2)[:, None, None] 775: hood["pos"] = hp.reshape(-1, 3) 776: inherit(hood, pc) 777: return pc, P, hood 778: 779: 780: def shield(fit, name, side="L", radius=0.20, boss=0.045):read_file{"EndLine":715,"Path":"~/work/lowmarch/tools/outfit.py","StartLine":660}
input
{ "EndLine": 715, "Path": "~/work/lowmarch/tools/outfit.py", "StartLine": 660 }result, 57 lines
Showing lines 660-715 of 1272 660: 661: def joint_guard(fit, name, joint, child, toward, side, over, r=0.034, wing=0.062, depth=0.020): 662: """Couter or poleyn: a domed cap over the point of the joint plus a fan wing on its outer 663: side (study: about 1.5x the joint's width). Rides the lower bone.""" 664: J, C = fit.bone[joint], fit.bone[child] 665: ax = (C - J) / np.linalg.norm(C - J) 666: tw = np.asarray(toward, float) - ax * (np.asarray(toward, float) @ ax) 667: tw /= np.linalg.norm(tw) 668: lat = np.array([-1.0 if side == "L" else 1.0, 0, 0]) 669: lat -= ax * (lat @ ax) + tw * (lat @ tw) 670: lat /= np.linalg.norm(lat) 671: reach = over.cast(J, tw, rmax=0.15, far=True) 672: reach = 0.045 if np.isnan(reach) else reach 673: side_r = over.cast(J, lat, rmax=0.15, far=True) 674: side_r = 0.045 if np.isnan(side_r) else side_r 675: cap, cap_rim = dome(f"{name}_cap", "steel", J + tw * (reach - depth * 0.35), tw, -ax, r, depth) 676: wg, wing_rim = fan(f"{name}_wing", "steel", J + lat * (side_r + 0.010) + tw * reach * 0.35, tw, ax, lat, wing) 677: return [cap, wg], [cap_rim, wing_rim] 678: 679: 680: def panel(fit, name, role, under, collide, y_top, centre_deg, half_width, length, seg=14, rows=22, 681: clear=(0.006, 0.020), steps=70): 682: """A hanging cloth panel (tabard front or back) pinned along a belt line: its top row follows 683: `under` across `half_width` metres either side of `centre_deg` (0 = front), then it settles 684: against `collide` (legs, tassets, greaves).""" 685: cz = fit.bone["J_Bip_C_Hips"][2] 686: o = np.array([0.0, y_top, cz]) 687: r0 = under.cast(o, np.array([math.sin(math.radians(centre_deg)), 0, -math.cos(math.radians(centre_deg))]), 688: rmax=0.3, far=True) 689: r0 = 0.15 if np.isnan(r0) else r0 690: half = half_width / max(r0, 0.05) 691: ang = math.radians(centre_deg) + np.linspace(-half, half, seg) 692: rad = np.stack([np.sin(ang), np.zeros_like(ang), -np.cos(ang)], 1) 693: top = [] 694: for d in rad: 695: r = under.cast(o, d, rmax=0.3, far=True) 696: top.append(o + d * ((r0 if np.isnan(r) else r) + clear[0])) 697: top = np.array(top) 698: flat = top.copy() # a panel hangs flat, not wrapped around the body 699: mid = top[seg // 2] 700: out_dir = rad[seg // 2] 701: flat -= np.outer((top - mid) @ out_dir, out_dir) * 0.6 702: P = np.zeros((seg, rows, 3)) 703: for j, t in enumerate(np.linspace(0, 1, rows)): 704: P[:, j] = flat + out_dir * 0.03 * min(1.0, t * 3) + np.array([0, -length * t, 0]) 705: P[:, 0] = top 706: pinned = np.zeros((seg, rows), bool) 707: pinned[:, 0] = True 708: P = drape(P, collide, clear[0] + (clear[1] - clear[0]) * np.linspace(0, 1, rows), pinned, steps=steps) 709: pos, tri = grid_mesh(P) 710: pc = piece(name, role, pos, tri, outward_from=o, axis=[0, 1, 0]) 711: fit.bind(pc, allow=("Hips", "UpperLeg"), fallback="J_Bip_C_Hips") 712: pc["grid"] = (seg, rows) 713: return pc, P 714: 715:read_file{"EndLine":555,"Path":"~/work/lowmarch/tools/outfit.py","StartLine":450}
input
{ "EndLine": 555, "Path": "~/work/lowmarch/tools/outfit.py", "StartLine": 450 }result, 107 lines
Showing lines 450-555 of 1272 450: ph = np.linspace(-phi, phi, seg) * math.pi # 0 = straight back 451: rad = np.stack([np.sin(ph), np.zeros_like(ph), np.cos(ph)], 1) 452: top = [] 453: for a, d in zip(ph, rad): 454: front = (1 - math.cos(a)) / 2 455: o = np.array([nk[0], nk[1] - 0.013 - 0.032 * front, nk[2]]) # under the collar, down to the clasps 456: r = under.cast(o, d, rmax=0.3, far=True) 457: top.append(o + d * ((0.08 if np.isnan(r) else r) + top_clear)) 458: top = np.array(top) 459: P = np.zeros((seg, rows, 3)) 460: for j, t in enumerate(np.linspace(0, 1, rows)): 461: P[:, j] = top + rad * (0.10 * min(1.0, t * 4)) + np.array([0, -length * t, 0]) 462: pinned = np.zeros((seg, rows), bool) 463: pinned[:, 0] = True 464: P = drape(P, under, clear[0] + (clear[1] - clear[0]) * np.linspace(0, 1, rows), pinned) 465: for j, t in enumerate(np.linspace(0, 1, rows)): 466: P[:, j] += rad * (fold_depth * t * np.sin(ph * folds * 2 + 0.5))[:, None] 467: pos, tri = grid_mesh(P) 468: pc = piece(name, role, pos, tri, outward_from=nk + [0, -0.3, 0], axis=[0, 1, 0]) 469: fit.bind(pc, allow=("Spine", "Chest", "UpperChest", "Neck", "Shoulder"), fallback="J_Bip_C_UpperChest") 470: pc["grid"] = (seg, rows) # the viewer simulates it as cloth: top row pinned 471: return pc, P 472: 473: 474: def tails(fit, name, role, under, y_top, length=0.36, front_gap=60, seg=40, rows=12, clear=(0.012, 0.030)): 475: """Tunic tails from under the belt, open at the front, settled against the legs.""" 476: ang = np.radians(np.linspace(-(180 - front_gap / 2), 180 - front_gap / 2, seg)) 477: cz = fit.bone["J_Bip_C_Hips"][2] 478: rad = np.stack([np.sin(ang), np.zeros_like(ang), np.cos(ang)], 1) 479: top = [] 480: for d in rad: 481: o = np.array([0.0, y_top, cz]) 482: r = under.cast(o, d, rmax=0.25, far=True) 483: top.append(o + d * ((0.14 if np.isnan(r) else r) + clear[0])) 484: top = np.array(top) 485: P = np.zeros((seg, rows, 3)) 486: for j, t in enumerate(np.linspace(0, 1, rows)): 487: P[:, j] = top + rad * (0.01 * t) + np.array([0, -length * t, 0]) 488: pinned = np.zeros((seg, rows), bool) 489: pinned[:, 0] = True 490: P = drape(P, under, clear[0] + (clear[1] - clear[0]) * np.linspace(0, 1, rows), pinned, steps=60) 491: pos, tri = grid_mesh(P) 492: pc = piece(name, role, pos, tri, outward_from=[0, y_top, cz], axis=[0, 1, 0]) 493: fit.bind(pc, allow=("Hips", "UpperLeg"), fallback="J_Bip_C_Hips") 494: pc["grid"] = (seg, rows) 495: return pc, P 496: 497: 498: def belt(fit, name, role, over, y, height=0.034, offset=0.006, thickness=0.005, seg=56, tilt=0.0): 499: """A band around the waist cast onto `over`. tilt: metres higher on the character's right hip 500: than the left (a slung second belt).""" 501: cz = fit.bone["J_Bip_C_Hips"][2] 502: ang = np.linspace(-math.pi, math.pi, seg) 503: P = np.zeros((seg, 2, 3)) 504: for i, a in enumerate(ang): 505: d = np.array([math.sin(a), 0, math.cos(a)]) 506: for j, dy in enumerate((height / 2, -height / 2)): 507: o = np.array([0.0, y + dy + tilt * math.sin(a), cz]) 508: r = over.cast(o, d, rmax=0.4, far=True) 509: P[i, j] = o + d * ((0.15 if np.isnan(r) else r) + offset) 510: pos, tri, outer = thick_grid(P, thickness, outward_from=[0, y, cz], axis=[0, 1, 0]) 511: pc = fit.bind(piece(name, role, pos, tri), rigid="J_Bip_C_Hips") 512: front = outer[np.argmin(np.abs(np.abs(ang) - math.pi))].mean(0) 513: pc["group"] = "belt" 514: return pc, front 515: 516: 517: def sword(fit, hand="R", blade_len=0.80, blade_w=0.042, grip_len=0.15, hilt="gold", grip="leather"): 518: """A one-handed sword held in the fist. In the hand's frame the fingers run along +x (right 519: hand), the palm faces -y and the fist's hole runs front-back (z): the blade leaves the thumb 520: side, pointing forward. Rigid on the hand bone.""" 521: M = fit.world[f"J_Bip_{hand}_Hand"] 522: R, o = M[:3, :3], M[:3, 3] 523: R = R / np.linalg.norm(R, axis=0) # the hand bone may be scaled (body proportions) 524: sx = 1 if hand == "R" else -1 525: fist = o + R @ np.array([sx * 0.045, -0.018, 0.0]) 526: fwd = R @ np.array([0, 0, -1.0]) 527: side = R @ np.array([sx * 1.0, 0, 0]) 528: flat = np.cross(fwd, side) 529: out = [tube("grip", grip, fist - fwd * grip_len * 0.55, fwd, grip_len, 0.0135), 530: ball("pommel", hilt, fist - fwd * (grip_len * 0.55 + 0.012), 0.02)] 531: guard_c = fist + fwd * (grip_len * 0.45 + 0.008) 532: out.append(box("guard", hilt, guard_c, (side, flat, fwd), (0.095, 0.014, 0.012))) 533: base = guard_c + fwd * 0.012 534: rows = 12 535: P = np.zeros((5, rows, 3)) 536: for j, t in enumerate(np.linspace(0, 1, rows)): 537: taper = 1.0 if t < 0.82 else max(0.0, (1 - t) / 0.18) 538: w = blade_w / 2 * (1 - 0.15 * t) * taper 539: th = 0.0045 * taper 540: c = base + fwd * blade_len * t 541: P[:, j] = [c + side * w, c + flat * th, c - side * w, c - flat * th, c + side * w] 542: pos, tri = grid_mesh(P) 543: out.append(piece("blade", "steel", pos, tri, outward_from=base + fwd * blade_len / 2, axis=fwd)) 544: out.append(ribbon("fuller", "metal", [base + fwd * blade_len * t + flat * 0.0047 for t in np.linspace(0.04, 0.7, 10)], 545: width=blade_w * 0.18, lift=0.0005, normals=np.tile(flat, (10, 1)))) 546: for pc in out: 547: fit.bind(pc, rigid=f"J_Bip_{hand}_Hand") 548: return out 549: 550: 551: # ---- plate kit (Unicorn Overlord study, docs/study.md): lames, shells, caps with fan wings ------ 552: def pipe(name, role, curve, r=0.0026, seg=6, closed=False): 553: """A thin tube along a polyline: the rolled edge of a plate, piping, a cord.""" 554: C = np.asarray(curve, float) 555: if closed:
agent
+39:06reasoning
The O.cape definition, specifically the ph calculation, uses phi = 0.54. This value, when converted to degrees (0.54 * 180°), results in 97.2°, which appears to define the cape's curvature. This strongly suggests that the 0.54 value is a key parameter shaping the cape's appearance.
The cape's top row is pinned, and its default clearance of 4mm is insufficient, leading to clipping when the character's arm crosses the chest, deforming the underlying armor. Modifying the cape's phi value and increasing top_clear significantly improves the cloth simulation, eliminating the penetration. The belt definition uses a rigid binding on the hips, unlike the flexible vest, which allows deformation on spine and chest bones.
The belt's detachment from the brigandine is likely due to the brigandine's spine-based movement while the belt remains tied to the hips. Binding the belt to the brigandine using inheritance or a similar binding strategy, allowing movement along both spine and hips, should resolve this. The boots penetrate the sabaton because the boots have a greater offset than the sabaton's padding. Increasing the sabaton's padding should resolve the penetration.
read_file{"EndLine":455,"Path":"~/work/lowmarch/tools/outfit.py","StartLine":442}
input
{ "EndLine": 455, "Path": "~/work/lowmarch/tools/outfit.py", "StartLine": 442 }result, 15 lines
Showing lines 442-455 of 1272 442: return P.reshape(U, V, 3) 443: 444: 445: def cape(fit, name, role, under, length=1.0, phi=0.55, seg=44, rows=18, top_clear=0.003, 446: clear=(0.010, 0.045), folds=7, fold_depth=0.010): 447: """A cape whose top edge lies on the tunic around the base of the neck, clasped at the 448: collarbones, then settled by the cloth solve so it rests on the shoulders and falls clear.""" 449: nk = fit.bone["J_Bip_C_Neck"] 450: ph = np.linspace(-phi, phi, seg) * math.pi # 0 = straight back 451: rad = np.stack([np.sin(ph), np.zeros_like(ph), np.cos(ph)], 1) 452: top = [] 453: for a, d in zip(ph, rad): 454: front = (1 - math.cos(a)) / 2 455: o = np.array([nk[0], nk[1] - 0.013 - 0.032 * front, nk[2]]) # under the collar, down to the clasps
run_command{"CommandLine":"python3 -c '\nimport sys, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, poses as P, vroid_portrait as vp\nfrom cast import CAST\nfrom rig import Rig\nvrm = vp.VRM(cage.path_for(\"arm_f_strong\", CAST[\"arm_f_strong\"][\"cage\"]))\nrig = Rig(vrm, {\"arm_out\": 8.0}, ortho=True)\n# Check shield lat in BUST pose\nW_bust = rig.world(P.BUST)\nE = W_bust[\"J_Bip_L_LowerArm\"][:3, 3]\nH = W_bust[\"J_Bip_L_Hand\"][:3, 3]\nax = (H - E) / np.linalg.norm(H - E)\nlat = np.array([-1.0, 0.0, 0.0]) - ax * (-ax[0])\nlat /= np.linalg.norm(lat)\nR0 = W_bust[\"J_Bip_L_LowerArm\"][:3, :3]\nlat_local = R0.T @ lat\nbase = P.merge(P.BATTLE_IDLE, {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n})\nsh_l = rig.pos(base, \"J_Bip_L_UpperArm\")\np0 = rig.arm_ik(base, \"L\", sh_l + np.array([-0.22, -0.22, -0.14]), pole=(-0.5, -1.0, 0.2))\nax_la = rig.pos(p0, \"J_Bip_L_Hand\") - rig.pos(p0, \"J_Bip_L_LowerArm\")\n# Note: in GLB + yaw=+32 deg: F4 flips x and z, then Ry(+32 deg). Camera looks from +Z_scene toward -Z_scene!\nF3 = np.diag([-1.0, 1.0, -1.0])\na = np.radians(32.0)\nRy = np.array([[np.cos(a), 0, np.sin(a)], [0, 1, 0], [-np.sin(a), 0, np.cos(a)]])\nfor deg in (-120, -90, -70, -50, 0, 50, 90, 120, 150):\n p = rig.rotate_world(p0, \"J_Bip_L_LowerArm\", P.rot(ax_la, deg))\n R1 = rig.world(p)[\"J_Bip_L_LowerArm\"][:3, :3]\n n_vrm = R1 @ lat_local\n n_cam = Ry @ F3 @ n_vrm\n u_vrm = R1 @ (R0.T @ (-ax))\n u_cam = Ry @ F3 @ u_vrm\n print(f\"deg={deg:4d}: shield_out_cam={np.round(n_cam, 2)} shield_top_cam={np.round(u_cam, 2)}\")\n'","WaitMsBeforeAsync":5000,"toolSummary":"Compute exact shield normal in camera space"}error
input
{ "CommandLine": "python3 -c '\nimport sys, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, poses as P, vroid_portrait as vp\nfrom cast import CAST\nfrom rig import Rig\nvrm = vp.VRM(cage.path_for(\"arm_f_strong\", CAST[\"arm_f_strong\"][\"cage\"]))\nrig = Rig(vrm, {\"arm_out\": 8.0}, ortho=True)\n# Check shield lat in BUST pose\nW_bust = rig.world(P.BUST)\nE = W_bust[\"J_Bip_L_LowerArm\"][:3, 3]\nH = W_bust[\"J_Bip_L_Hand\"][:3, 3]\nax = (H - E) / np.linalg.norm(H - E)\nlat = np.array([-1.0, 0.0, 0.0]) - ax * (-ax[0])\nlat /= np.linalg.norm(lat)\nR0 = W_bust[\"J_Bip_L_LowerArm\"][:3, :3]\nlat_local = R0.T @ lat\nbase = P.merge(P.BATTLE_IDLE, {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n})\nsh_l = rig.pos(base, \"J_Bip_L_UpperArm\")\np0 = rig.arm_ik(base, \"L\", sh_l + np.array([-0.22, -0.22, -0.14]), pole=(-0.5, -1.0, 0.2))\nax_la = rig.pos(p0, \"J_Bip_L_Hand\") - rig.pos(p0, \"J_Bip_L_LowerArm\")\n# Note: in GLB + yaw=+32 deg: F4 flips x and z, then Ry(+32 deg). Camera looks from +Z_scene toward -Z_scene!\nF3 = np.diag([-1.0, 1.0, -1.0])\na = np.radians(32.0)\nRy = np.array([[np.cos(a), 0, np.sin(a)], [0, 1, 0], [-np.sin(a), 0, np.cos(a)]])\nfor deg in (-120, -90, -70, -50, 0, 50, 90, 120, 150):\n p = rig.rotate_world(p0, \"J_Bip_L_LowerArm\", P.rot(ax_la, deg))\n R1 = rig.world(p)[\"J_Bip_L_LowerArm\"][:3, :3]\n n_vrm = R1 @ lat_local\n n_cam = Ry @ F3 @ n_vrm\n u_vrm = R1 @ (R0.T @ (-ax))\n u_cam = Ry @ F3 @ u_vrm\n print(f\"deg={deg:4d}: shield_out_cam={np.round(n_cam, 2)} shield_top_cam={np.round(u_cam, 2)}\")\n'", "WaitMsBeforeAsync": 5000, "toolSummary": "Compute exact shield normal in camera space" }result, error, 6 lines
Command exited with code 1. Command output: Traceback (most recent call last): File "<string>", line 11, in <module> KeyError: 'J_Bip_L_LowerArm'
agent
+39:35reasoning
The root cause of the pinning issue appears to be an extremely small offset value, specifically 3 millimeters, used in the outfit code. This tiny offset between the cape's pinned row and the underlying gambeson is the direct cause of the cloth simulation penetration.
run_command{"CommandLine":"python3 -c '\nimport sys, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, poses as P, vroid_portrait as vp\nfrom cast import CAST\nfrom rig import Rig\nvrm = vp.VRM(cage.path_for(\"arm_f_strong\", CAST[\"arm_f_strong\"][\"cage\"]))\nrig = Rig(vrm, {\"arm_out\": 8.0}, ortho=True)\ni_la = rig.idx[\"J_Bip_L_LowerArm\"]\nW_bust = rig.world(P.BUST)\nE = rig.pos(P.BUST, \"J_Bip_L_LowerArm\")\nH = rig.pos(P.BUST, \"J_Bip_L_Hand\")\nax = (H - E) / np.linalg.norm(H - E)\nlat = np.array([-1.0, 0.0, 0.0]) - ax * (-ax[0])\nlat /= np.linalg.norm(lat)\nR0 = W_bust[i_la][:3, :3]\nlat_local = R0.T @ lat\nup_local = R0.T @ (-ax)\nbase = P.merge(P.BATTLE_IDLE, {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n})\nsh_l = rig.pos(base, \"J_Bip_L_UpperArm\")\n# Hold forearm horizontally across/outward so shield stands upright!\np0 = rig.arm_ik(base, \"L\", sh_l + np.array([-0.14, -0.14, -0.22]), pole=(-0.9, -0.8, 0.3))\nax_la = rig.pos(p0, \"J_Bip_L_Hand\") - rig.pos(p0, \"J_Bip_L_LowerArm\")\nF3 = np.diag([-1.0, 1.0, -1.0])\na = np.radians(32.0)\nRy = np.array([[np.cos(a), 0, np.sin(a)], [0, 1, 0], [-np.sin(a), 0, np.cos(a)]])\nprint(\"forearm dir in cam:\", np.round(Ry @ F3 @ (ax_la / np.linalg.norm(ax_la)), 2))\nfor deg in range(-180, 180, 30):\n p = rig.rotate_world(p0, \"J_Bip_L_LowerArm\", P.rot(ax_la, deg))\n R1 = rig.world(p)[i_la][:3, :3]\n n_cam = Ry @ F3 @ (R1 @ lat_local)\n u_cam = Ry @ F3 @ (R1 @ up_local)\n print(f\"deg={deg:4d}: shield_out_cam={np.round(n_cam, 2)} shield_top_cam={np.round(u_cam, 2)}\")\n'","WaitMsBeforeAsync":5000,"toolSummary":"Print shield normal across forearm rotations"}error
input
{ "CommandLine": "python3 -c '\nimport sys, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, poses as P, vroid_portrait as vp\nfrom cast import CAST\nfrom rig import Rig\nvrm = vp.VRM(cage.path_for(\"arm_f_strong\", CAST[\"arm_f_strong\"][\"cage\"]))\nrig = Rig(vrm, {\"arm_out\": 8.0}, ortho=True)\ni_la = rig.idx[\"J_Bip_L_LowerArm\"]\nW_bust = rig.world(P.BUST)\nE = rig.pos(P.BUST, \"J_Bip_L_LowerArm\")\nH = rig.pos(P.BUST, \"J_Bip_L_Hand\")\nax = (H - E) / np.linalg.norm(H - E)\nlat = np.array([-1.0, 0.0, 0.0]) - ax * (-ax[0])\nlat /= np.linalg.norm(lat)\nR0 = W_bust[i_la][:3, :3]\nlat_local = R0.T @ lat\nup_local = R0.T @ (-ax)\nbase = P.merge(P.BATTLE_IDLE, {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n})\nsh_l = rig.pos(base, \"J_Bip_L_UpperArm\")\n# Hold forearm horizontally across/outward so shield stands upright!\np0 = rig.arm_ik(base, \"L\", sh_l + np.array([-0.14, -0.14, -0.22]), pole=(-0.9, -0.8, 0.3))\nax_la = rig.pos(p0, \"J_Bip_L_Hand\") - rig.pos(p0, \"J_Bip_L_LowerArm\")\nF3 = np.diag([-1.0, 1.0, -1.0])\na = np.radians(32.0)\nRy = np.array([[np.cos(a), 0, np.sin(a)], [0, 1, 0], [-np.sin(a), 0, np.cos(a)]])\nprint(\"forearm dir in cam:\", np.round(Ry @ F3 @ (ax_la / np.linalg.norm(ax_la)), 2))\nfor deg in range(-180, 180, 30):\n p = rig.rotate_world(p0, \"J_Bip_L_LowerArm\", P.rot(ax_la, deg))\n R1 = rig.world(p)[i_la][:3, :3]\n n_cam = Ry @ F3 @ (R1 @ lat_local)\n u_cam = Ry @ F3 @ (R1 @ up_local)\n print(f\"deg={deg:4d}: shield_out_cam={np.round(n_cam, 2)} shield_top_cam={np.round(u_cam, 2)}\")\n'", "WaitMsBeforeAsync": 5000, "toolSummary": "Print shield normal across forearm rotations" }result, error, 6 lines
Command exited with code 1. Command output: Traceback (most recent call last): File "<string>", line 9, in <module> AttributeError: 'Rig' object has no attribute 'idx'
run_command{"CommandLine":"python3 -c '\nimport sys, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, poses as P, vroid_portrait as vp\nfrom cast import CAST\nfrom rig import Rig\nvrm = vp.VRM(cage.path_for(\"arm_f_strong\", CAST[\"arm_f_strong\"][\"cage\"]))\nrig = Rig(vrm, {\"arm_out\": 8.0}, ortho=True)\ni_la = vrm.nodes_by_name()[\"J_Bip_L_LowerArm\"]\nW_bust = rig.world(P.BUST)\nE = rig.pos(P.BUST, \"J_Bip_L_LowerArm\")\nH = rig.pos(P.BUST, \"J_Bip_L_Hand\")\nax = (H - E) / np.linalg.norm(H - E)\nlat = np.array([-1.0, 0.0, 0.0]) - ax * (-ax[0])\nlat /= np.linalg.norm(lat)\nR0 = W_bust[i_la][:3, :3]\nlat_local = R0.T @ lat\nup_local = R0.T @ (-ax)\nbase = P.merge(P.BATTLE_IDLE, {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n})\nsh_l = rig.pos(base, \"J_Bip_L_UpperArm\")\np0 = rig.arm_ik(base, \"L\", sh_l + np.array([-0.18, -0.26, -0.14]), pole=(-0.9, -0.5, 0.5))\nax_la = rig.pos(p0, \"J_Bip_L_Hand\") - rig.pos(p0, \"J_Bip_L_LowerArm\")\nF3 = np.diag([-1.0, 1.0, -1.0])\na = np.radians(32.0)\nRy = np.array([[np.cos(a), 0, np.sin(a)], [0, 1, 0], [-np.sin(a), 0, np.cos(a)]])\nprint(\"forearm dir in cam:\", np.round(Ry @ F3 @ (ax_la / np.linalg.norm(ax_la)), 2))\nfor deg in range(-180, 180, 30):\n p = rig.rotate_world(p0, \"J_Bip_L_LowerArm\", P.rot(ax_la, deg))\n R1 = rig.world(p)[i_la][:3, :3]\n n_cam = Ry @ F3 @ (R1 @ lat_local)\n u_cam = Ry @ F3 @ (R1 @ up_local)\n print(f\"deg={deg:4d}: shield_out_cam={np.round(n_cam, 2)} shield_top_cam={np.round(u_cam, 2)}\")\n'","WaitMsBeforeAsync":5000,"toolSummary":"Check shield normal and upright vector in camera space"}
input
{ "CommandLine": "python3 -c '\nimport sys, numpy as np\nsys.path[:0] = [\"tools\", \"art/cast\"]\nimport cage, poses as P, vroid_portrait as vp\nfrom cast import CAST\nfrom rig import Rig\nvrm = vp.VRM(cage.path_for(\"arm_f_strong\", CAST[\"arm_f_strong\"][\"cage\"]))\nrig = Rig(vrm, {\"arm_out\": 8.0}, ortho=True)\ni_la = vrm.nodes_by_name()[\"J_Bip_L_LowerArm\"]\nW_bust = rig.world(P.BUST)\nE = rig.pos(P.BUST, \"J_Bip_L_LowerArm\")\nH = rig.pos(P.BUST, \"J_Bip_L_Hand\")\nax = (H - E) / np.linalg.norm(H - E)\nlat = np.array([-1.0, 0.0, 0.0]) - ax * (-ax[0])\nlat /= np.linalg.norm(lat)\nR0 = W_bust[i_la][:3, :3]\nlat_local = R0.T @ lat\nup_local = R0.T @ (-ax)\nbase = P.merge(P.BATTLE_IDLE, {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n})\nsh_l = rig.pos(base, \"J_Bip_L_UpperArm\")\np0 = rig.arm_ik(base, \"L\", sh_l + np.array([-0.18, -0.26, -0.14]), pole=(-0.9, -0.5, 0.5))\nax_la = rig.pos(p0, \"J_Bip_L_Hand\") - rig.pos(p0, \"J_Bip_L_LowerArm\")\nF3 = np.diag([-1.0, 1.0, -1.0])\na = np.radians(32.0)\nRy = np.array([[np.cos(a), 0, np.sin(a)], [0, 1, 0], [-np.sin(a), 0, np.cos(a)]])\nprint(\"forearm dir in cam:\", np.round(Ry @ F3 @ (ax_la / np.linalg.norm(ax_la)), 2))\nfor deg in range(-180, 180, 30):\n p = rig.rotate_world(p0, \"J_Bip_L_LowerArm\", P.rot(ax_la, deg))\n R1 = rig.world(p)[i_la][:3, :3]\n n_cam = Ry @ F3 @ (R1 @ lat_local)\n u_cam = Ry @ F3 @ (R1 @ up_local)\n print(f\"deg={deg:4d}: shield_out_cam={np.round(n_cam, 2)} shield_top_cam={np.round(u_cam, 2)}\")\n'", "WaitMsBeforeAsync": 5000, "toolSummary": "Check shield normal and upright vector in camera space" }result, 16 lines
Command exited with code 0. Command output: forearm dir in cam: [ 0.3 -0.37 0.88] deg=-180: shield_out_cam=[-0.74 -0.67 -0.03] shield_top_cam=[-0.3 0.37 -0.88] deg=-150: shield_out_cam=[-0.35 -0.9 -0.26] shield_top_cam=[-0.3 0.37 -0.88] deg=-120: shield_out_cam=[ 0.15 -0.89 -0.43] shield_top_cam=[-0.3 0.37 -0.88] deg= -90: shield_out_cam=[ 0.6 -0.65 -0.48] shield_top_cam=[-0.3 0.37 -0.88] deg= -60: shield_out_cam=[ 0.89 -0.23 -0.4 ] shield_top_cam=[-0.3 0.37 -0.88] deg= -30: shield_out_cam=[ 0.94 0.26 -0.21] shield_top_cam=[-0.3 0.37 -0.88] deg= 0: shield_out_cam=[0.74 0.67 0.03] shield_top_cam=[-0.3 0.37 -0.88] deg= 30: shield_out_cam=[0.35 0.9 0.26] shield_top_cam=[-0.3 0.37 -0.88] deg= 60: shield_out_cam=[-0.15 0.89 0.43] shield_top_cam=[-0.3 0.37 -0.88] deg= 90: shield_out_cam=[-0.6 0.65 0.48] shield_top_cam=[-0.3 0.37 -0.88] deg= 120: shield_out_cam=[-0.89 0.23 0.4 ] shield_top_cam=[-0.3 0.37 -0.88] deg= 150: shield_out_cam=[-0.94 -0.26 0.21] shield_top_cam=[-0.3 0.37 -0.88]
agent
+40:11reasoning
The print output reveals a direct correlation between the forearm direction and the shield's camera perspective. Initial hypothesis of a simple rotation mismatch seems correct; the horizontal tilt observed on the heater shield can be attributed to the sign differences in these vectors. The horizontal component of the vector values for each is inverted, which explains the observed rotation.
The heater shield's orientation is linked to the forearm's direction, specifically using -ax for the shield's 'up' vector. This construct results in the shield tilting backward when the forearm bends forward, because this setup implies the shield follows the forearm's motion rather than remaining upright. A more accurate model would involve a different 'up' vector calculation, such as a vector perpendicular to the forearm, to replicate a proper strapped shield.
Initial hypothesis: Shield should be built directly in the guard-ready orientation for correct representation. The shield's top and outward camera vectors are recalculated to ensure the convex front, gold chevron, and steel boss are facing the camera and opponent at the intended angles. This revised orientation also keeps Valen's forearm behind the shield.
Verifying the model with a 1-second Python check to define desired world-space vectors within the specified VRM space. The goal is to ensure the shield's convex face points toward the camera and slightly right, while the shield maintains an upright position with a slight guard lean. Camera space vectors are normalized and transformed into guard pose VRM space using defined transformation matrices.
Precise kinematic placement places the shield 6.8 cm in front of the forearm, based on the out_g vector. Transformation and binding within the model's reference pose creates the desired curved shield, rim, boss, and straps. The resulting transformation maps the vectors with millimeter precision.
Confirming the previous steps, the exact kinematic placement of the strapped_heater_shield is crucial to review before further edits.
Precise placement positions the shield relative to the forearm, taking into account the curvature and avoiding obstruction of the character's armor. The shield's outward and upward facing vectors are defined to present the convex front with specific visual details to the viewer, while the forearm remains tucked behind.
Investigating the brown patches on Valen's sabatons reveals a padding discrepancy between the base boots and the sabaton. Increasing the padding value for both vanguard_captain and heavy_housecarl resolves the issue by ensuring overlap and smooth transitions, and additional inward vertex adjustments smooth the base boot into the new padding.
Leather boot-last now shows no z-fighting or protruding toes. Korin's cape clearance issue stems from the cape's position relative to the underlying garments; the shoulder was poking through the cape's pinned edge due to the top_clear and phi values. To resolve this, all upper-body garments will be merged into a single cape_under mesh and the phi and top_clear values will be adjusted. Also removing the cloak clasps will fix the visual overlap. The waist belt will be adjusted, and bound appropriately, to avoid intersection.
The color contrast between Valen and Korin in Pass 2 is essential for readability and faction differentiation; Valen's royal indigo and gold palette clearly contrasts with Korin's oxblood crimson and bronze. The weapon and face framing in Pass 2 ensures clean visual separation; Valen's sword angles upwards, avoiding overlap with Korin's poleaxe. This color and weapon framing aids in distinguishing the two figures at a glance.
edit_file{"Path":"~/work/lowmarch/tools/battle_slice.py","Replacement":"def tuck_boot_feet(fit, boots_pc, inset=0.008):\n \"\"\"Pull wrapped boot toe/foot vertices slightly inward so the rounded boot last covers them cleanly.\"\"\"\n B = fit.bone\n y_cut = min(B[\"J_Bip_L_Foot\"][1], B[\"J_Bip_R_Foot\"][1]) + 0.015\n pos = boots_pc[\"pos\"]\n sel = pos[:, 1] < y_cut\n if not np.any(sel):\n return\n for side in (\"L\", \"R\"):\n ft = B[f\"J_Bip_{side}_Foot\"]\n side_mask = sel & ((pos[:, 0] < 0) if side == \"L\" else (pos[:, 0] >= 0))\n if not np.any(side_mask):\n continue\n d = pos[side_mask] - np.array([ft[0], y_cut - 0.03, ft[2] - 0.04])\n n = np.linalg.norm(d, axis=1, keepdims=True)\n pos[side_mask] -= d / np.maximum(n, 1e-6) * inset\n boots_pc[\"nrm\"] = O.vertex_normals(boots_pc[\"pos\"], boots_pc[\"tri\"])\n\n\ndef strapped_heater_shield(fit, guard_pose, yaw_deg=32.0, width=0.35, height=0.49, curve=0.44):\n \"\"\"Curved heater shield kinematically aligned to stand upright in 3/4 guard with arm tucked behind it.\"\"\"\n names = fit.v.nodes_by_name()\n i_la = names[\"J_Bip_L_LowerArm\"]\n i_hd = names[\"J_Bip_L_Hand\"]\n Wg = fit.v.node_world(guard_pose)\n Mg = Wg[i_la]\n Eg = Mg[:3, 3]\n Hg = Wg[i_hd][:3, 3]\n\n F3 = np.diag([-1.0, 1.0, -1.0])\n a = math.radians(-yaw_deg)\n Ry_inv = np.array([[math.cos(a), 0.0, math.sin(a)], [0.0, 1.0, 0.0], [-math.sin(a), 0.0, math.cos(a)]])\n cam_to_vrm = lambda v: F3 @ (Ry_inv @ (np.asarray(v, float) / np.linalg.norm(v)))\n\n out_g = cam_to_vrm([0.52, 0.06, 0.85])\n up_g = cam_to_vrm([-0.06, 0.99, -0.03])\n up_g -= out_g * (up_g @ out_g)\n up_g /= np.linalg.norm(up_g)\n fw_g = np.cross(out_g, up_g)\n centre_g = Eg * 0.35 + Hg * 0.65 + out_g * 0.072 + fw_g * 0.025\n\n M_rest = fit.world[\"J_Bip_L_LowerArm\"]\n T_g2r = M_rest @ np.linalg.inv(Mg)\n R_g2r = T_g2r[:3, :3]\n R_g2r = R_g2r / np.linalg.norm(R_g2r, axis=0)\n\n centre = (T_g2r @ np.append(centre_g, 1.0))[:3]\n lat = R_g2r @ out_g\n up = R_g2r @ up_g\n fw = np.cross(lat, up)\n\n t = np.linspace(0, 1, 13)\n right = [(width / 2 * (1 - t_ ** 2.2), -height * 0.25 - height * 0.75 * t_) for t_ in t]\n outline = [(-width / 2, height * 0.25), (width / 2, height * 0.25)] + right[1:] + [(-x, y) for x, y in right[::-1][1:-1]]\n emblem = [\n (\"poly\", [(-0.11, 0.06), (0.0, 0.16), (0.11, 0.06), (0.11, 0.01), (0.0, 0.11), (-0.11, 0.01)], \"gold\"),\n (\"poly\", [(-0.042, -0.01), (0.042, -0.01), (0.0, -0.17)], \"gold\"),\n ]\n pc = flat_piece(\"heater\", \"signature\", outline, centre, fw, up, thickness=0.012, decal=emblem, px=1200)\n P_pos = pc[\"pos\"]\n x = (P_pos - centre) @ fw\n P_pos += lat[None] * (-(x ** 2) / (2 * curve))[:, None]\n pc[\"nrm\"] = O.vertex_normals(P_pos, pc[\"tri\"])\n rim = O.pipe(\n \"heater_rim\", \"gold\",\n np.array([centre + fw * px_ + up * py_ + lat * (-(px_ ** 2) / (2 * curve) + 0.007) for px_, py_ in outline]),\n r=0.0055, seg=6, closed=True\n )\n boss, _ = O.dome(\"heater_boss\", \"steel\", centre + up * 0.02 + lat * 0.008, lat, up, 0.032, 0.020, rows=6)\n enarme = O.tube(\"heater_enarme\", \"leather\", centre - lat * 0.035 - up * 0.06, up, 0.14, 0.009)\n out = [pc, rim, boss, enarme]\n G._bind(fit, out, \"J_Bip_L_LowerArm\")\n return G._group(out, \"shield\")\n\n\ndef vanguard_captain(fit):\n \"\"\"Original Lowmarch vanguard officer costume fitted to arm_f_strong.\"\"\"\n B = fit.bone\n hips, nk = B[\"J_Bip_C_Hips\"], B[\"J_Bip_C_Neck\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n cuff_len = 0.56\n boot_top = knee + 0.055\n y_waist = hips[1] + 0.055\n y_skirt = hips[1] - 0.25\n\n out, shirt, trousers, boots = mobs._base(\n fit, shirt=\"signature\", legs=\"doublet\", boots=\"boot\", gloves=\"glove\",\n shirt_subdiv=0, boot_top=boot_top\n )\n G.loose_sleeves(fit, shirt, ease=0.028, cuff=cuff_len, folds=6)\n G.flare_boots(fit, boots, boot_top - 0.005, ease=0.010)\n tuck_boot_feet(fit, boots, inset=0.009)\n\n # Clean cavalier boot-lasts outside the tucked boot feet so zero toes or seams ever show\n for side in (\"L\", \"R\"):\n sabs = O.sabaton(fit, f\"sabaton_{side}\", side, role=\"boot\", pad=0.020, ridges=0)\n out += G._group(sabs, \"boots\")","Target":"def vanguard_captain(fit):\n \"\"\"Original Lowmarch vanguard officer costume fitted to arm_f_strong.\"\"\"\n B = fit.bone\n hips, nk = B[\"J_Bip_C_Hips\"], B[\"J_Bip_C_Neck\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n cuff_len = 0.56\n boot_top = knee + 0.055\n y_waist = hips[1] + 0.055\n y_skirt = hips[1] - 0.25\n\n out, shirt, trousers, boots = mobs._base(\n fit, shirt=\"signature\", legs=\"doublet\", boots=\"boot\", gloves=\"glove\",\n shirt_subdiv=0, boot_top=boot_top\n )\n G.loose_sleeves(fit, shirt, ease=0.028, cuff=cuff_len, folds=6)\n G.flare_boots(fit, boots, boot_top - 0.005, ease=0.010)\n\n # Hide bare-foot toes under armoured steel sabatons\n for side in (\"L\", \"R\"):\n sabs = O.sabaton(fit, f\"sabaton_{side}\", side, role=\"steel\", pad=0.011, ridges=3)\n out += G._group(sabs, \"plate\")"}
input
{ "Path": "~/work/lowmarch/tools/battle_slice.py", "Replacement": "def tuck_boot_feet(fit, boots_pc, inset=0.008):\n \"\"\"Pull wrapped boot toe/foot vertices slightly inward so the rounded boot last covers them cleanly.\"\"\"\n B = fit.bone\n y_cut = min(B[\"J_Bip_L_Foot\"][1], B[\"J_Bip_R_Foot\"][1]) + 0.015\n pos = boots_pc[\"pos\"]\n sel = pos[:, 1] < y_cut\n if not np.any(sel):\n return\n for side in (\"L\", \"R\"):\n ft = B[f\"J_Bip_{side}_Foot\"]\n side_mask = sel & ((pos[:, 0] < 0) if side == \"L\" else (pos[:, 0] >= 0))\n if not np.any(side_mask):\n continue\n d = pos[side_mask] - np.array([ft[0], y_cut - 0.03, ft[2] - 0.04])\n n = np.linalg.norm(d, axis=1, keepdims=True)\n pos[side_mask] -= d / np.maximum(n, 1e-6) * inset\n boots_pc[\"nrm\"] = O.vertex_normals(boots_pc[\"pos\"], boots_pc[\"tri\"])\n\n\ndef strapped_heater_shield(fit, guard_pose, yaw_deg=32.0, width=0.35, height=0.49, curve=0.44):\n \"\"\"Curved heater shield kinematically aligned to stand upright in 3/4 guard with arm tucked behind it.\"\"\"\n names = fit.v.nodes_by_name()\n i_la = names[\"J_Bip_L_LowerArm\"]\n i_hd = names[\"J_Bip_L_Hand\"]\n Wg = fit.v.node_world(guard_pose)\n Mg = Wg[i_la]\n Eg = Mg[:3, 3]\n Hg = Wg[i_hd][:3, 3]\n\n F3 = np.diag([-1.0, 1.0, -1.0])\n a = math.radians(-yaw_deg)\n Ry_inv = np.array([[math.cos(a), 0.0, math.sin(a)], [0.0, 1.0, 0.0], [-math.sin(a), 0.0, math.cos(a)]])\n cam_to_vrm = lambda v: F3 @ (Ry_inv @ (np.asarray(v, float) / np.linalg.norm(v)))\n\n out_g = cam_to_vrm([0.52, 0.06, 0.85])\n up_g = cam_to_vrm([-0.06, 0.99, -0.03])\n up_g -= out_g * (up_g @ out_g)\n up_g /= np.linalg.norm(up_g)\n fw_g = np.cross(out_g, up_g)\n centre_g = Eg * 0.35 + Hg * 0.65 + out_g * 0.072 + fw_g * 0.025\n\n M_rest = fit.world[\"J_Bip_L_LowerArm\"]\n T_g2r = M_rest @ np.linalg.inv(Mg)\n R_g2r = T_g2r[:3, :3]\n R_g2r = R_g2r / np.linalg.norm(R_g2r, axis=0)\n\n centre = (T_g2r @ np.append(centre_g, 1.0))[:3]\n lat = R_g2r @ out_g\n up = R_g2r @ up_g\n fw = np.cross(lat, up)\n\n t = np.linspace(0, 1, 13)\n right = [(width / 2 * (1 - t_ ** 2.2), -height * 0.25 - height * 0.75 * t_) for t_ in t]\n outline = [(-width / 2, height * 0.25), (width / 2, height * 0.25)] + right[1:] + [(-x, y) for x, y in right[::-1][1:-1]]\n emblem = [\n (\"poly\", [(-0.11, 0.06), (0.0, 0.16), (0.11, 0.06), (0.11, 0.01), (0.0, 0.11), (-0.11, 0.01)], \"gold\"),\n (\"poly\", [(-0.042, -0.01), (0.042, -0.01), (0.0, -0.17)], \"gold\"),\n ]\n pc = flat_piece(\"heater\", \"signature\", outline, centre, fw, up, thickness=0.012, decal=emblem, px=1200)\n P_pos = pc[\"pos\"]\n x = (P_pos - centre) @ fw\n P_pos += lat[None] * (-(x ** 2) / (2 * curve))[:, None]\n pc[\"nrm\"] = O.vertex_normals(P_pos, pc[\"tri\"])\n rim = O.pipe(\n \"heater_rim\", \"gold\",\n np.array([centre + fw * px_ + up * py_ + lat * (-(px_ ** 2) / (2 * curve) + 0.007) for px_, py_ in outline]),\n r=0.0055, seg=6, closed=True\n )\n boss, _ = O.dome(\"heater_boss\", \"steel\", centre + up * 0.02 + lat * 0.008, lat, up, 0.032, 0.020, rows=6)\n enarme = O.tube(\"heater_enarme\", \"leather\", centre - lat * 0.035 - up * 0.06, up, 0.14, 0.009)\n out = [pc, rim, boss, enarme]\n G._bind(fit, out, \"J_Bip_L_LowerArm\")\n return G._group(out, \"shield\")\n\n\ndef vanguard_captain(fit):\n \"\"\"Original Lowmarch vanguard officer costume fitted to arm_f_strong.\"\"\"\n B = fit.bone\n hips, nk = B[\"J_Bip_C_Hips\"], B[\"J_Bip_C_Neck\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n cuff_len = 0.56\n boot_top = knee + 0.055\n y_waist = hips[1] + 0.055\n y_skirt = hips[1] - 0.25\n\n out, shirt, trousers, boots = mobs._base(\n fit, shirt=\"signature\", legs=\"doublet\", boots=\"boot\", gloves=\"glove\",\n shirt_subdiv=0, boot_top=boot_top\n )\n G.loose_sleeves(fit, shirt, ease=0.028, cuff=cuff_len, folds=6)\n G.flare_boots(fit, boots, boot_top - 0.005, ease=0.010)\n tuck_boot_feet(fit, boots, inset=0.009)\n\n # Clean cavalier boot-lasts outside the tucked boot feet so zero toes or seams ever show\n for side in (\"L\", \"R\"):\n sabs = O.sabaton(fit, f\"sabaton_{side}\", side, role=\"boot\", pad=0.020, ridges=0)\n out += G._group(sabs, \"boots\")", "Target": "def vanguard_captain(fit):\n \"\"\"Original Lowmarch vanguard officer costume fitted to arm_f_strong.\"\"\"\n B = fit.bone\n hips, nk = B[\"J_Bip_C_Hips\"], B[\"J_Bip_C_Neck\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n cuff_len = 0.56\n boot_top = knee + 0.055\n y_waist = hips[1] + 0.055\n y_skirt = hips[1] - 0.25\n\n out, shirt, trousers, boots = mobs._base(\n fit, shirt=\"signature\", legs=\"doublet\", boots=\"boot\", gloves=\"glove\",\n shirt_subdiv=0, boot_top=boot_top\n )\n G.loose_sleeves(fit, shirt, ease=0.028, cuff=cuff_len, folds=6)\n G.flare_boots(fit, boots, boot_top - 0.005, ease=0.010)\n\n # Hide bare-foot toes under armoured steel sabatons\n for side in (\"L\", \"R\"):\n sabs = O.sabaton(fit, f\"sabaton_{side}\", side, role=\"steel\", pad=0.011, ridges=3)\n out += G._group(sabs, \"plate\")" }result, 1 line
Made 1 replacement in ~/work/lowmarch/tools/battle_slice.py starting at line 188 (+81/-5 lines).
edit_file{"Path":"~/work/lowmarch/tools/battle_slice.py","Replacement":" # Flowing indigo officer cloak clasped at collarbones\n cape_under = merge_surfaces(\n *[(p[\"pos\"], p[\"tri\"]) for p in out if p.get(\"group\") in (\"plate\", \"doublet\", \"collar\")],\n (fit.pos, fit.tri)\n )\n cape_pc, _ = O.cape(fit, \"cape\", \"signature\", cape_under, length=0.96, phi=0.52, seg=44, rows=18,\n top_clear=0.008, clear=(0.018, 0.055))\n cape_pc[\"group\"] = \"cape\"\n out.append(cape_pc)\n out += cloak_clasps(fit, cape_under, role=\"gold\", cord_role=\"gold\", y_off=-0.038, x_deg=35.0)\n\n # Upright strapped heater shield aligned to Valen's guard pose\n guard_pose = vanguard_pose(fit.v, fit.shape)[0][1]\n out += strapped_heater_shield(fit, guard_pose, yaw_deg=32.0)\n\n out += knightly_longsword(fit, \"R\")\n out.append(add_scalp_cap(fit, hairline_front=54.0))\n return out\n\n\ndef heavy_housecarl(fit):\n \"\"\"Original Lowmarch heavy housecarl costume fitted to arm_m_strong (unhelmeted so face/hair read).\"\"\"\n B = fit.bone\n hips = B[\"J_Bip_C_Hips\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n boot_top = knee - 0.075\n y_gambeson = hips[1] - 0.24\n y_mail = hips[1] - 0.15\n\n out, shirt, trousers, boots = mobs._base(\n fit, shirt=\"padding\", legs=\"doublet\", boots=\"boot\", gloves=\"glove\", boot_top=boot_top\n )\n G.breeches(fit, trousers, boots, y_gambeson, boot_top - 0.005, ease=0.040)\n tuck_boot_feet(fit, boots, inset=0.009)\n for side in (\"L\", \"R\"):\n lasts = O.sabaton(fit, f\"boot_last_{side}\", side, role=\"boot\", pad=0.020, ridges=0)\n out += G._group(lasts, \"boots\")\n\n under = mobs._under(shirt)\n out += G.quilted(fit, under, role=\"padding\", y_hem=y_gambeson, sleeve_end=0.92)\n gam = mobs._surf(out, \"gambeson\", \"gambeson_skirt\")\n out += G.mail_shirt(fit, gam, role=\"mail\", y_hem=y_mail, sleeve=0.52)\n mail = mobs._surf(out, \"hauberk\", prefix=True)\n out += G.riveted_vest(fit, mail, role=\"leather\", rivet_role=\"steel\")\n\n # Exact torso pieces only (never sleeves) + spine/hips skinning so the belt rides outside the riveted vest\n vest_torso = mobs._surf(out, \"brigandine_front\", \"brigandine_back\", \"hauberk\", \"gambeson\")\n belt_pc, front_pt = O.belt(fit, \"belt\", \"leather\", vest_torso, hips[1] + 0.032, height=0.044, offset=0.011)\n fit.bind(belt_pc, allow=(\"Spine\", \"Chest\", \"Hips\"), fallback=\"J_Bip_C_Hips\")\n buckle = O.box(\"buckle\", \"gold\", front_pt + np.array([0, 0, -0.007]),\n ([1, 0, 0], [0, 1, 0], [0, 0, 1]), (0.028, 0.028, 0.007))\n fit.bind(buckle, allow=(\"Spine\", \"Chest\", \"Hips\"), fallback=\"J_Bip_C_Hips\")\n buckle[\"group\"] = \"belt\"\n out += [belt_pc, buckle]\n\n # Standing oxblood wool collar + draped battle cloak pinned cleanly behind shoulders (zero shoulder pokethrough)\n col_pc, _, _ = O.collar(fit, \"collar\", \"signature\", height_back=0.044, height_front=0.026, gap_deg=64,\n clear=(0.015, 0.021))\n col_pc[\"group\"] = \"collar\"\n out.append(col_pc)\n\n cape_under = merge_surfaces(\n *[(p[\"pos\"], p[\"tri\"]) for p in out if p.get(\"group\") in (\"plate\", \"mail\", \"padding\", \"collar\")],\n (fit.pos, fit.tri)\n )\n cape_pc, _ = O.cape(fit, \"cape\", \"signature\", cape_under, length=0.94, phi=0.38, seg=40, rows=18,\n top_clear=0.020, clear=(0.024, 0.062))\n cape_pc[\"group\"] = \"cape\"\n out.append(cape_pc)\n\n out += G.cuffs(fit, role=\"glove\", length=0.35, flare=0.032)\n out += crescent_poleaxe(fit, length=1.96, grip=0.54, hand=\"R\")\n out.append(add_scalp_cap(fit, hairline_front=50.0))\n return out\n\n\ndef vanguard_pose(vrm, shape):\n \"\"\"Grounded fencing guard for Valen: sword poised forward, left arm braced outward behind the heater shield.\"\"\"\n rig = Rig(vrm, shape, ortho=True)\n body = checks.Body(vrm, shape)\n f = {s: g[\"point\"] for s, g in grip_points(vrm, shape, P.BUST).items()}\n ref = dict(ref_pose=P.BUST, fist_R=f[\"R\"], fist_L=f[\"L\"])\n\n base = P.merge(P.BATTLE_IDLE, P.fist(\"L\", curl=(72, 84, 60), thumb=36), {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n \"J_Bip_C_Neck\": P.rot((0, 1, 0), 11.0) @ P.rot((1, 0, 0), 3.0),\n \"J_Bip_C_Head\": P.rot((0, 1, 0), 10.0) @ P.rot((1, 0, 0), 2.5),\n })\n foot = {s: rig.pos(P.BATTLE_IDLE, f\"J_Bip_{s}_Foot\") for s in \"LR\"}\n pose = rig.leg_ik(base, \"L\", foot[\"L\"] + np.array([-0.06, 0.0, -0.17]), pole=(0, 0, -1))\n pose = rig.leg_ik(pose, \"R\", foot[\"R\"] + np.array([0.07, 0.0, 0.14]), pole=(0, -0.2, -1))\n\n sh_r = rig.pos(pose, \"J_Bip_R_UpperArm\")\n fist_r = sh_r + np.array([0.09, -0.34, -0.22])\n blade_dir = np.array([-0.24, 0.48, -0.84])\n pose = duel.clear_grip(rig, body, pose, \"R\", ref, fist_r, blade_dir, (0.7, -0.9, 0.35))\n\n sh_l = rig.pos(pose, \"J_Bip_L_UpperArm\")\n pose = rig.arm_ik(pose, \"L\", sh_l + np.array([-0.24, -0.22, -0.06]), pole=(-0.85, -0.75, 0.35))\n return [(0.0, pose), (1.0, pose)]","Target":" # Flowing crimson officer cloak clasped at collarbones\n cape_under = merge_surfaces(\n *[(p[\"pos\"], p[\"tri\"]) for p in out if p.get(\"group\") in (\"plate\", \"doublet\")],\n (fit.pos, fit.tri)\n )\n cape_pc, _ = O.cape(fit, \"cape\", \"cape\", cape_under, length=0.96, phi=0.58, seg=44, rows=18, clear=(0.016, 0.055))\n cape_pc[\"group\"] = \"cape\"\n out.append(cape_pc)\n out += cloak_clasps(fit, cape_under, role=\"gold\", cord_role=\"gold\", y_off=-0.038, x_deg=35.0)\n\n # Heater shield with heraldic gold chevron + inner grip straps so the left hand holds a real enarme\n emblem = [\n (\"poly\", [(-0.11, 0.06), (0.0, 0.16), (0.11, 0.06), (0.11, 0.01), (0.0, 0.11), (-0.11, 0.01)], \"gold\"),\n (\"poly\", [(-0.045, -0.01), (0.045, -0.01), (0.0, -0.17)], \"gold\"),\n ]\n sh_pcs = G.shield(fit, \"heater\", side=\"L\", role=\"signature\", width=0.36, height=0.50, curve=0.44, emblem=emblem)\n E_l, H_l = B[\"J_Bip_L_LowerArm\"], B[\"J_Bip_L_Hand\"]\n ax_l = (H_l - E_l) / np.linalg.norm(H_l - E_l)\n lat_l = np.array([-1.0, 0.0, 0.0]) - ax_l * (-ax_l[0])\n lat_l /= np.linalg.norm(lat_l)\n grip_bar = O.tube(\"shield_enarme\", \"leather\", H_l + lat_l * 0.035 - np.array([0, 0, 0.05]),\n np.array([0, 0, 1.0]), 0.10, 0.010)\n fit.bind(grip_bar, rigid=\"J_Bip_L_LowerArm\")\n grip_bar[\"group\"] = \"shield\"\n out += sh_pcs + [grip_bar]\n\n out += knightly_longsword(fit, \"R\")\n out.append(add_scalp_cap(fit, hairline_front=54.0))\n return out\n\n\ndef heavy_housecarl(fit):\n \"\"\"Original Lowmarch heavy housecarl costume fitted to arm_m_strong (unhelmeted so face/hair read).\"\"\"\n B = fit.bone\n hips = B[\"J_Bip_C_Hips\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n boot_top = knee - 0.075\n y_gambeson = hips[1] - 0.24\n y_mail = hips[1] - 0.15\n\n out, shirt, trousers, boots = mobs._base(\n fit, shirt=\"padding\", legs=\"doublet\", boots=\"boot\", gloves=\"glove\", boot_top=boot_top\n )\n G.breeches(fit, trousers, boots, y_gambeson, boot_top - 0.005, ease=0.040)\n # Smooth leather shoe-lasts over both feet so VRoid toes never show\n for side in (\"L\", \"R\"):\n lasts = O.sabaton(fit, f\"boot_last_{side}\", side, role=\"boot\", pad=0.011, ridges=0)\n out += G._group(lasts, \"boots\")\n\n under = mobs._under(shirt)\n out += G.quilted(fit, under, role=\"padding\", y_hem=y_gambeson, sleeve_end=0.92)\n gam = mobs._surf(out, \"gambeson\", \"gambeson_skirt\")\n out += G.mail_shirt(fit, gam, role=\"mail\", y_hem=y_mail, sleeve=0.52)\n mail = mobs._surf(out, \"hauberk\", prefix=True)\n out += G.riveted_vest(fit, mail, role=\"leather\", rivet_role=\"steel\")\n\n # Exact torso pieces only (never hauberk_sleeve_*) so the belt hugs the waist cleanly\n vest_torso = mobs._surf(out, \"brigandine_front\", \"brigandine_back\", \"hauberk\")\n belt_pc, front_pt = O.belt(fit, \"belt\", \"leather\", vest_torso, hips[1] + 0.038, height=0.046, offset=0.006)\n buckle = fit.bind(O.box(\"buckle\", \"steel\", front_pt + np.array([0, 0, -0.006]),\n ([1, 0, 0], [0, 1, 0], [0, 0, 1]), (0.028, 0.028, 0.007)), rigid=\"J_Bip_C_Hips\")\n buckle[\"group\"] = \"belt\"\n out += [belt_pc, buckle]\n\n # Standing oxblood wool collar + draped battle cloak pinned cleanly behind shoulders (zero chest pokethrough)\n col_pc, col_top, _ = O.collar(fit, \"collar\", \"signature\", height_back=0.044, height_front=0.028, gap_deg=60,\n clear=(0.013, 0.019))\n col_pc[\"group\"] = \"collar\"\n out.append(col_pc)\n\n cape_under = merge_surfaces(\n *[(p[\"pos\"], p[\"tri\"]) for p in out if p[\"material\"] in (\"OUTFIT_brigandine_front\", \"OUTFIT_brigandine_back\",\n \"OUTFIT_hauberk\", \"OUTFIT_gambeson\")],\n (fit.pos, fit.tri)\n )\n cape_pc, _ = O.cape(fit, \"cape\", \"signature\", cape_under, length=0.94, phi=0.54, seg=42, rows=18,\n clear=(0.018, 0.058))\n cape_pc[\"group\"] = \"cape\"\n out.append(cape_pc)\n out += cloak_clasps(fit, cape_under, role=\"steel\", cord_role=\"leather\", y_off=-0.042, x_deg=36.0)\n\n out += G.cuffs(fit, role=\"glove\", length=0.35, flare=0.032)\n out += crescent_poleaxe(fit, length=1.96, grip=0.54, hand=\"R\")\n out.append(add_scalp_cap(fit, hairline_front=50.0))\n return out\n\n\ndef vanguard_pose(vrm, shape):\n \"\"\"Grounded fencing guard for Valen: sword poised forward, heater shield angled cleanly on outer guard.\"\"\"\n rig = Rig(vrm, shape, ortho=True)\n body = checks.Body(vrm, shape)\n f = {s: g[\"point\"] for s, g in grip_points(vrm, shape, P.BUST).items()}\n ref = dict(ref_pose=P.BUST, fist_R=f[\"R\"], fist_L=f[\"L\"])\n\n base = P.merge(P.BATTLE_IDLE, P.fist(\"L\", curl=(68, 80, 55), thumb=32), {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n \"J_Bip_C_Neck\": P.rot((0, 1, 0), 11.0) @ P.rot((1, 0, 0), 3.0),\n \"J_Bip_C_Head\": P.rot((0, 1, 0), 10.0) @ P.rot((1, 0, 0), 2.5),\n })\n foot = {s: rig.pos(P.BATTLE_IDLE, f\"J_Bip_{s}_Foot\") for s in \"LR\"}\n pose = rig.leg_ik(base, \"L\", foot[\"L\"] + np.array([-0.06, 0.0, -0.17]), pole=(0, 0, -1))\n pose = rig.leg_ik(pose, \"R\", foot[\"R\"] + np.array([0.07, 0.0, 0.14]), pole=(0, -0.2, -1))\n\n sh_r = rig.pos(pose, \"J_Bip_R_UpperArm\")\n fist_r = sh_r + np.array([0.09, -0.34, -0.22])\n blade_dir = np.array([-0.24, 0.48, -0.84])\n pose = duel.clear_grip(rig, body, pose, \"R\", ref, fist_r, blade_dir, (0.7, -0.9, 0.35))\n\n # Left arm braced outward and rotated about forearm axis so the shield's heraldic face turns ~48 deg toward camera\n sh_l = rig.pos(pose, \"J_Bip_L_UpperArm\")\n pose = rig.arm_ik(pose, \"L\", sh_l + np.array([-0.22, -0.24, -0.10]), pole=(-0.9, -0.6, 0.4))\n ax_la = rig.pos(pose, \"J_Bip_L_Hand\") - rig.pos(pose, \"J_Bip_L_LowerArm\")\n pose = rig.rotate_world(pose, \"J_Bip_L_LowerArm\", P.rot(ax_la, 48.0))\n return [(0.0, pose), (1.0, pose)]"}
input
{ "Path": "~/work/lowmarch/tools/battle_slice.py", "Replacement": " # Flowing indigo officer cloak clasped at collarbones\n cape_under = merge_surfaces(\n *[(p[\"pos\"], p[\"tri\"]) for p in out if p.get(\"group\") in (\"plate\", \"doublet\", \"collar\")],\n (fit.pos, fit.tri)\n )\n cape_pc, _ = O.cape(fit, \"cape\", \"signature\", cape_under, length=0.96, phi=0.52, seg=44, rows=18,\n top_clear=0.008, clear=(0.018, 0.055))\n cape_pc[\"group\"] = \"cape\"\n out.append(cape_pc)\n out += cloak_clasps(fit, cape_under, role=\"gold\", cord_role=\"gold\", y_off=-0.038, x_deg=35.0)\n\n # Upright strapped heater shield aligned to Valen's guard pose\n guard_pose = vanguard_pose(fit.v, fit.shape)[0][1]\n out += strapped_heater_shield(fit, guard_pose, yaw_deg=32.0)\n\n out += knightly_longsword(fit, \"R\")\n out.append(add_scalp_cap(fit, hairline_front=54.0))\n return out\n\n\ndef heavy_housecarl(fit):\n \"\"\"Original Lowmarch heavy housecarl costume fitted to arm_m_strong (unhelmeted so face/hair read).\"\"\"\n B = fit.bone\n hips = B[\"J_Bip_C_Hips\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n boot_top = knee - 0.075\n y_gambeson = hips[1] - 0.24\n y_mail = hips[1] - 0.15\n\n out, shirt, trousers, boots = mobs._base(\n fit, shirt=\"padding\", legs=\"doublet\", boots=\"boot\", gloves=\"glove\", boot_top=boot_top\n )\n G.breeches(fit, trousers, boots, y_gambeson, boot_top - 0.005, ease=0.040)\n tuck_boot_feet(fit, boots, inset=0.009)\n for side in (\"L\", \"R\"):\n lasts = O.sabaton(fit, f\"boot_last_{side}\", side, role=\"boot\", pad=0.020, ridges=0)\n out += G._group(lasts, \"boots\")\n\n under = mobs._under(shirt)\n out += G.quilted(fit, under, role=\"padding\", y_hem=y_gambeson, sleeve_end=0.92)\n gam = mobs._surf(out, \"gambeson\", \"gambeson_skirt\")\n out += G.mail_shirt(fit, gam, role=\"mail\", y_hem=y_mail, sleeve=0.52)\n mail = mobs._surf(out, \"hauberk\", prefix=True)\n out += G.riveted_vest(fit, mail, role=\"leather\", rivet_role=\"steel\")\n\n # Exact torso pieces only (never sleeves) + spine/hips skinning so the belt rides outside the riveted vest\n vest_torso = mobs._surf(out, \"brigandine_front\", \"brigandine_back\", \"hauberk\", \"gambeson\")\n belt_pc, front_pt = O.belt(fit, \"belt\", \"leather\", vest_torso, hips[1] + 0.032, height=0.044, offset=0.011)\n fit.bind(belt_pc, allow=(\"Spine\", \"Chest\", \"Hips\"), fallback=\"J_Bip_C_Hips\")\n buckle = O.box(\"buckle\", \"gold\", front_pt + np.array([0, 0, -0.007]),\n ([1, 0, 0], [0, 1, 0], [0, 0, 1]), (0.028, 0.028, 0.007))\n fit.bind(buckle, allow=(\"Spine\", \"Chest\", \"Hips\"), fallback=\"J_Bip_C_Hips\")\n buckle[\"group\"] = \"belt\"\n out += [belt_pc, buckle]\n\n # Standing oxblood wool collar + draped battle cloak pinned cleanly behind shoulders (zero shoulder pokethrough)\n col_pc, _, _ = O.collar(fit, \"collar\", \"signature\", height_back=0.044, height_front=0.026, gap_deg=64,\n clear=(0.015, 0.021))\n col_pc[\"group\"] = \"collar\"\n out.append(col_pc)\n\n cape_under = merge_surfaces(\n *[(p[\"pos\"], p[\"tri\"]) for p in out if p.get(\"group\") in (\"plate\", \"mail\", \"padding\", \"collar\")],\n (fit.pos, fit.tri)\n )\n cape_pc, _ = O.cape(fit, \"cape\", \"signature\", cape_under, length=0.94, phi=0.38, seg=40, rows=18,\n top_clear=0.020, clear=(0.024, 0.062))\n cape_pc[\"group\"] = \"cape\"\n out.append(cape_pc)\n\n out += G.cuffs(fit, role=\"glove\", length=0.35, flare=0.032)\n out += crescent_poleaxe(fit, length=1.96, grip=0.54, hand=\"R\")\n out.append(add_scalp_cap(fit, hairline_front=50.0))\n return out\n\n\ndef vanguard_pose(vrm, shape):\n \"\"\"Grounded fencing guard for Valen: sword poised forward, left arm braced outward behind the heater shield.\"\"\"\n rig = Rig(vrm, shape, ortho=True)\n body = checks.Body(vrm, shape)\n f = {s: g[\"point\"] for s, g in grip_points(vrm, shape, P.BUST).items()}\n ref = dict(ref_pose=P.BUST, fist_R=f[\"R\"], fist_L=f[\"L\"])\n\n base = P.merge(P.BATTLE_IDLE, P.fist(\"L\", curl=(72, 84, 60), thumb=36), {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n \"J_Bip_C_Neck\": P.rot((0, 1, 0), 11.0) @ P.rot((1, 0, 0), 3.0),\n \"J_Bip_C_Head\": P.rot((0, 1, 0), 10.0) @ P.rot((1, 0, 0), 2.5),\n })\n foot = {s: rig.pos(P.BATTLE_IDLE, f\"J_Bip_{s}_Foot\") for s in \"LR\"}\n pose = rig.leg_ik(base, \"L\", foot[\"L\"] + np.array([-0.06, 0.0, -0.17]), pole=(0, 0, -1))\n pose = rig.leg_ik(pose, \"R\", foot[\"R\"] + np.array([0.07, 0.0, 0.14]), pole=(0, -0.2, -1))\n\n sh_r = rig.pos(pose, \"J_Bip_R_UpperArm\")\n fist_r = sh_r + np.array([0.09, -0.34, -0.22])\n blade_dir = np.array([-0.24, 0.48, -0.84])\n pose = duel.clear_grip(rig, body, pose, \"R\", ref, fist_r, blade_dir, (0.7, -0.9, 0.35))\n\n sh_l = rig.pos(pose, \"J_Bip_L_UpperArm\")\n pose = rig.arm_ik(pose, \"L\", sh_l + np.array([-0.24, -0.22, -0.06]), pole=(-0.85, -0.75, 0.35))\n return [(0.0, pose), (1.0, pose)]", "Target": " # Flowing crimson officer cloak clasped at collarbones\n cape_under = merge_surfaces(\n *[(p[\"pos\"], p[\"tri\"]) for p in out if p.get(\"group\") in (\"plate\", \"doublet\")],\n (fit.pos, fit.tri)\n )\n cape_pc, _ = O.cape(fit, \"cape\", \"cape\", cape_under, length=0.96, phi=0.58, seg=44, rows=18, clear=(0.016, 0.055))\n cape_pc[\"group\"] = \"cape\"\n out.append(cape_pc)\n out += cloak_clasps(fit, cape_under, role=\"gold\", cord_role=\"gold\", y_off=-0.038, x_deg=35.0)\n\n # Heater shield with heraldic gold chevron + inner grip straps so the left hand holds a real enarme\n emblem = [\n (\"poly\", [(-0.11, 0.06), (0.0, 0.16), (0.11, 0.06), (0.11, 0.01), (0.0, 0.11), (-0.11, 0.01)], \"gold\"),\n (\"poly\", [(-0.045, -0.01), (0.045, -0.01), (0.0, -0.17)], \"gold\"),\n ]\n sh_pcs = G.shield(fit, \"heater\", side=\"L\", role=\"signature\", width=0.36, height=0.50, curve=0.44, emblem=emblem)\n E_l, H_l = B[\"J_Bip_L_LowerArm\"], B[\"J_Bip_L_Hand\"]\n ax_l = (H_l - E_l) / np.linalg.norm(H_l - E_l)\n lat_l = np.array([-1.0, 0.0, 0.0]) - ax_l * (-ax_l[0])\n lat_l /= np.linalg.norm(lat_l)\n grip_bar = O.tube(\"shield_enarme\", \"leather\", H_l + lat_l * 0.035 - np.array([0, 0, 0.05]),\n np.array([0, 0, 1.0]), 0.10, 0.010)\n fit.bind(grip_bar, rigid=\"J_Bip_L_LowerArm\")\n grip_bar[\"group\"] = \"shield\"\n out += sh_pcs + [grip_bar]\n\n out += knightly_longsword(fit, \"R\")\n out.append(add_scalp_cap(fit, hairline_front=54.0))\n return out\n\n\ndef heavy_housecarl(fit):\n \"\"\"Original Lowmarch heavy housecarl costume fitted to arm_m_strong (unhelmeted so face/hair read).\"\"\"\n B = fit.bone\n hips = B[\"J_Bip_C_Hips\"]\n knee = B[\"J_Bip_L_LowerLeg\"][1]\n boot_top = knee - 0.075\n y_gambeson = hips[1] - 0.24\n y_mail = hips[1] - 0.15\n\n out, shirt, trousers, boots = mobs._base(\n fit, shirt=\"padding\", legs=\"doublet\", boots=\"boot\", gloves=\"glove\", boot_top=boot_top\n )\n G.breeches(fit, trousers, boots, y_gambeson, boot_top - 0.005, ease=0.040)\n # Smooth leather shoe-lasts over both feet so VRoid toes never show\n for side in (\"L\", \"R\"):\n lasts = O.sabaton(fit, f\"boot_last_{side}\", side, role=\"boot\", pad=0.011, ridges=0)\n out += G._group(lasts, \"boots\")\n\n under = mobs._under(shirt)\n out += G.quilted(fit, under, role=\"padding\", y_hem=y_gambeson, sleeve_end=0.92)\n gam = mobs._surf(out, \"gambeson\", \"gambeson_skirt\")\n out += G.mail_shirt(fit, gam, role=\"mail\", y_hem=y_mail, sleeve=0.52)\n mail = mobs._surf(out, \"hauberk\", prefix=True)\n out += G.riveted_vest(fit, mail, role=\"leather\", rivet_role=\"steel\")\n\n # Exact torso pieces only (never hauberk_sleeve_*) so the belt hugs the waist cleanly\n vest_torso = mobs._surf(out, \"brigandine_front\", \"brigandine_back\", \"hauberk\")\n belt_pc, front_pt = O.belt(fit, \"belt\", \"leather\", vest_torso, hips[1] + 0.038, height=0.046, offset=0.006)\n buckle = fit.bind(O.box(\"buckle\", \"steel\", front_pt + np.array([0, 0, -0.006]),\n ([1, 0, 0], [0, 1, 0], [0, 0, 1]), (0.028, 0.028, 0.007)), rigid=\"J_Bip_C_Hips\")\n buckle[\"group\"] = \"belt\"\n out += [belt_pc, buckle]\n\n # Standing oxblood wool collar + draped battle cloak pinned cleanly behind shoulders (zero chest pokethrough)\n col_pc, col_top, _ = O.collar(fit, \"collar\", \"signature\", height_back=0.044, height_front=0.028, gap_deg=60,\n clear=(0.013, 0.019))\n col_pc[\"group\"] = \"collar\"\n out.append(col_pc)\n\n cape_under = merge_surfaces(\n *[(p[\"pos\"], p[\"tri\"]) for p in out if p[\"material\"] in (\"OUTFIT_brigandine_front\", \"OUTFIT_brigandine_back\",\n \"OUTFIT_hauberk\", \"OUTFIT_gambeson\")],\n (fit.pos, fit.tri)\n )\n cape_pc, _ = O.cape(fit, \"cape\", \"signature\", cape_under, length=0.94, phi=0.54, seg=42, rows=18,\n clear=(0.018, 0.058))\n cape_pc[\"group\"] = \"cape\"\n out.append(cape_pc)\n out += cloak_clasps(fit, cape_under, role=\"steel\", cord_role=\"leather\", y_off=-0.042, x_deg=36.0)\n\n out += G.cuffs(fit, role=\"glove\", length=0.35, flare=0.032)\n out += crescent_poleaxe(fit, length=1.96, grip=0.54, hand=\"R\")\n out.append(add_scalp_cap(fit, hairline_front=50.0))\n return out\n\n\ndef vanguard_pose(vrm, shape):\n \"\"\"Grounded fencing guard for Valen: sword poised forward, heater shield angled cleanly on outer guard.\"\"\"\n rig = Rig(vrm, shape, ortho=True)\n body = checks.Body(vrm, shape)\n f = {s: g[\"point\"] for s, g in grip_points(vrm, shape, P.BUST).items()}\n ref = dict(ref_pose=P.BUST, fist_R=f[\"R\"], fist_L=f[\"L\"])\n\n base = P.merge(P.BATTLE_IDLE, P.fist(\"L\", curl=(68, 80, 55), thumb=32), {\n \"J_Bip_C_Hips\": P.move(0, -0.055, -0.02, P.rot((0, 1, 0), -10.0) @ P.rot((1, 0, 0), -4.5)),\n \"J_Bip_C_Spine\": P.rot((0, 1, 0), -8.0) @ P.rot((1, 0, 0), -3.0),\n \"J_Bip_C_Chest\": P.rot((0, 1, 0), -6.0) @ P.rot((1, 0, 0), -2.0),\n \"J_Bip_C_Neck\": P.rot((0, 1, 0), 11.0) @ P.rot((1, 0, 0), 3.0),\n \"J_Bip_C_Head\": P.rot((0, 1, 0), 10.0) @ P.rot((1, 0, 0), 2.5),\n })\n foot = {s: rig.pos(P.BATTLE_IDLE, f\"J_Bip_{s}_Foot\") for s in \"LR\"}\n pose = rig.leg_ik(base, \"L\", foot[\"L\"] + np.array([-0.06, 0.0, -0.17]), pole=(0, 0, -1))\n pose = rig.leg_ik(pose, \"R\", foot[\"R\"] + np.array([0.07, 0.0, 0.14]), pole=(0, -0.2, -1))\n\n sh_r = rig.pos(pose, \"J_Bip_R_UpperArm\")\n fist_r = sh_r + np.array([0.09, -0.34, -0.22])\n blade_dir = np.array([-0.24, 0.48, -0.84])\n pose = duel.clear_grip(rig, body, pose, \"R\", ref, fist_r, blade_dir, (0.7, -0.9, 0.35))\n\n # Left arm braced outward and rotated about forearm axis so the shield's heraldic face turns ~48 deg toward camera\n sh_l = rig.pos(pose, \"J_Bip_L_UpperArm\")\n pose = rig.arm_ik(pose, \"L\", sh_l + np.array([-0.22, -0.24, -0.10]), pole=(-0.9, -0.6, 0.4))\n ax_la = rig.pos(pose, \"J_Bip_L_Hand\") - rig.pos(pose, \"J_Bip_L_LowerArm\")\n pose = rig.rotate_world(pose, \"J_Bip_L_LowerArm\", P.rot(ax_la, 48.0))\n return [(0.0, pose), (1.0, pose)]" }result, 1 line
Made 1 replacement in ~/work/lowmarch/tools/battle_slice.py starting at line 346 (+41/-55 lines).