A 3D model pipeline, pushed by Gemini 4 Argon
agent
+10:16reasoning
Initial investigation of index.html reveals an existing WebGL shader with a three-quarter top-left key light vector defined. This indicates a pre-existing lighting solution consistent with the desired illumination. Further scrutiny is warranted regarding the visual artifact of a perceived "surgery scar" on the neck.
The normal bending function in tools/vroid_portrait.py appears to introduce a discontinuity in neck shading due to how PAINT_FS calculates lighting, causing the "surgery scar" effect. This is likely because the sharp normal change alters the lit value in a stepped fashion across the throat. This is happening despite castShadow() already providing real shadows.
The "surgery scar" likely arises from how the normal bending function interacts with the lighting calculation, creating a sharp discontinuity in shading on the neck. This discontinuity causes a stepped lit value change, especially when uShadeOnly is enabled and shadowing is in place. Initial tests on different body primitives are needed, along with inspecting high-resolution renders of scenes built using existing tools and assets. The goal is to isolate a visual test case representative of the core issue.
Initial examination of the relevant Python modules (outfit.py, gear.py, mobs.py, rig.py, clips.py, duel.py, terrain.py) and the WebGL renderer (review/vroid-02/index.html) suggests a potential divergence from the initial project reflection. The core issue of a single visual, a high-resolution battle scene rendered with the WebGL renderer, might be a more effective starting point. This contrasts with the reflection's focus on primitive shapes. The project might have already composed a frame that it is not taking as a base.
Initial suspicion is a fundamental problem in the normal calculation or lighting interaction, leading to the "surgery scar" visual artifact. The normal bending function's interaction with the lighting in the existing shader is likely the primary cause. A detailed inspection of the render with representative characters and armor will be conducted to isolate and understand the root cause.
The focus should shift to recreating a battle encounter screen from a tactics RPG, using either a two-hero sword bind on the plains stage or a four-unit squad clash. The existing WebGL renderer's tabs (Duel, Battle, Portrait, Lineup) suggest it's designed to create a scene with both the 3D stage and unit portraits. A 35° three-quarter bust portrait crop is important to show the active unit in a tactics HUD frame.
Initial focus will be on rendering the Duel, Battle, and Portrait views at high resolution within the existing WebGL renderer to assess visual artifacts. Test cases will use arm_m_heroic and arm_f_slender, evaluating a knight dress from outfit.py and outline plate armor from plates.py. There's a need to understand why saber_study.py worked well, especially considering its utilization of plates.py.
read_file{"EndLine":350,"Path":"~/work/lowmarch/tools/saber_study.py","StartLine":1}
input
{ "EndLine": 350, "Path": "~/work/lowmarch/tools/saber_study.py", "StartLine": 1 }result, 351 lines
Showing lines 1-350 of 541 1: """Benchmark only, NOT FOR THE GAME: Saber (Fate/stay night) in her armoured dress, built with the 2: outline-plate kit (tools/plates.py) to measure how close it can get to a well-known design. Saber is 3: Type-Moon's; the game's characters are original designs at this level of detail. 4: 5: Built from a written study of the official art (model sheets front, back and three-quarter, and a 6: figure for the hidden sides), never from the images themselves. Sizes are fractions of her height H 7: (skull to sole) or of her head height hd, read off the study and placed on Elaine's base body, whose 8: landmarks agree with the study's to a few percent (chin 0.14 H, waist 0.30-0.32 H, ankle 0.94 H). 9: """ 10: import math 11: 12: import numpy as np 13: 14: import outfit as O 15: from fitting import Surface, merge_surfaces 16: from plates import TorsoChart, LimbChart, ConeChart, outline_plate, stiffen, flat_piece, taper 17: 18: 19: def _grouped(pcs, g): 20: for pc in pcs: 21: if pc is not None: 22: pc["group"] = g 23: return [pc for pc in pcs if pc is not None] 24: 25: 26: # ---- decal shapes, in a chart's (u, v) with sizes in metres -------------------------------------- 27: def _to_uv(chart, u0, v0, pts): 28: """Metric offsets (across, up) from (u0, v0) on a torso-type chart -> (u, v) points.""" 29: r = float(chart.radius(u0, v0)) 30: return [(u0 + math.degrees(dx / r), v0 + dy) for dx, dy in pts] 31: 32: 33: def leaf(chart, u0, v0, ang, length, width, ch="paint"): 34: """A tapering blade from (u0, v0) at `ang` degrees from straight up (+ toward +u).""" 35: a = math.radians(ang) 36: al, ac = np.array([math.sin(a), math.cos(a)]), np.array([math.cos(a), -math.sin(a)]) 37: t = np.linspace(0, 1, 14) 38: w = width / 2 * np.sqrt(t + 0.08) * (1 - t) ** 0.85 * 1.6 39: left = [tuple(al * length * ti + ac * wi) for ti, wi in zip(t, w)] 40: right = [tuple(al * length * ti - ac * wi) for ti, wi in zip(t[::-1], w[::-1])] 41: return ("poly", _to_uv(chart, u0, v0, left + right), ch) 42: 43: 44: def curl(chart, u0, v0, radius, turns=1.25, width=0.0022, flip=1, ch="paint"): 45: """A spiral stroke (the swirl glyphs), unwinding from its centre.""" 46: th = np.linspace(0, turns * 2 * math.pi, 40) 47: rr = radius * (0.25 + 0.75 * th / th[-1]) 48: pts = [(flip * r * math.cos(x), r * math.sin(x)) for r, x in zip(rr, th)] 49: return ("line", _to_uv(chart, u0, v0, pts), width, ch) 50: 51: 52: def stroke(chart, u0, v0, pts, width=0.0022, ch="paint"): 53: return ("line", _to_uv(chart, u0, v0, pts), width, ch) 54: 55: 56: def build(fit): 57: B = fit.bone 58: P = fit.pos[np.unique(fit.tri)] 59: top, sole = float(P[:, 1].max()), float(P[:, 1].min()) 60: H = top - sole 61: hd = H / 7.06 # this base's head height (measured) 62: y = lambda f: top - f * H # a height given as a fraction of H from the skull 63: nk, hips = B["J_Bip_C_Neck"], B["J_Bip_C_Hips"] 64: cz = float(hips[2]) 65: knee = B["J_Bip_L_LowerLeg"][1] 66: out = [] 67: 68: def cuff_plane(side): # sleeves end inside the gauntlet 69: a, hd_ = B[f"J_Bip_{side}_LowerArm"], B[f"J_Bip_{side}_Hand"] 70: n = (hd_ - a) / np.linalg.norm(hd_ - a) 71: return n, n @ (a + (hd_ - a) * 0.7) 72: 73: # ---- under layers: dress bodice and sleeves, dark tights, leg shells, black gloves ---------- 74: torso = ("Spine", "Chest", "UpperChest", "Bust", "Shoulder", "UpperArm", "LowerArm", "Neck", "Hips") 75: bodice = O.wrap(fit, "bodice", "signature", torso, offset=0.006, exclude=("UpperLeg",), 76: y_min=hips[1] + 0.02, y_max=nk[1] + 0.012, hems=[cuff_plane("L"), cuff_plane("R")]) 77: tights = O.wrap(fit, "tights", "doublet", ("Hips", "UpperLeg", "LowerLeg"), offset=0.004, y_max=hips[1] + 0.03, subdiv=1) 78: boots = O.wrap(fit, "boots", "metal", ("LowerLeg", "Foot"), offset=0.012, y_max=knee - 0.10, exclude=("ToeBase",), 79: subdiv=1, hems=[((0, 1, 0), knee - 0.105)]) 80: gloves = O.wrap(fit, "gloves", "glove", ("Hand", "Thumb", "Index", "Middle", "Ring", "Little"), 81: offset=0.0035, min_w=0.3, smooth=4) 82: out += _grouped([bodice], "dress") + _grouped([tights], "trousers") + _grouped([boots], "boots") + _grouped([gloves], "gloves") 83: torso_only = O.without(bodice, ("Shoulder", "UpperArm", "LowerArm", "Hand")) 84: chest = Surface(*torso_only) 85: 86: # ---- collar: a close stand collar, gold band along its top, gold line down the front ---------- 87: col, rim, fronts = O.collar(fit, "collar", "signature", height_back=0.040, height_front=0.034, gap_deg=6, 88: clear=(0.008, 0.012)) 89: band = rim - np.array([0, 0.0042, 0]) 90: out += _grouped([col, O.inherit(O.ribbon("collar_band", "gold", band, width=0.0075, lift=0.0012, 91: normals=O.near_normals(col, band)), col)], "dress") 92: for k, edge in enumerate(fronts): 93: out += _grouped([O.inherit(O.ribbon(f"collar_front{k}", "gold", edge, width=0.0035, lift=0.0012, 94: normals=O.near_normals(col, edge)), col)], "dress") 95: 96: # ---- the chest chart (the bodice without its sleeves) -------------------------------------- 97: tc = TorsoChart(chest, y(0.36), y(0.14), cz=cz, du=2.0, dv=0.006, smooth=(1.6, 1.4)) 98: 99: # back: two short gold strips from the collar base, down and outward (a Lambda) 100: for s in (-1, 1): 101: pts = tc.point(np.array([180 + s * 6, 180 + s * 26]), np.array([y(0.165), y(0.215)]), off=0.002) 102: out += _grouped(_bind_strip(fit, pts, s, tc, y), "dress") 103: 104: # ---- cuirass: domed panels between grooves, studs at the junctions, painted blue motifs ------- 105: yb, yv, ybust = y(0.303), y(0.280), y(0.246) 106: 107: def front_top(u): 108: a = abs(u) 109: if a <= 34: 110: return y(0.197) 111: if a <= 80: 112: return y(0.197) + (y(0.226) - y(0.197)) * ((a - 34) / 46) ** 1.3 113: return y(0.226) + (y(0.236) - y(0.226)) * min(1.0, (a - 80) / 18) 114: 115: seams, studs = [], [] 116: for s in (-1, 1): 117: seams += [[(s * 34, y(0.199)), (s * 60, ybust), (s * 38, y(0.262)), (s * 14, y(0.274)), (0, yv)], 118: [(s * 60, ybust), (s * 99, ybust)], 119: [(s * 31, y(0.267)), (s * 52, y(0.288)), (s * 60, yb - 0.004)]] 120: studs += [(s * 60, ybust), (s * 31, y(0.267)), (s * 60, yb + 0.012)] 121: seams.append([(0, yv), (0, yb - 0.004)]) 122: motif = [] 123: # bust panel: a curl glyph with a dot, a stem down to the V, a fan of six blades rising from it 124: motif += [curl(tc, 0, y(0.213), 0.0075, turns=1.1), ("dot", (0, y(0.205)), 0.0023, "paint"), 125: stroke(tc, 0, y(0.219), [(0, 0), (0, -(y(0.219) - y(0.276)))], width=0.0016)] 126: for s in (-1, 1): 127: for ang, L in ((20, 0.056), (40, 0.072), (60, 0.086)): 128: motif.append(leaf(tc, 0, y(0.277), s * ang, L, 0.016)) 129: for ang, L in ((22, 0.034), (46, 0.040), (70, 0.036)): # the abdomen panels: small fans up and out 130: motif.append(leaf(tc, s * 14, y(0.301), s * ang, L, 0.010)) 131: front, fx = outline_plate("cuirass", "steel", tc, -99, 99, lambda u: yb, front_top, offset=0.011, crown=0.004, 132: thickness=0.003, nu=110, nv=44, roll=0.0022, roll_edges=("top",), roll_role="steel", 133: seams=seams, groove=(0.0060, 0.0022), panel_crown=0.0035, studs=studs, stud_r=0.0038, 134: decal=motif, decal_px=1600) 135: back_top = lambda u: y(0.190) + (y(0.236) - y(0.190)) * (abs(((u % 360) - 180)) / 82) ** 1.6 136: bseams = [[(129, ybust), (180, y(0.262)), (231, ybust)], [(99, y(0.283)), (261, y(0.283))]] 137: back, bx = outline_plate("backplate", "steel", tc, 99, 261, lambda u: yb, back_top, offset=0.011, crown=0.004, 138: thickness=0.003, nu=80, nv=36, roll=0.0022, roll_edges=("top",), roll_role="steel", 139: seams=bseams, groove=(0.0035, 0.0018), panel_crown=0.003, 140: studs=[(129, ybust), (231, ybust)], stud_r=0.0038, decal_px=1200) 141: # the gorget: a separate plate over the collar's foot, stepping out from the chest 142: gmotif = [curl(tc, -2.0, y(0.178), 0.0060, turns=1.0), curl(tc, 2.0, y(0.181), 0.0060, turns=1.0, flip=-1)] 143: for s in (-1, 1): 144: gmotif += [leaf(tc, s * 9, y(0.188), s * 50, 0.028, 0.0062), leaf(tc, s * 13, y(0.192), s * 68, 0.030, 0.0062)] 145: gorget, gx = outline_plate("gorget", "steel", tc, -38, 38, 146: lambda u: y(0.201) - 0.007 * (1 - (u / 38) ** 2), 147: lambda u: y(0.170) - 0.008 * max(0.0, (abs(u) - 28) / 10) ** 2, 148: offset=0.023, crown=0.003, thickness=0.003, nu=48, nv=18, roll=0.0022, 149: roll_edges=("top", "bottom"), roll_role="steel", 150: studs=[(-33, y(0.197)), (33, y(0.197))], stud_r=0.0036, decal=gmotif, decal_px=1800) 151: for pc in (front, back, gorget): 152: fit.bind(pc, allow=("Spine", "Chest", "UpperChest", "Bust"), fallback="J_Bip_C_Chest") 153: for pc in fx: 154: O.inherit(pc, front) 155: for pc in bx: 156: O.inherit(pc, back) 157: for pc in gx: 158: O.inherit(pc, gorget) 159: gorget["W"][:] = 0 160: gorget["J"][:, 0] = fit.jnames.index("J_Bip_C_UpperChest") 161: gorget["W"][:, 0] = 1.0 162: for pc in gx: 163: O.inherit(pc, gorget) 164: out += _grouped([front, back, gorget] + fx + bx + gx, "plate") 165: 166: # ---- belt: near-black leather at the natural waist, laced at the front ----------------------- 167: belt, bfront = O.belt(fit, "belt", "leather", chest, y(0.311), height=0.034, offset=0.004, thickness=0.005) 168: out += _grouped([belt], "belt") 169: lace = [] 170: ex, ey_ = np.array([1.0, 0, 0]), np.array([0, 1.0, 0]) 171: c0 = bfront + np.array([0, 0, -0.006]) 172: eye = {(sx, k): c0 + ex * sx * 0.011 + ey_ * (0.011 - 0.016 * k) for sx in (-1, 1) for k in range(3)} 173: for k in range(2): 174: for sx in (-1, 1): 175: a, b = eye[(sx, k)], eye[(-sx, k + 1)] 176: lace.append(O.pipe(f"lace{k}{(sx + 1) // 2}", "glove", np.linspace(a, b, 6) + np.array([0, 0, -0.002 * (k + 1)]), 177: r=0.0017, seg=6)) 178: for (sx, k), p in eye.items(): 179: lace.append(O.ball(f"eyelet{k}{(sx + 1) // 2}", "steel", p, 0.0028, seg=8, rows=5, squash=(1, 1, 0.5))) 180: for pc in lace: 181: fit.bind(pc, rigid="J_Bip_C_Hips") 182: out += _grouped(lace, "belt") 183: 184: # ---- skirts: the white petticoat (cloth), the open blue overskirt, the violet front panel ------ 185: y_top, y_hem = y(0.322), y(0.790) 186: r_hem = 0.24 * H 187: r0 = lambda u: tc.radius(u, y(0.322)) + 0.014 188: r0_mean = float(np.mean([r0(u) for u in range(-180, 180, 10)])) 189: 190: def r_base(u, v): # the overskirt's cone before it clears the petticoat 191: t = np.clip((y_top - v) / (y_top - y_hem), 0, 1.15) 192: return r0(u) + (r_hem - r0_mean) * t ** 1.45 193: 194: # petticoat: full circle, to mid-calf, the hem cut into sawtooth teeth with a gold lozenge on each 195: legs = merge_surfaces((tights["pos"], tights["tri"]), (boots["pos"], boots["tri"])) 196: waist = merge_surfaces(torso_only, (tights["pos"], tights["tri"])) 197: pt_top = y(0.335) 198: seg, rows, teeth = 96, 24, 48 199: # not simulated: the viewer's cloth pushes a skirt out of the legs by a few centimetres, which took 200: # it through the stiff overskirt; skinned like the overskirt instead, the two move together 201: pet, grid = O.skirt(fit, "petticoat", "heraldry", waist, legs, pt_top, pt_top - y(0.858), flare=r_hem - 0.165, 202: seg=seg, rows=rows, folds=8, fold_depth=0.006) 203: # the upper part is always hidden under the overskirt and tassets, and the settle crumples it over 204: # the hips (a fold whose surface faces inward): rebuild it as a smooth ring between the body and the 205: # overskirt's base cone, blending into the settled cloth below 206: body_c = TorsoChart(waist, y(0.56), y(0.32), cz=cz, du=3.0, dv=0.01, smooth=(1.2, 1.2)) 207: Pp = pet["pos"].reshape(seg, rows, 3) 208: hz = np.stack([Pp[..., 0], Pp[..., 2] - cz], -1) # horizontal offset from the axis 209: rr = np.linalg.norm(hz, axis=-1) 210: d0 = hz / np.maximum(rr[..., None], 1e-9) 211: dcol = np.repeat(d0[:, :1], rows, 1) # each column's own direction, from its 212: a_ = np.clip((Pp[..., 1] - y(0.52)) / (y(0.46) - y(0.52)), 0, 1) # top point (columns that crossed 213: dn = d0 * (1 - a_[..., None]) + dcol * a_[..., None] # over each other made the fold) 214: dn /= np.maximum(np.linalg.norm(dn, axis=-1, keepdims=True), 1e-9) 215: up = np.degrees(np.arctan2(dn[..., 0], -dn[..., 1])) 216: ring = np.maximum(body_c.radius(up, Pp[..., 1]) + 0.006, r_base(up, Pp[..., 1]) - 0.010) 217: r_new = rr + (ring - rr) * a_ 218: Pp[..., 0] = dn[..., 0] * r_new 219: Pp[..., 2] = cz + dn[..., 1] * r_new 220: pet["pos"] = Pp.reshape(-1, 3) 221: G = pet["pos"].reshape(seg, rows, 3) 222: # the settle swings a flared skirt down, so it hangs longer than asked: scale it back to end at mid-calf 223: y0_, y1_ = G[:, 0, 1].mean(), G[0::2, -1, 1].mean() 224: G[..., 1] = y0_ - (y0_ - G[..., 1]) * (y0_ - y(0.858)) / (y0_ - y1_) 225: G[1::2, -1] = G[1::2, -2] + (G[1::2, -1] - G[1::2, -2]) * 0.05 # every other column ends a row early: teeth 226: pet["pos"] = G.reshape(-1, 3) 227: pet["nrm"] = O.vertex_normals(pet["pos"], pet["tri"]) 228: # decal: the hem's lozenges, in (s, t) = (round the skirt, folded at the back so the seam repeats 229: # nothing; up the skirt, the lowest fifth only) 230: from plates import Canvas 231: cv = Canvas(512, 256) 232: for i in range(0, seg // 2 + 1, 2): 233: s_ = 1 - abs(2 * i / seg - 1) 234: cv.dot((s_, 0.5 / 0.2 / (rows - 1)), 2.0, 26, "gold") 235: pet["decal"] = cv.array() 236: ii, jj = np.meshgrid(np.arange(seg), np.arange(rows), indexing="ij") 237: s_uv = 1 - np.abs(2 * ii / seg - 1) 238: t_uv = np.clip((1 - jj / (rows - 1)) / 0.2, 0, 1) 239: t_uv[1::2, -1] = np.clip((1 - (rows - 2 + 0.05) / (rows - 1)) / 0.2, 0, 1) 240: pet["uv"] = np.stack([s_uv, t_uv], -1).reshape(-1, 2) 241: stiffen(pet, fit, share=0.65) 242: pet.pop("closed", None) 243: pet["covered_by"] = ["overskirt", "front_panel"] # for the layer check: it must never show through them 244: out += _grouped([pet], "dress") 245: # the overskirt's cone, kept a centimetre outside the petticoat everywhere: the petticoat settles 246: # against the body, which bulges out behind the hips past a plain cone (it showed through there) 247: under = TorsoChart(Surface(pet["pos"], pet["tri"]), y(0.80), y(0.335), cz=cz, du=3.0, dv=0.01, smooth=(1.2, 1.2)) 248: 249: def r_over(u, v): 250: base = r_base(u, v) 251: # outside the petticoat by 1.6 cm over the hips and below; at the waist the band hugs the body 252: w = np.clip((y(0.335) - v) / (y(0.335) - y(0.380)), 0, 1) 253: return base + np.maximum(0, under.radius(u, v) + 0.016 - base) * w 254: 255: cone = ConeChart(r_over, cz=cz) 256: 257: # overskirt: a stiff cone, open at the front, a gold-edged slit at the back 258: slit_h, slit_w = 0.34 * (y_top - y_hem), math.degrees(0.2 * hd / r_hem) 259: 260: def over_bottom(u): 261: return y_hem + slit_h * max(0.0, 1 - abs(u - 180) / slit_w) 262: 263: over, _ = outline_plate("overskirt", "signature", cone, 27, 333, over_bottom, lambda u: y_top + 0.012, offset=0.0, 264: thickness=0.004, nu=150, nv=26, trim=0.035 * hd, roll=0) 265: # layers over the petticoat take its weights (nearest vertex): weights copied from the body 266: # differ between a layer close to the thighs and one further out, and the layers then cross 267: O.inherit(over, pet) 268: out += _grouped([over], "dress") 269: 270: # front panel: a violet apron from the belt, filling the overskirt's opening, scooped corners 271: # ending in points with silver pendants, gold edges, two crescent hooks and a small triangle 272: y_ph, y_tip = y(0.745), y(0.690) 273: panel_r = lambda u, v: r_over(u, v) - 0.0025 274: 275: def p_top(u): 276: a = abs(u) 277: if a <= 24: 278: return y_top + 0.010 279: return y(0.625) - (y(0.625) - y_tip) * ((a - 24) / 8) ** 0.55 280: 281: def p_bottom(u): 282: a = abs(u) 283: return y_ph if a <= 26 else y_ph + (y_tip - y_ph) * (a - 26) / 6 284: 285: pcone = ConeChart(panel_r, cz=cz) 286: deco = [] 287: for s in (-1, 1): 288: cx_, cy_ = s * 15.5, y_ph + 0.024 289: th = np.linspace(math.radians(200), math.radians(-20), 16) 290: arc = [(s * 0.016 * math.cos(t_), 0.010 * math.sin(t_) + 0.002) for t_ in th] 291: deco.append(stroke(pcone, cx_, cy_, arc, width=0.0042, ch="gold")) 292: deco.append(("poly", _to_uv(pcone, 0, y_ph, [(-0.012, 0.0), (0.012, 0.0), (0.0, 0.020)]), "gold")) 293: panel, _ = outline_plate("front_panel", "violet", pcone, -32, 32, p_bottom, p_top, offset=0.0, thickness=0.003, 294: nu=130, nv=30, trim=0.0055, roll=0, decal=deco, decal_px=900) 295: O.inherit(panel, pet) # moves with the petticoat under it 296: out += _grouped([panel], "dress") 297: pend = [] 298: for k, (u_, v_) in enumerate([(-32, y_tip), (32, y_tip), (-26, y_ph), (26, y_ph)]): 299: p0 = pcone.point(u_, v_, off=0.003) 300: pend.append(O.ball(f"pendant_bead{k}", "steel", p0 - np.array([0, 0.004, 0]), 0.0055, seg=10, rows=6)) 301: drop = O.ball(f"pendant{k}", "steel", p0 - np.array([0, 0.036, 0]), 0.0085, seg=12, rows=10, squash=(1, 3.6, 1)) 302: D = drop["pos"] 303: tt = np.clip((D[:, 1] - D[:, 1].min()) / np.ptp(D[:, 1]), 0, 1) # a teardrop: thin at the top 304: c_ = D.mean(0) 305: D[:, [0, 2]] = c_[[0, 2]] + (D[:, [0, 2]] - c_[[0, 2]]) * (1 - 0.75 * tt ** 1.5)[:, None] 306: drop["nrm"] = O.vertex_normals(D, drop["tri"]) 307: pend.append(drop) 308: for pc in pend: 309: O.inherit(pc, panel) 310: out += _grouped(pend, "dress") 311: 312: # ---- tassets: three faceted plates over each hip, shingled, notched at the inner corners ------- 313: tas_r = lambda u, v: r_over(u, v) + 0.010 314: tcone = ConeChart(tas_r, cz=cz) 315: notch = 0.1 * hd 316: for side, s in (("R", 1), ("L", -1)): 317: for k, (vt, vb, uf, ub) in enumerate([(y(0.316), y(0.420), 21, 157), (y(0.408), y(0.520), 24, 154), 318: (y(0.508), y(0.660), 28, 150)]): 319: nd = math.degrees(notch / float(tas_r(90, vb))) 320: 321: def bot(u, vb=vb, uf=uf, ub=ub, nd=nd): 322: a = abs(u) 323: return vb + notch if (a - uf < nd or ub - a < nd) else vb 324: u0, u1 = (uf, ub) if s > 0 else (-ub, -uf) 325: fac = [u0, s * 72, s * 114, u1] if s > 0 else [u0, s * 114, s * 72, u1] 326: st_ = [(s * (uf + 2.5), vt - 0.016), (s * (uf + 6.5), vt - 0.016)] if k == 0 else [] 327: st_ += [(s * (uf + nd + 2.5), vb + notch + 0.012), (s * (ub - nd - 2.5), vb + notch + 0.012)] 328: pl, px_ = outline_plate(f"tasset_{side}{k}", "steel", tcone, u0, u1, bot, lambda u, vt=vt: vt, offset=0.004, 329: thickness=0.004, nu=64, nv=16, roll=0, facets=fac, 330: flare=lambda u, v, s_, t: 0.010 * (1 - t) ** 1.3, studs=st_, stud_r=0.0032) 331: fit.bind(pl, blend={"J_Bip_C_Hips": 0.7 - 0.15 * k, f"J_Bip_{side}_UpperLeg": 0.3 + 0.15 * k}) 332: for pc in px_: 333: O.inherit(pc, pl) 334: out += _grouped([pl] + px_, "plate") 335: 336: # ---- puffed sleeves: boxy, peaked at the outer top, gathered at the armpit; gold piping --------- 337: for side, s in (("R", 1), ("L", -1)): 338: out += _grouped(_puff(fit, side, s, hd), "dress") 339: 340: # ---- gauntlets: four stacked bands, ribbed, riveted on the inner edge; a knuckle plate --------- 341: for side, s in (("R", 1), ("L", -1)): 342: la, hd_ = B[f"J_Bip_{side}_LowerArm"], B[f"J_Bip_{side}_Hand"] 343: fore = O.limb_surface(fit, (f"{side}_LowerArm", f"{side}_Hand"), side) 344: lc = LimbChart(fore, la, hd_, front=(0, 0, -1), v_range=(-0.2, 1.5)) 345: outside = 90.0 * s 346: inside = -outside # the inner forearm, in -180..180 347: bands = [(0.36, 0.57), (0.55, 0.76), (0.74, 0.95), (0.93, 1.20)] 348: for k, (v0, v1) in enumerate(bands): 349: off = 0.026 + 0.0035 * k 350: fl = (lambda u, v, s_, t: 0.006 * t ** 1.5) if k == 0 else None