A mech game prototype, pushed by GPT-6.2-Astra
agent (cont.)
+1:15exec_commandsed -n '243,294p;853,887p' kit/light.py && cat kit/cockpit_light.py | head -150 (+1 more)
command
sed -n '243,294p;853,887p' kit/light.py && cat kit/cockpit_light.py | head -150 rg -n 'cockpit_light|cockpitMount|cockpit\.position' src/game/game.ts && rg -n '(def pilot|def points|def pose|bike|seat)' kit/figure.py | tail -28 && rg -n '(build_cockpit|pilot\(|seat| z )' kit/cockpit_light.py | tail -37
result, 209 lines
Script completed Wall time 0.1 seconds Output: Warning: truncated output (original token count: 3452) Total output lines: 237 role = "frame" elif abs(c.x) < .2: role = spine if c.z > 5.08 else "frame" else: role = hi if c.z > 5.08 else lo put(f"{n}_core{i}", p, role, C) # the rear hatch: a dark plate, four ejection motors round it, a handle and one status lamp yb = back + .02 put(f"{n}_hatch", prism(octo(w * .5, .42, .1, x=0, y=4.78), yb, yb + .05, "xz"), "joint", C, smooth=False) put(f"{n}_hatch_bar", prism(octo(w * .3, .05, .02, x=0, y=4.86), yb + .05, yb + .09, "xz"), "metal", C, smooth=False) for kk, (x, z) in enumerate(((-.36, 4.62), (.36, 4.62), (-.36, 4.96), (.36, 4.96))): put(f"{n}_eject{kk}", cylinder(.045, yb - .02, yb + .07, 10, axis="y", at=(x * w / 1.06, z)), "trim", C) put(f"{n}_core_lamp", cylinder(.025, yb, yb + .07, 8, axis="y", at=(.18, 4.66)), "lamp_green", C) # side armour standing proud of the hull, a vent behind the harken, a ridge along the top plate_role = {"knight": "main", "line": "accent", "lancer": "accent"}[v] plate = sc([(hw - .02, 4.7), (hw + .035, 4.73), (hw + .045, 5.4), (hw - .02, 5.46)], [(.34, 4.7), (back - .22, 4.68), (back - .08, 4.92), (back - .22, 5.34), (.46, 5.46), (.34, 5.28)], top=[(hw - .02, .34), (hw + .045, .4), (hw + .045, back - .1), (hw - .02, back - .06)], sharp=40) for i, p in enumerate(split(plate, [((0, .78, 5.1), (0, 1, -.5))], gap=.025)): two(f"{n}_core_side{i}", p, plate_role if centre(p).y < .78 + (centre(p).z - 5.1) * .5 else "frame", C, C) two(f"{n}_core_vent", merge(*[box(hw - .01, hw + .03, back - .36 + .06 * i, back - .325 + .06 * i, 4.46, 4.62) for i in range(4)]), "frame", C, C, smooth=False) ridge = sc([(-.07, top - .05), (.07, top - .05), (.05, top + .035), (-.05, top + .035)], [(.44, top - .05), (back - .34, top - .07), (back - .4, top + .02), (.52, top + .035)], sharp=40) put(f"{n}_core_ridge", ridge, "trim" if v == "knight" else "frame", C) if v == "knight": # a dark sensor housing across the top front edge, a sensor strip in its face, one blade antenna pod = sc([(-.3, top - .12), (.3, top - .12), (.26, top + .05), (-.26, top + .05)], [(.24, top - .12), (.5, top - .1), (.56, top + .04), (.3, top + .05), (.22, top - .02)], top=[(-.3, .22), (.3, .22), (.3, .56), (-.3, .56)], sharp=36) put(f"{n}_sensor_pod", pod, "frame", C) put(f"{n}_sensor_strip", box(-.2, .2, .21, .235, top - .05, top - .02), "sensor", C, smooth=False) ant = transform(two_view([(-.012, 0), (.012, 0), (.006, .42), (-.006, .42)], [(-.03, 0), (.05, 0), (.08, .42), (.06, .42)]), mat((.2, .45, top + .03), rx=-35)) put(f"{n}_sensor_blade", ant, "frame", C, smooth=False) # rails where the block docks into the torso for s, sx in (("L", 1), ("R", -1)): put(f"{n}_core_rail.{s}", box(sx * .2 - .03, sx * .2 + .03, -.02, .12, 4.5, 5.0), "joint", C, smooth=False) empty(f"{n}_seat", (0, .62, 4.75), J["cockpit"]) # ---- heads -------------------------------------------------------------------------------------------------- def _cranium(front, side, top, sharp): return sc(front, side, top, sharp) def head_knight(J, n): """A small crested helm: a narrow T-slit under a brow that dips to the centre, a raked blade crest and two horns swept back along the crown. The rear of the helm is its own plate.""" Hd = J["head"] cage = two_view([(-.15, 5.25), (.15, 5.25), (.19, 5.43), (.18, 5.6), (.1, 5.7), (-.1, 5.7), (-.18, 5.6), (-.19, 5.43)], [(-.22, 5.3), (-.23, 5.47), (-.19, 5.62), (-.05, 5.72), (.13, 5.69), (.22, 5.5), (.21, 5.3), (.1, 5.23), (-.1, 5.24)], def build_light(variant="knight", n=None, shutters_open=False): n = n or variant[0] SWAP.clear() if variant == "line": SWAP.update(main="accent", accent="main") J = joints(variant) inner(J, n) core_block(J, n, variant) {"knight": chest_knight, "line": chest_line, "lancer": chest_lancer}[variant](J, n) if variant == "knight": head_knight(J, n) elif variant == "line": head_line(J, n, shutters_open) else: head_lancer(J, n) # lumbar plates close the lower back under the block lumbar = sc([(.02, 3.84), (.2, 3.84), (.38, 4.1), (.42, 4.4), (.02, 4.4)], [(.12, 3.84), (.3, 3.84), (.38, 4.4), (.18, 4.4)], top=[(.02, .12), (.44, .12), (.44, .28), (.2, .4), (.02, .42)], sharp=34) for i, p in enumerate(split(lumbar, [((0, 0, 4.12), (0, 0, 1))], gap=.025)): two(f"{n}_lumbar{i}", p, "main" if centre(p).z > 4.12 else "accent", J["torso"], J["torso"]) pelvis(J, n, variant) arms(J, n, variant) legs(J, n, variant) float_pack(J, n, variant) harken(J, n, (min(CORE[variant]["w"] / 2 + .07, .62), -.22, 4.5), {"knight": "accent", "line": "main", "lancer": "accent"}[variant]) stretch_arms(J, 1.08) proportion(J, variant) SWAP.clear() return J["frame"] LAB = [("knight", "A: knight, the lead frame", False), ("line", "B: line, the grunt, factsphere open", True), ("lancer", "C: lancer, fast assault", False), ("line", "D: line, factsphere shut", False)] """The light frame's cockpit: the inside of its core block, the armoured box in the frame's back that ejects whole. Like kit/cockpit.py the pilot's eye is the origin and the pilot looks along +Y (+X right, …719 tokens truncated…fr, [(-hw - .01, -hh - RAIL - .012), (hw + .01, -hh - RAIL - .012), (hw + .01, -hh - RAIL), (-hw - .01, -hh - RAIL)], .0, .06)) # mullions on the panel edges, thin and dark so the band reads as one wraparound picture for az in EDGES[1:-1]: a = math.radians(az) p = edge(az, RHO - .004) fr = Frame((p.x, p.y, zc), (math.cos(a), -math.sin(a), 0), (0, 0, 1)) mull.append(slab(fr, [(-.008, -hh - .01), (.008, -hh - .01), (.008, hh + .01), (-.008, hh + .01)], -.01, .016)) solid("band_rails", merge(*rails), "frame", root, .004) solid("band_lips", merge(*lips), "joint", root, .003) solid("band_mullions", merge(*mull), "joint", root, .003) # the band ends: a pillar each side where the screens meet the side walls for sx in (1, -1): p = edge(96 * sx, RHO) q = Vector((HW * sx, p.y - .1, 0)) solid(f"band_end.{'R' if sx > 0 else 'L'}", quad_panel((p.x, p.y, FLOOR), (p.x, p.y, ROOF), (q.x, q.y, ROOF), (q.x, q.y, FLOOR), .04), "frame", root, .005) def hood(root): """Above the band: a sloped liner from the top rail up to the roof, a status strip in its middle, lamps and a padded brow bar.""" top = BAND[1] + RAIL panels = [] for i in range(len(EDGES) - 1): a0, a1 = EDGES[i], EDGES[i + 1] p0, p1 = edge(a0, RHO + .01), edge(a1, RHO + .01) q0, q1 = edge(a0, RHO - .18), edge(a1, RHO - .18) panels.append(quad_panel((p0.x, p0.y, top), (p1.x, p1.y, top), (q1.x, q1.y, ROOF), (q0.x, q0.y, ROOF), .03)) solid("hood", merge(*panels), "interior", root, .004) fr, hw = chord(-26, 26) # the status strip set into the top rail over the head-up display hh = (BAND[1] - BAND[0]) / 2 tilt = Frame(fr.at(0, hh + RAIL / 2, .03), (1, 0, 0), (0, 0, 1)) solid("strip_frame", slab(tilt, [(-.17, -.022), (.17, -.022), (.17, .022), (-.17, .022)], .0, .008), "joint", root, .002) facing(tilt.at(0, 0, .009), .3, .034, "screen.top", root, normal=tilt.w) lamps = [] for sx in (1, -1): p = tilt.at(sx * .21, 0, 0) lamps.append(loft([(p.z - .008, octo(.01, .01, .003, x=p.x, y=p.y)), (p.z + .008, octo(.01, .01, .003, x=p.x, y=p.y))])) solid("strip_lamps", merge(*lamps), "lamp_green", root) # roof: ribs across a liner, a dome light solid("roof", loft([(ROOF, octo(2 * HW, RHO - BACK, .1, y=(RHO + BACK) / 2)), (ROOF + .04, octo(2 * HW, RHO - BACK, .1, y=(RHO + BACK) / 2))]), "interior", root, .006) ribs = [loft([(ROOF - .035, octo(2 * HW - .02, .04, .01, y=y)), (ROOF, octo(2 * HW - .02, .04, .01, y=y))]) for y in (-.5, -.2, .1)] solid("roof_ribs", merge(*ribs), "frame", root, .004) solid("roof_light", loft([(ROOF - .012, octo(.22, .05, .015, y=-.05)), (ROOF, octo(.24, .06, .015, y=-.05))]), "light", root) def console(root): """Below the band: a console receding from the bottom rail with three small displays angled at the eye, the knee room under it.""" bot = BAND[0] - RAIL panels, knees = [], [] for i in range(len(EDGES) - 1): a0, a1 = EDGES[i], EDGES[i + 1] p0, p1 = edge(a0, RHO + .01), edge(a1, RHO + .01) q0, q1 = edge(a0, RHO + .14), edge(a1, RHO + .14) panels.append(quad_panel((p0.x, p0.y, bot), (p1.x, p1.y, bot), (q1.x, q1.y, bot - .34), (q0.x, q0.y, bot - .34), .03)) # the knee well: the block's front wall from the console down to the floor knees.append(quad_panel((q0.x, q0.y, bot - .34), (q1.x, q1.y, bot - .34), (q1.x, q1.y, FLOOR), (q0.x, q0.y, FLOOR), .03)) solid("console", merge(*panels), "frame", root, .004) solid("knee_well", merge(*knees), "interior", root, .004) # displays: one between the grips, one outboard of each, tilted up at the eye for name, az, w, h in (("screen.C", 0, .2, .11), ("screen.L", -37, .16, .1), ("screen.R", 37, .16, .1)): a = math.radians(az) d = RHO - .01 c = Vector((d * math.sin(a), d * math.cos(a), bot - .07)) n = (-c).normalized() u = Vector((math.cos(a), -math.sin(a), 0)) v = n.cross(u).normalized() if v.z < 0: v = -v fr = Frame(c, u, v) solid(f"{name}_bezel", slab(fr, [(-w / 2 - .018, -h / 2 - .018), (w / 2 + .018, -h / 2 - .018), (w / 2 + .018, h / 2 + .018), (-w / 2 - .018, h / 2 + .018)], -.03, .012), "joint", root, .004) facing(fr.at(0, 0, .014), w, h, name, root, normal=fr.w) keys = [slab(fr, octo(.022, .012, .003, x=-w / 2 + w * (k + .5) / 5, y=-h / 2 - .03), .012, .02) for k in range(5)] solid(f"{name}_keys", merge(*keys), "trim" if name == "screen.C" else "metal", root, .002) def walls(root): """Side walls, floor and the hatch: the block's inner shell.""" for sx, s in ((1, "R"), (-1, "L")): x = HW * sx y1 = edge(96, RHO).y - .1 solid(f"wall.{s}", quad_panel((x, BACK, FLOOR), (x, BACK, ROOF), (x, y1, ROOF), (x, y1, FLOOR), .04), "interior", root, .005) # padded side bolsters and a rail of switches at elbow height pad = subd(loft([(x - sx * .03, octo(.5, .26, .06, y=-.32, x=-.55)), (x - sx * .07, octo(.46, .22, .05, y=-.32, x=-.55))], axis="x"), 1, 50) solid(f"bolster.{s}", pad, "suit", root, smooth=True) rail = loft([(x - sx * .02, octo(.56, .05, .01, y=-.15, x=-.2)), (x - sx * .06, octo(.56, .05, .01, y=-.15, x=-.2))], axis="x") 54: light: { model: 'cockpit_light', glow: [0, 0.02, -0.42], eye: [0, 0.3, 0] }, 184: const shell = cls.id === 'light' ? null : await model('cockpit_light'); 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 51: "bike": dict(lift=0.0, joints={ 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)), 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.""" 359:def pilot(parent, at=(0.0, 0.0), n="pilot", role="hazard", pose="stand", z=0.0, turn=0.0, skip=(), parents=None): 5:The block has no window. The pilot rides a bike-style seat leaning forward, hands on two grips, and 10:hatch is the block's back face behind the seat. 165:def seat(root, pts): 166: """The bike-style seat under the pilot, a post to the floor, foot pegs.""" 167: s = pts["seat"] 170: solid("seat", cushion, "suit", root, smooth=True) 171: solid("seat_pan", loft([(s.z - .14, octo(.2, .4, .06, x=s.x, y=s.y - .06)), (s.z - .09, octo(.22, .42, .07, x=s.x, y=s.y - .06))]), 173: solid("seat_post", loft([(FLOOR, octo(.12, .16, .03, y=s.y - .08)), (s.z - .13, octo(.08, .12, .025, y=s.y - .06))]), "joint", root, .006) 203:def build_cockpit_light(): 211: at, z = (-e.x, -e.y), -e.z 214: seat(root, pts) 215: pilot(root, at, n="pilot", role="trim", pose="bike", z=z, turn=180, skip=("head",), parents=sticks)
agent
+1:31The light frame already has an ejectable cockpit in its back. I’ll use that existing model for a cutaway showing where the pilot sits and which parts leave with them. That gives the review a concrete example while leaving the owner’s new mech for the restart.
exec_commandsed -n '1,35p;195,228p' kit/cockpit_light.py && sed -n '811,853p' kit/light.py && sed -n '35,101p;359,399p' kit/figure.py && sed -n '36,70p;150,200p' src/game/game.ts (+2 more)
command
sed -n '1,35p;195,228p' kit/cockpit_light.py && sed -n '811,853p' kit/light.py && sed -n '35,101p;359,399p' kit/figure.py && sed -n '36,70p;150,200p' src/game/game.ts python - <<'PY' import json,struct for model in ['light','cockpit_light','lab_pilot']: with open('public/assets/'+model+'.glb','rb') as f: f.seek(12);l,t=struct.unpack('II',f.read(8)); g=json.loads(f.read(l)) print(model) for n in g['nodes']: if model=='cockpit_light' or n['name'] in ('frame','core','backpack','pelvis','thigh.L','foot.L','waist','torso','cockpit','k_seat','slot1'): print(n['name'],*[n[k] for k in ('translation','rotation','scale') if k in n]) PY rg -n 'def eye|def helmet|def head' kit/figure.py && ls /usr/share/fonts/truetype/ubuntu && date --utc && git log -1 --format=%sresult, 412 lines
Script completed Wall time 0.1 seconds Output: """The light frame's cockpit: the inside of its core block, the armoured box in the frame's back that ejects whole. Like kit/cockpit.py the pilot's eye is the origin and the pilot looks along +Y (+X right, +Z up), and the game renders it from a camera at the origin over the world. The block has no window. The pilot rides a bike-style seat leaning forward, hands on two grips, and sees out through a band of screens on the block's inner walls that wraps from one side to the other ahead of the pilot: five flat panels round the eye, the world showing through each. The middle panel carries the head-up display (screen.main), the others are camera feeds (feed.*) that come up during start-up. Small displays sit low between and beside the grips, a status strip over the band, and the hatch is the block's back face behind the seat. Screens are empties named screen.* and feed.* with w and h extras, local -Y facing the eye, as in cockpit.py. The grips are stick.L and stick.R; the pilot's hands hang on them and follow. """ import math from mathutils import Vector from cockpit import Frame, facing, quad_panel, slab from figure import pilot, points from lib import cylinder, empty, loft, merge, octo, solid, subd # The band: five panels on a circle of radius RHO round the eye, each a chord. Edges at these azimuths. RHO = .56 EDGES = (-96, -61, -26, 26, 61, 96) BAND = (-.16, .2) # bottom and top of the screens RAIL = .045 # bezel rail height above and below the band # The block's inside: half width, back wall, floor and roof, all from the eye. HW, BACK, FLOOR, ROOF = .58, -.8, -1.22, .44 def chord(a0, a1): """The flat panel between two azimuths on the band circle: its Frame and half width.""" a, h = math.radians((a0 + a1) / 2), math.radians((a1 - a0) / 2) d = RHO * math.cos(h) solid(f"grip_boot.{s}", subd(loft([(base.z - .03, octo(.07, .07, .02, x=base.x, y=base.y)), (base.z + .03, octo(.05, .05, .015, x=base.x, y=base.y))]), 1, 50), "joint", root, smooth=True) arm = quad_panel((base.x - .03, base.y, base.z - .03), (base.x + .03, base.y, base.z - .03), (base.x + .03, RHO + .1, BAND[0] - RAIL - .2), (base.x - .03, RHO + .1, BAND[0] - RAIL - .2), .04) solid(f"grip_arm.{s}", arm, "frame", root, .004) return pivot def build_cockpit_light(): root = empty("cockpit", (0, 0, 0)) band(root) hood(root) console(root) walls(root) # the pilot, turned to face +Y with the eye on the origin e = points("bike", turn=180)["eye"] at, z = (-e.x, -e.y), -e.z pts = points("bike", at, z, 180) sticks = {f"hand.{s}": grip(root, pts[f"grip.{s}"], 1 if pts[f"grip.{s}"].x > 0 else -1, s) for s in ("L", "R")} seat(root, pts) pilot(root, at, n="pilot", role="trim", pose="bike", z=z, turn=180, skip=("head",), parents=sticks) return root shins and its helm sunk into the collar, the lancer slim and long-shinned.""" k = SHAPE[v] frame = J["frame"] lo, hi = .4, 1.78 # ankle to knee if k["shin"] != 1.0: d = (k["shin"] - 1) * (hi - lo) def zmap(p, d=d): p = p.copy() if p.z >= hi: p.z += d elif p.z > lo: p.z = lo + (p.z - lo) * k["shin"] return p remap(_tree(frame)[1:], zmap) for s, sx in (("L", 1), ("R", -1)): for part, dx in (("shoulder", k["sho"]), ("thigh", k["hip"])): if dx: remap(_tree(J[part, s]), lambda p, dx=dx * sx: p + Vector((dx, 0, 0))) for part in ("upperarm", "forearm", "thigh", "shin"): f = k["thigh"] if part == "thigh" else k["limb"] if f != 1.0: j = J[part, s] c = j.matrix_world.translation.copy() remap([o for o in j.children if o.type == "MESH"], lambda p, c=c, f=f: Vector((c.x + (p.x - c.x) * f, c.y + (p.y - c.y) * f, p.z))) # the pauldrons grow outward from the shoulder joint so the arm hangs under them j = J["shoulder", s] c = j.matrix_world.translation.copy() shells = [o for o in j.children if o.type == "MESH" and not any(t in o.name for t in ("shoulder_block", "trunnion"))] remap(shells, lambda p, c=c: Vector((c.x + (p.x - c.x) * k["pd"], c.y + (p.y - c.y) * 1.06, c.z + (p.z - c.z) * 1.04))) if k["waist"] != 1.0: mid = [o for jn in ("pelvis", "waist") for o in J[jn].children if o.type == "MESH"] remap(mid, lambda p: Vector((p.x * k["waist"], p.y, p.z))) if k["head"]: remap(_tree(J["neck"]), lambda p: p + Vector((0, 0, k["head"]))) # ---- frames ------------------------------------------------------------------------------------------------- VARIANTS = ("knight", "line", "lancer") def build_light(variant="knight", n=None, shutters_open=False): "hand": ("forearm", (.205, .01, .865)), "thigh": ("pelvis", (.095, 0, .91)), "shin": ("thigh", (.1, -.005, .5)), "foot": ("shin", (.1, .02, .085)), } SIDED = {"upperarm", "forearm", "hand", "thigh", "shin", "foot"} # Joint rotations in degrees: (pitch about X, sideways about Y, twist about Z), applied in rest axes. # A positive pitch tips an upward bone forward (-Y) and a downward bone back. A positive sideways # value tips a downward left bone toward the centre line, mirrored on the right. # `fingers` curls the fingers (degrees per knuckle), `thumb` closes the thumb. POSES = { "stand": dict(lift=0.0, joints={ "upperarm": (-3, -7, 0), "forearm": (-12, 2, -20), "hand": (-4, 0, 0), "thigh": (0, -1.5, 0), "shin": (2, 0, 0), "foot": (-2, 0, 0), "head": (-2, 0, 0)}, fingers=(22, 18), thumb=10), "bike": dict(lift=0.0, joints={ "pelvis": (24, 0, 0), "chest": (18, 0, 0), "head": (-42, 0, 0), "upperarm": (-124, -11, 0), "forearm": (-8, 4, -84), "hand": (8, 0, 6), "thigh": (-86, -5, 0), "shin": (112, 3, 0), "foot": (-32, 0, 0)}, fingers=(78, 72), thumb=55), } # Points of interest in the rest pose, by joint: the eye (between the eyes, inside the helmet), the # grip in each hand, the seat contact under the pelvis, the ball of each foot. MARKS = {"eye": ("head", (0, -.085, 1.645)), "grip": ("hand", (.2, -.004, .79)), "seat": ("pelvis", (0, .0, .86)), "peg": ("foot", (.1, -.07, .02))} def _rot(p, r, t): return Matrix.Rotation(math.radians(p), 4, "X") @ Matrix.Rotation(math.radians(r), 4, "Y") @ Matrix.Rotation(math.radians(t), 4, "Z") def rig(pose="stand"): """World matrices per joint (keys like "thigh.L") for a pose, feet-on-the-ground for stand.""" P = POSES[pose] M = {} for name, (parent, piv) in SKELETON.items(): for s, sx in ((("L", 1), ("R", -1)) if name in SIDED else (("", 1),)): key = f"{name}.{s}" if s else name pk = None if parent is None else (f"{parent}.{s}" if parent in SIDED else parent) p, r, t = P["joints"].get(name, (0, 0, 0)) c = Vector((piv[0] * sx, piv[1], piv[2])) local = Matrix.Translation(c) @ _rot(p, r * sx, t * sx) @ Matrix.Translation(-c) M[key] = (M[pk] if pk else Matrix.Translation((0, 0, P["lift"]))) @ local return M def place(at=(0.0, 0.0), z=0.0, turn=0.0): """The placement of a built pilot: turned `turn` degrees about Z, then moved to (at, z).""" return Matrix.Translation((at[0], at[1], z)) @ Matrix.Rotation(math.radians(turn), 4, "Z") def points(pose="stand", at=(0.0, 0.0), z=0.0, turn=0.0): """Posed marks in world space: eye, grip.L/R, seat, peg.L/R.""" M = rig(pose) off = place(at, z, turn) out = {} for mark, (joint, p) in MARKS.items(): if joint in SIDED: for s, sx in (("L", 1), ("R", -1)): out[f"{mark}.{s}"] = off @ M[f"{joint}.{s}"] @ Vector((p[0] * sx, p[1], p[2])) else: out[mark] = off @ M[joint] @ Vector(p) return out def pilot(parent, at=(0.0, 0.0), n="pilot", role="hazard", pose="stand", z=0.0, turn=0.0, skip=(), parents=None): """Build the pilot under `parent`, the rest pose's feet at `at` and height z, turned `turn` degrees about Z (0 faces -Y), in a pose. `skip` drops parts by joint ("head", "chest", ...), for a cockpit seen from the pilot's own eye. `parents` hangs joints on other objects ({"hand.L": stick}), so hands follow a moving grip. Returns points(pose) at that placement.""" acc = "trim" if role == "hazard" else role P = POSES[pose] parts = torso(acc) + ([] if "head" in skip else helmet(acc)) for sx, s in ((1, "L"), (-1, "R")): side_parts = arm(sx, acc) + hand(sx, P["fingers"], P["thumb"]) + leg(sx, acc) + foot(sx) parts += [(f"{j}.{s}", r, bm) for j, r, bm in side_parts] M = rig(pose) off = place(at, z, turn) groups = {} for joint, r, bm in parts: if joint.split(".")[0] in skip: bm.free() continue transform(bm, off @ M[joint]) groups.setdefault((joint, r), []).append(bm) for (joint, r), bms in groups.items(): solid(f"{n}_{joint.replace('.', '_')}_{r}", merge(*bms), r, (parents or {}).get(joint, parent), smooth=True, panels=False) return points(pose, at, z, turn) import { glassRadio } from './contact'; import { createAudio } from '../audio'; import { debrisOnly } from '../sim/defence'; import { contractFrames, contractMode, contractModels, loadContract, startContract } from './contract'; import { EjectRigs, capsuleView } from '../render/eject'; import { WreckView } from './wrecks'; import { Tips } from '../hud/tips'; const STEP = 1 / 120; /** Mech centre above its feet; the sim tracks the centre. */ const CENTRE = 9.5; const MODEL_OF: Record<WeaponId, ModelName> = { beam_rifle: 'rifle', heavy_cannon: 'cannon' }; /** * The pod each class flies from: its model, where the screens' glow sits in pod space, and the eye's * offset from the frame's cockpit node in metres along the frame's axes (the world camera sits there). * The light pod is the inside of the core block: the pilot's eye rides 0.3 m over the block's centre. */ const COCKPITS: Record<FrameClassId, { model: ModelName; glow: readonly number[]; eye: readonly number[] }> = { light: { model: 'cockpit_light', glow: [0, 0.02, -0.42], eye: [0, 0.3, 0] }, standard: { model: 'cockpit', glow: [0, 0.1, -0.9], eye: [0, 0, 0] }, heavy: { model: 'cockpit', glow: [0, 0.1, -0.9], eye: [0, 0, 0] }, }; /** Each class's frame model and its variants (kit/build.py). `?variant=line` flies `light_line`, `?frame=standard&variant=a` * flies `striker_a` (frame A of the design rounds, provisional). */ const VARIANTS: Record<FrameClass['id'], ModelName[]> = { light: ['light', 'light_line', 'light_lancer'], standard: ['striker', 'striker_a', 'striker_b'], heavy: ['heavy', 'heavy_B', 'heavy_C'], }; function frameModel(cls: FrameClass, variant: string | null): ModelName { const list = VARIANTS[cls.id]; return list.find((m) => m === `${list[0]}_${variant}`) ?? list[0]; } /** Controls that act once per press. */ const ONE_SHOT = ['launch', 'skip', 'drop', 'pickup', 'toggleAssist', 'harken'] as const; export async function startGame(canvas: HTMLCanvasElement, hudRoot: HTMLElement, q: URLSearchParams, saved: unknown = null, if (b.name === 'striker') applyDecals(spare, STRIKER_DECALS); treatEyes(spare, 'spill'); spare.position.copy(ship.slots[b.i]?.[b.fit][b.k] ?? ship.bays[b.i]); new MechRig(spare).apply(POSES.stand); scene.add(spare); spares.push(spare); } // ---- the cockpit: its own scene and camera, drawn over the world (pipeline overlay pass) ---- const podOf = COCKPITS[cls.id]; const cockpit = await model(podOf.model); const eye = new THREE.Object3D(); eye.position.fromArray(podOf.eye).divideScalar(mech.scale.x); frame.cockpit.add(eye); const pod = new THREE.Scene(); pod.add(cockpit); pod.environment = env; pod.environmentIntensity = 0.35; const podCam = new THREE.PerspectiveCamera(rig.camera.fov, 1, 0.02, 20); pod.add(podCam); const podSun = new THREE.DirectionalLight('#fff4e6', 2.2); pod.add(podSun, podSun.target); const podHemi = new THREE.HemisphereLight('#7f97c4', '#10161f', 0.35); pod.add(podHemi); const glowLight = new THREE.PointLight('#5fe6d8', 0.25, 2.2, 2); // the pod light reddens and swells on a hull hit (screens.alarm) const glowCalm = new THREE.Color('#5fe6d8'), glowAlarm = new THREE.Color('#ff2a1e'); glowLight.position.fromArray(podOf.glow); pod.add(glowLight); pipe.setOverlay(pod, podCam); // compile the pod's shaders now, not on the first switch to the cockpit view pipe.renderer.compile(pod, podCam); const screens = new CockpitScreens(cockpit); // an ejected pilot sits in the light pod's cramped shell (the core block, or a pod fitted the same) const shell = cls.id === 'light' ? null : await model('cockpit_light'); if (shell) pod.add(shell); const shellScreens = shell ? new CockpitScreens(shell) : screens; const sticks = ['stick.L', 'stick.R'].map((n) => cockpit.getObjectByName(n.replace('.', '')) ?? cockpit.getObjectByName(n)); const head = { pos: new THREE.Vector3(), vel: new THREE.Vector3(), last: new THREE.Vector3() }; const drones = new Map<number, THREE.Object3D>(); for (const t of world.targets) { const d = await model('drone'); scene.add(d); drones.set(t.id, d); } const loose = new Map<number, THREE.Object3D>(); const spills: THREE.Object3D[] = []; scene.traverse((o) => { if (o.userData.spill) spills.push(o); light foot.L [0, -1.3799999952316284, -0.029999999329447746] thigh.L [0.36000001430511475, -0.059999942779541016, 0] backpack [0, 0.2999997138977051, -0.5099999904632568] k_seat [0, -0.3000001907348633, 0] cockpit [0, 0, 0.029999971389770508] core [0, 1.2700002193450928, -0.6499999761581421] torso [0, 0.2999999523162842, 0] waist [0, 0.18000006675720215, 0] pelvis [0, 3.299999952316284, 0] frame cockpit_light back_wall band_end.L band_end.R band_lips band_mullions band_rails bolster.L bolster.R console feed.L1 [-0.36694908142089844, 0.019999999552965164, -0.3866836428642273] [0, 0.37055739760398865, 0, 0.9288095831871033] feed.L2 [-0.5223797559738159, 0.019999999552965164, -0.10627935081720352] [0, 0.6327053904533386, 0, 0.7743926048278809] feed.R1 [0.36694908142089844, 0.019999999552965164, -0.3866836428642273] [0, -0.37055739760398865, 0, 0.9288095831871033] feed.R2 [0.5223797559738159, 0.019999999552965164, -0.10627935081720352] [0, -0.6327053904533386, 0, 0.7743926048278809] floor grip_arm.L grip_arm.R grip_boot.L grip_boot.R hatch hatch_bar hatch_hinges hatch_lamp hood knee_well pegs pilot_chest_accent pilot_chest_main pilot_chest_suit pilot_chest_trim pilot_foot_L_joint pilot_foot_L_main pilot_foot_R_joint pilot_foot_R_main pilot_forearm_L_joint pilot_forearm_L_main pilot_forearm_L_suit pilot_forearm_L_trim pilot_forearm_R_joint pilot_forearm_R_main pilot_forearm_R_suit pilot_forearm_R_trim pilot_pelvis_accent pilot_pelvis_main pilot_pelvis_suit pilot_pelvis_trim pilot_shin_L_accent pilot_shin_L_main pilot_shin_L_suit pilot_shin_L_trim pilot_shin_R_accent pilot_shin_R_main pilot_shin_R_suit pilot_shin_R_trim pilot_thigh_L_main pilot_thigh_L_suit pilot_thigh_R_main pilot_thigh_R_suit pilot_upperarm_L_main pilot_upperarm_L_suit pilot_upperarm_L_trim pilot_upperarm_R_main pilot_upperarm_R_suit pilot_upperarm_R_trim roof roof_light roof_ribs screen.C [0, -0.2687390148639679, -0.5374780297279358] [-0.22975298762321472, 0, 0, 0.9732490181922913] screen.C_bezel screen.C_keys screen.L [-0.3234623670578003, -0.2687390148639679, -0.4292490482330322] [-0.21788015961647034, 0.30881649255752563, 0.07290171086788177, 0.9229550361633301] screen.L_bezel screen.L_keys screen.main [0, 0.019999999552965164, -0.5023247003555298] screen.R [0.3234623670578003, -0.2687390148639679, -0.4292490482330322] [-0.21788015961647034, -0.30881649255752563, -0.07290171086788177, 0.9229550361633301] screen.R_bezel screen.R_keys screen.top [0, 0.2224999964237213, -0.4643246829509735] seat seat_pan seat_post grip_button.L [0.2825002670288086, 0.25425565242767334, 0.46926286816596985] grip_cap.L [0.2825002670288086, 0.25425565242767334, 0.46926286816596985] grip_handle.L [0.2825002670288086, 0.25425565242767334, 0.46926286816596985] pilot_hand_L_main [0.2825002670288086, 0.25425565242767334, 0.46926286816596985] pilot_hand_L_suit [0.2825002670288086, 0.25425565242767334, 0.46926286816596985] stick.L [-0.2825002670288086, -0.25425565242767334, -0.46926286816596985] grip_button.R [-0.28250038623809814, 0.25425565242767334, 0.4692627191543579] grip_cap.R [-0.28250038623809814, 0.25425565242767334, 0.4692627191543579] grip_handle.R [-0.28250038623809814, 0.25425565242767334, 0.4692627191543579] pilot_hand_R_main [-0.28250038623809814, 0.25425565242767334, 0.4692627191543579] pilot_hand_R_suit [-0.28250038623809814, 0.25425565242767334, 0.4692627191543579] stick.R [0.28250038623809814, -0.25425565242767334, -0.4692627191543579] strip_frame strip_lamps wall.L wall.R wall_rail.L wall_rail.R cockpit lab_pilot slot1 [0.550000011920929, 0, 0] 335:def helmet(acc): Ubuntu-B.ttf Ubuntu-BI.ttf Ubuntu-C.ttf Ubuntu-L.ttf Ubuntu-LI.ttf12 more lines not shown.
exec_commandsed -n '222,245p' kit/light.py && sed -n '330,359p' kit/figure.py && rg -n 'def remap|def export|def solid|def material' kit/lib.py && cat /sys/fs/cgroup/cpu.max && ls /usr/share/fonts/truetype/noto | head && rg -n 'def float_pack' kit/light.py -A39
command
sed -n '222,245p' kit/light.py && sed -n '330,359p' kit/figure.py && rg -n 'def remap|def export|def solid|def material' kit/lib.py && cat /sys/fs/cgroup/cpu.max && ls /usr/share/fonts/truetype/noto | head && rg -n 'def float_pack' kit/light.py -A39
result, 62 lines
Script completed Wall time 0.0 seconds Output: "lancer": dict(w=.96, top=5.66, back=1.2, ch=.28, sharp=55)} def core_block(J, n, v): """The cockpit: a module behind the chest as wide as the shoulders and topping out over the head, a notch at its front for the head. The pilot sits on a bike-style seat inside. The rear face is the hatch, the whole block ejects (the core joint) and carries the harkens and the float pack.""" C = J["core"] k = CORE[v] w, top, back, ch = k["w"], k["top"], k["back"], k["ch"] hw = w / 2 body = sc([(-hw * .8, 4.38), (hw * .8, 4.38), (hw, 4.62), (hw, 5.36), (hw * .7, top), (-hw * .7, top), (-hw, 5.36), (-hw, 4.62)], [(.08, 4.4), (.08, 5.04), (.27, 5.14), (.27, top - .1), (.42, top), (back - .4, top - .02), (back, top - .42), (back + .04, 4.72), (back - .14, 4.4), (.3, 4.36)], top=[(-hw + ch, .0), (hw - ch, 0), (hw, ch), (hw, back - ch), (hw - ch, back + .1), (-hw + ch, back + .1), (-hw, back - ch), (-hw, ch)], sharp=k["sharp"]) cuts = [((.2, 0, 0), (1, 0, 0)), ((-.2, 0, 0), (1, 0, 0)), ((0, 0, 5.08), (0, -.15, 1)), ((0, back - .08, 0), (0, 1, 0))] hi, lo, spine = {"knight": ("hull", "accent", "main"), "line": ("hull", "main", "accent"), "lancer": ("main", "hull", "accent")}[v] for i, p in enumerate(split(body, cuts, gap=.03)): c = centre(p) if c.y > back - .1: role = "frame" elif abs(c.x) < .2: role = spine if c.z > 5.08 else "frame" SHELL = [S(1.5, .14, .15, y=.02), S(1.53, .2, .23), S(1.58, .245, .272, y=.002), S(1.65, .258, .288, y=.006), S(1.72, .24, .27, y=.012), S(1.77, .18, .21, y=.018), S(1.795, .08, .1, y=.02)] VISOR = [(-.1, 1.6), (.1, 1.6), (.122, 1.645), (.112, 1.69), (.06, 1.705), (-.06, 1.705), (-.112, 1.69), (-.122, 1.645)] def helmet(acc): out = [] shell = cut(form(SHELL, sharp=60), front(VISOR, -1, -.02, k=1), "DIFFERENCE") # the shell in two plates: a white crown and a jaw in the accent, the seam rising toward the back jaw, crown = halves(shell, (0, 0, 1.6), (0, -.4, 1), .008) out += [("head", "main", crown), ("head", "accent", jaw)] out.append(("head", "visor", plate(SHELL, -.012, front(VISOR, -1, -.0, k=1)))) # crest stripe from the brow over the crown, a short fin at its front out.append(("head", acc, plate(SHELL, .007, side([(-.2, 1.69), (.12, 1.69), (.12, 1.9), (-.2, 1.9)], k=0), box(-.015, .015, -1, 1, 1.6, 1.9)))) out.append(("head", acc, form([S(1.703, .018, .03, y=-.133), S(1.74, .014, .07, y=-.124), S(1.765, .008, .05, y=-.11)], lv=1, sharp=40))) # brow plate over the visor out.append(("head", "main", plate(SHELL, .009, front([(-.12, 1.702), (.12, 1.702), (.1, 1.732), (-.1, 1.732)], -1, -.04, k=1)))) # ear pods with an accent ring for sx in (1, -1): pod = loft([(.116, ell(.075, .075, .005, 1.645)), (.14, ell(.072, .072, .005, 1.645)), (.149, ell(.052, .052, .005, 1.645))], axis="x") out.append(("head", "main", mirror(subd(pod, 2, sharp=50), sx))) ringb = loft([(.145, ell(.034, .034, .005, 1.645)), (.154, ell(.03, .03, .005, 1.645))], axis="x") out.append(("head", acc, mirror(subd(ringb, 1, sharp=50), sx))) out.append(("head", "suit", form([S(1.47, .11, .11, y=.015), S(1.56, .1, .1, y=.015)]))) return out # ---- assembly ---------------------------------------------------------------------------------------------- def pilot(parent, at=(0.0, 0.0), n="pilot", role="hazard", pose="stand", z=0.0, turn=0.0, skip=(), parents=None): 46:def material(role): 176:def solid(name, bm, role, parent=None, bevel=0.0, segs=1, angle=40, smooth=False, outline=True, panels=None): 434:def export(path, extras=True): cat: /sys/fs/cgroup/cpu.max: No such file or directoryexec_commandsed -n '38,62p;176,228p' kit/lib.py && rg -n 'def float_pack' kit/light.py -A46 && ls /usr/share/fonts/truetype/noto | head && command -v node && rg 'def (transform|merge)' kit/lib.py
command
sed -n '38,62p;176,228p' kit/lib.py && rg -n 'def float_pack' kit/light.py -A46 && ls /usr/share/fonts/truetype/noto | head && command -v node && rg 'def (transform|merge)' kit/lib.py
result, 135 lines
Script completed Wall time 0.0 seconds Output: def reset(): for o in list(bpy.data.objects): bpy.data.objects.remove(o, do_unlink=True) for coll in (bpy.data.meshes, bpy.data.materials): for item in list(coll): coll.remove(item) def material(role): m = bpy.data.materials.get(role) if m is None: m = bpy.data.materials.new(role) c = PREVIEW.get(role, (0.7, 0.7, 0.7)) m.diffuse_color = (*c, 1.0) return m def link(o): bpy.context.scene.collection.objects.link(o) return o def empty(name, at=(0, 0, 0), parent=None, **extras): """A joint or marker. Children keep their world placement when parented to it.""" o = link(bpy.data.objects.new(name, None)) def solid(name, bm, role, parent=None, bevel=0.0, segs=1, angle=40, smooth=False, outline=True, panels=None): """Turn a bmesh into an object with a material role, an optional chamfer on edges sharper than `angle`, flat or smooth shading, parented to a joint without moving. Armour roles get panel seams on their large faces unless panels=False.""" me = bpy.data.meshes.new(name) bm.to_mesh(me) bm.free() me.materials.append(material(role)) o = link(bpy.data.objects.new(name, me)) if bevel > 0: mod = o.modifiers.new("bevel", "BEVEL") mod.width = bevel mod.segments = segs mod.limit_method = "ANGLE" mod.angle_limit = math.radians(angle) mod.use_clamp_overlap = True mod.miter_outer = "MITER_ARC" bake(o) if panels is None: panels = role in ("main", "accent", "hull") and not smooth if panels: panel_lines(o) me = o.data if smooth: me.shade_smooth() me.set_sharp_from_angle(angle=math.radians(35)) if not outline: o["outline"] = False if parent is not None: attach(o, parent) return o def panel_lines(o, min_area=1.1, width=0.05, depth=0.016): """Recess every large face slightly inside a thin border: reads as panel seams on armour.""" bm = bmesh.new() bm.from_mesh(o.data) faces = [f for f in bm.faces if f.calc_area() > min_area] if faces: bmesh.ops.inset_individual(bm, faces=faces, thickness=width, depth=-depth, use_even_offset=True) bm.to_mesh(o.data) bm.free() return o def bake(o): dg = bpy.context.evaluated_depsgraph_get() me = bpy.data.meshes.new_from_object(o.evaluated_get(dg)) old = o.data o.modifiers.clear() o.data = me me.name = old.name bpy.data.meshes.remove(old) 734:def float_pack(J, n, v): 735- """The float unit: a thruster core hung on the upper rear face of the core block, over the hatch, 736- two blades longer than the torso on the binder joints, two main thrusters under the core.""" 737- B = J["backpack"] 738- bk = CORE[v]["back"] 739- if v == "line": 740- body = sc([(-.38, 5.1), (.38, 5.1), (.42, 5.5), (.36, 5.62), (-.36, 5.62), (-.42, 5.5)], 741- [(bk - .05, 5.1), (bk + .24, 5.12), (bk + .28, 5.5), (bk + .18, 5.62), (bk - .4, 5.64), (bk - .3, 5.3)], sharp=50) 742- elif v == "knight": 743- body = sc([(-.34, 5.08), (.34, 5.08), (.42, 5.46), (.3, 5.66), (-.3, 5.66), (-.42, 5.46)], 744- [(bk - .05, 5.08), (bk + .2, 5.12), (bk + .34, 5.42), (bk + .2, 5.66), (bk - .4, 5.68), (bk - .3, 5.3)], 745- top=[(-.42, bk - .4), (.42, bk - .4), (.42, bk + .2), (.2, bk + .36), (-.2, bk + .36), (-.42, bk + .2)], sharp=34) 746- else: 747- body = sc([(-.3, 5.1), (.3, 5.1), (.36, 5.42), (.2, 5.6), (-.2, 5.6), (-.36, 5.42)], 748- [(bk - .05, 5.1), (bk + .16, 5.12), (bk + .4, 5.36), (bk + .3, 5.52), (bk - .4, 5.6), (bk - .3, 5.3)], 749- top=[(-.36, bk - .4), (.36, bk - .4), (.3, bk + .26), (0, bk + .44), (-.3, bk + .26)], sharp=30) 750- for i, p in enumerate(split(body, [((0, 0, 0), (1, 0, 0)), ((0, 0, 5.38), (0, -.3, 1))])): 751- put(f"{n}_pack{i}", p, "main" if centre(p).z > 5.38 else "accent", B) 752- nozzle_pair("main", (.2, bk + .14, 5.06), (0, .45, -.9), .1, .18, B, B) 753- wing(J, n, v) 754- 755- 756-def stretch_arms(J, k, z0=4.74): 757- """Lengthen both arms below the shoulder pivot by k: knightmare hands hang below the crotch. 758- Joints move down, every part on the arm is scaled in z about the pivot in world space.""" 759- import bpy as _bpy 760- S = Matrix.Translation((0, 0, z0)) @ Matrix.Diagonal((1, 1, k, 1)) @ Matrix.Translation((0, 0, -z0)) 761- for s in ("L", "R"): 762- chain = [J[p, s] for p in ("upperarm", "forearm", "hand", "grip")] 763- meshes = [o for j in chain for o in j.children if o.type == "MESH"] 764- before = {o.name: o.matrix_world.copy() for o in meshes} 765- for j in chain[1:]: 766- w = j.matrix_world.translation.copy() 767- w.z = z0 - k * (z0 - w.z) 768- j.location = j.parent.matrix_world.inverted() @ w 769- _bpy.context.view_layer.update() 770- for o in meshes: 771- o.data.transform(o.matrix_world.inverted() @ S @ before[o.name]) 772- 773- 774-# per variant: shin length factor, shoulder and hip offsets, waist width, limb girth, head drop 775-SHAPE = {"knight": dict(shin=1.0, sho=.06, hip=0.0, waist=1.0, limb=1.0, head=0.0, pd=1.2, thigh=1.08), 776- "line": dict(shin=.88, sho=.12, hip=.04, waist=1.18, limb=1.08, head=-.13, pd=1.15, thigh=1.16), 777- "lancer": dict(shin=1.1, sho=.02, hip=-.02, waist=.9, limb=.9, head=0.0, pd=1.15, thigh=.92)} 778- 779- 780-def _tree(o): NotoMono-Regular.ttf NotoSansMono-Bold.ttf NotoSansMono-Regular.ttf /opt/node/bin/node def merge(*bms): def transform(bm, m):exec_commandmkdir -p review/out/core-study tools/studies
command
mkdir -p review/out/core-study tools/studies cat > tools/studies/core.py <<'PY' """Exploded light cockpit study. Run from the project root with Blender in background mode.""" import argparse import math import sys from pathlib import Path import bmesh import bpy from bpy_extras.object_utils import world_to_camera_view from mathutils import Vector ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT / "kit")) import figure from lib import solid, transform parser = argparse.ArgumentParser() parser.add_argument("output", type=Path) parser.add_argument("--preview", action="store_true") args = parser.parse_args(sys.argv[sys.argv.index("--") + 1:]) bpy.ops.wm.read_factory_settings(use_empty=True) scene = bpy.context.scene def load(name): bpy.ops.import_scene.gltf(filepath=str(ROOT / "public/assets" / f"{name}.glb")) return next(o for o in bpy.context.selected_objects if o.parent is None) def linear(hex_value): def channel(pair): s = int(pair, 16) / 255 return s / 12.92 if s <= .04045 else ((s + .055) / 1.055) ** 2.4 return tuple(channel(hex_value[i:i+2]) for i in (0, 2, 4)) + (1,) def paint(name, color, metal=.15, rough=.36): mat = bpy.data.materials.new(name) mat.use_nodes = True bsdf = mat.node_tree.nodes.get("Principled BSDF") bsdf.inputs["Base Color"].default_value = linear(color) bsdf.inputs["Metallic"].default_value = metal bsdf.inputs["Roughness"].default_value = rough return mat # A study palette. Ochre singles out the pilot across the cabin's many material roles. finish = { "main": ("dadfdc", .25), "accent": ("4b636c", .42), "trim": ("ae5832", .38), "frame": ("43545a", .5), "joint": ("303b40", .45), "metal": ("829196", .8), "hull": ("abc2be", .35), "sensor": ("13434b", .25), "visor": ("16292c", .55), "glow_eye": ("85e6dc", .15), "glow_thruster": ("42666e", .25), "suit": ("335059", .15), "lamp_green": ("54bda1", .2), "interior": ("617279", .35), "screen": ("375e65", .3), "light": ("d9efe1", .2), } colors = {k: paint(k + " finish", *spec) for k, spec in finish.items()} pilot_colors = {k: paint("suit " + k, v) for k, v in { "main": "ee9545", "accent": "975337", "suit": "715144", "trim": "f1c78c", }.items()} frame = load("light") outer = bpy.data.objects["core"] cockpit_mount = bpy.data.objects["cockpit"].matrix_world.translation.copy() eye = cockpit_mount + Vector((0, 0, .30)) cabin = load("cockpit_light") # The overlay cockpit faces +Y. Turn it to the light frame's -Y and register its eye. cabin.rotation_euler.z = math.pi # The game omits the helmet for its first-person camera. Use the kit's matching bike pose. helmet_offset = figure.place(turn=180) helmet_offset.translation = -figure.points("bike", turn=180)["eye"] for _, role, mesh in figure.helmet("trim"): transform(mesh, helmet_offset @ figure.rig("bike")["head"]) solid("pilot_helmet_" + role, mesh, role, smooth=True, panels=False).parent = cabin # Reveal the rider by sectioning the imported liner down its side. Keep the rider, # seat, sticks and foot pegs intact. Thin cut edges retain the liner's thickness. cut_items = ("wall", "roof", "hatch", "band_", "floor", "console", "bolster", "hood", "back_wall", "knee_well", "screen", "strip") for obj in cabin.children_recursive: if obj.type != "MESH" or not obj.name.startswith(cut_items): continue mesh = bmesh.new() mesh.from_mesh(obj.data) # Cabin coordinates before placement. Its -X side faces the camera. mesh.transform(obj.matrix_local) bmesh.ops.bisect_plane(mesh, geom=[*mesh.verts, *mesh.edges, *mesh.faces], plane_co=(-.09, 0, 0), plane_no=(1, 0, 0), clear_inner=True) mesh.transform(obj.matrix_local.inverted()) mesh.to_mesh(obj.data) mesh.free() cabin.location = eye + Vector((0, 2.15, .10)) outer.location.y += 4.2 outer.location.z += .20 # Pose the existing rig just enough to separate the hands from the waist in profile. def pose(name, pitch=0, roll=0, yaw=0): obj = bpy.data.objects[name] obj.rotation_mode = "XYZ" obj.rotation_euler = [math.radians(a) for a in (pitch, roll, yaw)] pose("forearm.L", -32) pose("upperarm.L", -12, -5) pose("forearm.R", -24) pose("upperarm.R", 13, 5) pose("head", -3, 2, 20) pose("thigh.L", -10) pose("shin.L", 19) pose("thigh.R", 13) for obj in scene.objects: if obj.type != "MESH": continue for slot in obj.material_slots: role = slot.material.name.split(".")[0] palette = pilot_colors if obj.name.startswith("pilot_") else {} slot.material = palette.get(role) or colors.get(role, colors["frame"]) def area(name, location, target, power, size, tint): light = bpy.data.lights.new(name, "AREA") light.energy, light.shape, light.size, light.color = power, "DISK", size, tint lamp = bpy.data.objects.new(name, light) scene.collection.objects.link(lamp) lamp.location = location lamp.rotation_euler = (Vector(target) - lamp.location).to_track_quat("-Z", "Y").to_euler() area("Softbox", (4, -4, 11), (0, 1, 4), 1150, 6, (1, .94, .84)) area("Edge", (-4, 4, 9), (0, 2, 4), 1900, 5, (.81, .91, 1)) area("Fill", (3, 8, 6), (0, 4, 4), 480, 5, (.92, .97, 1)) scene.world = bpy.data.worlds.new("Studio") scene.world.use_nodes = True scene.world.node_tree.nodes["Background"].inputs["Color"].default_value = (.65, .73, .77, 1) scene.world.node_tree.nodes["Background"].inputs["Strength"].default_value = .48 camera = bpy.data.objects.new("Study camera", bpy.data.cameras.new("Study")) scene.collection.objects.link(camera) target = Vector((0, 2.38, 4.37)) direction = Vector((10, -4.1, 2.8)) camera.location = target + direction camera.rotation_euler = (-direction).to_track_quat("-Z", "Y").to_euler() camera.data.type, camera.data.ortho_scale = "ORTHO", 8.2 scene.camera = camera scene.render.engine = "CYCLES" scene.cycles.samples = 4 if args.preview else 48 scene.cycles.use_denoising = True scene.render.resolution_x, scene.render.resolution_y = 2000, 1080 scene.render.resolution_percentage = 40 if args.preview else 100 scene.render.film_transparent = True scene.render.image_settings.color_mode = "RGBA" scene.view_settings.view_transform = "AgX" scene.render.filepath = str(args.output.resolve()) bpy.context.view_layer.update() bpy.ops.render.render(write_still=True) PY ~/.local/bin/blender -b -t 8 --python-exit-code 1 -P tools/studies/core.py -- review/out/core-study/preview.png --preview > review/out/core-study/render.log 2>&1result, 4 lines
Script completed Wall time 0.4 seconds Output: {"chunk_id":"a0b035","wall_time_seconds":0.251269152,"session_id":29521,"original_token_count":0,"output":""}exec_commandtail -18 review/out/core-study/render.log && ls -l review/out/core-study && head -34 kit/lib.py && command -v fonttools
command
tail -18 review/out/core-study/render.log && ls -l review/out/core-study && head -34 kit/lib.py && command -v fonttools
result, 36 lines
Script completed Wall time 0.0 seconds Output: Warning: truncated output (original token count: 780) Total output lines: 55 22:47:37 | INFO: Blender create Mesh node grip_button.R 22:47:37 | INFO: Blender create Mesh node grip_cap.R.001 22:47:37 | INFO: Blender create Mesh node grip_handle.R 22:47:37 | INFO: Blender create Mesh node pilot_hand_R_main 22:47:37 | INFO: Blender create Mesh node pilot_hand_R_suit 22:47:37 | INFO: Blender create Mesh node strip_frame.001 22:47:37 | INFO: Blender create Mesh node strip_lamps 22:47:37 | INFO: Blender create Mesh node wall.L.001 22:47:37 | INFO: Blender create Mesh node wall.R.001 22:47:37 | INFO: Blender create Mesh node wall_rail.L.001 22:47:37 | INFO: Blender create Mesh node wall_rail.R.001 22:47:38 | INFO: glTF import finished in 0.29s ~/work/sortie/tools/studies/core.py:132: DeprecationWarning: 'World.use_nodes' is expected to be removed in Blender 6.0 scene.world.use_nodes = True 00:04.213 render | Saved: '~/work/sortie/review/out/core-study/preview.png' Blender 5.2.3 LTS (hash e13b728c6880 built 2026-10-22 01:35:05) Blend…280 tokens truncated….3, 1.0, 0.9), "glow_core": (0.3, 1.0, 0.9), "glow_thruster": (0.6, 0.78, 1.0), "glow_exhaust": (0.31, 0.56, 1.0), "metal": (0.55, 0.57, 0.6), "hull": (0.72, 0.73, 0.75), "hull_dark": (0.32, 0.33, 0.36), "deck": (0.25, 0.26, 0.28), "hazard": (0.9, 0.75, 0.1), "light": (1.0, 0.97, 0.9), "screen": (0.2, 0.8, 0.75), "glass": (0.1, 0.2, 0.25), "lamp_red": (1.0, 0.2, 0.15), "lamp_green": (0.3, 1.0, 0.4), "suit": (0.14, 0.19, 0.36), "glow_hot": (0.92, 1.0, 0.98), # raider salvage (palette.ts): donor paint, primer, rust, hand paint "donor_a": (0.78, 0.76, 0.72), "donor_b": (0.24, 0.34, 0.43), "donor_c": (0.36, 0.38, 0.26), "primer": (0.54, 0.55, 0.52), "rust": (0.42, 0.23, 0.13), "handpaint": (0.93, 0.89, 0.8), "warpaint": (0.76, 0.23, 0.15), # markings: pattern codes, service text, unit codes (a decal layer in geometry) "stencil": (0.13, 0.14, 0.16), "crystal": (0.8, 0.81, 0.84), "crystal_lit": (0.55, 0.45, 0.78), "glow_violet": (0.66, 0.48, 1.0),exec_command, view_imageconvert review/out/core-study/preview.png -background '#efeeea' -alpha remove review/out/core-study/on-paper.jpg (+1 more)
input
text(await tools.exec_command({cmd:"convert review/out/core-study/preview.png -background '#efeeea' -alpha remove review/out/core-study/on-paper.jpg"})); image((await tools.view_image({path:"~/work/sortie/review/out/core-study/on-paper.jpg"})).image_url)result, 4 lines
Script completed Wall time 0.1 seconds Output: {"chunk_id":"862f8f","wall_time_seconds":0.000003471,"exit_code":0,"original_token_count":0,"output":""}exec_commandsed -n '424,474p' kit/lib.py && ls -lh public/assets/light.glb && rg 'cockpit|frame$' review/out/core-study/render.log | head -15 && ls /usr/share/fonts/truetype
command
sed -n '424,474p' kit/lib.py && ls -lh public/assets/light.glb && rg 'cockpit|frame$' review/out/core-study/render.log | head -15 && ls /usr/share/fonts/truetype
result, 23 lines
Script completed Wall time 0.0 seconds Output: """Horizontal vent slats on a plane facing -Y at depth y.""" out = [] h = (z1 - z0) / n for i in range(n): zb = z0 + i * h out.append(prism([(x0, zb), (x1, zb), (x1, zb + h * (1 - gap)), (x0, zb + h * (1 - gap))], y - depth, y + 0.05, "xz")) return merge(*out) def export(path, extras=True): bpy.ops.export_scene.gltf(filepath=path, export_format="GLB", export_apply=True, export_yup=True, export_extras=extras, export_cameras=False, export_lights=False, export_materials="EXPORT", export_normals=True, export_texcoords=False) -rw------- 1 runner runner 1.6M Nov 17 22:43 public/assets/light.glb dejavu droid noto ubuntuexec_command, view_imagepython - <<'PY' (+1 more)
input
text(await tools.exec_command({cmd:`python - <<'PY' from pathlib import Path p=Path('tools/studies/core.py') s=p.read_text().replace('cabin.rotation_euler.z = math.pi','cabin.rotation_mode = "XYZ"\\ncabin.rotation_euler.z = math.pi').replace('Vector((0, 2.38, 4.37))','Vector((0, 2.76, 4.87))').replace('"ORTHO", 8.2','"ORTHO", 9.0') p.write_text(s) PY ~/.local/bin/blender -b -t 8 --python-exit-code 1 -P tools/studies/core.py -- review/out/core-study/preview.png --preview > review/out/core-study/render.log 2>&1 && convert review/out/core-study/preview.png -background '#efeeea' -alpha remove review/out/core-study/on-paper.jpg` }));image((await tools.view_image({path:"~/work/sortie/review/out/core-study/on-paper.jpg"})).image_url)result, 4 lines
Script completed Wall time 4.4 seconds Output: {"chunk_id":"d87ca2","wall_time_seconds":4.241190752,"exit_code":0,"original_token_count":0,"output":""}

