agent (cont.)

+10:26
  • read_file{"Path":"~/work/sortie/kit/makers/atelier.py"}

    input

    {
      "Path": "~/work/sortie/kit/makers/atelier.py"
    }

    result, 605 lines

    Showing lines 1-604 of 604
    1: """The houses' atelier plates: the captive maker of the houses, knightly frames built to order.
    2: 
    3: Motif (docs/visual-language.md, docs/study-atelier.md), held on every plate and grade:
    4:   flared sheets   every plate is a sheet bent round one axis, a cylinder or a cone, never a box: round
    5:                   in plan, straight lines up and down. Limbs, skirts and pauldrons flare toward their
    6:                   free edge (the greave into a bell over the ankle, the vambrace to the wrist, the
    7:                   tassets and the pauldrons to their hems). The chest is the one solid, round in plan.
    8:   flared pauldrons a flat roof carrying the mount pad over a cone that flares down and out to a gold
    9:                   hem, a flange swept up along its outboard edge
    10:   crest fin       one tall blade on the helm's centre line, raked back
    11:   tall, narrow    a small helm sunk between the pauldron flanges, a pinched waist, long greaves, set by
    12:                   `stance` (atelier builds only)
    13: Everything else stays plain. Grades are thickness, size and wrap of the same sheets:
    14:   light   the knight: thin sheets, wide gaps, small pauldrons, the longest crest, a rear core block
    15:           cockpit that ejects whole (on a `core` node), harkens under the chest corners, no hatch
    16:   medium  the line knight: fuller sheets, the chest hatch over the frame socket, a round backpack
    17:   heavy   the castellan: sheets that wrap, wide pauldrons with a second lame, a high gorget, knee fans,
    18:           a tabard, a broad pack shroud, a kite shield on the left forearm pad with a lance racked
    19:           along its front edge
    20: Heel spinners (a wheel under a curved fender) on every grade.
    21: 
    22: Livery roles, colour blocked: main for most sheets, accent in bounded fields (the crest, a chevron
    23: breastplate and the hatch, the core's or the pack's rear panel, a long panel down each greave, the
    24: heavy's tabard and shield pale), trim on the pauldron hems and the crest's edge. Bearing anchors in
    25: the standard places (left shoulder, chest left, right shoulder, both greaves), plus the back panel
    26: and the heavy's tabard and shield.
    27: 
    28:     plates(J, "medium")                                     one grade everywhere
    29:     plates(J, {"chest": "heavy", "default": "light"})       grade per segment
    30: The light chest has no hatch and goes with the light backpack (the core block): a light chest under a
    31: medium or heavy backpack leaves no cockpit.
    32: """
    33: import math
    34: 
    35: import bmesh
    36: import bpy
    37: from mathutils import Matrix, Vector
    38: 
    39: import frame_std
    40: from lib import circle, clip, copy, cylinder, empty, loft, merge, nozzle, octo, prism, rot, solid, transform, two_view
    41: from makers.shell import Plates, inset, subtract
    42: from mech import gltf_dir, nozzle_pair, place
    43: 
    44: CHAMFER = .03
    45: ROOF = frame_std.ROOF
    46: SEGMENTS = ("head", "chest", "waist", "pelvis", "shoulder", "upperarm", "forearm", "thigh", "shin", "foot", "backpack", "binder")
    47: 
    48: 
    49: def by(g, light, medium, heavy):
    50:     return {"light": light, "medium": medium, "heavy": heavy}[g]
    51: 
    52: 
    53: def lr(J, part):
    54:     return J[part, "L"], J[part, "R"]
    55: 
    56: 
    57: # ---- outlines and sheets ----------------------------------------------------------------------------------
    58: def bez(p0, c, p1, n=6):
    59:     """Points along a quadratic curve from p0 toward p1 bent toward c: p0 included, p1 not."""
    60:     out = []
    61:     for i in range(n):
    62:         t = i / n
    63:         out.append(((1 - t) ** 2 * p0[0] + 2 * (1 - t) * t * c[0] + t * t * p1[0], (1 - t) ** 2 * p0[1] + 2 * (1 - t) * t * c[1] + t * t * p1[1]))
    64:     return out
    65: 
    66: 
    67: def angles(a0, a1, step=12):
    68:     n = max(2, int(abs(a1 - a0) / step))
    69:     return [a0 + (a1 - a0) * i / n for i in range(n + 1)]
    70: 
    71: 
    72: def ring(c, r, a0, a1, t=None, step=12):
    73:     """A plan outline round a vertical axis at c: the arc of an ellipse with radii r from angle a0 to a1
    74:     (degrees, 0 is +x, -90 the front). With t, closed by the same arc t further in: a sheet of even
    75:     thickness. Without, closed by its chord."""
    76:     a = [math.radians(x) for x in angles(a0, a1, step)]
    77:     out = [(c[0] + r[0] * math.cos(x), c[1] + r[1] * math.sin(x)) for x in a]
    78:     if t is None:
    79:         return out
    80:     return out + [(c[0] + (r[0] - t) * math.cos(x), c[1] + (r[1] - t) * math.sin(x)) for x in reversed(a)]
    81: 
    82: 
    83: def flare(c, rings, a0, a1, t, step=12):
    84:     """A sheet t thick round a vertical axis through c, from angle a0 to a1, lofted through rings
    85:     [(z, rx, ry)]: a cylinder or a cone, flaring where the radii grow. A ring's z may be a function of
    86:     the angle (degrees), for a pointed or swept edge. A closed solid."""
    87:     a = angles(a0, a1, step)
    88:     bm = bmesh.new()
    89:     loops = []
    90:     for z, rx, ry in rings:
    91:         loop = []
    92:         for d, r0, r1 in [(x, rx, ry) for x in a] + [(x, rx - t, ry - t) for x in reversed(a)]:
    93:             q = math.radians(d)
    94:             zz = z(d) if callable(z) else z
    95:             loop.append(bm.verts.new((c[0] + r0 * math.cos(q), c[1] + r1 * math.sin(q), zz)))
    96:         loops.append(loop)
    97:     n = len(loops[0])
    98:     for p, q in zip(loops, loops[1:]):
    99:         for i in range(n):
    100:             j = (i + 1) % n
    101:             bm.faces.new((p[i], p[j], q[j], q[i]))
    102:     bm.faces.new(list(reversed(loops[0])))
    103:     bm.faces.new(loops[-1])
    104:     bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
    105:     return bm
    106: 
    107: 
    108: def halfplane(poly, a, b):
    109:     """The part of a convex polygon left of the line a->b (Sutherland-Hodgman, one edge)."""
    110:     side = lambda p: (b[0] - a[0]) * (p[1] - a[1]) - (b[1] - a[1]) * (p[0] - a[0])
    111:     out = []
    112:     for i, p in enumerate(poly):
    113:         q = poly[(i + 1) % len(poly)]
    114:         sp, sq = side(p), side(q)
    115:         if sp >= 0:
    116:             out.append(p)
    117:         if (sp >= 0) != (sq >= 0):
    118:             t = sp / (sp - sq)
    119:             out.append((p[0] + (q[0] - p[0]) * t, p[1] + (q[1] - p[1]) * t))
    120:     return out
    121: 
    122: 
    123: def rect(x0, x1, z0, z1):
    124:     return [(x0, z0), (x1, z0), (x1, z1), (x0, z1)]
    125: 
    126: 
    127: def sheet(front_o, side_o, plan_o):
    128:     """A solid: the front, side and plan outlines intersected."""
    129:     return two_view(front_o, side_o, plan_o)
    130: 
    131: 
    132: def bearing_at(name, at, normal, parent, size):
    133:     n = Vector(normal).normalized()
    134:     return empty(f"bearing.{name}", Vector(at) + n * .02, parent, dir=gltf_dir(-n), size=size)
    135: 
    136: 
    137: GROW = {"light": -.05, "medium": 0.0, "heavy": .1}  # how far a grade's limb sheets stand out from the medium's
    138: 
    139: 
    140: # ---- head -------------------------------------------------------------------------------------------------
    141: # The helm is drawn round the frame's head block, then everything on the head joint (the block too)
    142: # is seated lower, so the chin sits on the pauldron roofs between the flanges.
    143: HEAD_DROP = .72
    144: 
    145: 
    146: def helm_plan(k=0.0):
    147:     """The helm in plan: a sharp prow at the front, straight cheeks, a round back."""
    148:     w = .5 + k
    149:     left = [(0, -.86 - k), (.26 + k, -.64 - k), (w, -.3)] + bez((w, .36), (w - .02, .68 + k), (0, .7 + k))
    150:     right = [(-x, y) for x, y in reversed(left[1:])]
    151:     return left + [(0, .7 + k)] + right
    152: 
    153: 
    154: def head(P, J, g):
    155:     H = J["head"]
    156:     _head(P, J, g)
    157:     m = Matrix.Translation((0, 0, -HEAD_DROP))
    158:     for o in H.children:
    159:         if o.type == "MESH":
    160:             for v in o.data.vertices:
    161:                 v.co = m @ v.co
    162: 
    163: 
    164: def _head(P, J, g):
    165:     H = J["head"]
    166:     k = by(g, -.03, 0.0, .03)
    167:     hp = helm_plan(k)
    168:     w = .5 + k
    169:     # the crown over a jutting brow, the visor and the faceplate under it, the nape guard behind: one
    170:     # prow in plan, so the eye slit runs in a V
    171:     vee = lambda z, d=0.0: [(-w - d, z + .12), (0, z), (w + d, z + .12)]  # the brow and the visor run in a shallow V
    172:     P.solid("head_helmet", sheet(vee(16.38, .02) + [(w, 16.9), (.3, 17.2), (-.3, 17.2), (-w, 16.9)],
    173:                                  [(-1.08, 16.4), (.7, 16.4), (.7, 16.9), (.45, 17.2), (-.35, 17.2), (-1.0, 16.72)], inset(hp, -.05)), "main", H)
    174:     P.solid("head_visor", sheet(vee(16.17) + list(reversed(vee(16.4))), rect(-1.2, -.1, 16.1, 16.6), inset(hp, .08)), "visor", H, bevel=.01)
    175:     solid(f"{P.n}_head_slit", sheet(vee(16.25) + list(reversed(vee(16.33))), rect(-1.2, -.24, 16.1, 16.6), inset(hp, .06)), "glow_eye", H,
    176:           outline=False)
    177:     face = sheet(list(reversed(vee(16.19))) + [(-w + .1, 16.0), (-.16, 15.78), (.16, 15.78), (w - .1, 16.0)],
    178:                  [(-.95, 16.32), (-.88, 15.78), (.1, 15.78), (.1, 16.32)], hp)
    179:     # a breathing slot down the prow, dark inside
    180:     face = subtract(face, frame_std.box(-.035, .035, -1.2, -.66, 15.88, 16.18))
    181:     P.solid("head_face", face, "main", H)
    182:     P.solid("head_slot", frame_std.box(-.04, .04, -.74, -.64, 15.88, 16.18), "joint", H, bevel=.005)
    183:     flare_ = by(g, .1, .14, .2)
    184:     P.solid("head_nape", sheet(rect(-w - .02, w + .02, 15.78, 16.47), [(.05, 16.47), (.72, 16.47), (.72 + flare_, 15.78), (.05, 15.78)],
    185:                                inset(hp, -.04 - flare_)), "main", H)
    186:     P.solid("head_ear", cylinder(.12, w - .02, w + .09, 12, axis="x", at=(.0, 16.4)), "frame", H, H, bevel=.01)
    187:     # the crest fin: one blade on the centre line from the brow, raked back, its leading edge in trim.
    188:     # The light's sweeps furthest back, the heavy's stands tallest and runs down the nape
    189:     c = by(g, -.1, 0.0, .25)
    190:     lead = [(-.8, 16.95), (-.52, 17.4 + c * .4), (-.08, 17.9 + c), (.26, 18.1 + c)]
    191:     tail = [(.48, 18.0 + c), (.6, 17.5 + c * .5)]
    192:     if g == "light":
    193:         lead = [(-.8, 16.95), (-.45, 17.32), (.1, 17.72), (.8, 17.96)]
    194:         tail = [(1.2, 17.9), (1.0, 17.6), (.62, 17.2)]
    195:     tail += [(.82, 17.0), (.86, 16.3), (.66, 16.4), (.6, 16.95)] if g == "heavy" else [(.66, 17.0), (.6, 16.95)]
    196:     t = by(g, .055, .065, .08)
    197:     P.solid("head_crest", sheet(rect(-t, t, 16.2, 18.6), lead + tail, None), "accent", H, bevel=.015)
    198:     P.solid("head_crest_root", sheet(rect(-t - .06, t + .06, 16.9, 17.32), [(-.82, 16.9), (-.5, 17.32), (.5, 17.32), (.66, 16.9)], None), "main", H)
    199:     edge = [(y - .06, z + .06) for y, z in lead] + [(y + .06, z - .07) for y, z in reversed(lead)]
    200:     solid(f"{P.n}_head_crest_edge", sheet(rect(-t - .014, t + .014, 16.2, 18.6), edge, None), "trim", H, bevel=.008)
    201: 
    202: 
    203: # ---- torso ------------------------------------------------------------------------------------------------
    204: CHEVRON = (13.3, .32)  # the breastplate's accent field: above a V with its point at z on the centre line, rising per metre out
    205: 
    206: 
    207: def chest(P, J, g):
    208:     """A breastplate round in plan, narrow at the waist and flaring to the shoulders. Above a chevron it
    209:     is the accent field, the hatch with it. Light covers the socket with one plate (its cockpit is the
    210:     core block behind), medium and heavy carry the hatch on the cockpit joint so it leaves with the pod."""
    211:     T, C = J["torso"], J["cockpit"]
    212:     k = by(g, -.06, 0.0, .1)
    213:     bf = [(-.9 - k, 12.5), (.9 + k, 12.5), (1.46 + k, 14.2), (1.46 + k, 14.75), (1.3 + k, 15.0), (-1.3 - k, 15.0), (-1.46 - k, 14.75),
    214:           (-1.46 - k, 14.2)]
    215:     back = by(g, -.6, -.3, -.1)
    216:     bs = [(-1.25, 12.5), (-2.1, 13.3), (-2.1, 14.7), (-1.95, 15.0), (back, 15.0), (back, 12.5)]
    217:     r = (1.5 + k, 1.1 + k)
    218:     plan = ring((0, -.5), r, 180, 360, t=.16) if g == "light" else ring((0, -.5), r, 165 - k * 80, 375 + k * 80)
    219:     z0, s = CHEVRON
    220:     hi_f = halfplane(halfplane(bf, (-3, z0 + 3 * s), (0, z0)), (0, z0), (3, z0 + 3 * s))
    221:     hi = sheet(hi_f, bs, plan)
    222:     vee = [(0, z0 - .08), (4, z0 - .08 + 4 * s), (4, 20), (-4, 20), (-4, z0 - .08 + 4 * s)]
    223:     lo = subtract(sheet(bf, bs, plan), prism(vee, -4, 4, "xz"))
    224:     if g != "light":
    225:         hatch = sheet([(-.48, 12.98), (.48, 12.98), (.6, 13.12), (.6, 14.36), (-.6, 14.36), (-.6, 13.12)], bs, plan)
    226:         hatch = clip(hatch, y=(-60, -1.0))
    227:         hole = lambda: frame_std.box(-.66, .66, -3, 0, 12.92, 14.42)
    228:         hi, lo = subtract(hi, hole()), subtract(lo, hole())
    229:         P.solid("hatch", hatch, "accent", C)
    230:         P.solid("hatch_well", frame_std.box(-.7, .7, -1.3, -.98, 12.94, 14.4), "joint", T, bevel=.01)
    231:         solid(f"{P.n}_hatch_handle", frame_std.box(-.16, .16, -1.72, -1.6, 13.5, 13.58), "frame", C, .01)
    232:     P.solid("chest_hi", hi, "accent", T)
    233:     P.solid("chest_lo", lo, "main", T)
    234:     bearing_at("chest", (.95, -.5 - r[1] * math.sqrt(max(0, 1 - (.95 / r[0]) ** 2)), 14.35), (0, -1, 0), T, .9)
    235:     # the gorget round the neck, rising to the chin on the heavy grade
    236:     top = by(g, 15.2, 15.3, 15.62)
    237:     P.solid("gorget", flare((0, .05), [(14.92, 1.1, 1.04), (top, 1.0, .96)], 195, 345, by(g, .12, .16, .2)), "main", T)
    238:     P.solid("belly", flare((0, -.36), [(11.95, .86 + k, .78), (12.52, 1.0 + k, .9)], 185, 355, by(g, .12, .2, .26)), "main", T)
    239:     if g != "light":
    240:         # back plates either side of the backpack, round in plan
    241:         P.solid("chest_back", flare((0, .35), [(13.0, 1.62 + k, .98), (14.95, 1.66 + k, 1.02)], 12, 80, by(g, 0, .22, .3)), "main", T, T)
    242:     if g == "heavy":
    243:         # side plates over the ribs, the reactor vents in them
    244:         P.solid("chest_side", sheet(rect(1.3, 1.72, 12.7, 14.4), [(-.7, 12.7), (.7, 12.7), (.78, 14.4), (-.78, 14.4)],
    245:                                     ring((.9, 0), (.84, .86), -70, 70)), "main", T, T)
    246:         slats = merge(*[prism([(-.4, z), (.4, z), (.4, z + .08), (-.4, z + .08)], 1.7, 1.78, "yz") for z in (13.1, 13.3, 13.5, 13.7)])
    247:         P.solid("chest_vent", slats, "frame", T, T, bevel=.008)
    248:     if g == "light":
    249:         harkens(P, J)
    250: 
    251: 
    252: def harkens(P, J):
    253:     """Harken launchers under the chest corners, muzzles forward and a little out: a pod, a reel showing
    254:     outboard, a clawed anchor in the muzzle. harken.L/R sit at the muzzles."""
    255:     T = J["torso"]
    256:     x, y, z = 1.36, -1.28, 12.92
    257:     d = Vector((.3, -1, 0)).normalized()
    258:     pod = loft([(0, circle(.24, 12)), (-.9, circle(.26, 12)), (-1.0, circle(.22, 12))])
    259:     P.solid("harken_pod", place(pod, Vector((x, y, z)) - d, d), "main", T, T)
    260:     P.solid("harken_reel", cylinder(.2, x + .14, x + .3, 14, axis="x", at=(-.62, z)), "joint", T, T, bevel=.01)
    261:     P.solid("harken_adapter", frame_std.box(1.0, 1.3, -.95, -.3, z - .12, z + .12), "frame", T, T, bevel=.015)
    262:     for s, sx in (("L", 1), ("R", -1)):
    263:         ds = Vector((d.x * sx, d.y, 0))
    264:         p = Vector((x * sx, y, z)) + ds * .06
    265:         j = empty(f"harken.{s}", p, T, dir=gltf_dir(ds))
    266:         solid(f"{P.n}_harken_ring.{s}", place(loft([(0, circle(.2, 14)), (-.07, circle(.18, 14))]), p, ds), "frame", j)
    267:         solid(f"{P.n}_harken_spike.{s}", place(loft([(0, circle(.1, 8)), (-.14, circle(.11, 8)), (-.42, circle(.012, 8))]), p, ds), "metal", j)
    268: 
    269: 
    270: def waist(P, J, g):
    271:     """A pinched abdomen sheet flaring up to the chest, the frame's rams showing either side. Heavy
    272:     closes the back too."""
    273:     W = J["waist"]
    274:     k = by(g, -.04, 0.0, .17)
    275:     rings = [(11.2, .72 + k * .9, .62 + k * .3), (11.95, .86 + k, .7 + k * .3)]
    276:     P.solid("waist_front", flare((0, -.12), rings, 185, 355, by(g, .12, .2, .26)), "main", W)
    277:     if g == "heavy":
    278:         P.solid("waist_back", flare((0, .12), rings, 20, 160, .2), "main", W)
    279: 
    280: 
    281: def pelvis(P, J, g):
    282:     """A fauld round the front of the belt, a pointed crotch plate, long front tassets flaring round the
    283:     thighs to pointed hems, side tassets under the hip pads, a culet behind in one or two lames. The
    284:     heavy hangs a tabard between the tassets."""
    285:     Pv = J["pelvis"]
    286:     P.solid("fauld", flare((0, 0), [(10.55, 1.42, 1.06), (11.08, 1.32, 1.0)], 185, 355, by(g, .14, .22, .28)), "main", Pv)
    287:     P.solid("crotch", sheet([(-.5, 10.6), (.5, 10.6), (.42, 10.1), (.14, 9.66), (-.14, 9.66), (-.42, 10.1)],
    288:                             [(-1.02, 10.6), (-.38, 10.6), (-.38, 9.66), (-.8, 9.66)], None), "main", Pv)
    289:     bot = by(g, 9.45, 9.15, 8.95)
    290:     G = GROW[g]
    291:     hem = lambda a: bot + .42 * min(1.0, abs(a - 268) / 62)  # pointed at the front of the thigh
    292:     P.solid("tasset", flare((1.12, -.1), [(10.78, .86 + G, .92 + G), (hem, 1.12 + G, 1.12 + G)], 200, 330, by(g, .1, .16, .22)), "main", Pv, Pv)
    293:     P.solid("tasset_hinge", frame_std.box(1.82, 2.12, -.22, .22, 10.42, 10.6), "frame", Pv, Pv, bevel=.012)
    294:     zs = by(g, 9.45, 9.25, 9.0)
    295:     P.solid("tasset_side", flare((1.32, 0), [(10.5, .78, .82), (zs, 1.2 + G, .98 + G)], -62, 62, by(g, .1, .14, .2)), "main", Pv, Pv)
    296:     lames = by(g, [(10.95, 10.05)], [(10.95, 10.2), (10.32, 9.62)], [(10.95, 10.1), (10.22, 8.75)])
    297:     for i, (za, zb) in enumerate(lames):
    298:         a = (8, 88) if g == "heavy" and i else (12, 86)
    299:         P.solid(f"culet{i}", flare((0, 0), [(za, 1.2 + i * .06, 1.08 + i * .06), (zb, 1.34 + i * .14, 1.24 + i * .14)], *a, by(g, .12, .16, .22)),
    300:                 "main", Pv, Pv)
    301:     if g == "heavy":
    302:         tab = lambda a: 8.55 + .3 * min(1.0, abs(a - 270) / 22)
    303:         P.solid("tabard", flare((0, -.3), [(10.6, .9, .98), (tab, 1.0, 1.04)], 248, 292, .1), "accent", Pv)
    304:         bearing_at("tabard", (0, -1.36, 9.7), (0, -1, 0), Pv, .6)
    305: 
    306: 
    307: # ---- arms -------------------------------------------------------------------------------------------------
    308: PAULDRON_C = (2.36, 0.0)
    309: # per grade: the cone's radii at the roof, at the hem, the hem's height, the flange's rise, thickness
    310: PAULDRON = {"light": dict(top=(.66, .76), hem=(.84, .86), zf=14.12, rise=.36, t=.1),
    311:             "medium": dict(top=(.76, .84), hem=(1.24, 1.02), zf=13.58, rise=.52, t=.14),
    312:             "heavy": dict(top=(.8, .88), hem=(1.44, 1.14), zf=13.36, rise=.66, t=.18)}
    313: 
    314: 
    315: def shoulder(P, J, g):
    316:     """The pauldron: a flat roof at the pad height on every grade, a cone flaring from it down and out to
    317:     a gold hem, a flange swept up along the outboard edge of the roof. The heavy hangs a second lame
    318:     under the hem. A root cover fills the step from the chest."""
    319:     S = lr(J, "shoulder")
    320:     p = PAULDRON[g]
    321:     c, a = PAULDRON_C, 125
    322:     (rx0, ry0), (rx1, ry1), zf, t = p["top"], p["hem"], p["zf"], p["t"]
    323:     P.solid("pauldron", flare(c, [(ROOF - .02, rx0, ry0), (zf, rx1, ry1)], -a, a, t), "main", *S)
    324:     P.solid("pauldron_roof", loft([(ROOF - .24, ring(c, (rx0 + .03, ry0 + .03), -a, a)), (ROOF, ring(c, (rx0 + .03, ry0 + .03), -a, a))]), "main", *S)
    325:     # the flange: rising from the roof's edge and leaning out, highest at the outboard point
    326:     rise = p["rise"]
    327:     top = lambda d: ROOF + rise * (1 - .85 * (d / 72) ** 2)
    328:     P.solid("pauldron_flange", flare(c, [(ROOF - .2, rx0 + .02, ry0 + .02), (top, rx0 + .18, ry0 + .12)], -72, 72, .1), "main", *S)
    329:     rz = lambda z, d: (rx0 + (rx1 - rx0) * (ROOF - z) / (ROOF - zf) + d, ry0 + (ry1 - ry0) * (ROOF - z) / (ROOF - zf) + d)
    330:     P.solid("pauldron_hem", flare(c, [(zf + .2, *rz(zf + .2, .07)), (zf - .03, *rz(zf - .03, .07))], -a, a, t + .12), "trim", *S, bevel=.012)
    331:     if g == "heavy":
    332:         P.solid("pauldron_lame", flare(c, [(zf + .2, rx1 - .02, ry1 - .02), (zf - .5, rx1 + .2, ry1 + .1)], -112, 112, .14), "main", *S)
    333:     P.solid("shoulder_bracket", frame_std.box(2.8, 2.96, -.14, .14, 14.3, 14.56), "frame", *S, bevel=.02)
    334:     P.solid("shoulder_root", sheet(rect(1.6, 2.0, 14.0, 15.05), [(-.8, 14.0), (.25, 14.0), (.25, 15.05), (-.5, 15.05), (-.8, 14.8)],
    335:                                    ring((1.8, -.1), (.3, .72), 180, 360)), "main", *S)
    336:     xb = c[0] + (rx0 + rx1) / 2
    337:     for side, j, sx in (("L", S[0], 1), ("R", S[1], -1)):
    338:         bearing_at(f"shoulder.{side}", (xb * sx, 0, (ROOF + zf) / 2), (sx, 0, -(rx1 - rx0) / (ROOF - zf)), j, .5)
    339: 
    340: 
    341: def upperarm(P, J, g):
    342:     """A sleeve round the bone, open toward the body, widening a little to the elbow: light a front and a
    343:     back sheet."""
    344:     UA = lr(J, "upperarm")
    345:     G = GROW[g]
    346:     rings = [(13.72, .5 + G, .5 + G), (12.5, .56 + G, .55 + G)]
    347:     if g == "light":
    348:         P.solid("upperarm", flare((2.45, 0), rings, -75, 70, .12), "main", *UA)
    349:         P.solid("upperarm_back", flare((2.45, 0), rings, 100, 150, .12), "main", *UA)
    350:     else:
    351:         P.solid("upperarm", flare((2.45, 0), rings, -by(g, 0, 150, 165), by(g, 0, 150, 165), by(g, 0, .2, .3)), "main", *UA)
    352: 
    353: 
    354: def forearm(P, J, g):
    355:     """A vambrace flaring to the wrist, the weapon pad proud of its outer face, and a pointed couter
    356:     over the back of the elbow."""
    357:     FA = lr(J, "forearm")
    358:     G = GROW[g]
    359:     rx = lambda r: min(r + G, .53) if G > 0 else r + G  # the outer face stays inside the pad
    360:     rings = [(11.55, rx(.44), .52 + G), (10.9, rx(.5), .58 + G), (9.82, rx(.56) + (.06 if G > 0 else 0), .66 + G)]
    361:     if g == "light":
    362:         P.solid("forearm", flare((2.5, 0), rings, -80, 80, .12), "main", *FA)
    363:         P.solid("forearm_back", flare((2.5, 0), rings, 105, 160, .12), "main", *FA)
    364:     else:
    365:         P.solid("forearm", flare((2.5, 0), rings, -by(g, 0, 150, 170), by(g, 0, 160, 170), by(g, 0, .2, .28)), "main", *FA)
    366:     k = by(g, -.08, 0.0, .08)
    367:     P.solid("couter", sheet([(2.05, 11.45), (2.95 + k, 11.45), (3.02 + k, 11.95), (2.85 + k, 12.4 + k), (2.05, 12.4 + k)],
    368:                             [(-.1, 12.4 + k), (.42, 12.4 + k), (.8 + k, 11.92), (.42, 11.45), (-.1, 11.45)], ring((2.5, .1), (.62 + k, .8 + k), -100, 120)),
    369:             "main", *FA)
    370:     if g == "heavy":
    371:         shield(P, J)
    372: 
    373: 
    374: SHIELD_CANT = -25.0  # the shield turns this far about the vertical toward the front
    375: 
    376: 
    377: def shield(P, J):
    378:     """The castellan's kite shield on the left forearm pad, round in plan, canted toward the front, a pale
    379:     down its face, a lance racked along its front edge."""
    380:     F = J["forearm", "L"]
    381:     at = frame_std.PADS["forearm"][1]
    382:     x0 = at[0] + frame_std.PAD_T + .1  # the pad's face
    383:     turn = lambda bm: transform(bm, rot("Z", SHIELD_CANT, about=(x0, 0, at[2])))
    384:     solid(f"{P.n}_shield_mount", frame_std.box(x0, x0 + .3, -.22, .22, 10.2, 10.64), "frame", F, .015)
    385:     xs = x0 + .3
    386:     outer = bez((xs, -1.4), (xs + .7, 0), (xs, 1.4), 20) + [(xs, 1.4)]
    387:     face = outer + [(x - .16, y) for x, y in reversed(outer)]
    388:     kite = [(-1.4, 12.9), (1.4, 12.9), (1.3, 10.2), (0, 7.4), (-1.3, 10.2)]
    389:     solid(f"{P.n}_shield", turn(sheet(rect(xs - .3, xs + .9, 7.3, 13.0), kite, face)), "main", F, CHAMFER, smooth=True)
    390:     pale = [(x + .04, y) for x, y in outer if abs(y) < .36]
    391:     pale = pale + [(x - .1, y) for x, y in reversed(pale)]
    392:     solid(f"{P.n}_shield_pale", turn(sheet(rect(xs - .3, xs + 1.0, 8.0, 12.7), [(-.34, 12.7), (.34, 12.7), (.34, 8.5), (0, 8.0), (-.34, 8.5)], pale)),
    393:           "accent", F, .015, smooth=True)
    394:     # a gold chief across the top edge
    395:     chief = [(x + .03, y) for x, y in outer] + [(x - .19, y) for x, y in reversed(outer)]
    396:     solid(f"{P.n}_shield_chief", turn(sheet(rect(xs - .3, xs + 1.0, 12.68, 12.98), [(-1.46, 12.68), (1.46, 12.68), (1.46, 12.98), (-1.46, 12.98)], chief)),
    397:           "trim", F, .01, smooth=True)
    398:     b = Vector((xs + .45, 0, 11.3))
    399:     bearing_at("shield", rot("Z", SHIELD_CANT, about=(x0, 0, at[2])) @ b, rot("Z", SHIELD_CANT).to_3x3() @ Vector((1, 0, 0)), F, 1.6)

    205 more lines not shown.

  • read_file{"Path":"~/work/sortie/kit/lab/board_sleek.py"}

    input

    {
      "Path": "~/work/sortie/kit/lab/board_sleek.py"
    }

    result, 317 lines

    Showing lines 1-316 of 316
    1: """Estoc (line B), sleek knight: few strong shapes in smooth compound curves, every one ending in a sharp
    2: tapered point (docs/study-atelier.md). Knightmare elegance on the atelier's stance.
    3: 
    4: Leaf pauldrons swept back to a rising point, a keeled breastplate whose hem runs to a V, a corseted
    5: waist, long blade tassets pointed at the hem, spiked couters, knee guards rising to a point, greaves
    6: that sweep to a point over the instep, twin blades swept back from the helm. Thin gold piping on the
    7: hems only. Long smooth faces carry long highlights: this direction leans hardest on the sheen.
    8: 
    9: Grades by plate count (plates(J, P, g)): the light a smaller leaf, a bellows waist, short blade tassets,
    10: an arming sleeve, one pair of short blades on the helm, the core block. The medium the board's line
    11: knight. The heavy a second leaf under the first and a blade under that, a V plate over the lower breast,
    12: flank blades, tassets in two layers, blade add-ons over the vambraces, cuisses and greaves, knee blades,
    13: two pairs of helm blades.
    14: """
    15: import math
    16: 
    17: from knightkit import Sheet, addon, band, by, curve, horn, joint_covers, lames, lin, put, put2, rim, smooth, tent
    18: from lib import copy
    19: from makers import atelier
    20: from makers.atelier import bearing_at, lr
    21: from makers.shell import subtract
    22: 
    23: FRONT = lin(-172, -8, 32)
    24: breast_r = curve([1.0, 1.34, 1.52, 1.52, 1.42, 1.26, 1.1])
    25: 
    26: 
    27: def keel(u, z, grow=0.0, z0=12.1, z1=15.05):
    28:     r = breast_r(min(max((z - z0) / (z1 - z0), 0), 1)) + grow
    29:     a = math.radians(u)
    30:     return (r * 1.08 * math.cos(a), -.15 + r * math.sin(a), z)
    31: 
    32: 
    33: def chest(P, J, g):
    34:     T, C = J["torso"], J["cockpit"]
    35:     H = T if g == "light" else C  # the light's cockpit is the core block: its breast does not open
    36:     bot = lambda u: 12.1 + .7 * (1 - tent(u, -90, 70))  # the hem runs down to a V
    37:     top = lambda u: 15.05 - .28 * tent(u, -90, 40) - .55 * smooth(abs(u + 90), 56, 80)
    38:     ridge = lambda u, v: .2 * tent(u, -90, 34) * (1 - smooth(v, .85, 1))  # a keel, crisp on its crest
    39:     hi = lambda u: 12.9 + 1.2 * (1 - tent(u, -90, 100)) ** 1.6  # the ivory field above a second V, clear of the socket
    40:     s = Sheet(lambda u, v: keel(u, bot(u) + (top(u) - bot(u)) * v), FRONT, lin(0, 1, 16), .15, disp=ridge, inside=(0, 0, 13.6))
    41:     bm = s.bm()
    42:     up = subtract(copy(bm), _below(hi))
    43:     lo = subtract(bm, _above(hi))
    44:     # the ivory field above the V is the hatch: it leaves with the pod, so no box is cut in the breast
    45:     P.solid("hatch", up, "accent", H, bevel=.012)
    46:     P.solid("breast_lo", lo, "main", T, bevel=.012)
    47:     rim(P, "breast_pipe", s.edge("v0", out=.01), .045, T)
    48:     bearing_at("chest", (1.0, -1.55, 14.3), (0, -1, 0), T, .8)
    49:     back = band((0, .15), 12.3, lambda u: 15.0 - .4 * smooth(u, 55, 80), [1.0, 1.42, 1.56, 1.5, 1.3], lin(14, 82, 10), nv=10, kx=1.04, ky=.92, t=.14)
    50:     put(P, "backplate", back, "main", T, T)
    51:     gg = band((0, .05), 14.8, 15.36, [1.14, 1.04, .92], lin(-168, -12, 24), nv=5, kx=1.05, t=.12)
    52:     put(P, "gorget", gg, "main", T)
    53:     if g == "light":
    54:         return
    55:     g2 = band((0, .05), 15.2, 15.62, [1.0, .94, .86], lin(-164, -16, 22), nv=4, kx=1.05, t=.1)
    56:     put(P, "gorget2", g2, "main", T)
    57:     rim(P, "gorget2_pipe", g2.edge("v1", out=.01), .04, T)
    58:     if g != "heavy":
    59:         return
    60:     # the castellan: a V plate over the lower breast, blades down the flanks
    61:     vb = lambda u: 12.0 + .7 * (1 - tent(u, -90, 70))
    62:     vt = lambda u: 12.75 + .5 * (1 - tent(u, -90, 70))
    63:     v = Sheet(lambda u, v: keel(u, vb(u) + (vt(u) - vb(u)) * v, .17), lin(-158, -22, 28), lin(0, 1, 5), .14,
    64:               disp=lambda u, v: .2 * tent(u, -90, 34), inside=(0, 0, 13.0))
    65:     put(P, "breast_v", v, "main", T)
    66:     rim(P, "breast_v_pipe", v.edge("v1", out=.01), .045, T)
    67:     P.solid("flank_blade", horn([(1.5, -.3, 14.3), (1.62, -.2, 13.6), (1.6, -.1, 12.9), (1.42, 0, 12.2)], .26, n=10, power=1.0, squash=.3,
    68:                                 up=(1, 0, 0)), "main", T, T, bevel=0)
    69: 
    70: 
    71: def _below(h):
    72:     """A solid under the curve z = h(u) on the chest front (u in plan degrees)."""
    73:     return _split(h, -1)
    74: 
    75: 
    76: def _above(h):
    77:     return _split(h, 1)
    78: 
    79: 
    80: def _split(h, side):
    81:     import bmesh
    82:     bm = bmesh.new()
    83:     us = lin(-178, -2, 120)
    84:     far = 30 if side > 0 else -30
    85:     rings = []
    86:     for z in (None, far):
    87:         ring = []
    88:         for u in us:
    89:             a = math.radians(u)
    90:             zz = h(u) if z is None else h(u) + far
    91:             ring += [bm.verts.new((.2 * math.cos(a), -.15 + .2 * math.sin(a), zz)), bm.verts.new((4 * math.cos(a), -.15 + 4 * math.sin(a), zz))]
    92:         rings.append(ring)
    93:     n = len(us)
    94:     A, B = rings
    95:     for i in range(n - 1):
    96:         a0, a1, b0, b1 = A[2 * i], A[2 * i + 1], A[2 * i + 2], A[2 * i + 3]
    97:         c0, c1, d0, d1 = B[2 * i], B[2 * i + 1], B[2 * i + 2], B[2 * i + 3]
    98:         bm.faces.new((a0, b0, b1, a1))
    99:         bm.faces.new((c0, c1, d1, d0))
    100:         bm.faces.new((a1, b1, d1, c1))
    101:         bm.faces.new((a0, c0, d0, b0))
    102:     bm.faces.new((A[0], A[1], B[1], B[0]))
    103:     bm.faces.new((A[-2], B[-2], B[-1], A[-1]))
    104:     bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
    105:     return bm
    106: 
    107: 
    108: def waist(P, J, g):
    109:     W = J["waist"]
    110:     if g == "light":
    111:         return  # a bellows waist (joint_covers)
    112:     s = band((0, -.1), 11.3, 12.3, [.94, .8, .86, .96], lin(-170, -10, 26), nv=8, kx=1.08, t=.16,
    113:              disp=lambda u, v: .08 * tent(u, -90, 30))
    114:     put(P, "corset", s, "main", W)
    115: 
    116: 
    117: def pelvis(P, J, g):
    118:     Pv = J["pelvis"]
    119:     heavy = g == "heavy"
    120:     f = band((0, 0), 10.55, 11.25, [1.42, 1.36, 1.2], lin(-172, -8, 30), nv=5, kx=1.06, ky=.84, t=.16, disp=lambda u, v: .1 * tent(u, -90, 30))
    121:     put(P, "fauld", f, "main", Pv)
    122:     P.solid("crotch", atelier.sheet([(-.5, 10.6), (.5, 10.6), (.36, 10.0), (0, 9.5), (-.36, 10.0)],
    123:                                     [(-1.04, 10.6), (-.38, 10.6), (-.38, 9.5), (-.9, 9.5)], None), "main", Pv)
    124:     # a long blade tasset over each thigh, pointed at the hem
    125:     hem = by(g, lambda u: 9.2 + .7 * (1 - tent(u, -100, 62)), lambda u: 8.35 + .95 * (1 - tent(u, -100, 62)),
    126:              lambda u: 8.0 + 1.0 * (1 - tent(u, -100, 62)))
    127:     t = band((1.1, -.12), hem, 10.72, lambda u, v: 1.18 - .22 * v + .06 * math.sin(math.pi * v), lin(-164, -36, 24), nv=10, t=.14,
    128:              disp=lambda u, v: .07 * tent(u, -100, 22))
    129:     put(P, "tasset", t, "main", Pv, Pv)
    130:     rim(P, "tasset_pipe", t.edge("v0", out=.01), .04, Pv, Pv)
    131:     if g != "light":
    132:         # a shorter blade over the long one: the tasset in two layers
    133:         oh = lambda u: 9.0 + .8 * (1 - tent(u, -100, 56))
    134:         t2 = band((1.1, -.12), oh, 10.76, lambda u, v: 1.3 - .22 * v + .06 * math.sin(math.pi * v), lin(-156, -44, 20), nv=8, t=.13,
    135:                   disp=lambda u, v: .07 * tent(u, -100, 22))
    136:         put(P, "tasset_over", t2, "main", Pv, Pv)
    137:         rim(P, "tasset_over_pipe", t2.edge("v0", out=.01), .045, Pv, Pv)
    138:     if heavy:
    139:         lames(P, "tasset_side_lame", (1.3, 0), 9.4, 2, .4, .32, 1.12, -.03, lin(-46, 46, 12), Pv, Pv, "main", "main")
    140:     if g == "light":
    141:         c = band((0, 0), 10.0, 10.95, [1.36, 1.28, 1.22], lin(10, 88, 12), nv=4, ky=.92, t=.12)
    142:         put(P, "culet", c, "main", Pv, Pv)
    143:         return
    144:     side = band((1.3, 0), lambda u: 9.25 + .5 * (1 - tent(u, 0, 50)), 10.55, [1.12, .86], lin(-50, 50, 12), nv=6, t=.12)
    145:     put(P, "tasset_side", side, "main", Pv, Pv)
    146:     c = band((0, 0), lambda u: 9.6 + .5 * smooth(u, 20, 80), 10.95, [1.42, 1.3, 1.22], lin(10, 88, 12), nv=6, ky=.92, t=.14)
    147:     put(P, "culet", c, "main", Pv, Pv)
    148: 
    149: 
    150: def shoulder(P, J, g):
    151:     """A leaf: one shell over the shoulder, blunt in front, drawn back and up into a point. The castellan
    152:     layers a second leaf under it and a blade under that."""
    153:     S = lr(J, "shoulder")
    154:     # light one small leaf, medium a leaf over a second, heavy one great leaf over a long swept mantle: the
    155:     # extra mass goes into one gesture, the surfaces stay smooth
    156:     leaves = by(g, [(.82, 0.0, 2.0, 1.75)], [(1.0, 0.0, 2.0, 1.75), (.9, -.55, 1.4, 1.75)], [(1.12, 0.0, 2.2, 1.75), (1.0, -.5, 1.0, 2.9)])
    157:     for i, (k, dz, rise, length) in enumerate(leaves):
    158:         leaf(P, S, f"pauldron{i}" if i else "pauldron", k, dz, rise, ridge=i == 0, pipe="trim" if i == 0 else "main", length=length)
    159:     for side, j, sx in (("L", S[0], 1), ("R", S[1], -1)):
    160:         bearing_at(f"shoulder.{side}", (3.8 * sx, .1, 14.2), (sx, 0, 0), j, .5)
    161: 
    162: 
    163: def leaf(P, S, name, k, dz, rise, ridge=True, pipe="trim", length=1.75):
    164: 
    165:     def width(s):
    166:         return (1 - abs(s) ** 4) ** .35 if s < 0 else (1 - s ** 1.4) ** .8  # a broad root in front, one point behind
    167: 
    168:     def f(s, p):
    169:         back = max(s, 0.0)
    170:         w = width(s)
    171:         y = s * (1.2 if s < 0 else length) * k
    172:         xc, zc = 2.5 + .7 * k * back ** 2, 14.4 + dz + rise * k * back ** 2  # the point sweeps up and out behind the shoulder, seen from the front
    173:         a = math.radians(p)
    174:         c, n = math.cos(a), math.sin(a)
    175:         return (xc + 1.36 * k * w * math.copysign(abs(c) ** .75, c), .06 + y, zc + .86 * k * w * math.copysign(abs(n) ** .85, n))
    176:     # a ridge along the crown from the root into the point
    177:     sh = Sheet(f, lin(-1.0, .985, 40), lin(116, -96, 28) if ridge else lin(70, -96, 22), .15,
    178:                disp=(lambda s, p: .16 * width(s) * tent(p, 52, 26)) if ridge else None, inside=(2.5, 0, 14.3 + dz))
    179:     put(P, name, sh, "main", *S)
    180:     if pipe:
    181:         rim(P, f"{name}_pipe", sh.edge("v1", out=.01), .045, *S, role=pipe)
    182: 
    183: 
    184: def upperarm(P, J, g):
    185:     UA = lr(J, "upperarm")
    186:     if g == "light":
    187:         return  # an arming sleeve (joint_covers)
    188:     s = band((2.45, 0), 12.4, 13.6, [.56, .54, .5], lin(-150, 150, 26), nv=5, t=.16)
    189:     put(P, "sleeve", s, "main", *UA)
    190:     if g == "heavy":
    191:         lames(P, "sleeve_lame", (2.45, 0), 13.7, 1, .4, .3, .62, 0, lin(-150, 150, 26), *UA, "main", "trim")
    192: 
    193: 
    194: def forearm(P, J, g):
    195:     FA = lr(J, "forearm")
    196:     k = by(g, .7, 1.0, 1.2)
    197:     s = band((2.5, 0), 9.86, 11.6, [.6, .54, .48, .47], lin(-165, 165, 40), nv=8, kx=.92, t=.16,
    198:              disp=lambda u, v: .07 * tent(u, -90, 26))
    199:     put(P, "vambrace", s, "main", *FA)
    200:     rim(P, "vambrace_pipe", s.edge("v0", out=.01), .04, *FA)
    201:     # the couter: a swept spike off the back of the elbow
    202:     P.solid("couter", horn([(2.5, .2, 12.0), (2.56, .2 + .5 * k, 12.05), (2.62, .2 + 1.0 * k, 12.05 + .25 * k), (2.66, .2 + 1.35 * k, 12.05 + .7 * k)],
    203:                            .42, n=12, power=1.2, squash=.7), "main", *FA, bevel=0)
    204:     if g != "light":
    205:         cuff = band((2.5, 0), 9.5, 9.92, [.62, .58], lin(-165, 165, 30), nv=2, kx=.92, t=.1)
    206:         put(P, "vambrace_cuff", cuff, "main", *FA)
    207:     if g == "heavy":
    208:         addon(P, "vambrace_blade", (2.5, 0), lambda v: .66 - .08 * v, lin(-140, -40, 12), 9.95, 11.4, .55, *FA, "main", kx=.92, studs=0, rim_role="main")
    209:     P.solid("couter_cup", Sheet(_cup((2.5, .1, 11.95)), lin(0, 360, 20), lin(0, 80, 6), .1, wrap=True, inside=(2.5, 0, 11.95)).bm(), "main", *FA, bevel=0)
    210: 
    211: 
    212: def _cup(c):
    213:     from knightkit import cap
    214:     return cap(c, (0, 1, 0), (.55, .55, .4))
    215: 
    216: 
    217: def thigh(P, J, g):
    218:     TH = lr(J, "thigh")
    219:     s = band((1.16, -.05), 6.75, 9.7, [.74, .8, .86, .86], lin(-162, -18, 24), nv=10, t=.2, disp=lambda u, v: .1 * tent(u, -90, 30))
    220:     put(P, "cuisse", s, "main", *TH)
    221:     if g == "light":
    222:         return
    223:     b = band((1.16, -.05), 7.0, 9.5, [.72, .8, .84], lin(28, 152, 16), nv=6, t=.18)
    224:     put(P, "cuisse_back", b, "main", *TH)
    225:     if g == "heavy":
    226:         addon(P, "cuisse_blade", (1.16, -.05), lambda v: .98 + .04 * v, lin(-136, -44, 14), 7.4, 9.5, .8, *TH, "main", studs=0, rim_role="main")
    227: 
    228: 
    229: GC = (1.2, .02)
    230: 
    231: 
    232: def shin(P, J, g):
    233:     SH = lr(J, "shin")
    234:     heavy = g == "heavy"
    235:     # the knee guard: a shell over the knee rising to a point above it
    236:     top = lambda u: 6.55 + 1.0 * tent(u, -90, 46) ** 1.6
    237:     k = band((1.2, -.12), 5.45, top, lambda u, v: .74 + .08 * math.sin(math.pi * v) - .14 * v * v, lin(-160, -20, 26), nv=10, ky=1.1, t=.16,
    238:              disp=lambda u, v: .1 * tent(u, -90, 30))
    239:     put(P, "knee", k, "main", *SH)
    240:     rim(P, "knee_pipe", k.edge("v0", out=.01), .04, *SH)
    241:     # the greave: one smooth sheet, its hem swept down to a point over the instep
    242:     hem = lambda u: 1.7 - .55 * tent(u, -90, 50) ** 1.5
    243:     g_ = band(GC, hem, 5.45, [1.08, .86, .68, .64, .66, .6, .55], lin(-176, -4, 34), nv=14, ky=1.14, t=.16,
    244:              disp=lambda u, v: .09 * tent(u, -90, 30) * (1 - smooth(v, .9, 1)))
    245:     put(P, "greave", g_, "main", *SH)
    246:     if heavy:
    247:         addon(P, "greave_blade", GC, lambda v: [1.14, .96, .8, .74, .74][min(int(v * 4.999), 4)] + .02, lin(-124, -56, 12), 2.2, 5.1, 1.2, *SH,
    248:               "main", ky=1.14, studs=0, rim_role="main")
    249:     if g != "light":
    250:         for nm, sx in (("o", 1), ("i", -1))[:by(g, 0, 1, 2)]:
    251:             x = 1.2 + sx * .72
    252:             P.solid(f"knee_blade_{nm}", horn([(x, -.1, 6.0), (x + sx * .12, .2, 6.3), (x + sx * .2, .6, 6.8)], .3, n=10, power=1.0, squash=.3,
    253:                                                up=(1, 0, 0)), "main", *SH, bevel=0)
    254:     if g == "light":
    255:         rim(P, "greave_pipe", g_.edge("v0", out=.01), .045, *SH)
    256:         calf = band(GC, 2.0, 5.2, [.9, .76, .66, .7, .72, .6], lin(40, 140, 14), nv=10, ky=1.12, t=.1)
    257:         put(P, "calf", calf, "main", *SH)
    258:         return
    259:     panel = band(GC, lambda u: hem(u) + .25, 5.2, [1.12, .9, .72, .68, .7, .64, .58], lin(-108, -72, 8), nv=14, ky=1.14, t=.08,
    260:                  disp=lambda u, v: .09 * tent(u, -90, 30) * (1 - smooth(v, .9, 1)))
    261:     put(P, "greave_panel", panel, "accent", *SH)
    262:     rim(P, "greave_pipe", g_.edge("v0", out=.01), .045, *SH)
    263:     calf = band(GC, 1.92, 5.3, [1.0, .84, .7, .76, .82, .66], lin(10, 170, 22), nv=12, ky=1.12, t=.14)
    264:     put(P, "calf", calf, "main", *SH)
    265:     for side, j, sx in (("L", SH[0], 1), ("R", SH[1], -1)):
    266:         bearing_at(f"shin.{side}", (1.2 * sx, GC[1] - .85, 4.0), (0, -1, 0), j, .4)
    267: 
    268: 
    269: def helm_blades(g):
    270:     def make(P, J):
    271:         """Twin blades swept back from the temples: short on the light, a second lower pair on the heavy."""
    272:         from knightkit import head_layers
    273:         H = J["head"]
    274:         pairs = by(g, [(.6, 0)], [(1.0, 0)], [(1.0, 0), (.7, -.32)])
    275:         for i, (k, dz) in enumerate(pairs):
    276:             for s, sx in (("L", 1), ("R", -1)):
    277:                 b = horn([(.5 * sx, -.2, 16.5 + dz), (.62 * sx, -.2 + .4 * k, 16.5 + dz + .25 * k), (.74 * sx, -.2 + .9 * k, 16.5 + dz + .6 * k),
    278:                           (.8 * sx, -.2 + 1.4 * k, 16.5 + dz + 1.1 * k)], .2, n=10, power=1.1, squash=.25, up=(1, 0, 0))
    279:                 P.solid(f"helm_blade{i}.{s}", b, "trim", H, bevel=0)
    280:         head_layers(P, J, g)
    281:     return make
    282: 
    283: 
    284: def back(P, J, g):
    285:     """A smooth plate over the pack drawn up to a point between the binders, broader on the castellan."""
    286:     from knightkit import back_layers
    287:     if g == "light":
    288:         return
    289:     B = J["backpack"]
    290:     k = by(g, 0, 0.0, .45)
    291:     back_layers(P, J, g, "main")
    292:     s = band((0, 1.5), 12.7 - k * .3, lambda u: 14.4 + 1.0 * tent(u, 90, 34) ** 1.4, [1.2 + k, 1.26 + k, 1.22 + k, 1.1 + k], lin(54, 126, 24), nv=10,
    293:              kx=.86, t=.12,
    294:              disp=lambda u, v: .08 * tent(u, 90, 22))
    295:     put(P, "pack_plate", s, "accent", B)
    296:     rim(P, "pack_plate_pipe", s.edge("v0", out=.01), .04, B)
    297: 
    298: 
    299: def plates(J, P, g="medium"):
    300:     from knightkit import helm, sabaton, shoulder_root
    301:     helm(P, J, g, helm_blades(g))
    302:     chest(P, J, g)
    303:     waist(P, J, g)
    304:     pelvis(P, J, g)
    305:     shoulder(P, J, g)
    306:     shoulder_root(P, J)
    307:     upperarm(P, J, g)
    308:     forearm(P, J, g)
    309:     thigh(P, J, g)
    310:     shin(P, J, g)
    311:     sab = by(g, ((.55, -3.4),), ((.55, -3.6),), ((.55, -1.4), (-1.2, -3.7)))
    312:     sabaton(P, J, lames=sab, point=1.0, keel=.08, rims="all")
    313:     atelier.backpack(P, J, g)
    314:     back(P, J, g)
    315:     atelier.binder(P, J, g)
    316:     joint_covers(P, J, g, style="bellows", fauld="bellows")