A mech game prototype, pushed by Gemini 4 Argon
agent (cont.)
+0:58read_file{"Path":"~/work/sortie/src/render/palette.ts"}
input
{ "Path": "~/work/sortie/src/render/palette.ts" }result, 176 lines
Showing lines 1-175 of 175 1: // Material roles are named in the kit (kit/lib.py). A palette paints every role; factions and 2: // companies get their own palettes, the models stay the same. 3: 4: export type Role = 5: | 'main' | 'accent' | 'trim' | 'frame' | 'joint' | 'visor' | 'metal' | 'sensor' 6: | 'glow_eye' | 'glow_core' | 'glow_thruster' | 'glow_beam' | 'glow_exhaust' 7: | 'hull' | 'hull_dark' | 'interior' | 'deck' | 'hazard' | 'light' | 'screen' | 'glass' 8: | 'lamp_red' | 'lamp_green' | 'suit' | 'glow_hot' 9: // raider salvage: paint from the donor machines, primer patches, bare rust and hand paint 10: | 'donor_a' | 'donor_b' | 'donor_c' | 'primer' | 'rust' | 'handpaint' | 'warpaint' 11: | 'crystal' | 'crystal_lit' | 'glow_violet' 12: // markings on plates: pattern codes, service text, unit codes 13: | 'stencil'; 14: 15: export interface Paint { 16: color: string; 17: /** Emissive roles: brightness multiplier, values above 1 feed the bloom. */ 18: glow?: number; 19: /** Physically based surface: roughness, metalness, clearcoat (paint sheen). */ 20: rough?: number; 21: metal?: number; 22: coat?: number; 23: /** Rust blotches and streaks over the surface, 0..1 (raider salvage). */ 24: rust?: number; 25: /** A lit surface that also gives off its own colour at this strength (lit from inside). */ 26: emit?: number; 27: /** Painted roles: a lacquered finish, 0..1, kept under every look: roughness no higher than `rough`, less 28: * weathering of the colour, and from 0.5 a clear coat this strong. */ 29: lacquer?: number; 30: } 31: 32: export type Palette = Record<Role, Paint>; 33: 34: const paint = (color: string, rough = 0.42, coat = 0.35): Paint => ({ color, rough, metal: 0, coat }); 35: const metal = (color: string, rough = 0.42, m = 0.85): Paint => ({ color, rough, metal: m }); 36: 37: const base: Palette = { 38: main: paint('#d9dce1'), 39: accent: paint('#27527a'), 40: trim: paint('#c9452f', 0.4), 41: frame: metal('#5b6069', 0.48, 0.8), 42: joint: metal('#33363c', 0.55, 0.9), 43: visor: { color: '#06080b', rough: 0.22, metal: 0.2, coat: 1 }, 44: metal: metal('#9aa0a8', 0.3, 1), 45: sensor: { color: '#1d6b5c', rough: 0.2, metal: 0.3, coat: 1 }, 46: glow_eye: { color: '#7ef7e6', glow: 4 }, 47: glow_core: { color: '#7ef7e6', glow: 2.4 }, 48: /** The lit throat inside a thruster bell, the exhaust's colour. */ 49: glow_thruster: { color: '#9cc6ff', glow: 3 }, 50: /** Thruster plumes (render/plume.ts): the mantle colour, the core runs it to white. Glow scales 51: * the whole plume. A maker or faction tints its drives here. */ 52: glow_exhaust: { color: '#4f8fff', glow: 1 }, 53: glow_beam: { color: '#ff5ccf', glow: 5 }, 54: hull: paint('#a9adb4', 0.55, 0.15), 55: hull_dark: metal('#4a4f57', 0.6, 0.6), 56: interior: metal('#5e6168', 0.7, 0.3), 57: deck: metal('#3f434a', 0.7, 0.6), 58: hazard: paint('#e3b62b', 0.6, 0), 59: light: { color: '#fff3df', glow: 1.7 }, 60: screen: { color: '#4fd8cc', glow: 1.6 }, 61: glass: { color: '#8f9fc4', rough: 0.22, metal: 0.1, coat: 1 }, 62: lamp_red: { color: '#ff3a2e', glow: 4 }, 63: lamp_green: { color: '#48ff6c', glow: 4 }, 64: suit: paint('#1f2a4f', 0.6, 0), 65: /** The white-hot core inside an eye or sensor lamp. */ 66: glow_hot: { color: '#eafffb', glow: 2.6 }, 67: /** Donor paint on salvaged parts: in a clean palette, the merc's own colours and an olive. */ 68: donor_a: paint('#d9dce1'), 69: donor_b: paint('#27527a'), 70: donor_c: paint('#5c6143'), 71: primer: paint('#8a8d84', 0.7, 0), 72: rust: metal('#6a3a20', 0.85, 0.35), 73: handpaint: paint('#ece4cc', 0.7, 0), 74: warpaint: paint('#c9452f', 0.6, 0), 75: /** The aliens' one material: unpainted silver, no seams. */ 76: crystal: metal('#c6c9d0', 0.44, 0.95), 77: /** Alien crystal lit from inside by the core, the lining of an opened geode. */ 78: crystal_lit: { color: '#a796dc', rough: 0.4, metal: 0.9, emit: 0.42 }, 79: /** The alien core light. */ 80: glow_violet: { color: '#7b3dff', glow: 2.6 }, 81: /** Stencilled markings: dark ink on light plates, light ink on dark ones. */ 82: stencil: { color: '#23272d', rough: 0.7, metal: 0 }, 83: }; 84: 85: const worn = (color: string, rust: number, rough = 0.6): Paint => ({ color, rough, metal: 0, coat: 0, rust }); 86: 87: export const PALETTES = { 88: /** The player's default frame paint. */ 89: merc: base, 90: /** The Administration: gate white plates, petrol blue accent blocks (the chest, the boots, the cheeks), 91: * gate cyan lights and trim. A light livery, so the frame goes darker to keep the value step. */ 92: admin: { 93: ...base, 94: main: paint('#e4e8eb'), 95: accent: paint('#1b5c5a', 0.45), 96: trim: paint('#3fa7c9', 0.35), 97: frame: metal('#3a3e45', 0.5, 0.8), 98: joint: metal('#24262b', 0.55, 0.9), 99: glow_eye: { color: '#5fd0f0', glow: 4 }, 100: glow_core: { color: '#5fd0f0', glow: 2.4 }, 101: glow_hot: { color: '#e6fbff', glow: 2.6 }, 102: glow_thruster: { color: '#9ee6ff', glow: 3 }, 103: glow_exhaust: { color: '#3fc4ff', glow: 1 }, 104: }, 105: /** The houses: lacquered wine plates, ivory accent fields (the crest, the breastplate, the back panel, the 106: * tabard and the shield pale), warm gold trim on the hems and the crest's edge, emerald lenses and pale gold 107: * drives. The wine is lifted a step and lacquered so its curves carry highlights, the frame is a darker, less 108: * metallic steel so the plates keep a value step above it in shade too (docs/study-atelier.md). */ 109: houses: { 110: ...base, 111: main: { ...paint('#781c33', 0.36, 0.5), lacquer: 0.45 }, 112: accent: { ...paint('#ece3cc', 0.38, 0.4), lacquer: 0.4 }, 113: trim: metal('#e6b84a', 0.3, 0.75), 114: frame: metal('#4c5058', 0.55, 0.4), 115: joint: metal('#3a3c42', 0.55, 0.9), 116: metal: metal('#b5ab98', 0.3, 1), 117: stencil: { color: '#e6dcc4', rough: 0.7, metal: 0 }, 118: glow_eye: { color: '#4dffa6', glow: 4 }, 119: // the reactor glow through the chest sides stays low, the lenses carry the green 120: glow_core: { color: '#2fb877', glow: 0.7 }, 121: glow_hot: { color: '#eafff2', glow: 2.6 }, 122: glow_thruster: { color: '#ffe3a8', glow: 3 }, 123: glow_exhaust: { color: '#ffcf6a', glow: 1 }, 124: }, 125: /** Automated pilotless frames: black and gunmetal shell, red only in lenses, seam lines and stencils. The 126: * gunmetal is light enough to read as a block against the black at range. */ 127: automaton: { 128: ...base, 129: main: paint('#1d1e23', 0.38), 130: accent: paint('#5e646c', 0.34), 131: metal: metal('#3e4046', 0.5, 0.8), 132: trim: paint('#d12b35', 0.4), 133: frame: metal('#2c2d33', 0.5), 134: stencil: { color: '#c9c4b8', rough: 0.7, metal: 0 }, 135: glow_eye: { color: '#ff2f3f', glow: 4.5 }, 136: glow_core: { color: '#ff2f3f', glow: 5 }, 137: glow_hot: { color: '#ffe4e4', glow: 2.6 }, 138: glow_thruster: { color: '#ff9a7a', glow: 3 }, 139: glow_exhaust: { color: '#ff3a2a', glow: 1 }, 140: }, 141: /** Raiders: sun-faded salvage in three donors' paint, primer patches, rust, hand paint. */ 142: raider: { 143: ...base, 144: main: worn('#9c8550', 0.35), 145: accent: worn('#5e2c22', 0.3), 146: trim: worn('#c0561a', 0.3), 147: frame: { ...metal('#4d4842', 0.6, 0.75), rust: 0.25 }, 148: joint: metal('#2f2c29', 0.62, 0.85), 149: metal: { ...metal('#8c8780', 0.45, 0.9), rust: 0.3 }, 150: hazard: worn('#d9a92a', 0.3), 151: donor_a: worn('#c6c3b8', 0.3), 152: donor_b: worn('#3e566e', 0.3), 153: donor_c: worn('#5c6143', 0.35), 154: primer: worn('#8a8d84', 0.2, 0.75), 155: rust: { ...metal('#5e3019', 0.85, 0.35), rust: 0.75 }, 156: handpaint: worn('#ece4cc', 0.15, 0.75), 157: warpaint: worn('#9e1f16', 0.2, 0.7), 158: stencil: worn('#2a2723', 0.2, 0.8), 159: glow_eye: { color: '#ffb347', glow: 4 }, 160: glow_core: { color: '#ff9a3c', glow: 2.6 }, 161: glow_hot: { color: '#fff1d6', glow: 2.6 }, 162: // patched up drives burn dirty and orange 163: glow_thruster: { color: '#ffb36e', glow: 3 }, 164: glow_exhaust: { color: '#ff7a1e', glow: 1.1 }, 165: }, 166: /** Silver aliens: the kit builds them from the crystal roles alone, any core or eye light goes violet. */ 167: alien: { 168: ...base, 169: glow_eye: { color: '#7b3dff', glow: 2.6 }, 170: glow_core: { color: '#7b3dff', glow: 2.6 }, 171: glow_hot: { color: '#efe6ff', glow: 2.6 }, 172: }, 173: } satisfies Record<string, Palette>; 174: 175: export type PaletteName = keyof typeof PALETTES;
agent
+1:05reasoning
Initial hypothesis: examining related files may reveal clues. Investigating the contents of the specified Python files, focusing on potential dependencies or shared functionalities. Reviewing these files to understand object interactions and identify any commonalities.
read_file{"Path":"~/work/sortie/kit/mech.py"}
input
{ "Path": "~/work/sortie/kit/mech.py" }result, 401 lines
Showing lines 1-400 of 400 1: """Mech frames. A frame is a tree of joint empties with rigid armour parented to them, so the game 2: poses it by rotating joints (no skinning). Left is +X (the model faces -Y). 3: 4: Joint tree (names are the contract with src/render/mech.ts): 5: frame > pelvis > waist > torso > neck > head 6: torso > shoulder.L > upperarm.L > forearm.L > hand.L > grip.L 7: torso > backpack > binder.L 8: torso > cockpit 9: pelvis > thigh.L > shin.L > foot.L 10: Thruster exits are empties named nozzle.* with a "dir" extra (exhaust direction, glTF axes). 11: 12: Proportions follow measured Gundam 00 line art (review/out/refs/proportions.md): head about a tenth 13: of the height, hip joint at 60%, shoulder span about half the height on shells that stand off a 14: compact chest, a waist a ninth of the height, every limb in layered shells over a dark inner frame. 15: """ 16: from mathutils import Matrix, Vector 17: 18: from lib import (circle, clip, copy, cylinder, empty, halves, loft, merge, mirror_x, nozzle, octo, piston, prism, rot, slats, solid, 19: transform, two_view) 20: 21: BEVEL = 0.05 22: 23: 24: def gltf_dir(v): 25: v = Vector(v).normalized() 26: return [round(v.x, 4), round(v.z, 4), round(-v.y, 4)] 27: 28: 29: def place(bm, at, direction): 30: """Turn a part built along -Z to point along `direction`, then move it to `at`.""" 31: q = Vector((0, 0, -1)).rotation_difference(Vector(direction).normalized()) 32: return transform(bm, Matrix.Translation(Vector(at)) @ q.to_matrix().to_4x4()) 33: 34: 35: def pair(name, bm_left, role, jl, jr, **kw): 36: """Make the left part and its mirror on the right.""" 37: bm_right = mirror_x(bm_left) 38: return solid(f"{name}.L", bm_left, role, jl, **kw), solid(f"{name}.R", bm_right, role, jr, **kw) 39: 40: 41: def nozzle_pair(name, at, direction, r, length, jl, jr, shell="frame", housing=True): 42: ex = Vector(at) 43: for side, j, sx in (("L", jl, 1), ("R", jr, -1)): 44: p = Vector((ex.x * sx, ex.y, ex.z)) 45: d = Vector((direction[0] * sx, direction[1], direction[2])) 46: bell, glow = nozzle(r, length) 47: solid(f"{name}.{side}", place(bell, p, d), shell, j, smooth=True) 48: solid(f"{name}.{side}.glow", place(glow, p, d), "glow_thruster", j, outline=False) 49: # an armoured housing around the throat, so the nozzle reads as mounted, not floating 50: if housing: 51: house = loft([(length * .5, octo(r * 2.5, r * 2.5, r * .6)), (-length * .3, octo(r * 2.3, r * 2.3, r * .55))]) 52: solid(f"{name}_housing.{side}", place(house, p, d), "main", j, bevel=.02, panels=False) 53: empty(f"nozzle.{name}.{side}", p + d.normalized() * length, j, dir=gltf_dir(d), radius=r) 54: 55: 56: def seam(bm, a, b, gap=.05): 57: """Split a solid along the line a->b of the front view (x, z): two plates with a real seam.""" 58: a, b = Vector((a[0], 0, a[1])), Vector((b[0], 0, b[1])) 59: d = (b - a).normalized() 60: n = Vector((-d.z, 0, d.x)) 61: return halves(bm, a, n, gap) 62: 63: 64: def pair_pieces(name, pieces, role, jl, jr, **kw): 65: for i, bm in enumerate(pieces): 66: pair(f"{name}{i}", bm, role, jl, jr, **kw) 67: 68: 69: def joints(): 70: J = {"frame": empty("frame", (0, 0, 0), frame="striker", height=17.6)} 71: J["pelvis"] = empty("pelvis", (0, 0, 10.6), J["frame"]) 72: J["waist"] = empty("waist", (0, 0, 11.1), J["pelvis"]) 73: J["torso"] = empty("torso", (0, 0, 11.9), J["waist"]) 74: J["neck"] = empty("neck", (0, 0, 15.3), J["torso"]) 75: J["head"] = empty("head", (0, 0, 15.85), J["neck"]) 76: J["backpack"] = empty("backpack", (0, 1.5, 13.8), J["torso"]) 77: J["cockpit"] = empty("cockpit", (0, -0.75, 13.7), J["torso"]) 78: for s, sx in (("L", 1), ("R", -1)): 79: J["shoulder", s] = empty(f"shoulder.{s}", (2.0 * sx, 0, 14.6), J["torso"]) 80: J["upperarm", s] = empty(f"upperarm.{s}", (2.45 * sx, 0, 14.4), J["shoulder", s]) 81: J["forearm", s] = empty(f"forearm.{s}", (2.5 * sx, 0, 11.95), J["upperarm", s]) 82: J["hand", s] = empty(f"hand.{s}", (2.5 * sx, 0, 9.6), J["forearm", s]) 83: J["grip", s] = empty(f"grip.{s}", (2.36 * sx, -0.02, 9.12), J["hand", s]) 84: J["thigh", s] = empty(f"thigh.{s}", (1.15 * sx, 0, 10.55), J["pelvis"]) 85: J["shin", s] = empty(f"shin.{s}", (1.2 * sx, 0, 6.1), J["thigh", s]) 86: J["foot", s] = empty(f"foot.{s}", (1.2 * sx, 0.1, 1.55), J["shin", s]) 87: J["binder", s] = empty(f"binder.{s}", (0.9 * sx, 2.25, 14.7), J["backpack"]) 88: return J 89: 90: 91: def lr(J, part): 92: return J[part, "L"], J[part, "R"] 93: 94: 95: def build_pelvis(J): 96: P = J["pelvis"] 97: solid("pelvis_core", loft([(9.95, octo(.9, 1.3, .25)), (10.4, octo(2.2, 1.7, .4)), (11.0, octo(2.3, 1.75, .45))]), 98: "frame", P, BEVEL) 99: # the waist belt flares from the abdomen out to hip width; everything below hangs from it 100: solid("belt", loft([(10.55, octo(3.2, 2.05, .5)), (10.98, octo(2.1, 1.7, .42))]), "main", P, BEVEL) 101: solid("belt_buckle", two_view([(-.3, 10.58), (.3, 10.58), (.18, 10.96), (-.18, 10.96)], 102: [(-1.14, 10.58), (-.96, 10.58), (-.86, 10.96), (-1.02, 10.96)]), "trim", P, .02) 103: pair("hip_block", loft([(10.2, octo(.42, .95, .1, x=1.74)), (10.72, octo(.42, .95, .1, x=1.74))]), "frame", P, P, bevel=.02) 104: solid("codpiece", two_view([(-.2, 9.62), (.2, 9.62), (.32, 10.2), (.3, 10.58), (-.3, 10.58), (-.32, 10.2)], 105: [(-1.14, 9.68), (-.75, 9.68), (-.8, 10.58), (-1.08, 10.58), (-1.22, 10.2)]), "trim", P, BEVEL) 106: # front skirt: two blades sweeping out from the centre like an arrowhead 107: pair("skirt_front", two_view([(.45, 10.62), (1.45, 10.62), (2.05, 10.3), (1.65, 9.6), (.65, 9.9)], 108: [(-1.34, 9.55), (-1.02, 9.55), (-.94, 10.66), (-1.24, 10.66)]), "main", P, P, bevel=BEVEL) 109: pair("skirt_front_edge", two_view([(.68, 9.85), (1.64, 9.55), (1.74, 9.71), (.72, 9.99)], 110: [(-1.4, 9.47), (-1.06, 9.47), (-1.02, 10.05), (-1.36, 10.05)]), "accent", P, P, bevel=0.015) 111: # side skirts flare out toward the bottom, tips swept back 112: # side skirts hinge from the hip blocks: a cap plate over a ridged main plate 113: pair("skirt_side", two_view([(2.0, 9.5), (2.34, 9.5), (2.12, 10.5), (1.86, 10.52)], 114: [(-.6, 9.5), (1.05, 9.5), (.95, 10.54), (-.9, 10.54)], 115: top=[(1.8, -1.0), (2.17, -1.0), (2.42, .05), (2.17, 1.15), (1.8, 1.15)]), "main", P, P, bevel=BEVEL) 116: pair("skirt_side_cap", two_view([(1.86, 10.28), (2.3, 10.22), (2.22, 10.74), (1.86, 10.76)], 117: [(-.72, 10.22), (.92, 10.22), (.86, 10.76), (-.78, 10.76)]), "accent", P, P, bevel=0.025) 118: pair("skirt_side_plate", two_view([(2.26, 9.66), (2.4, 9.69), (2.26, 10.16), (2.12, 10.14)], 119: [(-.4, 9.66), (.85, 9.66), (.78, 10.16), (-.55, 10.16)]), "frame", P, P, bevel=0.015) 120: # rear skirt as two overlapping scales with a gap over the hip mechanism 121: # rear skirt: descending chevrons, a gap at the centre 122: pair("skirt_rear", two_view([(.14, 10.6), (1.26, 10.66), (1.61, 10.35), (1.46, 9.92), (.64, 9.82), (.18, 10.05)], 123: [(.92, 9.75), (1.26, 9.75), (1.32, 10.7), (.94, 10.7)]), "main", P, P, bevel=BEVEL) 124: pair("skirt_rear_low", two_view([(.14, 10.1), (.62, 9.93), (1.3, 10.02), (1.3, 9.63), (.6, 9.4), (.14, 9.6)], 125: [(1.02, 9.36), (1.36, 9.36), (1.36, 10.14), (1.02, 10.14)]), "main", P, P, bevel=0.03) 126: 127: 128: def build_waist(J): 129: W = J["waist"] 130: solid("abdomen", loft([(10.9, octo(1.6, 1.4, .35)), (11.95, octo(1.85, 1.55, .38))]), "joint", W, 0.03) 131: # three stacked plates in front, each a little wider and further forward than the one below 132: for i, (z0, z1, hw, y) in enumerate(((10.98, 11.34, .64, -.84), (11.28, 11.64, .72, -.88), (11.58, 11.96, .8, -.92))): 133: solid(f"abs{i}", two_view([(-hw, z0), (hw, z0), (hw + .06, z1), (-hw - .06, z1)], 134: [(y + .02, z0), (y + .24, z0), (y + .24, z1), (y - .02, z1)], 135: top=[(-hw - .1, y + .3), (hw + .1, y + .3), (hw + .1, y + .1), (0, y - .06), (-hw - .1, y + .1)]), 136: "frame", W, 0.02) 137: pair("abs_side", two_view([(.72, 11.0), (.96, 11.05), (1.02, 11.92), (.78, 11.92)], 138: [(-.5, 11.0), (.5, 11.0), (.56, 11.92), (-.56, 11.92)]), "frame", W, W, bevel=0.02) 139: 140: 141: def build_torso(J): 142: T = J["torso"] 143: # a dark structural core; the armour is separate plates over it 144: solid("chest", loft([(11.9, octo(1.9, 1.6, .4, y=.05)), (12.6, octo(2.4, 2.05, .45)), (13.9, octo(3.0, 2.45, .55, y=-.05)), 145: (14.9, octo(2.8, 2.25, .5)), (15.3, octo(1.8, 1.55, .4))]), "frame", T, BEVEL) 146: # central hatch: a ridged block down the chest front that carries the reactor lens 147: solid("hatch", two_view([(-.55, 12.75), (.55, 12.75), (.6, 14.5), (.4, 14.78), (-.4, 14.78), (-.6, 14.5)], 148: [(-1.62, 12.75), (-1.2, 12.75), (-1.3, 14.78), (-1.66, 14.62), (-1.8, 13.8)], 149: top=[(-.7, -1.0), (.7, -1.0), (.7, -1.55), (0, -1.84), (-.7, -1.55)]), "main", T, .03) 150: pair("chest_plate", two_view([(.58, 14.82), (1.18, 14.88), (1.55, 14.62), (1.78, 14.28), (1.55, 13.85), (.6, 14.08)], 151: [(-1.64, 13.6), (-1.1, 13.6), (-1.26, 14.88), (-1.5, 14.88), (-1.72, 13.85)]), 152: "accent", T, T, bevel=BEVEL) 153: rib = two_view([(.6, 12.7), (.9, 12.6), (1.6, 13.2), (1.62, 13.54), (.6, 13.88)], 154: [(-1.49, 12.5), (-.95, 12.5), (-1.1, 13.92), (-1.35, 13.92), (-1.57, 13.55)]) 155: pair_pieces("rib_plate", seam(rib, (.6, 13.22), (1.62, 13.05)), "accent", T, T, bevel=0.03) 156: pair("chest_strip", two_view([(.6, 14.84), (1.18, 14.9), (1.57, 14.64), (1.8, 14.28), (1.64, 14.2), (1.42, 14.5), (1.1, 14.7), 157: (.6, 14.64)], 158: [(-1.72, 13.9), (-1.22, 13.9), (-1.36, 14.96), (-1.6, 14.96), (-1.8, 14.2)]), "main", T, T, bevel=0.02) 159: pair("side_plate", two_view([(1.42, 12.9), (1.62, 12.9), (1.68, 14.4), (1.48, 14.6)], 160: [(-.95, 12.9), (.9, 12.9), (.95, 14.4), (-1.05, 14.45)]), "main", T, T, bevel=0.03) 161: solid("belly", two_view([(-.95, 11.92), (.95, 11.92), (1.22, 12.62), (-1.22, 12.62)], 162: [(-1.34, 11.9), (-.98, 11.9), (-1.08, 12.66), (-1.4, 12.66)]), "main", T, BEVEL) 163: solid("belly_vent", slats(-.6, .6, 12.02, 12.48, -1.38, 3, depth=.08), "frame", T) 164: # the reactor lens in the chest 165: solid("lens_socket", prism(circle(.44, 12, 0, 13.62), -1.92, -1.5, "xz"), "frame", T, 0.03) 166: solid("lens", prism(circle(.33, 12, 0, 13.62), -1.97, -1.9, "xz"), "sensor", T, smooth=True) 167: solid("lens_core", prism(circle(.11, 8, 0, 13.62), -1.99, -1.95, "xz"), "glow_core", T) 168: # collar: thin folded plates (front and side) with room around the neck 169: pair("collar", two_view([(.55, 14.72), (1.46, 14.76), (1.55, 15.3), (1.1, 15.55), (.62, 15.45)], 170: [(-1.0, 14.7), (-.84, 14.7), (-.68, 15.55), (-.84, 15.55)]), "main", T, T, bevel=0.025) 171: pair("collar_side", two_view([(1.36, 14.7), (1.52, 14.7), (1.42, 15.5), (1.26, 15.5)], 172: [(-.9, 14.7), (.7, 14.7), (.6, 15.5), (-.7, 15.5)]), "main", T, T, bevel=0.025) 173: pair("collar_vent", slats(.72, 1.26, 14.86, 15.2, -1.0, 3, depth=.06), "frame", T, T) 174: solid("neck_guard", two_view([(-.55, 15.2), (.55, 15.2), (.5, 15.86), (-.5, 15.86)], 175: [(.25, 15.2), (.72, 15.2), (.64, 15.86), (.36, 15.86)]), "main", T, .02) 176: solid("back_plate", two_view([(-.95, 12.35), (.95, 12.35), (1.62, 14.92), (-1.62, 14.92)], 177: [(1.14, 12.35), (1.46, 12.35), (1.52, 14.92), (1.24, 14.92)]), "accent", T, BEVEL) 178: 179: 180: def build_head(J): 181: N, H = J["neck"], J["head"] 182: solid("neck_core", cylinder(.36, 15.25, 16.0, 10), "joint", N, smooth=True) 183: solid("neck_ring", loft([(15.5, octo(.95, .9, .2)), (15.68, octo(.86, .82, .18))]), "frame", N, .015) 184: # cranium: the top plate, tapered toward the back in plan 185: solid("cranium", two_view([(-.62, 16.66), (.62, 16.66), (.58, 17.05), (.36, 17.28), (-.36, 17.28), (-.58, 17.05)], 186: [(-.86, 16.7), (-.5, 17.2), (.25, 17.3), (.72, 17.0), (.78, 16.66)], 187: top=[(-.4, -.88), (.4, -.88), (.62, -.4), (.55, .6), (0, .86), (-.55, .6), (-.62, -.4)]), "main", H, .03) 188: solid("skull", loft([(15.95, octo(.9, 1.15, .25, y=.05)), (16.7, octo(1.1, 1.4, .3, y=.0))]), "frame", H, .02) 189: # side plates frame the face and run back past the ears 190: pair("helmet_side", two_view([(.48, 15.98), (.7, 16.28), (.77, 16.9), (.62, 17.04), (.55, 16.5), (.42, 16.06)], 191: [(-.72, 15.98), (.62, 15.98), (.74, 16.6), (.5, 17.04), (-.56, 17.0), (-.82, 16.52)]), "main", H, H, bevel=.025) 192: # sensor band under a broad, slightly peaked brow hood 193: solid("visor", two_view([(-.6, 16.48), (.6, 16.48), (.6, 16.64), (-.6, 16.64)], 194: [(-.97, 16.46), (-.62, 16.46), (-.62, 16.66), (-.95, 16.66)]), "visor", H, 0.01) 195: solid("sensor_band", two_view([(-.5, 16.535), (.5, 16.535), (.5, 16.585), (-.5, 16.585)], 196: [(-.99, 16.5), (-.93, 16.5), (-.93, 16.62), (-.99, 16.62)]), "glow_eye", H) 197: solid("brow_hood", two_view([(-.68, 16.62), (.68, 16.62), (.62, 16.8), (.18, 16.88), (-.18, 16.88), (-.62, 16.8)], 198: [(-1.07, 16.62), (-.55, 16.62), (-.55, 16.88), (-.95, 16.86)], 199: top=[(-.7, -.5), (.7, -.5), (.7, -.92), (0, -1.1), (-.7, -.92)]), "main", H, 0.02) 200: # lower face: a dark recessed mask with vertical vents, two faceted plates over it 201: solid("mask", two_view([(-.3, 15.9), (.3, 15.9), (.42, 16.45), (-.42, 16.45)], 202: [(-.72, 15.9), (-.5, 15.9), (-.55, 16.46), (-.8, 16.46)]), "frame", H, 0.015) 203: vents = [prism([(x - .025, 15.98), (x + .025, 15.98), (x + .025, 16.3), (x - .025, 16.3)], -.8, -.7, "xz") for x in (-.1, 0, .1)] 204: solid("mask_vents", merge(*vents), "joint", H) 205: pair("mask_plate", two_view([(.12, 15.92), (.36, 16.0), (.44, 16.42), (.16, 16.42)], 206: [(-.84, 15.95), (-.6, 15.95), (-.62, 16.44), (-.88, 16.44)]), "main", H, H, bevel=0.015) 207: # ear sensors: blocks with a lens on the outer face 208: pair("ear", two_view([(.7, 16.3), (.86, 16.33), (.86, 16.66), (.7, 16.7)], 209: [(-.25, 16.3), (.22, 16.3), (.28, 16.66), (-.2, 16.7)]), "accent", H, H, bevel=.02) 210: pair("ear_lens", cylinder(.085, .85, .9, 12, axis="x", at=(-.01, 16.48)), "sensor", H, H, smooth=True) 211: solid("helmet_rear", two_view([(-.55, 16.08), (.55, 16.08), (.6, 16.7), (-.6, 16.7)], 212: [(.42, 16.04), (.8, 16.2), (.82, 16.7), (.52, 16.76)]), "main", H, .02) 213: solid("rear_fin", prism([(.45, 16.95), (.92, 16.86), (1.0, 17.0), (.62, 17.18)], -.05, .05, "yz"), "frame", H, .01) 214: solid("crest", two_view([(-.1, 16.9), (.1, 16.9), (.04, 17.62), (-.04, 17.62)], 215: [(-.62, 16.98), (-.34, 17.25), (.48, 17.60), (.67, 17.54), (.15, 17.12), (-.32, 16.94)]), "trim", H, 0.01) 216: 217: 218: def build_arms(J): 219: pair("shoulder_block", loft([(1.45, octo(1.5, 1.4, .35, y=14.55)), (2.62, octo(1.45, 1.35, .35, y=14.55))], axis="x"), 220: "frame", *lr(J, "shoulder"), bevel=BEVEL) 221: # the shoulder shell: a folded plate (top and outer drop) standing off the block 222: # shoulder shell: a swept roof and a separate outer blade, tapered in plan, open underneath 223: plan = [(1.85, -.65), (3.25, -1.05), (4.3, .10), (4.1, .75), (3.2, 1.1), (1.85, .60)] 224: side = [(-1.3, 14.2), (1.3, 14.2), (1.3, 15.95), (-1.3, 15.95)] 225: cap = [(-.90, 15.35), (.30, 15.65), (.95, 15.20), (.70, 14.55), (-.65, 14.65)] 226: roof = two_view([(1.90, 15.16), (3.38, 15.87), (3.72, 15.61), (3.45, 15.15), (2.12, 14.87)], 227: [(-1.25, 14.75), (.4, 15.95), (1.15, 15.4), (.9, 14.8), (-.9, 14.75)], top=plan) 228: pair_pieces("shell", seam(roof, (2.78, 14.6), (2.62, 16.2), gap=.05), "accent", *lr(J, "shoulder"), bevel=0.03) 229: pair("shell_under", two_view([(2.1, 14.74), (3.3, 15.06), (3.36, 14.86), (2.2, 14.58)], cap, top=plan), 230: "frame", *lr(J, "shoulder"), bevel=0.02) 231: pair("trunnion", cylinder(.325, 2.25, 2.95, 12, axis="x", at=(0, 14.55)), "joint", *lr(J, "shoulder"), smooth=True) 232: for k, y in (("f", -.45), ("r", .45)): 233: pair(f"fork_{k}", two_view([(2.2, 14.1), (2.9, 14.2), (2.9, 14.95), (2.2, 15.0)], 234: [(y - .08, 14.1), (y + .08, 14.1), (y + .08, 15.0), (y - .08, 15.0)]), "frame", 235: *lr(J, "shoulder"), bevel=0.02) 236: pair("shell_blade", two_view([(3.62, 15.84), (4.2, 15.65), (3.98, 14.65), (3.72, 14.5), (3.55, 15.08)], side, top=plan), 237: "accent", *lr(J, "shoulder"), bevel=0.04) 238: pair("shell_edge", two_view([(2.0, 14.86), (3.55, 15.06), (3.55, 15.18), (1.95, 14.98)], side, 239: top=[(1.85, -.74), (3.25, -1.14), (3.42, -.9), (1.9, -.52)]), 240: "main", *lr(J, "shoulder"), bevel=0.012) 241: pair("shell_fin", prism([(-.6, 15.5), (1.0, 15.55), (.8, 16.05), (.05, 15.95)], 2.9, 3.05, "yz"), "main", 242: *lr(J, "shoulder"), bevel=0.02) 243: pair("upperarm_core", loft([(12.2, octo(.85, .9, .22, x=2.5)), (14.2, octo(.9, .95, .24, x=2.48))]), "joint", 244: *lr(J, "upperarm"), bevel=0.03) 245: # front and rear shells with channels down the sides that show the core 246: cuff = loft([(12.5, octo(.85, .95, .22, x=2.53)), (13.6, octo(1.1, 1.13, .28, x=2.54))]) 247: cuff_b = copy(cuff) 248: pair("upperarm_front", clip(cuff, y=(-1, -.08)), "main", *lr(J, "upperarm"), bevel=0.03) 249: pair("upperarm_rear", clip(cuff_b, y=(.08, 1)), "main", *lr(J, "upperarm"), bevel=0.03) 250: pair("upperarm_band", loft([(13.62, octo(1.16, 1.18, .28, x=2.54)), (13.84, octo(1.16, 1.18, .28, x=2.54))]), "accent", 251: *lr(J, "upperarm"), bevel=0.02) 252: pair("elbow", cylinder(.48, 2.0, 3.0, 12, axis="x", at=(0, 11.95)), "joint", *lr(J, "upperarm"), smooth=True) 253: # a longer forearm, its armour split down its length into outer and inner halves over a dark core 254: pair("forearm_core", loft([(9.62, octo(.6, .7, .15, x=2.5)), (11.95, octo(.8, .9, .2, x=2.5))]), "frame", 255: *lr(J, "forearm"), bevel=0.02) 256: arm_side = [(-.45, 9.65), (.45, 9.65), (.65, 11.4), (.55, 12.1), (-.55, 12.1), (-.65, 11.4)] 257: out = two_view([(2.56, 11.86), (2.91, 12.08), (3.22, 11.43), (3.03, 10.45), (2.80, 9.68), (2.56, 9.78)], arm_side, 258: top=[(2.5, -.7), (3.0, -.7), (3.26, 0), (3.0, .7), (2.5, .7)]) 259: pair_pieces("forearm_out", seam(out, (2.56, 11.45), (3.18, 11.22)), "main", *lr(J, "forearm"), bevel=0.03) 260: pair("elbow_actuator", piston((2.5, .62, 12.35), (2.5, .56, 11.55), r=.09), "joint", *lr(J, "forearm"), smooth=True) 261: pair("forearm_in", two_view([(2.125, 9.65), (2.44, 9.65), (2.44, 12.0), (2.0, 12.0), (1.95, 11.4)], arm_side), 262: "main", *lr(J, "forearm"), bevel=0.04) 263: pair("forearm_plate", two_view([(2.98, 10.3), (3.12, 10.3), (3.26, 11.3), (3.12, 11.3)], 264: [(-.5, 10.25), (.5, 10.25), (.6, 11.35), (-.6, 11.35)]), "accent", *lr(J, "forearm"), bevel=0.02) 265: pair("elbow_guard", two_view([(2.1, 11.5), (3.0, 11.5), (3.0, 12.2), (2.55, 12.45), (2.1, 12.2)], 266: [(.45, 11.45), (.8, 11.55), (1.0, 11.95), (.8, 12.35), (.45, 12.4)]), "main", 267: *lr(J, "forearm"), bevel=0.03) 268: pair("wrist_guard", loft([(9.6, octo(.98, 1.04, .22, x=2.52)), (9.8, octo(1.02, 1.08, .24, x=2.52))]), "accent", 269: *lr(J, "forearm"), bevel=0.02) 270: pair("wrist", cylinder(.28, 9.4, 9.75, 10, at=(2.5, 0)), "joint", *lr(J, "hand"), smooth=True) 271: pair("palm", loft([(8.9, octo(.5, .82, .1, x=2.52)), (9.5, octo(.46, .8, .1, x=2.52))]), "frame", *lr(J, "hand"), bevel=0.02) 272: pair("fingers", loft([(8.75, octo(.42, .82, .13, x=2.27)), (9.35, octo(.44, .82, .13, x=2.27))]), "frame", 273: *lr(J, "hand"), bevel=0.025) 274: pair("thumb", loft([(9.02, octo(.24, .24, .06, x=2.32, y=-.5)), (9.4, octo(.26, .26, .06, x=2.38, y=-.46))]), "frame", 275: *lr(J, "hand"), bevel=0.02) 276: pair("hand_guard", two_view([(2.72, 9.0), (2.86, 9.05), (2.86, 9.55), (2.72, 9.55)], 277: [(-.4, 9.0), (.4, 9.0), (.42, 9.55), (-.42, 9.55)]), "main", *lr(J, "hand"), bevel=0.015) 278: 279: 280: def build_legs(J): 281: pair("hip_ball", cylinder(.5, .55, 1.6, 12, axis="x", at=(0, 10.55)), "joint", *lr(J, "thigh"), smooth=True) 282: pair("thigh_core", loft([(6.7, octo(.8, .95, .22, x=1.2)), (9.0, octo(1.3, 1.45, .34, x=1.18)), 283: (10.25, octo(1.15, 1.3, .3, x=1.15))]), "frame", *lr(J, "thigh"), bevel=BEVEL) 284: # thigh shells taper to the knee, with dark channels between them 285: tf = two_view([(.72, 9.95), (1.62, 9.95), (1.95, 9.32), (1.72, 8.58), (1.53, 7.36), (.91, 7.36), (.63, 8.40), (.49, 9.24)], 286: [(-.96, 7.3), (-.55, 7.3), (-.55, 9.95), (-.86, 9.95), (-1.02, 8.6)], 287: top=[(.4, -.5), (2.0, -.5), (2.0, -.8), (1.22, -1.12), (.4, -.8)]) 288: pair_pieces("thigh_front", seam(tf, (.64, 8.72), (1.79, 8.94)), "main", *lr(J, "thigh"), bevel=0.04) 289: pair("thigh_panel", two_view([(1.0, 7.72), (1.36, 7.72), (1.4, 7.8), (1.4, 8.3), (1.34, 8.37), (1.02, 8.37), (.96, 8.3), (.96, 7.8)], 290: [(-1.04, 7.65), (-.94, 7.65), (-.94, 8.42), (-1.0, 8.42)]), "frame", *lr(J, "thigh"), bevel=0.01) 291: pair("thigh_outer", two_view([(1.66, 7.45), (1.8, 7.5), (2.12, 9.3), (1.96, 9.75)], 292: [(-.42, 7.45), (.5, 7.45), (.62, 9.6), (-.5, 9.6)]), "main", *lr(J, "thigh"), bevel=0.03) 293: pair("thigh_rear", two_view([(.82, 7.45), (1.58, 7.45), (1.86, 9.4), (.56, 9.4)], 294: [(.36, 7.45), (.55, 7.45), (.84, 9.4), (.62, 9.4)]), "main", *lr(J, "thigh"), bevel=0.03) 295: 296: pair("knee_joint", cylinder(.5, .65, 1.75, 12, axis="x", at=(0, 6.1)), "joint", *lr(J, "shin"), smooth=True) 297: pair("knee_disc", cylinder(.48, 1.78, 1.98, 16, axis="x", at=(.1, 6.15)), "accent", *lr(J, "shin"), smooth=True) 298: pair("knee_lens", cylinder(.3, 1.98, 2.04, 16, axis="x", at=(.1, 6.15)), "sensor", *lr(J, "shin"), smooth=True) 299: pair("kneecap", two_view([(.75, 5.85), (1.65, 5.85), (1.72, 6.5), (1.2, 6.95), (.68, 6.5)], 300: [(-1.15, 5.85), (-.6, 5.85), (-.55, 6.7), (-.82, 6.95), (-1.15, 6.3)], 301: top=[(.6, -.4), (1.8, -.4), (1.8, -.85), (1.2, -1.2), (.6, -.85)]), "main", 302: *lr(J, "shin"), bevel=0.04) 303: pair("shin_core", loft([(1.75, octo(.85, 1.0, .22, x=1.2, y=.1)), (5.8, octo(1.0, 1.15, .26, x=1.2))]), "frame", 304: *lr(J, "shin"), bevel=0.03) 305: # one envelope (narrow ankle, calf bulge high and back) cut into front, outer, inner and rear shells 306: env = loft([(1.85, octo(1.1, 1.3, .3, x=1.2, y=.05)), (3.0, octo(1.35, 1.6, .38, x=1.2, y=.15)), 307: (4.3, octo(1.65, 2.0, .45, x=1.2, y=.3)), (5.6, octo(1.2, 1.45, .32, x=1.2, y=.05))]) 308: parts = {"shin_front": dict(y=(-2, -.2)), "shin_outer": dict(x=(1.5, 3), y=(-.08, .62)), 309: "shin_inner": dict(x=(-1, .9), y=(-.08, .62)), "shin_rear": dict(y=(.74, 3))} 310: for name, box in parts.items(): 311: pair(name, clip(copy(env), **box), "main", *lr(J, "shin"), bevel=0.03) 312: env.free() 313: sp = two_view([(.80, 5.42), (1.49, 5.42), (1.70, 4.55), (1.57, 3.40), (1.43, 2.08), (.96, 2.08), (.77, 3.45), (.65, 4.52)], 314: [(-.8, 2.05), (-.62, 2.05), (-.68, 5.44), (-.86, 5.44), (-.92, 4.3)], 315: top=[(.6, -.5), (1.75, -.5), (1.75, -.66), (1.17, -.98), (.6, -.66)]) 316: pair_pieces("shin_plate", seam(sp, (.75, 3.60), (1.59, 3.25), gap=.06), "main", *lr(J, "shin"), bevel=0.03) 317: for k, x in (("i", .86), ("o", 1.54)): 318: pair(f"knee_rail_{k}", loft([(6.45, octo(.18, .25, .04, x=x, y=.18)), (7.4, octo(.18, .25, .04, x=x, y=.18))]), "frame", 319: *lr(J, "shin"), bevel=0.015) 320: pair("knee_actuator", piston((1.2, .62, 7.25), (1.2, .74, 5.55), r=.1), "joint", *lr(J, "shin"), smooth=True) 321: pair("calf_blister", two_view([(.78, 4.25), (1.62, 4.25), (1.62, 5.05), (.78, 5.05)], 322: [(.85, 4.3), (1.58, 4.55), (1.5, 5.05), (.85, 5.05)]), "main", *lr(J, "shin"), bevel=0.04) 323: pair("achilles", piston((1.2, .72, 2.4), (1.2, .86, 1.75), r=.07), "joint", *lr(J, "shin"), smooth=True) 324: pair("shin_side", two_view([(1.9, 2.8), (2.02, 2.85), (2.1, 4.4), (1.98, 4.45)], 325: [(-.3, 2.8), (.6, 2.8), (.75, 4.4), (-.2, 4.4)]), "accent", *lr(J, "shin"), bevel=0.02) 326: pair("calf_vent", slats(.95, 1.45, 2.4, 3.1, 1.0, 3, depth=.08), "frame", *lr(J, "shin")) 327: nozzle_pair("calf", (1.2, 1.38, 4.4), (0, .5, -.85), .3, .5, *lr(J, "shin"), housing=False) 328: 329: 330: pair("ankle", cylinder(.42, .75, 1.65, 12, axis="x", at=(.1, 1.55)), "joint", *lr(J, "foot"), smooth=True) 331: foot_plan = [(.95, -2.3), (1.45, -2.3), (1.7, -2.05), (1.85, -1.0), (1.80, 1.2), (.60, 1.2), (.55, -1.0), (.7, -2.05)] 332: # the spat: a ridged guard over the front of the ankle, riding on the foot 333: pair("ankle_spat", two_view([(.62, 1.05), (1.78, 1.05), (1.7, 2.02), (1.2, 2.24), (.7, 2.02)], 334: [(-.98, 1.05), (-.5, 1.05), (-.45, 2.0), (-.7, 2.24), (-1.02, 1.6)], 335: top=[(.5, -.3), (1.9, -.3), (1.9, -.8), (1.2, -1.06), (.5, -.8)]), "main", *lr(J, "foot"), bevel=.03) 336: pair("instep", two_view([(.55, .15), (1.85, .15), (1.8, .9), (1.5, 1.12), (.9, 1.12), (.6, .9)], 337: [(-.9, .15), (.9, .15), (.85, 1.0), (.2, 1.2), (-.85, 1.1)], top=foot_plan), "main", *lr(J, "foot"), bevel=.03) 338: pair("toe_base", two_view([(.58, .12), (1.82, .12), (1.78, .78), (.62, .78)], 339: [(-1.55, .12), (-.98, .12), (-.95, 1.0), (-1.5, .86)], top=foot_plan), "main", *lr(J, "foot"), bevel=.03) 340: pair("toe", two_view([(.58, .1), (1.82, .1), (1.78, .74), (.62, .74)], 341: [(-2.3, .1), (-1.62, .1), (-1.6, .84), (-2.0, .7), (-2.3, .3)], top=foot_plan), "trim", *lr(J, "foot"), bevel=.04) 342: pair("heel", two_view([(.62, .1), (1.8, .1), (1.76, .98), (.66, .98)], 343: [(.86, .1), (1.62, .1), (1.66, .5), (1.36, .98), (.86, 1.08)]), "trim", *lr(J, "foot"), bevel=.04) 344: pair("ankle_guard", two_view([(1.8, .35), (1.96, .4), (1.96, 1.2), (1.8, 1.26)], 345: [(-.62, .35), (.72, .35), (.62, 1.2), (-.5, 1.2)]), "accent", *lr(J, "foot"), bevel=.02) 346: for k, (y0, y1) in (("front", (-2.15, -.95)), ("back", (-.85, 1.1))): 347: pad = [(x, min(max(y, y0), y1)) for x, y in [(.84, -2.15), (1.56, -2.15), (1.84, -1.0), (1.7, 1.08), (.7, 1.08), (.56, -1.0)]] 348: pair(f"sole_{k}", prism(pad, 0.0, 0.14, "xy"), "joint", *lr(J, "foot"), bevel=.02) 349: 350: 351: def build_backpack(J): 352: B = J["backpack"] 353: solid("back_mount", loft([(1.2, octo(1.8, 2.2, .4, y=13.8)), (1.95, octo(1.7, 2.1, .4, y=13.8))], axis="y"), "frame", B, BEVEL) 354: solid("reactor", loft([(1.9, circle(.85, 12, 0, 13.9)), (2.85, circle(.5, 12, 0, 13.9))], axis="y"), "main", B, smooth=True) 355: solid("reactor_ring", loft([(2.0, circle(.95, 12, 0, 13.9)), (2.2, circle(.95, 12, 0, 13.9))], axis="y"), "accent", B, 356: smooth=True) 357: solid("reactor_tip", loft([(2.82, circle(.54, 12, 0, 13.9)), (3.0, circle(.46, 12, 0, 13.9))], axis="y"), "frame", B, 358: smooth=True) 359: solid("reactor_glow", loft([(2.92, circle(.22, 12, 0, 13.9)), (2.95, circle(.22, 12, 0, 13.9))], axis="y"), "glow_core", B) 360: for s, sx in (("L", 1), ("R", -1)): 361: m = Matrix.Translation((.9 * sx, 2.25, 14.7)) @ rot("Y", 32 * sx) @ rot("X", -28) 362: pivot = Vector((.9 * sx, 2.25, 14.7)) 363: solid(f"binder_hinge.{s}", cylinder(.225, pivot.x - .25, pivot.x + .25, 12, axis="x", at=(pivot.y, pivot.z)), "joint", 364: J["binder", s], smooth=True) 365: for k, dy in (("a", -.2), ("b", .2)): 366: solid(f"binder_fork{k}.{s}", two_view([(pivot.x - .28, 14.35), (pivot.x + .28, 14.35), (pivot.x + .28, 14.95), (pivot.x - .28, 14.95)], 367: [(2.0 + dy - .06, 14.35), (2.0 + dy + .06, 14.35), (2.25 + dy + .06, 14.95), (2.25 + dy - .06, 14.95)]), 368: "frame", B, bevel=0.015) 369: # a dark spar between two thin blades 370: spar = loft([(-.7, octo(.22, .3, .06)), (2.3, octo(.16, .24, .04))]) 371: solid(f"binder_spar.{s}", transform(spar, m), "frame", J["binder", s], bevel=0.015) 372: for k, bx in (("a", .12), ("b", -.12)): 373: blade = prism([(-.38, -.6), (.36, -.5), (.24, 2.1), (-.16, 2.25)], bx - .06, bx + .06, "yz") 374: solid(f"binder_blade{k}.{s}", transform(blade, m), "main", J["binder", s], bevel=0.02) 375: tip = loft([(1.9, octo(.32, .44, .08)), (2.6, octo(.2, .3, .05))]) 376: solid(f"binder_tip.{s}", transform(tip, m), "accent", J["binder", s], bevel=0.015) 377: bell, glow = nozzle(.3, .55) 378: down = m.to_3x3() @ Vector((0, 0, -1)) 379: at = m @ Vector((0, 0, -.7)) 380: solid(f"binder_nozzle.{s}", place(bell, at, down), "frame", J["binder", s], smooth=True) 381: solid(f"binder_nozzle.{s}.glow", place(glow, at, down), "glow_thruster", J["binder", s]) 382: empty(f"nozzle.binder.{s}", at + down * .55, J["binder", s], dir=gltf_dir(down), radius=.3) 383: hilt = transform(cylinder(.14, 0, 1.15, 8), Matrix.Translation((.62 * sx, 2.05, 14.85)) @ rot("X", -30)) 384: solid(f"saber_hilt.{s}", hilt, "frame", B, smooth=True) 385: cap = transform(cylinder(.17, 1.0, 1.2, 8), Matrix.Translation((.62 * sx, 2.05, 14.85)) @ rot("X", -30)) 386: solid(f"saber_cap.{s}", cap, "trim", B, smooth=True) 387: nozzle_pair("main", (.55, 2.05, 12.65), (0, .45, -.9), .42, .8, B, B) 388: 389: 390: def build_striker(): 391: J = joints() 392: build_pelvis(J) 393: build_waist(J) 394: build_torso(J) 395: build_head(J) 396: J["neck"].location.z -= .24 # the head sits down between the collar plates 397: build_arms(J) 398: build_legs(J) 399: build_backpack(J)1 more lines not shown.
read_file{"Path":"~/work/sortie/kit/lab/assembly.py"}
input
{ "Path": "~/work/sortie/kit/lab/assembly.py" }result, 210 lines
Showing lines 1-209 of 209 1: """Fit lab variants onto the full striker frame: its head, chest armour and feet are removed and 2: variants built onto the same joints. This is part swapping, the way the game will do it.""" 3: import re 4: 5: import bpy 6: from mathutils import Matrix, Vector 7: 8: import backkit 9: import bodykit 10: import chestkit 11: import headkit 12: from lib import attach, empty 13: from mech import build_striker 14: 15: # striker parts replaced by a chest variant (base names; Blender may add .001 suffixes) 16: CHEST_PARTS = {"chest_plate.L", "chest_plate.R", "chest_strip.L", "chest_strip.R", "rib_plate0.L", "rib_plate0.R", "rib_plate1.L", 17: "rib_plate1.R", "side_plate.L", "side_plate.R", "belly", "belly_vent", "lens_socket", "lens", "lens_core", "hatch", 18: "collar.L", "collar.R", "collar_side.L", "collar_side.R", "collar_vent.L", "collar_vent.R", "back_plate", "neck_guard"} 19: 20: 21: def base(name): 22: return re.sub(r"\.\d{3}$", "", name) 23: 24: 25: def joint(frame, name): 26: for o in frame.children_recursive: 27: if o.type == "EMPTY" and base(o.name) == name: 28: return o 29: raise KeyError(name) 30: 31: 32: def remove(objs): 33: for o in objs: 34: bpy.data.objects.remove(o, do_unlink=True) 35: 36: 37: def fit(build, at, parent): 38: """Build a variant into a temporary empty at `at`, then hand its parts to a frame joint.""" 39: tmp = empty("_fit", at) 40: build(tmp) 41: for ob in list(tmp.children): 42: ob.matrix_parent_inverse = Matrix.Identity(4) 43: ob.location = (0, 0, 0) 44: bpy.context.view_layer.update() 45: for ob in list(tmp.children): 46: attach(ob, parent) 47: bpy.data.objects.remove(tmp, do_unlink=True) 48: 49: 50: def assemble(head_parts, chest, foot, n, extras=(), fold=0.0): 51: frame = build_striker() 52: bpy.context.view_layer.update() 53: head_j, torso_j = joint(frame, "head"), joint(frame, "torso") 54: remove([o for o in head_j.children_recursive if o.type == "MESH"]) 55: remove([o for o in torso_j.children if o.type == "MESH" and base(o.name) in CHEST_PARTS]) 56: for s in ("L", "R"): 57: remove([o for o in joint(frame, f"foot.{s}").children_recursive if o.type == "MESH" and base(o.name) != f"ankle.{s}"]) 58: bodykit.CONTEXT = False 59: try: 60: fit(lambda r: headkit.head_gen4(r, f"{n}h", head_parts, extras, fold), (0, -.05, 15.55), head_j) 61: fit(lambda r: chest(r, f"{n}c"), (0, 0, 11.9), torso_j) 62: for s, sx in (("L", 1), ("R", -1)): 63: fit(lambda r, s=s: foot(r, f"{n}f{s}"), (1.2 * sx, .1, .15), joint(frame, f"foot.{s}")) 64: finally: 65: bodykit.CONTEXT = True 66: return frame 67: 68: 69: H = dict(headkit.GEN4) 70: COMBOS = [ 71: ("A", "Mantle IV", lambda r, n: bodykit.chest_hatch3(r, n, diamond=True), bodykit.foot_claw3), 72: ("B", "Duelist IV", bodykit.chest_swept3, bodykit.foot_raptor), 73: ("C", "Sentinel IV", bodykit.chest_cuirass3, bodykit.foot_sabaton2), 74: ("D", "Warden IV", bodykit.chest_hatch3, bodykit.foot_talon), 75: ("E", "Tracker IV", bodykit.chest_swept3, bodykit.foot_skid), 76: ("F", "Lancer IV", bodykit.chest_cuirass3, bodykit.foot_boot2), 77: ] 78: 79: 80: def build_assembly_lab(): 81: root = empty("lab", (0, 0, 0)) 82: for i, (tag, head, chest, foot) in enumerate(COMBOS): 83: frame = assemble(H[head], chest, foot, f"a{i}") 84: slot = empty(f"slot{i}", (i * 11.0, 0, 0), root, label=f"{tag}: {head}") 85: attach(frame, slot) 86: frame.matrix_parent_inverse = Matrix.Identity(4) 87: frame.location = (0, 0, 0) 88: bpy.context.view_layer.update() 89: return root 90: 91: 92: # striker shoulder-shell parts replaced by a shoulder variant (block, trunnion and forks stay) 93: SHOULDER_PARTS = {"shell0", "shell1", "shell_under", "shell_blade", "shell_edge", "shell_fin"} 94: 95: 96: def move(j, at): 97: j.location = j.parent.matrix_world.inverted() @ Vector(at) 98: bpy.context.view_layer.update() 99: 100: 101: def refit_back(frame, pack, shoulder, n): 102: """Swap a frame's backpack and shoulder shells. Variants build into roots at the origin in world 103: coordinates; the binder joints move to the pack's hinge before the parts are handed over.""" 104: pack_j = joint(frame, "backpack") 105: J = {"P": pack_j, "L": joint(frame, "binder.L"), "R": joint(frame, "binder.R"), 106: "SL": joint(frame, "shoulder.L"), "SR": joint(frame, "shoulder.R")} 107: remove([o for o in pack_j.children_recursive if o.type == "MESH" or base(o.name).startswith("nozzle")]) 108: for k in ("SL", "SR"): 109: remove([o for o in J[k].children if o.type == "MESH" and base(o.name).rsplit(".", 1)[0] in SHOULDER_PARTS]) 110: roots = {k: empty(f"_{k}") for k in J} 111: x, y, z = pack(roots, f"{n}p") 112: move(J["L"], (x, y, z)) 113: move(J["R"], (-x, y, z)) 114: shoulder(roots, f"{n}s") 115: for k, root in roots.items(): 116: for ob in list(root.children): 117: attach(ob, J[k]) 118: bpy.data.objects.remove(root, do_unlink=True) 119: 120: 121: def assemble_back(pack, shoulder, n): 122: """Frame A with a backpack and shoulder variant.""" 123: frame = assemble(H["Mantle IV"], COMBOS[0][2], bodykit.foot_claw3, n) 124: if pack is not None: 125: refit_back(frame, pack, shoulder, n) 126: return frame 127: 128: 129: def build_back_lab(): 130: root = empty("lab", (0, 0, 0)) 131: combos = [("now", "current pack and shoulders", None, None)] + [ 132: (chr(65 + i), f"{p} + {s}", pf, sf) for i, ((p, pf), (s, sf)) in enumerate(zip(backkit.PACKS, backkit.SHOULDERS))] 133: for i, (tag, label, pack, shoulder) in enumerate(combos): 134: frame = assemble_back(pack, shoulder, f"b{i}") 135: slot = empty(f"slot{i}", (i * 11.0, 0, 0), root, label=f"{tag}: {label}") 136: attach(frame, slot) 137: frame.matrix_parent_inverse = Matrix.Identity(4) 138: frame.location = (0, 0, 0) 139: bpy.context.view_layer.update() 140: return root 141: 142: 143: def build_chest_frames(): 144: """Round 14: each new chest with one of the angled heads, on the wing pack and swept shoulders.""" 145: root = empty("lab", (0, 0, 0)) 146: for i, ((chest, cf), (head, parts, extras, fold)) in enumerate(zip(chestkit.CHESTS4, headkit.GEN5)): 147: frame = assemble(parts, cf, bodykit.foot_claw3, f"c{i}", extras, fold) 148: refit_back(frame, backkit.pack_wings, backkit.shoulder_swept, f"c{i}") 149: slot = empty(f"slot{i}", (i * 11.0, 0, 0), root, label=f"{chr(65 + i)}: {chest} chest, {head}") 150: attach(frame, slot) 151: frame.matrix_parent_inverse = Matrix.Identity(4) 152: frame.location = (0, 0, 0) 153: bpy.context.view_layer.update() 154: return root 155: 156: 157: SHOW = [("A", "Mantle V", "Hatch IV", "Wings", "Swept", "Claw II"), 158: ("B", "Duelist V", "Prow", "Sunk drive", "Thruster", "Raptor"), 159: ("C", "Warden V", "Layered", "Fairing", "Shield", "Sabaton II"), 160: ("D", "Surveyor V", "Intakes", "Keel", "Sode", "Skid"), 161: ("E", "Sentinel V", "Gorget", "Rack", "Round", "Boot II"), 162: ("F", "Lancer V", "Frame", "Saddle", "Open frame", "Talon"), 163: ("G", "Tracker V", "Intakes", "Saddle", "Swept", "Talon")] 164: 165: 166: def show_frame(i, n=None): 167: """One SHOW mix as a game model: frame A is SHOW[0]. The root is tagged striker_a, striker_b...""" 168: tag, head, chest, pack, shoulder, foot = SHOW[i] 169: parts, extras, fold = {h[0]: h[1:] for h in headkit.GEN5}[head] 170: n = n or f"f{tag.lower()}" 171: frame = assemble(parts, dict(chestkit.CHESTS4)[chest], dict(bodykit.FEET3)[foot], n, extras, fold) 172: refit_back(frame, dict(backkit.PACKS)[pack], dict(backkit.SHOULDERS)[shoulder], n) 173: frame["frame"] = f"striker_{tag.lower()}" 174: return frame 175: 176: 177: def game_frame(i): 178: """A SHOW mix built alone as a game model (striker_a, striker_b): every node keeps its exact name.""" 179: frame = show_frame(i) 180: # a pack's binder bells are named like the binder joints and come out binder.L.001: name them as 181: # the striker does, so a game model has no suffixed node 182: for o in frame.children_recursive: 183: if o.type == "MESH" and base(o.name) != o.name: 184: stem, side = base(o.name).rsplit(".", 1) 185: o.name = f"{stem}_nozzle.{side}" 186: assert not [o.name for o in frame.children_recursive if base(o.name) != o.name] 187: return frame 188: 189: 190: def build_show(formation=False): 191: """Round 15: the round 13 and 14 parts mixed into seven frames. In a row 13 m apart, or in a V 192: behind frame A with the outer frames turned in a little.""" 193: heads = {h[0]: h[1:] for h in headkit.GEN5} 194: chests, packs, shoulders, feet = (dict(x) for x in (chestkit.CHESTS4, backkit.PACKS, backkit.SHOULDERS, bodykit.FEET3)) 195: root = empty("lab", (0, 0, 0)) 196: for i, (tag, head, chest, pack, shoulder, foot) in enumerate(SHOW): 197: parts, extras, fold = heads[head] 198: frame = assemble(parts, chests[chest], feet[foot], f"s{i}", extras, fold) 199: refit_back(frame, packs[pack], shoulders[shoulder], f"s{i}") 200: side, rank = (1 if i % 2 else -1), (i + 1) // 2 201: at = (9.0 * side * rank, 6.0 * rank, 0) if formation else (i * 13.0, 0, 0) 202: slot = empty(f"slot{i}", at, root, label=f"{tag}: {head}, {chest}, {pack}, {shoulder}, {foot}") 203: attach(frame, slot) 204: frame.matrix_parent_inverse = Matrix.Identity(4) 205: frame.location = (0, 0, 0) 206: if formation: 207: slot.rotation_euler.z = -.17 * side * min(rank, 1) 208: bpy.context.view_layer.update() 209: return root