A mech game prototype, pushed by Gemini 4 Argon
agent (cont.)
+33:39read_file{"EndLine":350,"Path":"~/work/sortie/kit/lab/knightkit.py","StartLine":210}
input
{ "EndLine": 350, "Path": "~/work/sortie/kit/lab/knightkit.py", "StartLine": 210 }result, 142 lines
Showing lines 210-350 of 536 210: 211: def cap(c, axis, radii, up=(0, 0, 1)): 212: """f(u, v) for an ellipsoid round c with its pole along `axis`: u the angle round the axis in 213: degrees (0 toward `up`), v the angle from the pole in degrees. radii = (across up, across, along 214: the axis). Elbow and knee cops, fans and domes that face sideways.""" 215: z = Vector(axis).normalized() 216: x = Vector(up) - z * Vector(up).dot(z) 217: x = x.normalized() if x.length > 1e-6 else z.orthogonal().normalized() 218: y = z.cross(x) 219: c = Vector(c) 220: ra, rb, rp = radii 221: 222: def f(u, v): 223: a, b = math.radians(u), math.radians(v) 224: return c + x * (ra * math.sin(b) * math.cos(a)) + y * (rb * math.sin(b) * math.sin(a)) + z * (rp * math.cos(b)) 225: return f 226: 227: 228: def put(P, name, sheet, role, jl, jr=None, bevel=0): 229: """A sheet as a plate on a joint (mirrored onto jr).""" 230: P.solid(name, sheet.bm(), role, jl, jr, bevel=bevel) 231: 232: 233: def rim(P, name, pts, r, jl, jr=None, role="trim", rope=0.0, closed=False): 234: """A rolled rim along points, in trim by default.""" 235: P.solid(name, bead(pts, r, rope=rope, closed=closed), role, jl, jr, bevel=0) 236: 237: 238: def curve(vals): 239: """A smooth function on [0, 1] through evenly spaced values.""" 240: n = len(vals) - 1 241: s = spline([(i / n, v) for i, v in enumerate(vals)]) 242: return lambda t: s(t)[1] 243: 244: 245: def band(c, z0, z1, r, us, nv=6, kx=1.0, ky=1.0, t=.12, disp=None, wrap=False): 246: """A sheet round a vertical axis through c = (x, y) from height z0 to z1 (numbers or functions of 247: u). The radius r is a number, a pair (at z0, at z1), a list of evenly spaced values or a function 248: r(u, v), with v 0 at z0 and 1 at z1. Lames, tassets, greaves, sleeves.""" 249: Z0 = z0 if callable(z0) else (lambda u: z0) 250: Z1 = z1 if callable(z1) else (lambda u: z1) 251: if callable(r): 252: R = r 253: elif isinstance(r, (int, float)): 254: R = lambda u, v: r 255: elif len(r) == 2: 256: R = lambda u, v: r[0] + (r[1] - r[0]) * v 257: else: 258: g = curve(r) 259: R = lambda u, v: g(v) 260: 261: def f(u, v): 262: a = math.radians(u) 263: rr = R(u, v) 264: return (c[0] + rr * kx * math.cos(a), c[1] + rr * ky * math.sin(a), Z0(u) + (Z1(u) - Z0(u)) * v) 265: um = us[len(us) // 2] 266: if wrap: 267: us = list(us)[:-1] # a closed ring: the last angle is the first 268: return Sheet(f, us, lin(0, 1, nv), t, disp=disp, inside=(c[0], c[1], (Z0(um) + Z1(um)) / 2), wrap=wrap) 269: 270: 271: def helm(P, J, g, extra=None, base=True): 272: """The atelier's helm (makers.atelier) with `extra(P, J)` adding parts on the head joint, all 273: seated low between the pauldrons as atelier.head does. base=False leaves the atelier helm out, for a 274: line that draws its own (its shell must be named head_helmet, which atelier.crown_z reads).""" 275: from mathutils import Matrix 276: 277: from makers import atelier 278: H = J["head"] 279: if base: 280: atelier._head(P, J, g) 281: if extra is not None: 282: extra(P, J) 283: m = Matrix.Translation((0, 0, -atelier.HEAD_DROP)) 284: for o in H.children: 285: if o.type == "MESH": 286: for v in o.data.vertices: 287: v.co = m @ v.co 288: 289: 290: def horn(pts, r0, n=10, power=1.4, squash=1.0, up=(0, 0, 1)): 291: """A solid tapering from radius r0 at the first point to a sharp tip at the last, along a line of 292: points (bend it for a swept horn). `squash` flattens the section across `up`: a blade.""" 293: P = [Vector(p) for p in pts] 294: m = len(P) 295: L = [0.0] 296: for i in range(1, m): 297: L.append(L[-1] + (P[i] - P[i - 1]).length) 298: bm = bmesh.new() 299: rings = [] 300: for i in range(m): 301: t = (P[min(i + 1, m - 1)] - P[max(i - 1, 0)]).normalized() 302: a = Vector(up) - t * Vector(up).dot(t) 303: a = a.normalized() if a.length > 1e-6 else t.orthogonal().normalized() 304: b = t.cross(a) 305: r = r0 * max(1 - L[i] / L[-1], 0.0) ** power 306: if i == m - 1: 307: rings.append([bm.verts.new(P[i])]) 308: break 309: rings.append([bm.verts.new(P[i] + (a * math.cos(2 * math.pi * k / n) + b * squash * math.sin(2 * math.pi * k / n)) * r) for k in range(n)]) 310: for i in range(m - 2): 311: x, y = rings[i], rings[i + 1] 312: for k in range(n): 313: bm.faces.new((x[k], x[(k + 1) % n], y[(k + 1) % n], y[k])) 314: tip = rings[-1][0] 315: last = rings[-2] 316: for k in range(n): 317: bm.faces.new((last[k], last[(k + 1) % n], tip)) 318: bm.faces.new(list(reversed(rings[0]))) 319: bmesh.ops.recalc_face_normals(bm, faces=bm.faces) 320: return bm 321: 322: 323: def shoulder_root(P, J, role="main"): 324: """A curved inner spaulder cowl bridging the step from the breastplate to the pauldron.""" 325: S = (J["shoulder", "L"], J["shoulder", "R"]) 326: sh = band((1.82, -.04), 13.55, 15.08, [.68, .78, .72], lin(-155, 155, 22), nv=6, kx=1.08, ky=.96, t=.14, 327: disp=lambda u, v: .07 * tent(u, -90, 36)) 328: put(P, "shoulder_root", sh, role, *S) 329: rim(P, "shoulder_root_rim", sh.edge("v0", out=.01), .04, *S, role="trim") 330: 331: 332: def strip(path, w, t, grow_f): 333: """A flat band of width w along a path on a surface: path(s) -> (u, z) for s in [0, 1], grow_f(u, z, out) -> 334: the surface point at plan angle u and height z pushed out by `out`.""" 335: def f(s, k): 336: u, z = path(s) 337: return grow_f(u, z + k * w / 2, 0.0) 338: return Sheet(f, lin(0, 1, 16), lin(-1, 1, 2), t, inside=(0, 0, 13.6)) 339: 340: 341: def sabaton(P, J, lames=((.55, -3.35),), point=1.0, keel=0.0, rims="front", rope=0.0, role="main"): 342: """A sabaton arched over the frame's foot, in foot space (frame_std.place_foot fits it), plus the 343: atelier's heel spinner. `lames` are (heel end y, toe end y) spans, each laid over the next toward 344: the toe. `point` 1 narrows the toe to a point, 0 keeps it broad and round. `keel` raises a ridge down 345: the instep. `rims`: "front" rolls each lame's toe edge in trim, "all" rims the whole hem, None none.""" 346: import frame_std 347: from makers import atelier 348: FT = (J["foot", "L"], J["foot", "R"]) 349: fit = frame_std.place_foot 350: y_tip = min(b for _, b in lames)read_file{"EndLine":330,"Path":"~/work/sortie/kit/lab/board_sleek.py","StartLine":1}
input
{ "EndLine": 330, "Path": "~/work/sortie/kit/lab/board_sleek.py", "StartLine": 1 }result, 318 lines
Showing lines 1-317 of 317 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=0) 46: P.solid("breast_lo", lo, "main", T, bevel=0) 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.05, 12.35, [1.04, .84, .88, 1.0], lin(-176, -4, 28), nv=8, kx=1.08, t=.16, 113: disp=lambda u, v: .09 * tent(u, -90, 30)) 114: put(P, "corset", s, "main", W) 115: rim(P, "corset_pipe", s.edge("v0", out=.01), .04, W) 116: 117: 118: def pelvis(P, J, g): 119: Pv = J["pelvis"] 120: heavy = g == "heavy" 121: 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)) 122: put(P, "fauld", f, "main", Pv) 123: P.solid("crotch", atelier.sheet([(-.5, 10.6), (.5, 10.6), (.36, 10.0), (0, 9.5), (-.36, 10.0)], 124: [(-1.04, 10.6), (-.38, 10.6), (-.38, 9.5), (-.9, 9.5)], None), "main", Pv) 125: # a long blade tasset over each thigh, pointed at the hem 126: hem = by(g, lambda u: 9.2 + .7 * (1 - tent(u, -100, 62)), lambda u: 8.35 + .95 * (1 - tent(u, -100, 62)), 127: lambda u: 8.0 + 1.0 * (1 - tent(u, -100, 62))) 128: 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, 129: disp=lambda u, v: .07 * tent(u, -100, 22)) 130: put(P, "tasset", t, "main", Pv, Pv) 131: rim(P, "tasset_pipe", t.edge("v0", out=.01), .04, Pv, Pv) 132: if g != "light": 133: # a shorter blade over the long one: the tasset in two layers 134: oh = lambda u: 9.0 + .8 * (1 - tent(u, -100, 56)) 135: 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, 136: disp=lambda u, v: .07 * tent(u, -100, 22)) 137: put(P, "tasset_over", t2, "main", Pv, Pv) 138: rim(P, "tasset_over_pipe", t2.edge("v0", out=.01), .045, Pv, Pv) 139: if heavy: 140: lames(P, "tasset_side_lame", (1.3, 0), 9.4, 2, .4, .32, 1.12, -.03, lin(-46, 46, 12), Pv, Pv, "main", "main") 141: if g == "light": 142: c = band((0, 0), 10.0, 10.95, [1.36, 1.28, 1.22], lin(10, 88, 12), nv=4, ky=.92, t=.12) 143: put(P, "culet", c, "main", Pv, Pv) 144: return 145: 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) 146: put(P, "tasset_side", side, "main", Pv, Pv) 147: 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) 148: put(P, "culet", c, "main", Pv, Pv) 149: 150: 151: def shoulder(P, J, g): 152: """A leaf: one shell over the shoulder, blunt in front, drawn back and up into a point. The castellan 153: layers a second leaf under it and a blade under that.""" 154: S = lr(J, "shoulder") 155: # light one small leaf, medium a leaf over a second, heavy one great leaf over a long swept mantle: the 156: # extra mass goes into one gesture, the surfaces stay smooth 157: 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)]) 158: for i, (k, dz, rise, length) in enumerate(leaves): 159: 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) 160: for side, j, sx in (("L", S[0], 1), ("R", S[1], -1)): 161: bearing_at(f"shoulder.{side}", (3.8 * sx, .1, 14.2), (sx, 0, 0), j, .5) 162: 163: 164: def leaf(P, S, name, k, dz, rise, ridge=True, pipe="trim", length=1.75): 165: 166: def width(s): 167: return (1 - abs(s) ** 4) ** .35 if s < 0 else (1 - s ** 1.4) ** .8 # a broad root in front, one point behind 168: 169: def f(s, p): 170: back = max(s, 0.0) 171: w = width(s) 172: y = s * (1.2 if s < 0 else length) * k 173: 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 174: a = math.radians(p) 175: c, n = math.cos(a), math.sin(a) 176: return (xc + 1.36 * k * w * math.copysign(abs(c) ** .75, c), .06 + y, zc + .86 * k * w * math.copysign(abs(n) ** .85, n)) 177: # a ridge along the crown from the root into the point; stop p at -20 deg so the wing flares outward instead of curling under 178: sh = Sheet(f, lin(-1.0, .985, 40), lin(124, -20, 24) if ridge else lin(72, -26, 18), .15, 179: disp=(lambda s, p: .16 * width(s) * tent(p, 52, 26)) if ridge else None, inside=(2.5, 0, 14.3 + dz)) 180: put(P, name, sh, "main", *S) 181: if pipe: 182: rim(P, f"{name}_pipe", sh.edge("v1", out=.01), .045, *S, role=pipe) 183: 184: 185: def upperarm(P, J, g): 186: UA = lr(J, "upperarm") 187: if g == "light": 188: return # an arming sleeve (joint_covers) 189: s = band((2.45, 0), 12.4, 13.6, [.56, .54, .5], lin(-150, 150, 26), nv=5, t=.16) 190: put(P, "sleeve", s, "main", *UA) 191: if g == "heavy": 192: lames(P, "sleeve_lame", (2.45, 0), 13.7, 1, .4, .3, .62, 0, lin(-150, 150, 26), *UA, "main", "trim") 193: 194: 195: def forearm(P, J, g): 196: FA = lr(J, "forearm") 197: k = by(g, .7, 1.0, 1.2) 198: s = band((2.5, 0), 9.86, 11.6, [.6, .54, .48, .47], lin(-165, 165, 40), nv=8, kx=.92, t=.16, 199: disp=lambda u, v: .07 * tent(u, -90, 26)) 200: put(P, "vambrace", s, "main", *FA) 201: rim(P, "vambrace_pipe", s.edge("v0", out=.01), .04, *FA) 202: # the couter: a swept spike off the back of the elbow 203: 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)], 204: .42, n=12, power=1.2, squash=.7), "main", *FA, bevel=0) 205: if g != "light": 206: cuff = band((2.5, 0), 9.5, 9.92, [.62, .58], lin(-165, 165, 30), nv=2, kx=.92, t=.1) 207: put(P, "vambrace_cuff", cuff, "main", *FA) 208: if g == "heavy": 209: 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") 210: 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) 211: 212: 213: def _cup(c): 214: from knightkit import cap 215: return cap(c, (0, 1, 0), (.55, .55, .4)) 216: 217: 218: def thigh(P, J, g): 219: TH = lr(J, "thigh") 220: 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)) 221: put(P, "cuisse", s, "main", *TH) 222: if g == "light": 223: return 224: b = band((1.16, -.05), 7.0, 9.5, [.72, .8, .84], lin(28, 152, 16), nv=6, t=.18) 225: put(P, "cuisse_back", b, "main", *TH) 226: if g == "heavy": 227: 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") 228: 229: 230: GC = (1.2, .02) 231: 232: 233: def shin(P, J, g): 234: SH = lr(J, "shin") 235: heavy = g == "heavy" 236: # the knee guard: a shell over the knee rising to a point above it 237: top = lambda u: 6.55 + 1.0 * tent(u, -90, 46) ** 1.6 238: 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, 239: disp=lambda u, v: .1 * tent(u, -90, 30)) 240: put(P, "knee", k, "main", *SH) 241: rim(P, "knee_pipe", k.edge("v0", out=.01), .04, *SH) 242: # the greave: one smooth sheet, its hem swept down to a point over the instep 243: hem = lambda u: 1.7 - .55 * tent(u, -90, 50) ** 1.5 244: 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, 245: disp=lambda u, v: .09 * tent(u, -90, 30) * (1 - smooth(v, .9, 1))) 246: put(P, "greave", g_, "main", *SH) 247: if heavy: 248: 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, 249: "main", ky=1.14, studs=0, rim_role="main") 250: if g != "light": 251: for nm, sx in (("o", 1), ("i", -1))[:by(g, 0, 1, 2)]: 252: x = 1.2 + sx * .72 253: 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, 254: up=(1, 0, 0)), "main", *SH, bevel=0) 255: if g == "light": 256: rim(P, "greave_pipe", g_.edge("v0", out=.01), .045, *SH) 257: calf = band(GC, 2.0, 5.2, [.9, .76, .66, .7, .72, .6], lin(40, 140, 14), nv=10, ky=1.12, t=.1) 258: put(P, "calf", calf, "main", *SH) 259: return 260: 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, 261: disp=lambda u, v: .09 * tent(u, -90, 30) * (1 - smooth(v, .9, 1))) 262: put(P, "greave_panel", panel, "accent", *SH) 263: rim(P, "greave_pipe", g_.edge("v0", out=.01), .045, *SH) 264: 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) 265: put(P, "calf", calf, "main", *SH) 266: for side, j, sx in (("L", SH[0], 1), ("R", SH[1], -1)): 267: bearing_at(f"shin.{side}", (1.2 * sx, GC[1] - .85, 4.0), (0, -1, 0), j, .4) 268: 269: 270: def helm_blades(g): 271: def make(P, J): 272: """Twin blades swept back from the temples: short on the light, a second lower pair on the heavy.""" 273: from knightkit import head_layers 274: H = J["head"] 275: pairs = by(g, [(.6, 0)], [(1.0, 0)], [(1.0, 0), (.7, -.32)]) 276: for i, (k, dz) in enumerate(pairs): 277: for s, sx in (("L", 1), ("R", -1)): 278: 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), 279: (.8 * sx, -.2 + 1.4 * k, 16.5 + dz + 1.1 * k)], .2, n=10, power=1.1, squash=.25, up=(1, 0, 0)) 280: P.solid(f"helm_blade{i}.{s}", b, "trim", H, bevel=0) 281: head_layers(P, J, g) 282: return make 283: 284: 285: def back(P, J, g): 286: """A smooth plate over the pack drawn up to a point between the binders, broader on the castellan.""" 287: from knightkit import back_layers 288: if g == "light": 289: return 290: B = J["backpack"] 291: k = by(g, 0, 0.0, .45) 292: back_layers(P, J, g, "main") 293: 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, 294: kx=.86, t=.12, 295: disp=lambda u, v: .08 * tent(u, 90, 22)) 296: put(P, "pack_plate", s, "accent", B) 297: rim(P, "pack_plate_pipe", s.edge("v0", out=.01), .04, B) 298: 299: 300: def plates(J, P, g="medium"): 301: from knightkit import helm, sabaton, shoulder_root 302: helm(P, J, g, helm_blades(g)) 303: chest(P, J, g) 304: waist(P, J, g) 305: pelvis(P, J, g) 306: shoulder(P, J, g) 307: shoulder_root(P, J) 308: upperarm(P, J, g) 309: forearm(P, J, g) 310: thigh(P, J, g) 311: shin(P, J, g) 312: sab = by(g, ((.55, -3.4),), ((.55, -3.6),), ((.55, -1.4), (-1.2, -3.7))) 313: sabaton(P, J, lames=sab, point=1.0, keel=.08, rims="all") 314: atelier.backpack(P, J, g) 315: back(P, J, g) 316: atelier.binder(P, J, g) 317: joint_covers(P, J, g, style="bellows", fauld="bellows")read_file{"EndLine":120,"Path":"~/work/sortie/kit/lab/atelier_board.py","StartLine":1}
input
{ "EndLine": 120, "Path": "~/work/sortie/kit/lab/atelier_board.py", "StartLine": 1 }result, 65 lines
Showing lines 1-64 of 64 1: """The atelier's four house lines, each in three grades, one lab per line (docs/study-atelier.md): 2: 3: lab_atelier_a Harness plate armour taken seriously (board_plate) 4: lab_atelier_b Estoc sleek, few shapes, sharp points (board_sleek) 5: lab_atelier_c Blazon bold heraldic, per pale (board_heraldic) 6: lab_atelier_d Tilt lopsided tourney harness (board_tourney) 7: 8: Slots along X: slot1 light, slot2 medium, slot3 heavy. Round 1's medium for reference is lab_atelier's 9: slot2 (kit/lab/atelier_lab.py). In the houses' livery: 10: 11: /?view=lab_atelier_c&only=slot2&tx=20&palette=houses&bg=studio 12: 13: ATELIER_SLOTS=1,2 builds only those slots. 14: """ 15: import os 16: 17: import bpy 18: from mathutils import Matrix 19: 20: import board_heraldic 21: import board_plate 22: import board_sleek 23: import board_tourney 24: import frame_std 25: from lib import attach, empty 26: from makers import atelier 27: from makers.shell import Plates 28: 29: SPACING = 10.0 30: GRADES = ("light", "medium", "heavy") 31: KNEE = {"light": .41, "medium": .40, "heavy": .39} # round 1's .43 left a tenth of a metre of thigh 32: LINES = {"a": ("Harness", board_plate.plates), "b": ("Estoc", board_sleek.plates), "c": ("Blazon", board_heraldic.plates), 33: "d": ("Tilt", board_tourney.plates)} 34: 35: 36: def _place(frame, slot): 37: attach(frame, slot) 38: frame.matrix_parent_inverse = Matrix.Identity(4) 39: frame.location = (0, 0, 0) 40: bpy.context.view_layer.update() 41: 42: 43: def stance(J, knee): 44: frame_std.bend_knees(J, splay=atelier.SPLAY) 45: frame_std.proportion(J, atelier.crown_z(J), knee=knee, crotch=atelier.CROTCH_AT, crown=atelier.CROWN, shoulders=atelier.SHOULDER_OUT) 46: 47: 48: def build(line, g): 49: name, plates = LINES[line] 50: J = frame_std.build_frame(f"atelier_{name.lower()}_{g}") 51: plates(J, Plates(f"k{line}", atelier.CHAMFER, smooth=True), g) 52: stance(J, KNEE[g]) 53: return J["frame"] 54: 55: 56: def build_atelier_line(line): 57: only = os.environ.get("ATELIER_SLOTS") 58: root = empty("lab", (0, 0, 0)) 59: for i, g in enumerate(GRADES, 1): 60: if only and str(i) not in only.split(","): 61: continue 62: slot = empty(f"slot{i}", (i * SPACING, 0, 0), root, label=f"{LINES[line][0]} {g}") 63: _place(build(line, g), slot) 64: return rootread_file{"EndLine":120,"Path":"~/work/sortie/kit/build.py","StartLine":1}
input
{ "EndLine": 120, "Path": "~/work/sortie/kit/build.py", "StartLine": 1 }result, 74 lines
Showing lines 1-73 of 73 1: """Build every model into public/assets/*.glb. 2: 3: npm run kit # everything 4: npm run kit -- striker ship # just these 5: npm run kit -- block_dummy # a block model, kit/blocks/dummy.py 6: """ 7: import os 8: import sys 9: import time 10: 11: sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) 12: 13: import lib # noqa: E402 14: from block import build_block # noqa: E402 15: from cockpit import build_cockpit # noqa: E402 16: from cockpit_light import build_cockpit_light # noqa: E402 17: from mech import build_striker # noqa: E402 18: from heavy import build_heavy, build_heavy_lab # noqa: E402 19: from props import build_cannon, build_drone, build_rifle # noqa: E402 20: from ship import build_ship # noqa: E402 21: from station import build_station # noqa: E402 22: from salvage import build_salvage_pod, build_wreck_field # noqa: E402 23: from escape_pod import build_escape_pod # noqa: E402 24: from light import build_light, build_light_lab # noqa: E402 25: from automaton import build_automaton, build_automaton_lab # noqa: E402 26: from alien import build_alien, build_alien_lab # noqa: E402 27: sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "lab")) 28: from heads import build_head_lab, build_head_lab2 # noqa: E402 29: from headkit import build_head_lab3, build_head_lab4, build_head_lab5, build_head_lab6, build_head_lab7, build_head_lab8 # noqa: E402 30: from sizes import build_sizes # noqa: E402 31: from pilotlab import build_pilot_lab # noqa: E402 32: from assembly import build_assembly_lab, build_back_lab, build_chest_frames, build_show, game_frame # noqa: E402 33: from raider import build_raider, build_raider_lab # noqa: E402 34: from pattern_lab import build_pattern_lab, build_pattern_m # noqa: E402 35: from atelier_lab import build_atelier_lab # noqa: E402 36: from atelier_board import build_atelier_line # noqa: E402 37: from bodykit import build_chest_lab, build_chest_lab2, build_foot_lab, build_foot_lab2, build_chest_lab3, build_foot_lab3 # noqa: E402 38: 39: OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "public", "assets") 40: ASSETS = {"striker": build_striker, "striker_a": lambda: game_frame(0), "striker_b": lambda: game_frame(1), "rifle": build_rifle, "cannon": build_cannon, "drone": build_drone, 41: "cockpit": build_cockpit, "cockpit_light": build_cockpit_light, "ship": build_ship, "station": build_station, 42: "wreck_field": build_wreck_field, "salvage_pod": build_salvage_pod, "escape_pod": build_escape_pod, 43: "light": lambda: build_light("knight"), "light_line": lambda: build_light("line"), "light_lancer": lambda: build_light("lancer"), 44: "heavy": lambda: build_heavy("A"), "heavy_B": lambda: build_heavy("B"), "heavy_C": lambda: build_heavy("C"), 45: "lab_heads": build_head_lab, "lab_heads2": build_head_lab2, "lab_heads3": build_head_lab3, "lab_heads4": build_head_lab4, "lab_heads5": build_head_lab5, "lab_heads6": build_head_lab6, "lab_heads7": build_head_lab7, "lab_heads8": build_head_lab8, "lab_chests": build_chest_lab, "lab_feet": build_foot_lab, "lab_chests2": build_chest_lab2, "lab_feet2": build_foot_lab2, "lab_chests3": build_chest_lab3, "lab_feet3": build_foot_lab3, "lab_frames": build_assembly_lab, "lab_backs": build_back_lab, "lab_chests4": build_chest_frames, 46: "lab_show": build_show, "lab_show_v": lambda: build_show(formation=True), 47: "lab_heavy": build_heavy_lab, "lab_light": build_light_lab, "lab_sizes": build_sizes, "lab_pilot": build_pilot_lab, 48: "auto_tally": lambda: build_automaton("tally"), "auto_tick": lambda: build_automaton("tick"), 49: "auto_ledger": lambda: build_automaton("ledger"), 50: "alien_acicular": lambda: build_alien("acicular"), "alien_druse": lambda: build_alien("druse"), 51: "alien_druse_mimic": lambda: build_alien("druse_mimic"), "alien_geode": lambda: build_alien("geode"), 52: "raider_grunt": lambda: build_raider("grunt"), "raider_brawler": lambda: build_raider("brawler"), 53: "raider_boss": lambda: build_raider("boss"), 54: "pattern_m": build_pattern_m, "lab_pattern": build_pattern_lab, "lab_atelier": build_atelier_lab, "lab_atelier_a": lambda: build_atelier_line("a"), "lab_atelier_b": lambda: build_atelier_line("b"), 55: "lab_atelier_c": lambda: build_atelier_line("c"), "lab_atelier_d": lambda: build_atelier_line("d"), 56: "lab_auto": build_automaton_lab, "lab_alien": build_alien_lab, "lab_raider": build_raider_lab} 57: 58: 59: def main(names): 60: os.makedirs(OUT, exist_ok=True) 61: for name in names or [n for n in ASSETS if not n.startswith("lab")]: 62: t = time.time() 63: lib.reset() 64: if name.startswith("block_"): # scratch models, kit/blocks/<name>.py 65: build_block(name) 66: else: 67: ASSETS[name]() 68: path = os.path.normpath(os.path.join(OUT, f"{name}.glb")) 69: lib.export(path) 70: print(f"kit: {name} -> {path} ({os.path.getsize(path) // 1024} KB, {time.time() - t:.1f}s)") 71: 72: 73: main(sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])read_file{"EndLine":100,"Path":"~/work/sortie/kit/figure.py","StartLine":1}
input
{ "EndLine": 100, "Path": "~/work/sortie/kit/figure.py", "StartLine": 1 }result, 101 lines
Showing lines 1-100 of 383 1: """A 1.75 m pilot in a flight suit, for scale in labs and lineups and to sit in the light cockpit. 2: 3: A fitted dark undersuit with armoured plates on the chest, shoulders, forearms, thighs and shins, a 4: high collar, a life support pack, gloves and boots, and a sculpted helmet with a recessed dark visor, 5: ear pods and a crest stripe. Plates are the body's own surface grown outward and cut by an outline, 6: so they sit on the body like moulded armour and their edges read as real thickness. 7: 8: The body is modelled once standing (rest pose: facing -Y, Z up, feet on z=0) and posed rigidly per 9: joint, forward kinematics from the pelvis. Poses: 10: stand standing at ease, arms a little out 11: bike seated on a bike-style seat, leaning forward, hands forward on two grips (light cockpit) 12: `points(pose)` gives the posed eye, grips, seat and foot pegs without building anything, so a 13: cockpit can be laid out around the pilot. 14: 15: Roles: undersuit and gloves "suit", plates "main", secondary panels "accent", the crest stripe and 16: small markings the `role` argument. "hazard" paints world-space stripes a metre and a half apart, 17: which cut a person in half, so it falls back to "trim" here. 18: """ 19: import math 20: 21: import bmesh 22: import bpy 23: from mathutils import Matrix, Vector 24: 25: from lib import boolean, halves, link, loft, merge, prism, solid, subd, transform 26: 27: # ---- the skeleton, rest pose ------------------------------------------------------------------------------- 28: # joint: (parent, pivot). Pivots for the left side (+X); the right side mirrors x. 29: SKELETON = { 30: "pelvis": (None, (0, 0, .93)), 31: "chest": ("pelvis", (0, .01, 1.06)), 32: "head": ("chest", (0, .015, 1.5)), 33: "upperarm": ("chest", (.19, .01, 1.42)), 34: "forearm": ("upperarm", (.2, .02, 1.13)), 35: "hand": ("forearm", (.205, .01, .865)), 36: "thigh": ("pelvis", (.095, 0, .91)), 37: "shin": ("thigh", (.1, -.005, .5)), 38: "foot": ("shin", (.1, .02, .085)), 39: } 40: SIDED = {"upperarm", "forearm", "hand", "thigh", "shin", "foot"} 41: 42: # Joint rotations in degrees: (pitch about X, sideways about Y, twist about Z), applied in rest axes. 43: # A positive pitch tips an upward bone forward (-Y) and a downward bone back. A positive sideways 44: # value tips a downward left bone toward the centre line, mirrored on the right. 45: # `fingers` curls the fingers (degrees per knuckle), `thumb` closes the thumb. 46: POSES = { 47: "stand": dict(lift=0.0, joints={ 48: "upperarm": (-3, -7, 0), "forearm": (-12, 2, -20), "hand": (-4, 0, 0), 49: "thigh": (0, -1.5, 0), "shin": (2, 0, 0), "foot": (-2, 0, 0), "head": (-2, 0, 0)}, 50: fingers=(22, 18), thumb=10), 51: "bike": dict(lift=0.0, joints={ 52: "pelvis": (24, 0, 0), "chest": (18, 0, 0), "head": (-42, 0, 0), 53: "upperarm": (-124, -11, 0), "forearm": (-8, 4, -84), "hand": (8, 0, 6), 54: "thigh": (-86, -5, 0), "shin": (112, 3, 0), "foot": (-32, 0, 0)}, 55: fingers=(78, 72), thumb=55), 56: } 57: 58: # Points of interest in the rest pose, by joint: the eye (between the eyes, inside the helmet), the 59: # grip in each hand, the seat contact under the pelvis, the ball of each foot. 60: MARKS = {"eye": ("head", (0, -.085, 1.645)), "grip": ("hand", (.2, -.004, .79)), "seat": ("pelvis", (0, .0, .86)), 61: "peg": ("foot", (.1, -.07, .02))} 62: 63: 64: def _rot(p, r, t): 65: return Matrix.Rotation(math.radians(p), 4, "X") @ Matrix.Rotation(math.radians(r), 4, "Y") @ Matrix.Rotation(math.radians(t), 4, "Z") 66: 67: 68: def rig(pose="stand"): 69: """World matrices per joint (keys like "thigh.L") for a pose, feet-on-the-ground for stand.""" 70: P = POSES[pose] 71: M = {} 72: for name, (parent, piv) in SKELETON.items(): 73: for s, sx in ((("L", 1), ("R", -1)) if name in SIDED else (("", 1),)): 74: key = f"{name}.{s}" if s else name 75: pk = None if parent is None else (f"{parent}.{s}" if parent in SIDED else parent) 76: p, r, t = P["joints"].get(name, (0, 0, 0)) 77: c = Vector((piv[0] * sx, piv[1], piv[2])) 78: local = Matrix.Translation(c) @ _rot(p, r * sx, t * sx) @ Matrix.Translation(-c) 79: M[key] = (M[pk] if pk else Matrix.Translation((0, 0, P["lift"]))) @ local 80: return M 81: 82: 83: def place(at=(0.0, 0.0), z=0.0, turn=0.0): 84: """The placement of a built pilot: turned `turn` degrees about Z, then moved to (at, z).""" 85: return Matrix.Translation((at[0], at[1], z)) @ Matrix.Rotation(math.radians(turn), 4, "Z") 86: 87: 88: def points(pose="stand", at=(0.0, 0.0), z=0.0, turn=0.0): 89: """Posed marks in world space: eye, grip.L/R, seat, peg.L/R.""" 90: M = rig(pose) 91: off = place(at, z, turn) 92: out = {} 93: for mark, (joint, p) in MARKS.items(): 94: if joint in SIDED: 95: for s, sx in (("L", 1), ("R", -1)): 96: out[f"{mark}.{s}"] = off @ M[f"{joint}.{s}"] @ Vector((p[0] * sx, p[1], p[2])) 97: else: 98: out[mark] = off @ M[joint] @ Vector(p) 99: return out 100:read_file{"EndLine":310,"Path":"~/work/sortie/kit/makers/atelier.py","StartLine":230}
input
{ "EndLine": 310, "Path": "~/work/sortie/kit/makers/atelier.py", "StartLine": 230 }result, 82 lines
Showing lines 230-310 of 604 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),read_file{"EndLine":180,"Path":"~/work/sortie/kit/makers/atelier.py","StartLine":110}
input
{ "EndLine": 180, "Path": "~/work/sortie/kit/makers/atelier.py", "StartLine": 110 }result, 72 lines
Showing lines 110-180 of 604 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))read_file{"EndLine":604,"Path":"~/work/sortie/kit/makers/atelier.py","StartLine":450}
input
{ "EndLine": 604, "Path": "~/work/sortie/kit/makers/atelier.py", "StartLine": 450 }result, 156 lines
Showing lines 450-604 of 604 450: P.solid("greave", flare(GREAVE_C, grow(GREAVE, G), *a, t), "main", *SH) 451: a, t = by(g, (38, 142), (22, 158), (10, 170)), by(g, .12, .18, .26) 452: calf = [(z, rx + G, ry + G + by(g, 0, 0, .25) * min(1.0, (5.4 - z) / 1.2)) for z, rx, ry in CALF] # the heavy's calf deepens away from the knee 453: P.solid("greave_calf", flare(GREAVE_C, calf, *a, t), "main", *SH) 454: panel = [(z, rx + G + .04, ry + G + .04) for z, rx, ry in GREAVE if z >= 2.3] 455: P.solid("greave_panel", flare(GREAVE_C, [(5.2, .52 + G + .04, .64 + G + .04)] + panel[1:], 256, 284, .08), "accent", *SH, bevel=.012) 456: for side, j, sx in (("L", SH[0], 1), ("R", SH[1], -1)): 457: bearing_at(f"shin.{side}", (1.2 * sx, GREAVE_C[1] - .7 - G - .06, 4.3), (0, -1, 0), j, .4) 458: if g == "heavy": 459: for nm, (x0, x1) in (("o", (1.86, 2.02)), ("i", (.38, .54))): 460: P.solid(f"poleyn_fan_{nm}", cylinder(.62, x0, x1, 16, axis="x", at=(-.24, 6.18)), "main", *SH, bevel=.02) 461: P.solid(f"poleyn_boss_{nm}", cylinder(.18, x0 - .04, x1 + .04, 10, axis="x", at=(-.24, 6.18)), "metal", *SH, bevel=.01) 462: 463: 464: def foot(P, J, g): 465: """A sabaton: a vamp bent over the instep and narrowing to a clipped point, split at the toe hinge, 466: over the frame's sole. A heel spinner behind: a wheel under a curved fender that leaves its lower 467: back arc bare.""" 468: FT = lr(J, "foot") 469: fit = frame_std.place_foot 470: k = by(g, -.03, 0.0, .04) 471: f = [(.72 - k, .3), (1.68 + k, .3), (1.68 + k, .7), (1.44, 1.12 + k), (.96, 1.12 + k), (.72 - k, .92)] 472: s = [(-.3, 1.12 + k), (.42, 1.04), (.9, .8), (1.0, .56), (1.0, .34), (-3.3, .3), (-3.44, .38), (-3.1, .5), (-1.56, .74 + k), (-.62, 1.1 + k)] 473: plan = [(.74 - k, 1.1), (1.66 + k, 1.1), (1.7 + k, -1.4)] + bez((1.7 + k, -1.4), (1.62, -2.6), (1.32, -3.42), 5) \ 474: + [(1.32, -3.42), (1.08, -3.42)] + bez((1.08, -3.42), (.78, -2.6), (.7 - k, -1.4), 5) + [(.7 - k, -1.4)] 475: whole = sheet(f, s, plan) 476: P.solid("sabaton_toe", fit(clip(copy(whole), y=(-60, -1.59))), "main", *FT) 477: P.solid("sabaton", fit(clip(whole, y=(-1.53, 60))), "main", *FT) 478: P.solid("sabaton_hinge", fit(cylinder(.09, .6, 1.8, 10, axis="x", at=(-1.56, .5))), "metal", *FT, bevel=.01) 479: spinner(P, J, g) 480: 481: 482: def spinner(P, J, g): 483: """The heel spinner: a wheel under a curved fender that leaves its lower back arc bare.""" 484: FT = lr(J, "foot") 485: # drawn where the fitted foot puts it and only turned with the foot, so the wheel stays round 486: turn = lambda bm: transform(bm, rot("Z", frame_std.TURN, about=(frame_std.ANKLE[0], frame_std.ANKLE[1], 0))) 487: r = by(g, .46, .42, .4) 488: y, z = 1.3, r + .02 489: P.solid("spinner_tyre", turn(cylinder(r, .92, 1.48, 20, axis="x", at=(y, z))), "joint", *FT, bevel=.01) 490: P.solid("spinner_hub", turn(cylinder(r * .5, .88, 1.52, 12, axis="x", at=(y, z))), "metal", *FT, bevel=.01) 491: arc = bez((y - r - .12, z), (y - .1, z + r * 2.3), (y + r * .7, z + r * .75), 8) + [(y + r * .7, z + r * .75)] 492: fender = arc + [(yy, zz - .1) for yy, zz in reversed(arc)] 493: P.solid("spinner_fender", turn(sheet(rect(.84, 1.56, 0, 2), fender, None)), "main", *FT, bevel=.012) 494: 495: 496: # ---- back ------------------------------------------------------------------------------------------------- 497: def backpack(P, J, g): 498: """Medium and heavy: a pack round at the back with an accent panel, two main bells, verniers, and on 499: the heavy a broad shroud with tanks. Light: the core block, the cockpit.""" 500: if g == "light": 501: return core_block(P, J) 502: B = J["backpack"] 503: k = by(g, 0, 0.0, .45) 504: hw, z0 = .94 + k, 12.4 - k * .3 505: depth = 1.1 + k * .5 506: P.solid("pack", loft([(z0, ring((0, 1.5), (hw, depth - .2), 0, 180)), (z0 + .3, ring((0, 1.5), (hw + .06, depth), 0, 180)), 507: (14.45, ring((0, 1.5), (hw + .06, depth), 0, 180)), (14.85, ring((0, 1.5), (hw - .2, depth - .35), 0, 180))]), "main", B) 508: P.solid("pack_panel", flare((0, 1.5), [(13.0, hw + .1, depth + .05), (14.3, hw + .1, depth + .05)], 60, 120, .09), "accent", B, bevel=.015) 509: bearing_at("back", (0, 1.5 + depth + .06, 13.65), (0, 1, 0), B, 1.0) 510: r = by(g, .32, .42, .48) 511: yb = 1.5 + depth * .6 512: P.solid("pack_throat", merge(*[cylinder(r * .9, z0 - .14, z0 + .02, 12, at=(sx * .48, yb)) for sx in (1, -1)]), "frame", B, bevel=.01) 513: nozzle_pair("main", (.48, yb, z0 - .1), (0, .55, -.84), r, .62 + r * .5, B, B, housing=False) 514: nozzle_pair("vernier", (.5, 1.5 + depth * .8, 14.55), (0, .96, .28), .13, .24, B, B, housing=False) 515: if g == "heavy": 516: for s, sx in (("L", 1), ("R", -1)): 517: x = sx * (hw - .1) 518: P.solid(f"pack_tank.{s}", loft([(12.5, octo(.5, .5, .18, x=x, y=1.9)), (14.3, octo(.5, .5, .18, x=x, y=1.9))]), "metal", B) 519: 520: 521: def core_block(P, J): 522: """The light's cockpit: a capsule behind the chest, round in plan, its top level with the helm, 523: held on two docking lugs either side with a dark seam all round. Its back face is the hatch, an 524: accent field. It rides its own `core` node so it ejects whole.""" 525: T = J["torso"] 526: C = empty("core", (0, 1.85, 14.1), T) 527: J["core"] = C 528: y0 = 1.18 529: rings = lambda r, k: ring((0, 1.78), (1.02 * r, .82 * r + k), 0, 180) + [(-1.02 * r, y0), (1.02 * r, y0)] 530: P.solid("core", loft([(12.1, rings(.9, 0)), (12.5, rings(1.0, 0)), (15.7, rings(1.0, 0)), (16.3, rings(.82, -.1))]), "main", C) 531: P.solid("core_hatch", flare((0, 1.78), [(12.8, 1.06, .86), (15.4, 1.06, .86)], 56, 124, .1), "accent", C, bevel=.015) 532: bearing_at("back", (0, 1.78 + .88, 14.4), (0, 1, 0), C, 1.0) 533: solid(f"{P.n}_core_handle", frame_std.box(-.2, .2, 2.62, 2.7, 15.0, 15.1), "frame", C, .01) 534: for s, sx in (("L", 1), ("R", -1)): 535: for z in (12.9, 15.3): 536: solid(f"{P.n}_core_lug{z:.0f}.{s}", frame_std.box(*sorted((.78 * sx, 1.12 * sx)), .9, 1.3, z - .2, z + .2), "frame", C, .015) 537: for i, z in enumerate((12.62, 12.82)): 538: solid(f"{P.n}_core_lamp{i}", frame_std.box(.72, .82, 2.3, 2.5, z, z + .1), "lamp_red", C) 539: P.solid("core_throat", merge(*[cylinder(.34, 11.96, 12.12, 12, at=(sx * .5, 2.0)) for sx in (1, -1)]), "frame", C, bevel=.01) 540: nozzle_pair("main", (.5, 2.0, 12.0), (0, .45, -.9), .36, .7, C, C, housing=False) 541: nozzle_pair("vernier", (.6, 2.45, 15.6), (0, .96, .28), .12, .22, C, C, housing=False) 542: 543: 544: def binder(P, J, g): 545: """Blades on the binder arms, swept back, bells under them. The light's core block has none.""" 546: if g == "light": 547: return 548: hgt = by(g, 1.2, 1.5, 1.8) 549: t = by(g, .08, .12, .16) 550: for s, sx in (("L", 1), ("R", -1)): 551: j = J["binder", s] 552: m = Matrix.Translation((.9 * sx, 2.25, 14.7)) @ rot("Y", 36 * sx) @ rot("X", -40) 553: spar = loft([(-.55, octo(.2, .26, .05)), (hgt * .5, octo(.16, .22, .04))]) 554: solid(f"{P.n}_binder_spar.{s}", transform(spar, m), "frame", j, .015) 555: xo = (.1 + t / 2) * sx 556: blade = [(-.42, -.5), (.36, -.5), (.5, hgt * .45), (.24, hgt), (-.42, hgt * .6)] 557: solid(f"{P.n}_binder_blade.{s}", transform(prism(blade, xo - t / 2, xo + t / 2, "yz"), m), "main", j, CHAMFER, panels=False) 558: bell, glow = nozzle(.2, .36) 559: down = m.to_3x3() @ Vector((0, 0, -1)) 560: at = m @ Vector((0, 0, -.5)) 561: solid(f"{P.n}_binder_bell.{s}", place(bell, at, down), "frame", j, smooth=True) 562: solid(f"{P.n}_binder_bell.{s}.glow", place(glow, at, down), "glow_thruster", j, outline=False) 563: empty(f"nozzle.binder.{s}", at + down * .36, j, dir=gltf_dir(down), radius=.2) 564: 565: 566: PARTS = {"head": head, "chest": chest, "waist": waist, "pelvis": pelvis, "shoulder": shoulder, "upperarm": upperarm, "forearm": forearm, 567: "thigh": thigh, "shin": shin, "foot": foot, "backpack": backpack, "binder": binder} 568: 569: 570: def plates(J, grade="medium", n="at"): 571: """Every atelier plate on a frame's joints. `grade` is one grade name or a dict of segment -> 572: grade with an optional "default".""" 573: pick = (lambda seg: grade) if isinstance(grade, str) else (lambda seg: grade.get(seg, grade.get("default", "medium"))) 574: P = Plates(n, CHAMFER, smooth=True) 575: for seg in SEGMENTS: 576: g = pick(seg) 577: if g: 578: PARTS[seg](P, J, g) 579: return P 580: 581: 582: # ---- stance ----------------------------------------------------------------------------------------------- 583: # The atelier's proportions (docs/study-atelier.md), as fractions of the crown height: a long greave 584: # under a short thigh, the crotch where the line mech has it, a slightly taller crown, the shoulders 585: # out like the line mech's (the flare gives the span), the feet closer together. 586: KNEE_AT = .43 587: CROTCH_AT = .54 588: CROWN = 17.2 589: SHOULDER_OUT = .25 590: SPLAY = .28 591: 592: 593: def stance(J, crown_z): 594: """bend_knees and proportion with the atelier's numbers. Run after the plates.""" 595: frame_std.bend_knees(J, splay=SPLAY) 596: frame_std.proportion(J, crown_z, knee=KNEE_AT, crotch=CROTCH_AT, crown=CROWN, shoulders=SHOULDER_OUT) 597: 598: 599: def crown_z(J): 600: """The helm's top, or the bare frame's head block, in world space.""" 601: bpy.context.view_layer.update() 602: meshes = [o for o in J["head"].children if o.type == "MESH"] 603: o = next((h for h in meshes if "head_helmet" in h.name), None) or next(h for h in meshes if "head_core" in h.name) 604: return max((o.matrix_world @ v.co).z for v in o.data.vertices)