Paladin (sheet 27), third pass: the limbs, pelvis, abdomen and pauldrons rebuilt as hard plates authored by their faces

The second pass's limb plates were free-cage shells 0.015 m thick lifted from traces: they read thin, sparse, and their fit moved nothing. They are deleted (paladin_limbs.py, platecage.py, plate_probe.py). Every plate is now called hard (paladin_form.KINDS) and written as a slab (an outline on its outer face, a thickness, a chamfer) or a housing of chamfered sections, the way nibu/fable-bastion-2 writes its hull: 108 convex solids 0.1 to 0.34 m thick (massing.hard), no shell and no folded face, with 99 stepped and bolted panels and 122 fits (slots, vents, ports, handles, lifting eyes) on top. The numbers are read off the sheet by hand under a grid and paladin_form says so, with the three places the views disagree; nothing is called a fit. The second pass's traces are kept only to score the plates (paladin_plates.png).

Legs: thigh 1.7 m wide by 2.0 deep, shin 1.6 by 2.2, each a dark core open to the rear under stepped shields; a kit ram across the back of each knee (mechlib.joint_ram, its pin recorded), bearing covers at knee and ankle, calf struts, feet 2.0 by 2.6.
Pelvis from its inset: crown block, wings, codpiece with step and lame, seat plates, ribbed hip drums. Abdomen: a ribbed column, pods with ports, a keel plate. 22 hoses at the waist, hips, knees, ankles and elbows (paladin_hard.hose).
Hull and turret kept from the first pass, with detail panels clipped to each plate (paladin_hard.clad_mass over paladin_body.torso_specs).
Left hand: handkit.hand on a new kit part, palm: fifteen pins with joint records (wrist, 12 finger joints, 2 thumb joints). 52 joint rows, none without limits.
Cameras: the sheet's horizon held (paladin_form.HORIZON, v 393 of 510): the hero camera's horizon at 77% of the frame as the sheet's, eye 1.86 m, lens 172 mm (band 85 to 1041), rms 11.1 px.
Marks: every numeral and triangle through surface.py (a "triangle" emblem added); paint.py and surface.py from nibu/fable-paint-2 (d1179a2), paint.apply("paladin") with a lighter grey khaki.
massing: plane_basis, slab_points, section_points (and hard, panel, clad, Face from nibu/fable-bastion-2).
Close-ups: azimuths corrected (positive is the mech's left), every one frames its part; abdomen and rear shin added. Sheets: the second pass added to paladin_before_after.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-12-03 12:20:27 +01:00
commit c35e57ee5a
14 changed files with 1860 additions and 1311 deletions

View file

@ -464,6 +464,23 @@ parts.append({
S("top", "mount", "waist_r", [0, "sy", "sz+0.35*depth"], "+z", "+y")]}) S("top", "mount", "waist_r", [0, "sy", "sz+0.35*depth"], "+z", "+y")]})
talon = next(p for p in parts if p["name"] == "talon") talon = next(p for p in parts if p["name"] == "talon")
# --- a hand whose every knuckle is a pin (handkit.py): a palm with four finger clevises and a thumb clevis
parts.append({
"name": "palm", "doc": "The palm of a pinned hand (handkit.py), z down the hand: a tongue on the wrist's pin (x) at z=0, a slab to z=drop, +y its back and -y its face; under its end four finger clevises abreast on pins along x (finger_a..finger_d: pivots, the roll is the finger's curl) and on its +x edge a thumb clevis on a pin along y (thumb: a pivot). Fingers are the kit's link and toe parts.",
"params": [P("width", 0.08, 2.0, 0.5), P("drop", 0.08, 2.0, 0.4), P("depth", 0.03, 1.0, 0.16), P("pin_r", 0.008, 0.2, 0.04, "the wrist pin"), P("finger_pin_r", 0.006, 0.1, 0.02)],
"bevel": "0.03*depth",
"shapes": [
xtube("1.6*pin_r", "0.6*width", "-0.3*width", 0, 0, 32),
box(["0.6*width", "min(depth,3.2*pin_r)", "0.3*drop"], [0, 0, "0.15*drop"]),
box(["width", "depth", "0.72*drop-1.9*finger_pin_r"], [0, 0, "0.28*drop+0.5*(0.72*drop-1.9*finger_pin_r)"]),
xtube("1.9*finger_pin_r", "width", "-0.5*width", 0, "drop", 16),
ytube("1.9*finger_pin_r", "0.8*depth", "0.5*width+1.9*finger_pin_r", "-0.4*depth", "0.5*drop", 16),
],
"sockets": [S("tongue", "pivot", "2*pin_r", [0, 0, 0], "+x", "+z")]
+ [S(f"finger_{k}", "pivot", "2*finger_pin_r", [f"{x}*width", 0, "drop"], "-x", "+z") for k, x in zip("abcd", (-0.375, -0.125, 0.125, 0.375))]
+ [S("thumb", "pivot", "2*finger_pin_r", ["0.5*width+1.9*finger_pin_r", 0, "0.5*drop"], "-y", "+x"),
S("back", "mount", "0.6*width", [0, "0.5*depth", "0.6*drop"], "+y", "+z"), S("face", "mount", "0.6*width", [0, "-0.5*depth", "0.6*drop"], "-y", "+z")]})
trident = json.loads(json.dumps(talon)) trident = json.loads(json.dumps(talon))
trident["name"], trident["doc"] = "trident", "A three-toed foot on an ankle pin (x) at z=0: the talon with a middle toe and a short heel." trident["name"], trident["doc"] = "trident", "A three-toed foot on an ankle pin (x) at z=0: the talon with a middle toe and a short heel."
trident["shapes"] += [box(["0.26*width", "0.62*length", "0.46*drop"], [0, "0.5*length", "0.77*drop"]), box(["0.2*width", "0.2*length", "0.3*drop"], [0, "0.88*length", "0.85*drop"])] trident["shapes"] += [box(["0.26*width", "0.62*length", "0.46*drop"], [0, "0.5*length", "0.77*drop"]), box(["0.2*width", "0.2*length", "0.3*drop"], [0, "0.88*length", "0.85*drop"])]

View file

@ -0,0 +1,100 @@
"""A hand whose every knuckle is a kit pin with a joint record. Runs inside Blender beside mechlib and bipedkit.
hands.py draws a hand as jointlib geometry: it closes by a curl, but brokkr_kitbash.joints reports none of it. Here
the palm is a kit part (gen_kit.py: palm, a tongue on the wrist's pin, four finger clevises and a thumb clevis) and
every phalanx a kit link (the last a toe) on a pivot, each with limits, so the report carries the wrist, twelve finger
joints and two thumb joints, and brokkr_kitbash.roll closes a finger inside its limits.
Ruling aetheria-release:ruling:mech-joints-match-concept-mechanically.
hand(name, forearm, ...) -> {"palm", "fingers" [[seg, seg, seg] * 4], "thumb" [seg, seg], "face" (world, where the
palm's face looks), "objects" (the armour plates, each parented to its segment)}
"""
import math
from mathutils import Matrix, Vector
import bipedkit as BK
import mechlib as M
T = Matrix.Translation
def _aim(seg, direction):
M.aim_roll(seg, (0, 0, 1), Vector(direction))
M.update()
def hand(name, forearm, socket="clevis", width=0.72, drop=0.5, depth=0.24, pin_r=0.09, finger=(0.34, 0.26, 0.2), finger_w=0.15, curl=(18.0, 24.0, 20.0), wrist=0.0,
thumb=(0.3, 0.24), thumb_out=40.0, plate="khaki", plate2="olive_light"):
"""LEFT FOREARM - MANIPULATOR & ENERGY inset (PALADIN, 27.webp): a broad armoured palm under the forearm's end,
four fingers of three phalanges, a thumb of two on the inboard edge. `curl` is each phalanx's bend as it stands,
`wrist` the palm's swing forward. The palm's face is its side to the mech's rear, as a hanging hand's is."""
fp = 0.42 * pin_r
palm = M.place("palm", f"{name}.Palm", mat="gunmetal", width=width, drop=drop, depth=depth, pin_r=pin_r, finger_pin_r=fp)
M.attach(palm, "tongue", forearm, socket, 0.0)
M.update()
along = (forearm.matrix_world.to_3x3() @ Vector((0, 0, 1))).normalized() # a kit link runs along its own +z
fore = Vector((0, 1, 0)) - along * along.y
fore.normalize()
_aim(palm, along * math.cos(math.radians(wrist)) + fore * math.sin(math.radians(wrist)))
BK.record(palm, "wrist_pitch", -40, 40, toward=fore)
R = palm.matrix_world.to_3x3()
down, face = (R @ Vector((0, 0, 1))).normalized(), (R @ Vector((0, -1, 0))).normalized()
if face.y > 0: # the palm's face is whichever of its broad sides looks to the mech's rear
face = -face
side = (R @ Vector((1, 0, 0))).normalized()
fingers, objects = [], []
def armour(seg, length, w, d, last=False):
"""A plate on the segment's back (the side away from the palm's face), a knuckle cap over its pin."""
back = -1.0 if (seg.matrix_world.to_3x3() @ Vector((0, 1, 0))).dot(face) > 0 else 1.0
g = M.Geo()
g.prism(M.frame_at((0, back * (0.5 * d + 0.004), 0.52 * length), (0, back, 0), (0, 0, 1)), M.rect(1.08 * w, 0.74 * length, 0.18 * w), 0.05, 0.02)
g.prism(M.frame_at((0, back * (0.5 * d + 0.03), 0.02), (0, back, 0.5), (0, 0, 1)), M.rect(1.12 * w, 0.4 * w + 0.2 * length, 0.2 * w), 0.045, 0.018)
if last:
g.prism(M.frame_at((0, 0, 0.98 * length), (0, 0, 1), (0, 1, 0)), M.rect(0.9 * w, 0.8 * d, 0.2 * w), 0.05, 0.03)
o = g.to_object(seg.name + ".plate", plate, seg, 1.0)
for p in o.data.polygons:
p.use_smooth = False
objects.append(o)
for k, key in enumerate("abcd"):
parent, sock, bend, segs = palm, f"finger_{key}", 0.0, []
w = finger_w * (0.94 if k in (0, 3) else 1.0)
for j, length in enumerate(finger):
length = length * (0.9 if k == 3 else 1.0)
seg = M.place("toe" if j == len(finger) - 1 else "link", f"{name}.F{k}.{j}", mat="gunmetal", length=length, width=w, depth=0.9 * w, pin_r=fp)
M.attach(seg, "tongue", parent, sock, 0.0)
bend += curl[j]
a = math.radians(bend)
_aim(seg, down * math.cos(a) + face * math.sin(a))
BK.record(seg, "finger_curl", -curl[j] - 4.0, 92.0 - curl[j], toward=face)
armour(seg, length, w, 0.9 * w, last=j == len(finger) - 1)
segs.append(seg)
parent, sock = seg, "clevis"
fingers.append(segs)
segs, parent, sock, lean = [], palm, "thumb", thumb_out
for j, length in enumerate(thumb):
seg = M.place("toe" if j == len(thumb) - 1 else "link", f"{name}.Thumb.{j}", mat="gunmetal", length=length, width=1.1 * finger_w, depth=finger_w, pin_r=fp)
M.attach(seg, "tongue", parent, sock, 0.0)
a = math.radians(lean)
_aim(seg, down * math.cos(a) + side * math.sin(a))
BK.record(seg, "thumb_swing" if j == 0 else "thumb_curl", -lean - 5.0 if j == 0 else -20.0, 50.0 if j == 0 else 60.0, toward=-side if j == 0 else face)
armour(seg, length, 1.1 * finger_w, finger_w, last=j == len(thumb) - 1)
segs.append(seg)
parent, sock, lean = seg, "clevis", lean - 25.0
g = M.Geo() # the palm's back plate and its knuckle guard
g.prism(M.frame_at((0, 0.5 * depth + 0.004, 0.52 * drop), (0, 1, 0), (0, 0, 1)), M.rect(1.06 * width, 0.8 * drop, 0.12 * width), 0.07, 0.03)
g.prism(M.frame_at((0, 0.5 * depth + 0.03, 0.96 * drop), (0, 1, -0.45), (0, 0, 1)), M.rect(1.1 * width, 0.3 * drop, 0.06 * width), 0.06, 0.025)
back = g.to_object(f"{name}.Palm.plate", plate, palm, 1.0)
g = M.Geo()
g.prism(M.frame_at((0, 0.5 * depth + 0.07, 0.5 * drop), (0, 1, 0), (0, 0, 1)), M.rect(0.62 * width, 0.42 * drop, 0.08 * width), 0.04, 0.015)
step = g.to_object(f"{name}.Palm.step", plate2, palm, 1.0)
for o in (back, step):
if face.dot(palm.matrix_world.to_3x3() @ Vector((0, 1, 0))) > 0: # the plate on the back, whichever way the palm was turned
o.matrix_basis = Matrix.Diagonal((1.0, -1.0, 1.0, 1.0))
for p in o.data.polygons:
p.use_smooth = False
objects.append(o)
M.update()
return {"palm": palm, "fingers": fingers, "thumb": segs, "face": face, "objects": objects}

View file

@ -8,6 +8,10 @@ a wall, so plates conform to the mass by construction and step from their neighb
Tools here (seraph_body uses each more than once): Tools here (seraph_body uses each more than once):
solid(name, points, faces, frame, ...) a closed cage, subdivided: the mass. Its mesh is in its own frame. solid(name, points, faces, frame, ...) a closed cage, subdivided: the mass. Its mesh is in its own frame.
cage(name, sheet, frame, ...) the same from a free-cage sheet as brokkr_kitbash.shell takes one (verts,
faces, creases, mirror): a closed, creased, minimal cage made a mass.
cage_sheet(sheet) is that sheet wound and with its poles declared, and
cage_report(sheet) what the shell action reports of it.
ellipsoid / slab cutters (hidden objects) in a mass's frame ellipsoid / slab cutters (hidden objects) in a mass's frame
carve(obj, cutters) wells: an exact Boolean difference, applied carve(obj, cutters) wells: an exact Boolean difference, applied
plate(name, mass, keep, ...) the mass's surface lifted `proud`, kept inside the half-spaces `keep` plate(name, mass, keep, ...) the mass's surface lifted `proud`, kept inside the half-spaces `keep`
@ -16,6 +20,23 @@ Tools here (seraph_body uses each more than once):
Curtain(cam, line, frame) a line traced on the concept as a cut: the solved camera's sight lines Curtain(cam, line, frame) a line traced on the concept as a cut: the solved camera's sight lines
along it, so the plate's edge is drawn exactly on the line along it, so the plate's edge is drawn exactly on the line
half(axis, sign, at) a half-space by axis: half("x", -1, 0.3) keeps x >= 0.3 half(axis, sign, at) a half-space by axis: half("x", -1, 0.3) keeps x >= 0.3
Hard plates (a plate whose silhouette the concept draws faceted: mech-lessons-2026-12-03; bastion_body uses each):
plane(point, normal) / through(a, b, c, out) a face as a half-space (n, d): kept where n.p <= d
corners(planes) the corners of the convex solid a set of faces bounds: every three
faces' meeting point that lies inside all the others. Authoring a
plate by its faces is what keeps every facet flat.
slab_points(at, normal, outline, thick) a hard plate as a thick slab: an outline drawn on its outer face (the
plane through `at` facing `normal`), the face's rim chamfered by `taper`
section_points(sections) a housing's corners from chamfered sections down a limb
hard(name, points, host, ...) a faceted solid on those corners (or any points): flat faces, every
edge chamfered by a bevel; obj["plate_kind"] = "hard"
panel(geo, polygon, ...) a raised inner panel on a flat polygon: inset, lifted, chamfered
clad(obj, geo, ...) detail plating after the main split: every large facet of a hard solid
gets its own raised panel, split in two at varied depths
Face(obj) a flat facet standing in for a surface.Skin, so surface.py's numerals,
emblems, bolt rows and handles land on a hard plate
""" """
import math import math
@ -62,6 +83,142 @@ def solid(name, points, faces, frame, mat="khaki", levels=1, flat=True):
return obj return obj
def _cage_bmesh(sheet):
"""(bmesh, crease layer) of a free-cage sheet, mirrored about x where it says so, its faces wound outward."""
V = [Vector(p) for p in sheet["verts"]]
faces = [list(f) for f in sheet["faces"]]
creases = [tuple(c) for c in sheet.get("creases", ())]
if sheet.get("mirror"):
tol = 0.005 * max(abs(p.x) for p in V)
twin = {}
for i, p in enumerate(list(V)):
if abs(p.x) <= tol:
V[i] = Vector((0.0, p.y, p.z))
twin[i] = i
else:
twin[i] = len(V)
V.append(Vector((-p.x, p.y, p.z)))
faces += [[twin[i] for i in reversed(f)] for f in faces]
creases += [(twin[a], twin[b], w) for a, b, w in creases if (twin[a], twin[b]) != (a, b)]
bm = bmesh.new()
verts = [bm.verts.new(p) for p in V]
for f in faces:
bm.faces.new([verts[i] for i in f])
bmesh.ops.recalc_face_normals(bm, faces=bm.faces[:])
layer = bm.edges.layers.float.new("crease_edge")
bm.verts.ensure_lookup_table()
for a, b, w in creases:
e = bm.edges.get((bm.verts[a], bm.verts[b]))
if e is None:
raise ValueError(f"cage: a crease on no edge ({a}, {b})")
e[layer] = w
return bm, layer
def cage_sheet(sheet, inside=None):
"""The sheet as brokkr_kitbash.shell takes it: every authored face wound counter-clockwise seen from outside (read
off the cage's recalculated normals; an open cage says where `inside` is, a point its faces look away from) and
its poles declared (the authored vertices whose valence is not 4 off the boundary, not 2 or 3 on it)."""
bm, _ = _cage_bmesh(sheet)
n = len(sheet["verts"])
out = dict(sheet)
if inside is not None and sum(f.normal.dot(f.calc_center_median() - Vector(inside)) * f.calc_area() for f in bm.faces) < 0:
bmesh.ops.reverse_faces(bm, faces=bm.faces[:])
out["faces"] = [[v.index for v in f.verts] for f in bm.faces[:len(sheet["faces"])]]
bm.verts.ensure_lookup_table()
out["poles"] = [i for i in range(n) if len(bm.verts[i].link_edges) not in ((2, 3) if bm.verts[i].is_boundary else (4,))]
bm.free()
return out
def cage_stats(sheet):
"""{"verts" (authored), "all_verts" (mirrored), "edges", "creased", "crease_share", "poles" {valence: count},
"triangles"} of the cage as built."""
bm, layer = _cage_bmesh(sheet)
poles = {}
for v in bm.verts:
if len(v.link_edges) != 4:
poles[len(v.link_edges)] = poles.get(len(v.link_edges), 0) + 1
out = {"verts": len(sheet["verts"]), "all_verts": len(bm.verts), "faces": len(bm.faces), "edges": len(bm.edges), "creased": sum(1 for e in bm.edges if e[layer] > 0),
"poles": poles, "triangles": sum(1 for f in bm.faces if len(f.verts) == 3), "closed": all(e.is_manifold for e in bm.edges)}
out["crease_share"] = out["creased"] / out["edges"]
bm.free()
return out
def cage(name, sheet, frame, mat="khaki", levels=3, flat=True):
"""A free cage made a mass: Catmull-Clark `levels` times with its creases, applied. Closed where the cage is."""
bm, _ = _cage_bmesh(sheet)
obj = _object(name, bm, mat, frame)
mod = obj.modifiers.new("Subdivision", "SUBSURF")
mod.levels = mod.render_levels = levels
mod.use_creases = True
M.bake(obj)
for p in obj.data.polygons:
p.use_smooth = not flat
return obj
def cage_through(sheet, levels=3, rounds=5):
"""The sheet with its vertices moved until the subdivided surface passes through the points it was authored at:
a Catmull-Clark surface lies inside its cage, by a tenth of its size on a cage this coarse, so a cage authored
on the concept's outline builds a mass a tenth too small. Each round moves every vertex by what its surface
point misses (a subdivided mesh keeps the cage's vertices first, in order)."""
want = [Vector(p) for p in sheet["verts"]]
out = dict(sheet, verts=[list(p) for p in sheet["verts"]])
for _ in range(rounds):
obj = cage("Cage.through", out, Matrix.Identity(4), levels=levels)
got = [obj.data.vertices[i].co.copy() for i in range(len(want))]
bpy.data.objects.remove(obj, do_unlink=True)
out["verts"] = [list(Vector(p) + (w - g)) for p, w, g in zip(out["verts"], want, got)]
if sheet.get("mirror"):
out["verts"] = [[0.0 if abs(w.x) < 1e-6 else p[0], p[1], p[2]] for p, w in zip(out["verts"], want)]
return out
def cage_shell(name, sheet, host=None, to_host=None, mat="khaki", thickness=0.1, levels=2, bevel=0.02, inside=(0, 0, 0)):
"""A sculpted plate as a minimal free cage, by brokkr_kitbash.shell: the sheet in its own frame, the object
parented to `host` at `to_host`. Prints the cage's count (CAGE). Returns the object."""
import json
result = bpy.ops.brokkr_kitbash.shell(object_name=name, sheet=json.dumps(cage_sheet(sheet, inside)), thickness=thickness, levels=levels, bevel=bevel, count_folds=True)
if "FINISHED" not in result:
raise SystemExit(f"cage_shell {name}: {result}")
report = json.loads(getattr(bpy.context.window_manager, M.KB.RESULT))
stats = cage_stats_open(sheet)
print("CAGE", name, json.dumps({"authored": len(sheet["verts"]), "cageVerts": report["cageVerts"], "cageFaces": report["cageFaces"], "creases": report["creases"], "crease_share": round(stats, 3),
"poles": report["poles"], "folded": report["folded"]}), flush=True)
obj = bpy.data.objects[name]
if host is not None:
obj.parent = host
obj.matrix_parent_inverse = Matrix.Identity(4)
obj.matrix_local = Matrix(to_host) if to_host is not None else Matrix.Identity(4)
M.assign(obj, mat)
for p in obj.data.polygons:
p.use_smooth = False
return obj
def cage_stats_open(sheet):
"""The share of the cage's edges that carry a crease (the rim's own weight not counted)."""
bm, layer = _cage_bmesh(sheet)
share = sum(1 for e in bm.edges if e[layer] > 0) / max(len(bm.edges), 1)
bm.free()
return share
def cage_report(sheet, thickness=0.05, levels=2):
"""What brokkr_kitbash.shell reports of the cage (it refuses an unsound one, naming the fault): the action's own
count of vertices, faces, creases and poles. The shell it makes is removed."""
import json
name = "Cage.report"
result = bpy.ops.brokkr_kitbash.shell(object_name=name, sheet=json.dumps(cage_sheet(sheet)), thickness=thickness, levels=levels)
if "FINISHED" not in result:
raise SystemExit(f"cage_report: {result}")
report = json.loads(getattr(bpy.context.window_manager, M.KB.RESULT))
bpy.data.objects.remove(bpy.data.objects[name], do_unlink=True)
return {key: report.get(key) for key in ("cageVerts", "cageFaces", "triangles", "creases", "poles", "closed", "subdividedFaces")}
def _cutter(name, bm, frame): def _cutter(name, bm, frame):
obj = _object(name, bm, "frame", frame) obj = _object(name, bm, "frame", frame)
obj.hide_render = obj.hide_viewport = True obj.hide_render = obj.hide_viewport = True
@ -212,3 +369,200 @@ def plate(name, mass, keep, proud=0.06, wall=0.08, mat="khaki", cutters=(), beve
lo, hi = (min(v.co[k] for v in obj.data.vertices) for k in range(3)), (max(v.co[k] for v in obj.data.vertices) for k in range(3)) lo, hi = (min(v.co[k] for v in obj.data.vertices) for k in range(3)), (max(v.co[k] for v in obj.data.vertices) for k in range(3))
print(f"PLATE {name}: {len(obj.data.polygons)} faces, " + " ".join(f"{a:.2f}..{b:.2f}" for a, b in zip(lo, hi)), flush=True) print(f"PLATE {name}: {len(obj.data.polygons)} faces, " + " ".join(f"{a:.2f}..{b:.2f}" for a, b in zip(lo, hi)), flush=True)
return obj return obj
# --- hard plates ---------------------------------------------------------------------------------------------------------
def plane(point, normal):
"""A face through `point` whose outward normal is `normal`: (n, d), kept where n.p <= d."""
n = Vector(normal).normalized()
return (n, n.dot(Vector(point)))
def through(a, b, c, out):
"""The face through three points, its outward side the one `out` points to."""
a, b, c = Vector(a), Vector(b), Vector(c)
n = (b - a).cross(c - a).normalized()
if n.dot(Vector(out)) < 0:
n = -n
return (n, n.dot(a))
def moved(face, by):
"""A face moved `by` metres along its outward normal (negative: inward)."""
return (face[0], face[1] + by)
def corners(planes, tol=1e-6):
"""The corners of the convex solid bounded by `planes` [(n, d)]: each three faces' meeting point that is inside
every other face. An unbounded or empty set of faces is an error, not a guess."""
out = []
P = [(Vector(n), float(d)) for n, d in planes]
for i in range(len(P)):
for j in range(i + 1, len(P)):
for k in range(j + 1, len(P)):
m = Matrix((P[i][0], P[j][0], P[k][0]))
if abs(m.determinant()) < 1e-7:
continue
p = m.inverted() @ Vector((P[i][1], P[j][1], P[k][1]))
if p.length < 1e3 and all(n.dot(p) <= d + tol for n, d in P) and not any((p - q).length < 1e-5 for q in out):
out.append(p)
if len(out) < 4:
raise ValueError(f"massing.corners: {len(planes)} faces bound no solid ({len(out)} corners)")
return out
def plane_basis(normal, up=(0, 0, 1), right=None):
"""(a, b, n): unit axes of the plane facing `normal`: b the in-plane part of `up`, a across it, turned to the
side `right` points to where one is given (so an outline's +a is a named direction on either side of a mech)."""
n = Vector(normal).normalized()
b = Vector(up) - n * n.dot(Vector(up))
if b.length < 1e-6:
raise ValueError("massing.plane_basis: up lies along the normal")
b.normalize()
a = b.cross(n)
if right is not None and a.dot(Vector(right)) < 0:
a = -a
return a, b, n
def slab_points(at, normal, outline, thick, taper=0.04, up=(0, 0, 1), right=None, back=1.0):
"""The corners of a hard plate authored as a slab: `outline` [(a, b)] is its outer face, drawn on the plane
through `at` facing `normal` (plane_basis); the face's rim is chamfered `taper` wide and deep; the back face
stands `thick` behind, its outline scaled by `back` about the middle (under 1: a plate undercut to its seat)."""
a, b, n = plane_basis(normal, up, right)
at = Vector(at)
flat = [Vector((x, y)) for x, y in outline]
area = 0.5 * sum(flat[i].x * flat[(i + 1) % len(flat)].y - flat[(i + 1) % len(flat)].x * flat[i].y for i in range(len(flat)))
ring = flat if area > 0 else flat[::-1]
inner = M._inset(ring, taper) if taper else ring
out = [at + a * p.x + b * p.y for p in inner]
if taper:
out += [at + a * p.x + b * p.y - n * taper for p in ring]
out += [at + a * p.x * back + b * p.y * back - n * thick for p in ring]
return out
def ring8(w, y0, y1, c):
"""A chamfered rectangle's eight corners: w across x, from y0 to y1."""
return [(-w / 2 + c, y0), (w / 2 - c, y0), (w / 2, y0 + c), (w / 2, y1 - c), (w / 2 - c, y1), (-w / 2 + c, y1), (-w / 2, y1 - c), (-w / 2, y0 + c)]
def section_points(sections):
"""A housing's corners from its sections down a limb: [(z, width, y0, y1, chamfer)]."""
return [(x, y, z) for z, w, y0, y1, c in sections for x, y in ring8(w, y0, y1, c)]
def hard(name, points, host=None, mat="olive", mirror=False, bevel=0.03, sx=1):
"""A hard plate or block: the faceted convex solid on `points` (massing.corners of its faces, or corners given
outright), every facet flat, every edge chamfered `bevel` wide. `sx` -1 builds its mirror across x; `mirror`
one solid across the centre line from its right half."""
g = M.Geo()
g.hull([(sx * Vector(p).x, Vector(p).y, Vector(p).z) for p in points], mirror=mirror)
bmesh.ops.dissolve_limit(g.bm, angle_limit=math.radians(0.5), verts=g.bm.verts[:], edges=g.bm.edges[:])
obj = g.to_object(name, mat, host, 1.0)
if bevel:
mod = obj.modifiers.new("Bevel", "BEVEL")
mod.width, mod.segments, mod.limit_method, mod.angle_limit = bevel, 1, "ANGLE", math.radians(12)
for p in obj.data.polygons:
p.use_smooth = False
obj["plate_kind"] = "hard"
return obj
def _clip(poly, point, normal):
"""A convex polygon (3D points in one plane) kept on the side of a line the normal points away from."""
out = []
for i, a in enumerate(poly):
b = poly[(i + 1) % len(poly)]
da, db = (a - point).dot(normal), (b - point).dot(normal)
if da <= 0:
out.append(a)
if (da < 0) != (db < 0) and abs(da - db) > 1e-9:
out.append(a + (b - a) * (da / (da - db)))
return out
def panel(geo, polygon, lift=0.05, inset=0.1, chamfer=0.02, out=None, sink=0.02, bolts=None, bolt_r=0.028):
"""A raised inner panel on a flat convex polygon (3D points, either winding): the polygon moved in `inset` on
every edge, standing `lift` proud, its outer rim chamfered. `bolts` is a Geo that takes a hex head inside each
of the panel's corners. Returns its frame (z the outward normal), or None for a polygon too small to take one."""
P = [Vector(p) for p in polygon]
c = sum(P, Vector()) / len(P)
n = sum(((P[i] - c).cross(P[(i + 1) % len(P)] - c) for i in range(len(P))), Vector())
if n.length < 1e-9:
return None
n.normalize()
if out is not None and n.dot(Vector(out)) < 0:
P.reverse()
n = -n
frame = M.frame_at(c, n)
inv = frame.inverted()
flat = [(inv @ p).to_2d() for p in P]
inner = M._inset(flat, inset)
area = lambda q: 0.5 * sum(q[i].x * q[(i + 1) % len(q)].y - q[(i + 1) % len(q)].x * q[i].y for i in range(len(q))) # noqa: E731
if area(inner) < 0.25 * area(flat) or area(inner) < 0.02:
return None
geo.prism(frame @ Matrix.Translation((0, 0, -sink)), inner, lift + sink, chamfer)
if bolts is not None:
for q in M._inset(inner, 3.2 * bolt_r):
bolts.cylinder(frame @ Matrix.Translation((q.x, q.y, lift + 0.3 * bolt_r)), bolt_r, 0.6 * bolt_r, 6)
return frame
def facets(obj, min_area=0.6):
"""The flat facets of a hard solid's own mesh, in its frame: [(points, normal, area)], largest first."""
out = []
for p in obj.data.polygons:
if p.area >= min_area:
out.append(([obj.data.vertices[i].co.copy() for i in p.vertices], p.normal.copy(), p.area))
return sorted(out, key=lambda f: -f[2])
def clad(obj, geo, keep=None, min_area=0.9, lifts=(0.045, 0.075), inset=0.11, gap=0.05, split=2.2, seed=0, bolts=None):
"""Detail plating on a hard solid, after the main split: each facet of at least `min_area` (and passing
`keep(normal, centre)`) takes a raised panel; a facet over `split` square metres is cut in two across its
longest side at an uneven share, the two panels at different lifts. Geometry goes into `geo`, in the solid's
frame; `bolts` is a Geo for the panels' corner bolts. Returns the number of panels made."""
import random
rnd = random.Random(seed)
made = 0
for pts, n, area in facets(obj, min_area):
c = sum(pts, Vector()) / len(pts)
if keep and not keep(n, c):
continue
if area > split:
k = max(range(len(pts)), key=lambda i: (pts[(i + 1) % len(pts)] - pts[i]).length)
a, b = pts[k], pts[(k + 1) % len(pts)]
way = (b - a).normalized()
at = a + (b - a) * rnd.uniform(0.36, 0.64)
parts = [_clip(pts, at - way * gap / 2, way), _clip(pts, at + way * gap / 2, -way)]
else:
parts = [pts]
order = list(lifts) if rnd.random() < 0.5 else list(reversed(lifts))
for i, part in enumerate(parts):
if len(part) >= 3 and panel(geo, part, lift=order[i % len(order)], inset=inset, out=n, bolts=bolts) is not None:
made += 1
return made
class Face:
"""A hard plate's flat facet standing in for a surface.Skin: surface.py's numeral, emblem, bolt_row, rivet_row,
grab_handle and lifting_eye take it. Frames are in the plate object's own frame; done() makes the geometry."""
def __init__(self, obj, mat="olive"):
self.obj, self.name, self.mat = obj, obj.name, mat
self.geos, self.decals, self.count = {}, [], 0
def frame(self, point, normal, up=(0, 0, 1)):
return M.frame_at(point, normal, up)
def sub(self, frame, x, y, roll=0.0, z=0.0):
return frame @ Matrix.Translation((x, y, z)) @ Matrix.Rotation(math.radians(roll), 4, "Z")
def geo(self, mat=None):
return self.geos.setdefault(mat or self.mat, M.Geo())
def done(self, smooth=32.0):
made = [g.to_object(f"{self.name}.fit.{mat}", mat, self.obj, smooth) for mat, g in self.geos.items() if len(g.bm.verts)]
self.geos = {}
return made + self.decals

View file

@ -7,9 +7,10 @@ The hook, after a mech is built and before it is rendered:
import paint; paint.apply("seraph") import paint; paint.apply("seraph")
apply(preset, ground=0.0, objects=None, scale=1.0, **overrides) swaps, by material name, every armour paint for apply(preset, ground=0.0, objects=None, scale=1.0, roles=None, glass="smoked", lens="lens", **overrides) swaps, by material name, every armour paint for
the preset's paint, every bare-metal material for its metal, every marking for its worn stencil; it leaves glass, the preset's paint, every bare-metal material for its metal, every marking for its worn stencil, every glass for
rubber, glows and pits alone; called again with another preset it repaints. Returns {old material name: new material}. `ground` is the world height of the a MechGlass (glass="smoked" on panes, lens="lens" on optics under `lens_below` metres across); it leaves rubber,
glows and pits alone; called again with another preset it repaints. Returns {old material name: new material}. `ground` is the world height of the
soles (mud and wet are measured from it); `scale` multiplies every noise frequency (a mech half as tall wants 2). soles (mud and wet are measured from it); `scale` multiplies every noise frequency (a mech half as tall wants 2).
An override is any MechPaint input by its lower-case name with underscores, e.g. apply("mcr3", wear=1.4); it An override is any MechPaint input by its lower-case name with underscores, e.g. apply("mcr3", wear=1.4); it
reaches the armour and the markings, not the bare metal (material() tunes one role alone). reaches the armour and the markings, not the bare metal (material() tunes one role alone).
@ -18,11 +19,35 @@ PRESETS seraph (cleaner, warm drab: 30.webp), mcr3 (grey drab, middli
breaker (dark, heavy wear, mud to the knee: 24.webp), paladin (27.webp), kestrel (29.webp). breaker (dark, heavy wear, mud to the knee: 24.webp), paladin (27.webp), kestrel (29.webp).
material(name, role="armour", preset="seraph", **overrides) material(name, role="armour", preset="seraph", **overrides)
one material of a preset: role is armour, metal, mark or hazard. one material of a preset: role is armour, metal, mark or hazard.
glass(name, preset="smoked", **overrides)
one MechGlass material. GLASS: smoked (a near-black canopy pane: RAPTOR, 38.webp), amber (a
dark amber dome: WYVERN, 35.webp), faceted (smoked, broken into panes by a dark lattice),
lens (a coated blue optic), lens_amber (a laser's or lamp's warm optic).
shield(objects=None, lights=None)
light-links the glass out of the stage's area lights; only a glass with Reflect over 0 needs it.
mirrored(*matrices)
True where a chain of frames (4x4 or 3x3) reverses handedness: what a marking placed in it
must be flipped by to read left to right. surface.decal asks it of the plate and the frame.
Why glass is its own group, and why it does not mirror the scene. mechlib.stage_field lights a mech with three
square area lights, the key 5 scene radii across at 4 radii: half the sky over a canopy. A smooth dielectric
mirrors that key at Fresnel strength, and the key's radiance is many times the sky's, so any glossy pane turned
up or forward renders pale whatever its colour. Measured on WYVERN pass 2's canopy (wyvern.blend, 16 samples, mean
scene-linear radiance of the pane): 0.236 as built (roughness 0.3, coat 0.15); 0.061 with the key hidden from
glossy rays; 0.037 under the world alone; 0.406 with mechlib's own "glass" (roughness 0.04, coat 1). Transmission,
the light path and the missing interior play no part: the pane is opaque, and with its specular off it renders
(0.012, 0.005, 0.002) brown. So MechGlass keeps Cycles' specular off (Reflect 0) and paints its reflection as
emission, from the reflected ray alone: a horizon-bright overcast sky in banks, a dark ground, a small sun's glint, all at
Fresnel strength. It reads the same on any stage. Reflect over 0 brings Cycles' own reflections back
(the mech's frames in the pane); then call shield() once the stage's lights exist, or the pane goes pale again.
group() the MechPaint node group (built once per file). Its layers, bottom up: group() the MechPaint node group (built once per file). Its layers, bottom up:
base paint Base Color, toned per plate by Object Info's Random and Geometry's Random Per Island (value, base paint Base Color, toned per plate by Object Info's Random and Geometry's Random Per Island (value,
and a little hue and saturation: Tone Variation), mottled by two world-space noises (Mottle). and a little hue and saturation: Tone Variation), mottled by two world-space noises (Mottle).
cover a marking's own colour over the paint (Cover Color, Cover); Cover Wear opens it, by Alpha, to cover a marking's own colour over the paint (Cover Color, Cover); Cover Wear opens it, by Alpha, to
the plate under the decal, in specks and in patches. the plate under the decal, in specks and in patches. Legibility (0 to 2) lifts the marking back
out of the film, streaks and dust laid over it, brightens it past 1 and closes part of the
wear; chips and mud still take it. 0 is the paint of the first pass, where a number under
breaker's grime could not be read at figure scale.
cavity grime Ambient Occlusion (4 samples, 0.45 m) darkens recesses, seams and the undersides of overhangs, cavity grime Ambient Occlusion (4 samples, 0.45 m) darkens recesses, seams and the undersides of overhangs,
and a thin film lies in patches on open faces (Grime, Grime Color). and a thin film lies in patches on open faces (Grime, Grime Color).
streaks noise stretched along world Z, on faces that stand upright, stronger where AO says something streaks noise stretched along world Z, on faces that stand upright, stronger where AO says something
@ -50,6 +75,7 @@ INPUTS = {
"Cover Color": ("NodeSocketColor", (0.2, 0.19, 0.165, 1.0)), "Cover Color": ("NodeSocketColor", (0.2, 0.19, 0.165, 1.0)),
"Cover": ("NodeSocketFloat", 0.0), "Cover": ("NodeSocketFloat", 0.0),
"Cover Wear": ("NodeSocketFloat", 0.5), "Cover Wear": ("NodeSocketFloat", 0.5),
"Legibility": ("NodeSocketFloat", 0.0),
"Grime": ("NodeSocketFloat", 1.0), "Grime": ("NodeSocketFloat", 1.0),
"Grime Color": ("NodeSocketColor", (0.02, 0.017, 0.013, 1.0)), "Grime Color": ("NodeSocketColor", (0.02, 0.017, 0.013, 1.0)),
"Streaks": ("NodeSocketFloat", 1.0), "Streaks": ("NodeSocketFloat", 1.0),
@ -75,32 +101,33 @@ PRESETS = {
# SERAPH, 30.webp: a warm grey drab, the cleanest of the sheets; small chips, light streaks, mud on the feet only. # SERAPH, 30.webp: a warm grey drab, the cleanest of the sheets; small chips, light streaks, mud on the feet only.
"seraph": {"armour": {"base_color": (0.066, 0.056, 0.038), "wear": 0.85, "grime": 0.8, "streaks": 0.8, "dust": 0.6, "mud": 0.8, "mud_top": 1.2, "wet_top": 2.0}, "seraph": {"armour": {"base_color": (0.066, 0.056, 0.038), "wear": 0.85, "grime": 0.8, "streaks": 0.8, "dust": 0.6, "mud": 0.8, "mud_top": 1.2, "wet_top": 2.0},
"metal": {**_METAL, "wear": 0.6, "mud": 0.8, "mud_top": 1.2}, "metal": {**_METAL, "wear": 0.6, "mud": 0.8, "mud_top": 1.2},
"mark": {"cover_color": (0.22, 0.21, 0.18), "cover_wear": 0.55}}, "mark": {"cover_color": (0.3, 0.29, 0.25), "cover_wear": 0.5, "legibility": 0.8}},
# MCR-3, 25.webp: greyer and darker, every plate chipped along its edges, streaked, dirty to the shin. # MCR-3, 25.webp: greyer and darker, every plate chipped along its edges, streaked, dirty to the shin.
"mcr3": {"armour": {"base_color": (0.048, 0.044, 0.034), "wear": 1.0, "grime": 1.0, "streaks": 1.0, "dust": 0.45, "mud": 1.0, "mud_top": 1.4, "wet_top": 2.4, "tone_variation": 0.32}, "mcr3": {"armour": {"base_color": (0.048, 0.044, 0.034), "wear": 1.0, "grime": 1.0, "streaks": 1.0, "dust": 0.45, "mud": 1.0, "mud_top": 1.4, "wet_top": 2.4, "tone_variation": 0.32},
"metal": {**_METAL, "wear": 0.9}, "metal": {**_METAL, "wear": 0.9},
"mark": {"cover_color": (0.2, 0.195, 0.175), "cover_wear": 0.5}}, "mark": {"cover_color": (0.3, 0.29, 0.26), "cover_wear": 0.45, "legibility": 0.9}},
# BREAKER, 24.webp: the same drab two stops down, the heaviest wear on any sheet, mud to the knee. # BREAKER, 24.webp: the same drab two stops down, the heaviest wear on any sheet, mud to the knee.
"breaker": {"armour": {"base_color": (0.03, 0.028, 0.021), "wear": 1.5, "grime": 1.3, "streaks": 1.3, "dust": 0.35, "mud": 1.3, "mud_top": 2.2, "wet_top": 4.0, "tone_variation": 0.35, "breaker": {"armour": {"base_color": (0.03, 0.028, 0.021), "wear": 1.5, "grime": 1.3, "streaks": 1.3, "dust": 0.35, "mud": 1.3, "mud_top": 2.2, "wet_top": 4.0, "tone_variation": 0.35,
"primer_color": (0.12, 0.11, 0.09)}, "primer_color": (0.12, 0.11, 0.09)},
"metal": {**_METAL, "wear": 1.3, "grime": 1.5, "mud": 1.3, "mud_top": 2.2}, "metal": {**_METAL, "wear": 1.3, "grime": 1.5, "mud": 1.3, "mud_top": 2.2},
"mark": {"cover_color": (0.19, 0.18, 0.15), "cover_wear": 0.75}}, "mark": {"cover_color": (0.3, 0.285, 0.24), "cover_wear": 0.6, "legibility": 0.75}},
# PALADIN, 27.webp: an olive greener than SERAPH's, middling wear. # PALADIN, 27.webp: an olive greener than SERAPH's, middling wear.
"paladin": {"armour": {"base_color": (0.05, 0.052, 0.033), "wear": 0.9, "grime": 0.9, "streaks": 0.9}, "paladin": {"armour": {"base_color": (0.05, 0.052, 0.033), "wear": 0.9, "grime": 0.9, "streaks": 0.9},
"metal": {**_METAL, "wear": 0.8}, "metal": {**_METAL, "wear": 0.8},
"mark": {"cover_wear": 0.5}}, "mark": {"cover_color": (0.3, 0.29, 0.25), "cover_wear": 0.5, "legibility": 0.8}},
# KESTREL, 29.webp: a light grey-green scout paint, thin wear, long streaks. # KESTREL, 29.webp: a light grey-green scout paint, thin wear, long streaks.
"kestrel": {"armour": {"base_color": (0.06, 0.062, 0.048), "wear": 0.8, "grime": 0.9, "streaks": 1.2, "mud_top": 1.0}, "kestrel": {"armour": {"base_color": (0.06, 0.062, 0.048), "wear": 0.8, "grime": 0.9, "streaks": 1.2, "mud_top": 1.0},
"metal": {**_METAL, "wear": 0.7}, "metal": {**_METAL, "wear": 0.7},
"mark": {"cover_wear": 0.5}}, "mark": {"cover_color": (0.3, 0.29, 0.25), "cover_wear": 0.5, "legibility": 0.8}},
} }
ROLES = { ROLES = {
"armour": {"khaki", "olive", "olive_light", "plate_olive", "plate_white", "plate_grey", "plate_sand", "drab", "drab_fit", "drab_dark", "drab_dark_fit"}, "armour": {"khaki", "olive", "olive_light", "plate_olive", "plate_white", "plate_grey", "plate_sand", "drab", "drab_fit", "drab_dark", "drab_dark_fit"},
"metal": {"gunmetal", "frame", "machine", "structure", "plate_dark"}, "metal": {"gunmetal", "frame", "machine", "structure", "plate_dark"},
"mark": {"stencil", "marking", "marking_fresh"}, "mark": {"stencil", "marking", "marking_fresh"},
"hazard": {"hazard", "accent_yellow"}, "hazard": {"hazard", "accent_yellow"},
"glass": {"glass", "canopy", "wyvern_canopy", "optic"},
} }
HAZARD = {"cover_color": (0.32, 0.2, 0.025), "cover_wear": 0.7} HAZARD = {"cover_color": (0.32, 0.2, 0.025), "cover_wear": 0.7, "legibility": 0.5}
class _Net: class _Net:
@ -163,11 +190,22 @@ class _Net:
return node.outputs[0] return node.outputs[0]
def _current(name, inputs):
"""The file's node group of this name if its inputs are this module's, else a new, empty one: a .blend painted
by an older paint.py keeps its group under <name>.old, for whatever still uses it."""
old = bpy.data.node_groups.get(name)
if old and [i.name for i in old.interface.items_tree if i.item_type == "SOCKET" and i.in_out == "INPUT"] == list(inputs):
return old
if old:
old.name = name + ".old"
return bpy.data.node_groups.new(name, "ShaderNodeTree")
def group(): def group():
"""The MechPaint node group; built on first call, then the one in the file.""" """The MechPaint node group; built on first call, then the one in the file."""
if GROUP in bpy.data.node_groups: tree = _current(GROUP, INPUTS)
return bpy.data.node_groups[GROUP] if tree.nodes:
tree = bpy.data.node_groups.new(GROUP, "ShaderNodeTree") return tree
for name, (kind, default) in INPUTS.items(): for name, (kind, default) in INPUTS.items():
s = tree.interface.new_socket(name, in_out="INPUT", socket_type=kind) s = tree.interface.new_socket(name, in_out="INPUT", socket_type=kind)
s.default_value = default s.default_value = default
@ -197,10 +235,11 @@ def group():
shade = n.math("ADD", n.math("ADD", n.ramp(blotch, 0.3, 0.7, (-0.3, 0.3)), n.ramp(speck, 0.3, 0.7, (-0.2, 0.2))), n.ramp(n.noise(pos, 6.0, 5.0, 0.7), 0.3, 0.7, (-0.22, 0.22))) shade = n.math("ADD", n.math("ADD", n.ramp(blotch, 0.3, 0.7, (-0.3, 0.3)), n.ramp(speck, 0.3, 0.7, (-0.2, 0.2))), n.ramp(n.noise(pos, 6.0, 5.0, 0.7), 0.3, 0.7, (-0.22, 0.22)))
col = n.vec("SCALE", hsv.outputs["Color"], scale=n.math("MULTIPLY_ADD", shade, G["Mottle"], 1.0)) col = n.vec("SCALE", hsv.outputs["Color"], scale=n.math("MULTIPLY_ADD", shade, G["Mottle"], 1.0))
# a marking's own colour over it, worn through by Alpha # a marking's own colour over it, worn through by Alpha
col = n.mix(col, n.vec("SCALE", G["Cover Color"], scale=n.ramp(n.noise(pos, 7.0, 4.0), 0.3, 0.7, (0.6, 1.05))), G["Cover"]) cover = n.vec("SCALE", G["Cover Color"], scale=n.ramp(n.noise(pos, 7.0, 4.0), 0.3, 0.7, (0.6, 1.05)))
col = n.mix(col, cover, G["Cover"])
fine_lo, patch_lo = n.ramp(G["Cover Wear"], 0.0, 1.0, (0.7, 0.46)), n.ramp(G["Cover Wear"], 0.0, 1.0, (0.82, 0.46)) fine_lo, patch_lo = n.ramp(G["Cover Wear"], 0.0, 1.0, (0.7, 0.46)), n.ramp(G["Cover Wear"], 0.0, 1.0, (0.82, 0.46))
gone = n.math("MAXIMUM", n.ramp(n.noise(pos, 38.0, 3.0, 0.6, 1.2), fine_lo, n.math("ADD", fine_lo, 0.03)), n.ramp(n.noise(pos, 4.5, 5.0), patch_lo, n.math("ADD", patch_lo, 0.05))) gone = n.math("MAXIMUM", n.ramp(n.noise(pos, 38.0, 3.0, 0.6, 1.2), fine_lo, n.math("ADD", fine_lo, 0.03)), n.ramp(n.noise(pos, 4.5, 5.0), patch_lo, n.math("ADD", patch_lo, 0.05)))
alpha = n.math("SUBTRACT", 1.0, n.mul(gone, n.math("MINIMUM", G["Cover"], 1.0)), clamp=True) alpha = n.math("SUBTRACT", 1.0, n.mul(gone, n.math("MINIMUM", G["Cover"], 1.0), n.ramp(G["Legibility"], 0.0, 2.0, (1.0, 0.3))), clamp=True)
# cavity grime # cavity grime
ao = tree.nodes.new("ShaderNodeAmbientOcclusion") ao = tree.nodes.new("ShaderNodeAmbientOcclusion")
@ -224,6 +263,8 @@ def group():
# dust on what looks up # dust on what looks up
dust = n.mul(n.ramp(up, 0.45, 0.95), n.ramp(n.noise(pos, 3.0, 6.0, 0.7), 0.25, 0.7, (0.25, 1.0)), G["Dust"], 0.6, clamp=True) dust = n.mul(n.ramp(up, 0.45, 0.95), n.ramp(n.noise(pos, 3.0, 6.0, 0.7), 0.25, 0.7, (0.25, 1.0)), G["Dust"], 0.6, clamp=True)
col = n.mix(col, G["Dust Color"], dust) col = n.mix(col, G["Dust Color"], dust)
# legibility: the marking's paint lifted back out of the film, streaks and dust; chips and mud below still take it
col = n.mix(col, n.vec("SCALE", cover, scale=n.ramp(G["Legibility"], 1.0, 2.0, (1.0, 1.7))), n.mul(G["Cover"], G["Legibility"], clamp=True))
# edge wear: chips to metal with a primer ring, scuffs on open faces # edge wear: chips to metal with a primer ring, scuffs on open faces
bevel = tree.nodes.new("ShaderNodeBevel") bevel = tree.nodes.new("ShaderNodeBevel")
@ -262,11 +303,195 @@ def group():
return tree return tree
def _input_name(key): GLASS_GROUP = "MechGlass"
for name in INPUTS: GLASS_INPUTS = {
"Tint": ("NodeSocketColor", (0.006, 0.007, 0.008, 1.0)), # the pane's own colour, seen where nothing shows through
"Interior": ("NodeSocketFloat", 0.5), # how much of Interior Color shows where the eye looks straight in
"Interior Color": ("NodeSocketColor", (0.01, 0.011, 0.012, 1.0)),
"Roughness": ("NodeSocketFloat", 0.04),
"Reflect": ("NodeSocketFloat", 0.0), # Cycles' own specular, 1 a plain dielectric: see shield()
"Sky": ("NodeSocketFloat", 2.2), # 1 is the physical reflection of the sky; the sheets paint it stronger
"Sky Color": ("NodeSocketColor", (0.58, 0.61, 0.67, 1.0)), # stage_field's world: (0.5, 0.53, 0.58) at 1.15
"Clouds": ("NodeSocketFloat", 1.0), # the reflected sky broken into banks, so a reflection has a shape
"Ground Color": ("NodeSocketColor", (0.06, 0.055, 0.05, 1.0)),
"Glint": ("NodeSocketFloat", 1.0),
"Glint Direction": ("NodeSocketVector", (0.35, 0.5, 0.8)), # toward the sun, in the world: high over the mech's front left, where the hero views stand
"Glint Size": ("NodeSocketFloat", 0.006), # 1 - cos of the sun's half angle: 0.006 is 6 degrees
"Facets": ("NodeSocketFloat", 0.0), # panes a metre; 0 is one pane
"Facet Tilt": ("NodeSocketFloat", 0.1),
"Mullion": ("NodeSocketFloat", 0.02), # the lattice bar's width, metres
"Mullion Color": ("NodeSocketColor", (0.003, 0.003, 0.003, 1.0)),
"Dirt": ("NodeSocketFloat", 1.0),
"Dirt Color": ("NodeSocketColor", (0.03, 0.028, 0.023, 1.0)),
"Scale": ("NodeSocketFloat", 1.0),
}
GLASS_OUTPUTS = {"Color": "NodeSocketColor", "Roughness": "NodeSocketFloat", "Specular": "NodeSocketFloat", "Normal": "NodeSocketVector", "Emission": "NodeSocketColor"}
_LENS = {"roughness": 0.02, "interior": 1.0, "dirt": 0.5}
GLASS = {
# RAPTOR, 38.webp, RECESSED COCKPIT: near-black panes in an armour lattice, a pale sky low on each, no interior.
"smoked": {},
# WYVERN, 35.webp, COCKPIT & SENSOR CANOPY: a dark amber dome, the amber showing where the eye looks in.
"amber": {"tint": (0.006, 0.0025, 0.001), "interior": 1.0, "interior_color": (0.02, 0.0062, 0.0012)},
# one blown pane read as a lattice of flat ones: for a canopy built as a single dome with no frames of its own.
"faceted": {"facets": 3.5, "facet_tilt": 0.12, "mullion": 0.022},
# a coated optic: a blue-violet depth, a cold reflection (WYVERN's projector and helmet sensor; RAPTOR's emitters).
"lens": {**_LENS, "tint": (0.004, 0.005, 0.012), "interior_color": (0.0015, 0.005, 0.022), "sky_color": (0.3, 0.45, 0.95), "sky": 1.2},
"lens_amber": {**_LENS, "tint": (0.012, 0.005, 0.002), "interior_color": (0.02, 0.0055, 0.0008), "sky_color": (0.95, 0.6, 0.3), "sky": 1.2},
}
def glass_group():
"""The MechGlass node group; built on first call, then the one in the file. See the module header for why its
reflection is painted. Its layers: the pane (Tint, Interior Color where the view is square to it, broken by a
slow noise); facets (a Voronoi lattice in the object's frame: each cell's normal tilted its own way, a bar of
Mullion Color on the cell borders); dirt (Ambient Occlusion puts it in the corners a frame makes, a noise on
what looks up); the painted reflection (sky above the reflected horizon, brightest at it and broken into banks by Clouds; ground below; a
sun's disc and halo about Glint Direction), at Fresnel strength for IOR 1.5, dimmed by the dirt."""
tree = _current(GLASS_GROUP, GLASS_INPUTS)
if tree.nodes:
return tree
for name, (kind, default) in GLASS_INPUTS.items():
tree.interface.new_socket(name, in_out="INPUT", socket_type=kind).default_value = default
for name, kind in GLASS_OUTPUTS.items():
tree.interface.new_socket(name, in_out="OUTPUT", socket_type=kind)
n = _Net(tree)
gin, gout = tree.nodes.new("NodeGroupInput"), tree.nodes.new("NodeGroupOutput")
G = gin.outputs
geo, coords = tree.nodes.new("ShaderNodeNewGeometry"), tree.nodes.new("ShaderNodeTexCoord")
own = n.vec("SCALE", coords.outputs["Object"], scale=G["Scale"])
def z_of(vector):
node = tree.nodes.new("ShaderNodeSeparateXYZ")
tree.links.new(vector, node.inputs[0])
return node.outputs["Z"]
# facets: a tilt a cell, a bar on the borders
on = n.ramp(G["Facets"], 0.0, 0.01)
cells = n.vec("SCALE", own, scale=G["Facets"])
lattice = {}
for feature in ("F1", "DISTANCE_TO_EDGE"):
node = tree.nodes.new("ShaderNodeTexVoronoi")
node.voronoi_dimensions, node.feature = "3D", feature
node.inputs["Scale"].default_value, node.inputs["Randomness"].default_value = 1.0, 0.75
tree.links.new(cells, node.inputs["Vector"])
lattice[feature] = node
tilt = n.vec("SCALE", n.vec("SUBTRACT", lattice["F1"].outputs["Color"], (0.5, 0.5, 0.5)), scale=n.mul(G["Facet Tilt"], on, 2.0))
normal = n.vec("NORMALIZE", n.vec("ADD", geo.outputs["Normal"], tilt))
half = n.mul(G["Mullion"], G["Facets"], 0.5)
bar = n.mul(n.ramp(lattice["DISTANCE_TO_EDGE"].outputs["Distance"], n.math("MULTIPLY_ADD", half, 1.25, 0.002), half), on)
# dirt: in the corners a frame makes, and on what looks up
ao = tree.nodes.new("ShaderNodeAmbientOcclusion")
ao.samples, ao.inputs["Distance"].default_value = 4, 0.22
patchy = n.ramp(n.noise(own, 6.0, 5.0, 0.7), 0.3, 0.65, (0.35, 1.0))
corner = n.mul(n.ramp(ao.outputs["AO"], 0.9, 0.45), patchy)
settled = n.mul(n.ramp(z_of(geo.outputs["Normal"]), 0.35, 0.95), n.ramp(n.noise(own, 2.2, 6.0, 0.7), 0.35, 0.7, (0.05, 0.45)))
dirt = n.mul(n.math("MAXIMUM", corner, settled), G["Dirt"], clamp=True)
# the pane: its tint, the interior's colour where the eye looks straight in
facing = tree.nodes.new("ShaderNodeLayerWeight")
facing.inputs["Blend"].default_value = 0.5
tree.links.new(normal, facing.inputs["Normal"])
square = n.math("POWER", n.math("SUBTRACT", 1.0, facing.outputs["Facing"], clamp=True), 3.0)
inside = n.mul(square, G["Interior"], n.ramp(n.noise(own, 2.6, 3.0, 0.5), 0.3, 0.7, (0.35, 1.0)), clamp=True)
col = n.mix(G["Tint"], G["Interior Color"], inside)
col = n.mix(col, G["Mullion Color"], bar)
col = n.mix(col, G["Dirt Color"], n.math("MULTIPLY", dirt, 0.8))
# the painted reflection, from the reflected ray
ray = n.vec("REFLECT", n.vec("SCALE", geo.outputs["Incoming"], scale=-1.0), normal)
rz = z_of(ray)
banks = n.noise(n.vec("MULTIPLY", ray, (1.6, 1.6, 4.0)), 1.0, 3.0, 0.55, 0.6)
banks = n.math("MULTIPLY_ADD", n.math("SUBTRACT", n.ramp(banks, 0.4, 0.62, (0.3, 1.45)), 1.0), G["Clouds"], 1.0)
sky = n.vec("SCALE", G["Sky Color"], scale=n.mul(n.ramp(rz, -0.06, 0.04), n.ramp(rz, 0.0, 0.75, (1.25, 0.4)), banks, G["Sky"]))
env = n.mix(n.vec("SCALE", G["Ground Color"], scale=G["Sky"]), sky, n.ramp(rz, -0.06, 0.04))
toward = n.vec("DOT_PRODUCT", ray, n.vec("NORMALIZE", G["Glint Direction"]))
edge = n.math("SUBTRACT", 1.0, G["Glint Size"])
disc = n.math("POWER", n.ramp(toward, n.math("MULTIPLY_ADD", G["Glint Size"], -3.0, edge), 1.0), 3.0)
halo = n.math("POWER", n.ramp(toward, 0.6, 1.0), 10.0)
sun = n.mul(n.math("ADD", n.math("MULTIPLY", disc, 7.0), n.math("MULTIPLY", halo, 0.4)), G["Glint"])
env = n.vec("ADD", env, n.vec("SCALE", (1.0, 0.96, 0.9), scale=sun))
fresnel = tree.nodes.new("ShaderNodeFresnel")
fresnel.inputs["IOR"].default_value = 1.5
tree.links.new(normal, fresnel.inputs["Normal"])
clear = n.mul(n.math("SUBTRACT", 1.0, n.math("MULTIPLY", dirt, 0.6)), n.math("SUBTRACT", 1.0, bar))
painted = n.vec("SCALE", env, scale=n.mul(fresnel.outputs[0], clear, n.math("SUBTRACT", 1.0, G["Reflect"], clamp=True)))
tree.links.new(col, gout.inputs["Color"])
tree.links.new(n.math("ADD", G["Roughness"], n.math("MAXIMUM", n.math("MULTIPLY", dirt, 0.55), n.math("MULTIPLY", bar, 0.5)), clamp=True), gout.inputs["Roughness"])
tree.links.new(n.mul(G["Reflect"], 0.5, n.math("SUBTRACT", 1.0, n.math("MULTIPLY", dirt, 0.6))), gout.inputs["Specular"])
tree.links.new(normal, gout.inputs["Normal"])
tree.links.new(painted, gout.inputs["Emission"])
return tree
def glass(name, preset="smoked", **overrides):
"""One MechGlass material: GLASS[preset], then `overrides` (MechGlass inputs, lower case with underscores)."""
values = {**GLASS[preset], **overrides}
mat = bpy.data.materials.get(name) or bpy.data.materials.new(name)
mat.use_nodes = True
nodes, links = mat.node_tree.nodes, mat.node_tree.links
nodes.clear()
out, bsdf, grp = nodes.new("ShaderNodeOutputMaterial"), nodes.new("ShaderNodeBsdfPrincipled"), nodes.new("ShaderNodeGroup")
grp.node_tree = glass_group()
for key, value in values.items():
socket = grp.inputs[_input_name(key, GLASS_INPUTS)]
socket.default_value = value if isinstance(value, (int, float)) or len(value) == len(socket.default_value) else (*value, 1.0)
for a, b in (("Color", "Base Color"), ("Roughness", "Roughness"), ("Specular", "Specular IOR Level"), ("Normal", "Normal"), ("Emission", "Emission Color")):
links.new(grp.outputs[a], bsdf.inputs[b])
bsdf.inputs["Emission Strength"].default_value = 1.0
links.new(bsdf.outputs[0], out.inputs[0])
tint = values.get("tint", GLASS_INPUTS["Tint"][1])
mat.diffuse_color = (*tint[:3], 1.0)
mat["paint_role"], mat["paint_glass"] = "glass", preset
return mat
_make_glass = glass # apply() has a parameter of that name
def shield(objects=None, lights=None):
"""Light-link glass out of the stage's softboxes, so a pane with Reflect over 0 mirrors the world and the mech
and not a key light half the sky across (the module header has the measurement). objects: default every
object whose only material is a MechGlass; lights: default every area light in the scene. Call it after the
stage's lights exist; call it again after adding glass. Returns the objects shielded. An object that also
carries another material is left alone and named: linking is per object, and its paint needs the lights."""
scene = bpy.context.scene
lights = lights or [o for o in scene.objects if o.type == "LIGHT" and o.data.type == "AREA"]
if objects is None:
objects = [o for o in scene.objects if o.type == "MESH" and any(s.material and s.material.get("paint_role") == "glass" for s in o.material_slots)]
mixed = [o.name for o in objects if any(not s.material or s.material.get("paint_role") != "glass" for s in o.material_slots)]
if mixed:
print("SHIELD left alone, glass beside another material:", ", ".join(mixed), flush=True)
objects = [o for o in objects if o.name not in mixed]
group_ = bpy.data.collections.get("paint.shielded") or bpy.data.collections.new("paint.shielded")
for obj in list(group_.objects):
group_.objects.unlink(obj)
for obj in objects:
group_.objects.link(obj)
for entry in group_.collection_objects:
entry.light_linking.link_state = "EXCLUDE"
for light in lights:
light.light_linking.receiver_collection = group_ if objects else None
return objects
def mirrored(*matrices):
"""True where the product of these frames (4x4 or 3x3, outermost first) reverses handedness: a reflection in
the object's world matrix, in a Build's to_host, or in a frame written for the other side. A marking laid in
such a chain reads right to left until its own x is reversed; surface.decal does that."""
sign = 1.0
for m in matrices:
sign *= (m.to_3x3() if len(m) == 4 else m).determinant()
return sign < 0.0
def _input_name(key, table=None):
table = INPUTS if table is None else table
for name in table:
if name.lower().replace(" ", "_") == key: if name.lower().replace(" ", "_") == key:
return name return name
raise KeyError(f"MechPaint has no input {key!r}; it has " + ", ".join(k.lower().replace(" ", "_") for k in INPUTS)) raise KeyError(f"no input {key!r}; there are " + ", ".join(k.lower().replace(" ", "_") for k in table))
def material(name, role="armour", preset="seraph", **overrides): def material(name, role="armour", preset="seraph", **overrides):
@ -298,8 +523,11 @@ def material(name, role="armour", preset="seraph", **overrides):
return mat return mat
def apply(preset="seraph", ground=0.0, objects=None, scale=1.0, roles=None, **overrides): def apply(preset="seraph", ground=0.0, objects=None, scale=1.0, roles=None, glass="smoked", lens="lens", lens_below=0.3, **overrides):
"""Repaint a built mech: see the module header. `roles` adds or moves material names, {name: role}.""" """Repaint a built mech: see the module header. `roles` adds or moves material names, {name: role}; a role of
None leaves that material alone. glass, lens: the GLASS preset (or a dict of MechGlass inputs, over "smoked"
unless it names a "preset") for panes and for optics, an optic being a glass object under `lens_below` metres
across at scale 1."""
role_of = {name: role for role, names in ROLES.items() for name in names} role_of = {name: role for role, names in ROLES.items() for name in names}
role_of.update(roles or {}) role_of.update(roles or {})
made, swapped = {}, {} made, swapped = {}, {}
@ -307,11 +535,20 @@ def apply(preset="seraph", ground=0.0, objects=None, scale=1.0, roles=None, **ov
if obj.type not in {"MESH", "CURVE", "FONT"} or obj.get("stage"): if obj.type not in {"MESH", "CURVE", "FONT"} or obj.get("stage"):
continue continue
for slot in obj.material_slots: for slot in obj.material_slots:
role = slot.material and (slot.material.get("paint_role") or role_of.get(slot.material.name)) # a painted mech can be repainted role = slot.material and role_of.get(slot.material.name, slot.material.get("paint_role")) # a painted mech can be repainted
if not role: if not role:
continue continue
if role not in made: key = role
made[role] = material(f"paint_{preset}_{role}", role, preset, ground_z=ground, scale=scale, **({} if role == "metal" else overrides)) if role == "glass":
swapped[slot.material.name] = made[role] key = "lens" if max(obj.dimensions) * scale < lens_below else "pane"
slot.material = made[role] if key not in made:
if role == "glass":
which = lens if key == "lens" else glass
made[key] = _make_glass(f"paint_glass_{key}", **({"preset": which} if isinstance(which, str) else which), scale=scale)
else:
made[key] = material(f"paint_{preset}_{role}", role, preset, ground_z=ground, scale=scale, **({} if role == "metal" else overrides))
swapped[slot.material.name] = made[key]
slot.material = made[key]
if any(m.get("paint_role") == "glass" and m.node_tree.nodes["Group"].inputs["Reflect"].default_value > 0 for m in made.values()):
shield()
return swapped return swapped

View file

@ -1,23 +1,25 @@
"""PALADIN: concept sheet images/27.webp, second pass (aetheria-release:ruling:second-passes-all-mechs). """PALADIN: concept sheet images/27.webp, third pass.
The character line is the chest's belt (paladin_form.BELT): the knuckle where the glacis under the turret breaks to The character line is the chest's belt (paladin_form.BELT): the knuckle where the glacis under the turret breaks to
the hull's upright band, a chevron in plan with the amber lamp at its stem. The first pass built it first and it the hull's upright band, a chevron in plan with the amber lamp at its stem. The first pass built it first and it
landed; the hull, turret and their plates are kept from it (paladin_body.py). landed; the hull and turret are kept from it (paladin_body.py) and take detail panels here.
What this pass rebuilds (paladin_limbs.py): What this pass rebuilds (paladin_hard.py, numbers in paladin_form.py):
the skeleton kit parts, every joint a pin with a joint record and limits (bipedkit.py): waist, per leg hip the plates every limb, the pelvis, the abdomen and the pauldrons as HARD plates authored by their faces
splay, hip pitch, knee, ankle pitch, ankle roll and feet.paladin_hoof's toes; per arm shoulder (massing.hard on massing.slab_points / section_points: the method of nibu/fable-bastion-2), 0.13 to
abduction, shoulder pitch, elbow. brokkr_kitbash.joints reports it (paladin_joints.json). 0.34 m thick, with stepped and bolted panels, slots, vents, ports, handles on top. Their numbers are
the cameras solved on the kit's joints as they stand, no horizon held (paladin_form.solve) read off the sheet by hand; nothing is a fit (paladin_form says so, and where the views disagree).
the plates thighs, shins, pauldrons, upper arms and the left forearm as free cages, the big ones fitted to the machinery a kit ram across the back of each knee, bearing covers, ribbed hip drums and a ribbed waist column,
edges traced on the sheet (platecage.py over brokkr_reference's fit), layered base / shield / calf struts, 30-odd hoses at the waist, hips, knees, ankles and elbows
block and lame; the detail pass by surface.Skin; then paint.apply("paladin"). the left hand handkit.hand: a kit palm and fifteen pins with joint records
the cameras the sheet's horizon held (paladin_form.HORIZON)
the marks every numeral and triangle through surface.py
PALADIN_STAGE: skeleton (the kit and the first pass's hull alone), full (default). MECH_QUICK renders by Workbench. PALADIN_STAGE: skeleton (the kit, the hull), legs (those and the lower body), full (default). MECH_QUICK renders by
Writes under MECH_OUT/paladin/: <stage>_<view>.png and <stage>_sil_<view>.png for the hero, rear and side views at Workbench. Writes under MECH_OUT/paladin/: <stage>_<view>.png and <stage>_sil_<view>.png for the hero, rear and side
the solved cameras (the sheet's own pixels), <stage>_character.png, <stage>_edges_hero.json (mechlib.built_edges), views at the solved cameras (the sheet's own pixels), <stage>_character.png, <stage>_edges_hero.json
<stage>_turn_*.png, component close-ups, paladin_report_<stage>.json (cameras, cages, fits, joints, the detail (mechlib.built_edges), <stage>_turn_*.png, component close-ups, paladin_report_<stage>.json (cameras, hard plates,
pass), paladin_joints.json, paladin.blend.""" joints, the detail pass), paladin_joints.json, paladin.blend."""
import json, math, os, sys, time import json, math, os, sys, time
from pathlib import Path from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent)) sys.path.insert(0, str(Path(__file__).resolve().parent))
@ -34,14 +36,14 @@ import addon_utils
if addon_utils.enable("brokkr_reference", default_set=True) is None: if addon_utils.enable("brokkr_reference", default_set=True) is None:
raise SystemExit("brokkr_reference could not be enabled") raise SystemExit("brokkr_reference could not be enabled")
import bipedkit as BK import bipedkit as BK
import paladin_limbs as PL import paladin_hard as PH
import platecage as PC
import surface import surface
surface.materials() surface.materials()
M.material("lamp_amber", (0.02, 0.02, 0.02), 0.0, 0.2, emission=((1.0, 0.5, 0.05), 12.0)) M.material("lamp_amber", (0.02, 0.02, 0.02), 0.0, 0.2, emission=((1.0, 0.5, 0.05), 12.0))
F, T = M.frame_at, Matrix.Translation F, T = M.frame_at, Matrix.Translation
STAGE = os.environ.get("PALADIN_STAGE", "full") STAGE = os.environ.get("PALADIN_STAGE", "full")
FULL = STAGE == "full" FULL = STAGE == "full"
LOWER = STAGE in ("legs", "full")
QUICK = bool(os.environ.get("MECH_QUICK")) QUICK = bool(os.environ.get("MECH_QUICK"))
OUT = Path(os.environ["MECH_OUT"]) / "paladin" OUT = Path(os.environ["MECH_OUT"]) / "paladin"
assert OUT.is_absolute() assert OUT.is_absolute()
@ -52,22 +54,37 @@ def adopt_named(host, *keys):
BK.adopt(host, [o for o in bpy.data.objects if o.parent is None and not o.get("stage") and not o.get("kit_part") and any(k in o.name for k in keys)]) BK.adopt(host, [o for o in bpy.data.objects if o.parent is None and not o.get("stage") and not o.get("kit_part") and any(k in o.name for k in keys)])
def mark(text, origin, direction, height):
"""A numeral through surface.py on whatever plate the ray from origin along direction meets (the world)."""
M.update()
hit, at, normal, _, obj, _ = bpy.context.scene.ray_cast(bpy.context.evaluated_depsgraph_get(), Vector(origin), Vector(direction).normalized())
if not hit:
PH.COUNT["failed"].append(f"mark {text}: the ray meets nothing")
return
face = MS.Face(obj, "gunmetal")
surface.numeral(face, obj.matrix_world.inverted() @ F(at + normal * 0.004, normal, (0, 0, 1)), text, height, "marking")
face.done()
PH.COUNT["marks"] += 1
# --- the skeleton, then the cameras on it --------------------------------------------------------------------------- # --- the skeleton, then the cameras on it ---------------------------------------------------------------------------
kits = PL.skeleton() kits = PH.skeleton()
points = PL.joint_points() points = PH.joint_points()
print("JOINT POINTS " + ", ".join(f"{k} ({p[0]:.2f}, {p[1]:.2f}, {p[2]:.2f})" for k, p in points.items()), flush=True) print("JOINT POINTS " + ", ".join(f"{k} ({p[0]:.2f}, {p[1]:.2f}, {p[2]:.2f})" for k, p in points.items()), flush=True)
cams = PF.solve(points) cams = PF.solve(points)
PL.CAMS.update(cams)
trunk, pelvis = kits["trunk"], kits["pelvis"] trunk, pelvis = kits["trunk"], kits["pelvis"]
M.update() M.update()
FR = trunk.matrix_world.copy() FR = trunk.matrix_world.copy()
print("skeleton s", round(time.time() - t0, 1), "waist", tuple(round(v, 3) for v in FR.translation), flush=True) print("skeleton s", round(time.time() - t0, 1), "waist", tuple(round(v, 3) for v in FR.translation), flush=True)
# --- the character line: the hull and the turret, as the first pass built them ------------------------------------------ # --- the character line: the hull and the turret, as the first pass built them, with detail panels ----------------------
with BK.Adopt(trunk): with BK.Adopt(trunk):
torso = PB.torso_mass(FR) torso = PB.torso_mass(FR)
turret = PB.turret_mass(FR) turret = PB.turret_mass(FR)
slot = PB.visor_cut(FR) slot = PB.visor_cut(FR)
if FULL:
PH.clad_mass("Torso", torso, PB.torso_specs())
PH.clad_mass("Turret", turret, PB.turret_specs(), take=lambda n: n.y < 0.5, min_area=0.25, inset=0.08)
PB.torso_plates(torso) PB.torso_plates(torso)
PB.turret_plates(turret, [slot]) PB.turret_plates(turret, [slot])
MS.carve(turret, [slot]) MS.carve(turret, [slot])
@ -76,16 +93,12 @@ with BK.Adopt(trunk):
import weapons_missile, weapons_rotary, weapons_sensor import weapons_missile, weapons_rotary, weapons_sensor
PB.mast(FR) PB.mast(FR)
PB.exchangers(FR) PB.exchangers(FR)
PB.abdomen(FR)
for sx in (-1, 1): for sx in (-1, 1):
PB.shoulder(FR, sx) PB.shoulder(FR, sx)
PL.pauldron_core(FR, sx) if FULL:
crowns, shoulders = {}, {} for sx in (-1, 1):
if FULL: PH.pauldron(FR, sx)
for sx in (-1, 1): with BK.Adopt(trunk):
PL.pauldron_shields(FR, sx, shoulders)
for sx in (-1, 1):
PL.pauldron_layers(FR, sx, shoulders)
PB.put("Battery", FR @ T((3.1, 0.45, 3.62)), weapons_missile.paladin_battery, size="M", cols=6, rows=4) PB.put("Battery", FR @ T((3.1, 0.45, 3.62)), weapons_missile.paladin_battery, size="M", cols=6, rows=4)
PB.put("EW", FR @ T((-3.1, 0.25, 2.95)), weapons_sensor.paladin_ew_module, size="M", dome=False, optic=False) PB.put("EW", FR @ T((-3.1, 0.25, 2.95)), weapons_sensor.paladin_ew_module, size="M", dome=False, optic=False)
b = PB.put("EWLow", FR @ T((-3.1, 1.45, 2.55))) # the EW inset's lower case, forward on the pauldron's roof b = PB.put("EWLow", FR @ T((-3.1, 1.45, 2.55))) # the EW inset's lower case, forward on the pauldron's roof
@ -94,36 +107,26 @@ with BK.Adopt(trunk):
for x in (-0.36, 0.0, 0.36): for x in (-0.36, 0.0, 0.36):
b["glass"].box(T((x, 0.525, -0.3)), (0.26, 0.02, 0.26)) b["glass"].box(T((x, 0.525, -0.3)), (0.26, 0.02, 0.26))
b.done() b.done()
if FULL: if FULL:
wy, wz = FR.translation.y, FR.translation.z wy, wz = FR.translation.y, FR.translation.z
PB.mark("Mark07.band", "07", (1.15 + 1.8, wy + 1.47 + 2.4, wz + 1.5), (-0.61, -0.79, 0.0), 0.36) mark("07", (1.15 + 1.8, wy + 1.47 + 2.4, wz + 1.72), (-0.61, -0.79, 0.0), 0.3)
PB.mark("Mark7.band", "7", (-1.15 - 1.8, wy + 1.47 + 2.4, wz + 1.5), (0.61, -0.79, 0.0), 0.34) mark("7", (-1.15 - 1.8, wy + 1.47 + 2.4, wz + 1.72), (0.61, -0.79, 0.0), 0.3)
print("upper s", round(time.time() - t0, 1), flush=True) print("upper s", round(time.time() - t0, 1), flush=True)
# --- the lower body ---------------------------------------------------------------------------------------------------- # --- the lower body ----------------------------------------------------------------------------------------------------
with BK.Adopt(pelvis): if LOWER:
PB.pelvis() PH.pelvis()
for sx in (-1, 1):
PB.hip(sx)
for s, sx in (("L", -1), ("R", 1)):
PL.leg_cores(s, sx)
if FULL:
for s, sx in (("L", -1), ("R", 1)): for s, sx in (("L", -1), ("R", 1)):
PL.leg_shields(s, sx, crowns) PH.leg(s, sx)
for s, sx in (("L", -1), ("R", 1)): PH.abdomen(FR)
PL.leg_layers(s, sx, crowns)
PL.knee(s)
adopt_named(kits["legs"][s]["upper"], f"Thigh{s}")
adopt_named(kits["legs"][s]["lower"], f"Shin{s}")
print("legs s", round(time.time() - t0, 1), flush=True) print("legs s", round(time.time() - t0, 1), flush=True)
# --- the arms ---------------------------------------------------------------------------------------------------------- # --- the arms ----------------------------------------------------------------------------------------------------------
hand = None
if FULL: if FULL:
for s, sx in (("L", -1), ("R", 1)): for s, sx in (("L", -1), ("R", 1)):
PL.upper_arm(s, sx) PH.upper_arm(s, sx)
adopt_named(kits["arms"][s]["upper"], f"UpperArm{s}") _, hand = PH.forearm_left()
PL.forearm_left(crowns)
adopt_named(kits["arms"]["L"]["lower"], "ForearmL", "HandL", "Emitter")
fr = kits["arms"]["R"]["lower"] fr = kits["arms"]["R"]["lower"]
M.update() M.update()
elbow = fr.matrix_world.translation.copy() elbow = fr.matrix_world.translation.copy()
@ -153,10 +156,15 @@ M.update()
lo, hi = M.bounds() lo, hi = M.bounds()
print("HEIGHT", round(hi.z - lo.z, 2), "LOW", round(lo.z, 2), "WIDTH", round(hi.x - lo.x, 2), "DEPTH", round(lo.y, 2), round(hi.y, 2), "stage", STAGE, "frozen", len(PB.FROZEN), "build s", round(time.time() - t0, 1), flush=True) print("HEIGHT", round(hi.z - lo.z, 2), "LOW", round(lo.z, 2), "WIDTH", round(hi.x - lo.x, 2), "DEPTH", round(lo.y, 2), round(hi.y, 2), "stage", STAGE, "frozen", len(PB.FROZEN), "build s", round(time.time() - t0, 1), flush=True)
M.tops() M.tops()
summary = PC.summary() kinds = {}
print("CAGES", json.dumps(summary), flush=True) for row in PH.HARD.values():
print("DETAIL", PL.DRESSED[0], "features placed,", len(PL.DRESS_FAILED), "failed", flush=True) kinds[row["kind"]] = kinds.get(row["kind"], 0) + 1
for line in PL.DRESS_FAILED: thick = [row["thick"] for row in PH.HARD.values() if row.get("thick")]
summary = {"solids": len(PH.HARD), "kinds": kinds, "corners": sum(r["corners"] for r in PH.HARD.values()), "facets": sum(r["facets"] for r in PH.HARD.values()),
"thinnest": min(thick) if thick else None, "thickest": max(thick) if thick else None, **{k: v for k, v in PH.COUNT.items() if k != "failed"}, "folded": sum(M.FOLDED.values())}
print("HARD", json.dumps(summary), flush=True)
print("DETAIL", PH.COUNT["panels"], "panels,", PH.COUNT["fits"], "fits,", PH.COUNT["marks"], "marks,", PH.COUNT["hoses"], "hoses,", PH.COUNT["rams"], "rams;", len(PH.COUNT["failed"]), "failed", flush=True)
for line in PH.COUNT["failed"]:
print(" DETAIL FAILED", line, flush=True) print(" DETAIL FAILED", line, flush=True)
if os.environ.get("PALADIN_BUILD_ONLY"): if os.environ.get("PALADIN_BUILD_ONLY"):
@ -166,13 +174,13 @@ if os.environ.get("PALADIN_BUILD_ONLY"):
import camsolve import camsolve
import paint import paint
if not os.environ.get("PALADIN_NO_PAINT"): if not os.environ.get("PALADIN_NO_PAINT"):
paint.apply("paladin", ground=0.0) paint.apply("paladin", ground=0.0, **PF.PAINT)
report = {"stage": STAGE, "height": round(hi.z - lo.z, 2), "width": round(hi.x - lo.x, 2), "frozen": len(PB.FROZEN), "cameras": {}, "cages": summary, report = {"stage": STAGE, "height": round(hi.z - lo.z, 2), "width": round(hi.x - lo.x, 2), "frozen": len(PB.FROZEN), "cameras": {}, "hard": summary,
"plates": {k: {a: b for a, b in v.items() if a != "crown"} for k, v in PC.PLATES.items()}, "joints": {"rows": len(rows), "rigid": joints["rigid"], "by_mechanism": by_mech, "plates": PH.HARD, "joints": {"rows": len(rows), "rigid": joints["rigid"], "by_mechanism": by_mech,
"without_limits": unlimited, "over_limit_roll_refused": refused}, "without_limits": unlimited, "over_limit_roll_refused": refused},
"detail": {"placed": PL.DRESSED[0], "failed": PL.DRESS_FAILED}, "joint_points": {k: [round(c, 3) for c in p] for k, p in points.items()}} "detail": {k: v for k, v in PH.COUNT.items()}, "joint_points": {k: [round(c, 3) for c in p] for k, p in points.items()}}
for tag, cam in cams.items(): for tag, cam in cams.items():
report["cameras"][tag] = {k: cam[k] for k in ("rms", "left_out", "lens", "lens_range", "azimuth", "elevation", "distance", "model", "worst")} report["cameras"][tag] = {k: cam.get(k) for k in ("rms", "left_out", "lens", "lens_range", "azimuth", "elevation", "distance", "model", "worst", "horizon")}
report["cameras"][tag]["eye_z"] = cam["C"][2] report["cameras"][tag]["eye_z"] = cam["C"][2]
report["cameras"][tag]["projected"] = {k: [float(c) for c in camsolve.project(cam, [points.get(k, PF.world(k))])[0]] for k in PF.VIEWS[tag]["marks"]} report["cameras"][tag]["projected"] = {k: [float(c) for c in camsolve.project(cam, [points.get(k, PF.world(k))])[0]] for k in PF.VIEWS[tag]["marks"]}
(OUT / f"paladin_report_{STAGE}.json").write_text(json.dumps(report, indent=1), encoding="utf-8") (OUT / f"paladin_report_{STAGE}.json").write_text(json.dumps(report, indent=1), encoding="utf-8")
@ -196,7 +204,7 @@ elif QUICK:
else: else:
M.shot(rig, cam, radius, 0, 0, OUT / f"{STAGE}_character.png", (1328, 800), solved=cams["hero"], box=CHARACTER) M.shot(rig, cam, radius, 0, 0, OUT / f"{STAGE}_character.png", (1328, 800), solved=cams["hero"], box=CHARACTER)
if FULL and not PARTS_ONLY and not os.environ.get("PALADIN_NO_EDGES"): if FULL and not PARTS_ONLY and not os.environ.get("PALADIN_NO_EDGES"):
armour = lambda name: not name.endswith((".machine", ".steel", ".rubber", ".glass", ".glow", ".glow_blue", ".lamp_amber")) and not name.startswith(("Mark", "Tri.")) # noqa: E731 armour = lambda name: name in PH.HARD or (name.startswith(("Torso.", "Turret.")) and not name.endswith((".panels", ".bolts", ".core"))) # noqa: E731 the plates themselves: no panel, fit, bolt or machine
(OUT / f"{STAGE}_edges_hero.json").write_text(json.dumps(M.built_edges(cams["hero"], keep=armour)), encoding="utf-8") (OUT / f"{STAGE}_edges_hero.json").write_text(json.dumps(M.built_edges(cams["hero"], keep=armour)), encoding="utf-8")
print("edges s", round(time.time() - t0, 1), flush=True) print("edges s", round(time.time() - t0, 1), flush=True)
for az in (() if PARTS_ONLY and not os.environ.get("PALADIN_TURNS") else (35, 90, 180, -35) if not QUICK else (35, 90, 180)): for az in (() if PARTS_ONLY and not os.environ.get("PALADIN_TURNS") else (35, 90, 180, -35) if not QUICK else (35, 90, 180)):
@ -205,12 +213,16 @@ if FULL and not os.environ.get("PALADIN_NO_PARTS"):
wy, wz = FR.translation.y, FR.translation.z wy, wz = FR.translation.y, FR.translation.z
P = {k: Vector(v) for k, v in points.items()} P = {k: Vector(v) for k, v in points.items()}
# the sheet's insets, each from about where the inset looks, and the rebuilt plates: (name, target, span, azimuth, elevation) # the sheet's insets, each from about where the inset looks, and the rebuilt plates: (name, target, span, azimuth, elevation)
shots = [("cockpit", (0, wy + 1.2, wz + 2.3), 4.2, -25, 8), ("battery", (2.95, wy + 0.6, wz + 3.5), 4.0, 28, -6), ("ew", (-2.9, wy + 0.6, wz + 3.2), 4.0, -30, 4), ("exchangers", (0, wy - 2.0, wz + 2.0), 5.6, 180, 0), shots = [("cockpit", (0, wy + 1.2, wz + 2.3), 4.2, -25, 8), ("battery", (2.95, wy + 0.6, wz + 3.5), 4.4, -30, -4), ("ew", (-2.9, wy + 0.8, wz + 3.0), 4.4, 32, 6), ("exchangers", (0, wy - 1.6, wz + 2.0), 5.8, 180, 2),
("gatling", tuple((P["elbow_r"] + P["muzzle_r"]) / 2), 4.8, 40, 6), ("hand", tuple(P["wrist_l"]), 3.6, -40, 4), ("gatling", tuple((P["elbow_r"] + P["muzzle_r"]) / 2), 4.6, -42, 4), ("hand", tuple(P["wrist_l"] + Vector((0, 0, -0.6))), 3.4, 6, 2),
("pelvis", (0, 0.8, 5.5), 4.2, 0, 0), ("knee", tuple(P["knee_l"]), 3.6, -55, 4), ("foot", (P["ankle_l"].x, 0.6, 0.6), 4.2, -40, 14), ("pelvis", (0, 0.6, P["hip_r"].z - 0.1), 4.4, 0, 2), ("knee", tuple(P["knee_r"] + Vector((0, 0, -0.3))), 4.0, -62, 4), ("foot", (P["ankle_l"].x, 0.35, 0.95), 5.0, 38, 10),
("pauldron_r", (3.1, wy + 0.3, wz + 1.9), 4.4, 38, 4), ("pauldron_side", (3.1, wy + 0.3, wz + 1.9), 4.4, 90, 2), ("pauldron_rear", (-3.1, wy + 0.3, wz + 1.9), 4.4, 150, 6), ("pauldron_r", (3.1, wy + 0.3, wz + 1.9), 4.6, -34, 2), ("pauldron_side", (3.1, wy + 0.3, wz + 1.7), 5.2, -90, 2), ("pauldron_rear", (-3.1, wy + 0.3, wz + 1.9), 4.8, 150, 4),
("thigh_r", tuple((P["hip_r"] + P["knee_r"]) / 2), 3.8, 25, 2), ("shin_r", tuple((P["knee_r"] + P["ankle_r"]) / 2), 3.8, 25, 2), ("thigh_r", tuple((P["hip_r"] + P["knee_r"]) / 2), 4.0, 12, 2), ("shin_r", tuple((P["knee_r"] + P["ankle_r"]) / 2 + Vector((0, 0, 0.2))), 4.2, -20, 2),
("leg_side", tuple(P["knee_r"]), 6.4, 90, 2), ("forearm_l", tuple((P["elbow_l"] + P["wrist_l"]) / 2), 3.4, -30, 4)] ("leg_side", tuple(P["knee_r"] + Vector((0, -0.2, -0.6))), 7.2, -90, 2), ("forearm_l", tuple((P["elbow_l"] + P["wrist_l"]) / 2), 4.2, 14, 4),
("abdomen", (0, wy + 0.8, wz + 0.5), 4.4, -12, 0), ("leg_rear", tuple((P["knee_l"] + P["ankle_l"]) / 2 + Vector((0, 0, 0.8))), 5.6, 152, 4)]
only = os.environ.get("PALADIN_SHOTS")
if only:
shots = [row for row in shots if row[0] in only.split(",")]
for name, target, span, az, el in shots: for name, target, span, az, el in shots:
M.closeup(rig, cam, Vector(target), 0.42 * span, az, el, OUT / f"part_{name}.png", (700, 620)) M.closeup(rig, cam, Vector(target), 0.42 * span, az, el, OUT / f"part_{name}.png", (700, 620))
bpy.ops.wm.save_as_mainfile(filepath=str(OUT / "paladin.blend")) bpy.ops.wm.save_as_mainfile(filepath=str(OUT / "paladin.blend"))

View file

@ -1,18 +1,17 @@
"""PALADIN's parts (concept sheet images/27.webp), over massing.py, mechlib.Build and the joints and weapons """PALADIN's hull and turret (concept sheet images/27.webp), over massing.py and mechlib.Build. Runs inside Blender.
libraries. Runs inside Blender. Every armoured part is a faceted solid first (mass(): a convex hull of the form's The chest, where the character line landed in the first pass, is kept: a faceted solid first (mass(): a convex hull
points) and plates after (armour(): massing.plate per plate, each frozen by brokkr_kitbash.freeze once its cuts are of the form's points) and plates cut from it (armour(): massing.plate per plate, frozen, the solid drawn back under
in, the solid drawn back under them as the dark core). them as the dark core). The third pass lays detail panels on those plates (paladin_hard.clad_mass over
torso_specs()). The skeleton, the limbs, the pelvis, the abdomen and the pauldrons are paladin_hard.py's.
Tools here, each used by more than one part: Tools here, each used by more than one part:
mass(name, points, frame) a faceted closed solid: the convex hull of points, coplanar triangles merged mass(name, points, frame) a faceted closed solid: the convex hull of points, coplanar triangles merged
armour(prefix, solid, specs) plates off a solid [(name, keep, proud, wall, bevel)], frozen; the solid becomes the core armour(prefix, solid, specs) plates off a solid [(name, keep, proud, wall, bevel)], frozen; the solid becomes the core
limb(a, b) a frame at a, z up the link from b to a, y forward, x to the mech's right put(name, to, fn) / aim(a, b) a Build at a world frame; a weapon's frame along a to b
sided(points, sx) points written with x outboard, for a side sided(points, sx) points written with x outboard, for a side
mark(...) / triangle(...) a stencil seated on whatever a ray hits freeze(obj) brokkr_kitbash.freeze, counted
Parts kept from the first pass, where the character line landed: torso_mass, turret_mass, torso_plates, Parts: torso_mass, turret_mass, torso_plates, turret_plates, visor, hatch, mast, shoulder, exchangers.
turret_plates, visor, hatch, mast, shoulder, exchangers, abdomen, pelvis, hip. The skeleton, the pauldrons and the
limbs' armour are the second pass's: paladin_limbs.py.
""" """
import math import math
@ -123,16 +122,6 @@ def armour(prefix, solid, specs, cutters=(), inset=0.05, plates=True):
return made return made
def limb(a, b):
a, b = Vector(a), Vector(b)
z = (a - b).normalized()
x = (Vector((1, 0, 0)) - z * z.x).normalized()
y = z.cross(x)
m = Matrix((x, y, z)).transposed().to_4x4()
m.translation = a
return m
def put(name, to, fn=None, **kw): def put(name, to, fn=None, **kw):
"""A Build at a frame in the world; fn(build, **kw) draws into it, or the caller does and calls done().""" """A Build at a frame in the world; fn(build, **kw) draws into it, or the caller does and calls done()."""
b = M.Build(name, None, to) b = M.Build(name, None, to)
@ -142,39 +131,6 @@ def put(name, to, fn=None, **kw):
return b.done() return b.done()
def mark(name, text, origin, direction, height, up=UP):
"""A stencil on whatever the ray from origin along direction hits first (the world)."""
M.update()
dg = bpy.context.evaluated_depsgraph_get()
d = Vector(direction).normalized()
hit, at, normal, _, obj, _ = bpy.context.scene.ray_cast(dg, Vector(origin), d)
if not hit:
print(f"MARK {name}: the ray hits nothing", flush=True)
return None
inv = obj.matrix_world.inverted()
frame = inv @ F(at + normal * 0.004, normal, up)
return M.stencil_text(name, obj, frame, text, height)
def triangle(name, origin, direction, size, up=UP):
"""The sheet's hollow triangle mark, point down, seated like mark()."""
M.update()
dg = bpy.context.evaluated_depsgraph_get()
hit, at, normal, _, obj, _ = bpy.context.scene.ray_cast(dg, Vector(origin), Vector(direction).normalized())
if not hit:
return None
g = M.Geo()
frame = F(at + normal * 0.004, normal, up)
yv = (frame.to_3x3() @ Vector((0, 1, 0)))
flip = -1.0 if yv.z > 0 else 1.0 # point down
pts = [(-0.5 * size, -0.45 * size * flip), (0.5 * size, -0.45 * size * flip), (0.0, 0.5 * size * flip)]
t = 0.09 * size
for i in range(3):
a, b = Vector(pts[i]), Vector(pts[(i + 1) % 3])
g.box(frame @ T(((a.x + b.x) / 2, (a.y + b.y) / 2, 0.0)) @ Matrix.Rotation(math.atan2(b.y - a.y, b.x - a.x), 4, "Z"), ((b - a).length + t, t, 0.004))
return g.to_object(name, "stencil")
# --- the character line: torso, turret, pauldrons as solids ---------------------------------------------------------- # --- the character line: torso, turret, pauldrons as solids ----------------------------------------------------------
def _ring(points, z): def _ring(points, z):
@ -214,17 +170,14 @@ def turret_mass(frame, mat=P):
return mass("Turret.mass", both(pts), frame @ T(t["at"]), mat) return mass("Turret.mass", both(pts), frame @ T(t["at"]), mat)
def torso_plates(solid, cutters=(), plates=True): def torso_specs():
"""The hull's plates, cut along the hull's own creases (facets): the glacis plates stand furthest proud and end """The hull's plates as armour() takes them: (name, keep, proud, wall, bevel, facets)."""
on the belt, the band's plates stand under it, so the knuckle is a step; the stem between the band's halves
carries the lamp."""
cx, cy = PF.BELT[2][0], PF.BELT[2][1] cx, cy = PF.BELT[2][0], PF.BELT[2][1]
specs = [("Stem", band("x", -0.43, 0.43) + band("y", 1.2), 0.14, 0.16, 0.04, BANDF), specs = [("Stem", band("x", -0.43, 0.43) + band("y", 1.2), 0.14, 0.16, 0.04, BANDF),
("GlacisC", band("x", -0.45, 0.45) + band("y", 0.4), 0.10, 0.12, 0.04, GLACIS), ("GlacisC", band("x", -0.45, 0.45) + band("y", 0.4), 0.10, 0.12, 0.04, GLACIS),
("Deck", [], 0.04, 0.08, 0.03, DECK), ("Deck", [], 0.04, 0.08, 0.03, DECK),
("GlacisBack", band("x", -1.2, 1.2) + band("y", None, -0.6), 0.10, 0.1, 0.04, GLACIS), ("GlacisBack", band("x", -1.2, 1.2) + band("y", None, -0.6), 0.10, 0.1, 0.04, GLACIS),
("BandBack", band("x", -1.25, 1.25) + band("y", None, -0.8), 0.05, 0.1, 0.04, BANDF) ("BandBack", band("x", -1.25, 1.25) + band("y", None, -0.8), 0.05, 0.1, 0.04, BANDF)] # the keel takes no plate: under the band the hull is the dark core, as the hero view has it
] # the keel takes no plate: under the band the hull is the dark core, as the hero view has it
for sx, s in ((1, "R"), (-1, "L")): for sx, s in ((1, "R"), (-1, "L")):
specs += [("Glacis" + s, out(sx, 0.49) + band("y", 0.3), 0.17, 0.14, 0.05, GLACIS), specs += [("Glacis" + s, out(sx, 0.49) + band("y", 0.3), 0.17, 0.14, 0.05, GLACIS),
("GlacisSide" + s, out(sx, 0.49) + band("y", -0.56, 0.26), 0.13, 0.12, 0.04, GLACIS), ("GlacisSide" + s, out(sx, 0.49) + band("y", -0.56, 0.26), 0.13, 0.12, 0.04, GLACIS),
@ -233,7 +186,22 @@ def torso_plates(solid, cutters=(), plates=True):
("Cheek" + s, out(sx, 1.0) + band("y", 0.28, cy - 0.02), 0.11, 0.14, 0.05, BANDF), ("Cheek" + s, out(sx, 1.0) + band("y", 0.28, cy - 0.02), 0.11, 0.14, 0.05, BANDF),
("Flank" + s, out(sx, 1.0) + band("y", -0.52, 0.24), 0.05, 0.12, 0.04, BANDF), ("Flank" + s, out(sx, 1.0) + band("y", -0.52, 0.24), 0.05, 0.12, 0.04, BANDF),
("Quarter" + s, out(sx, 1.29) + band("y", None, -0.56), 0.08, 0.12, 0.04, BANDF)] ("Quarter" + s, out(sx, 1.29) + band("y", None, -0.56), 0.08, 0.12, 0.04, BANDF)]
return armour("Torso", solid, specs, cutters, plates=plates) return specs
def torso_plates(solid, cutters=(), plates=True):
"""The hull's plates, cut along the hull's own creases (facets): the glacis plates stand furthest proud and end
on the belt, the band's plates stand under it, so the knuckle is a step; the stem between the band's halves
carries the lamp."""
return armour("Torso", solid, torso_specs(), cutters, plates=plates)
def turret_specs():
H = PF.TURRET["height"]
return [("Crown", band("z", 0.6 * H), 0.10, 0.12, 0.04),
("Brow", band("z", 0.22 * H, 0.6 * H - 0.02) + band("y", 0.2), 0.07, 0.14, 0.04),
("Rear", band("z", 0.22 * H, 0.6 * H - 0.02) + band("y", None, 0.16), 0.04, 0.1, 0.03),
("Jaw", band("z", None, 0.22 * H - 0.02), 0.03, 0.1, 0.03)]
def visor_cut(frame): def visor_cut(frame):
@ -242,12 +210,7 @@ def visor_cut(frame):
def turret_plates(solid, cutters=(), plates=True): def turret_plates(solid, cutters=(), plates=True):
H, h = PF.TURRET["height"], PF.TURRET["half"] return armour("Turret", solid, turret_specs(), cutters, plates=plates)
specs = [("Crown", band("z", 0.6 * H), 0.10, 0.12, 0.04),
("Brow", band("z", 0.22 * H, 0.6 * H - 0.02) + band("y", 0.2), 0.07, 0.14, 0.04),
("Rear", band("z", 0.22 * H, 0.6 * H - 0.02) + band("y", None, 0.16), 0.04, 0.1, 0.03),
("Jaw", band("z", None, 0.22 * H - 0.02), 0.03, 0.1, 0.03)]
return armour("Turret", solid, specs, cutters, plates=plates)
def visor(frame): def visor(frame):
@ -355,57 +318,7 @@ def exchangers(frame):
return b.done() return b.done()
def abdomen(frame): # --- weapons' frames -----------------------------------------------------------------------------------------------------
"""Hero view, under the band: a ribbed column down to the waist ring, an armoured pod a side, a hose loop a side."""
b = put("Abdomen", frame)
g, k = b["gunmetal"], b["khaki"]
foot = PF.FOOT_RING[0][2]
for i in range(5):
z = 0.02 + i * (foot - 0.05) / 5
g.box(T((0, 0.25, z + 0.04)), (1.15 - 0.04 * i, 1.5, 0.07))
g.box(T((0, 0.25, z + 0.1)), (0.95, 1.35, 0.06))
for s in (-1, 1):
k.hull([(s * 0.62, 1.0, 0.52), (s * 1.1, 0.85, 0.5), (s * 1.18, 0.5, 0.2), (s * 0.66, 1.08, 0.12), (s * 1.0, 0.95, 0.02), (s * 0.7, 0.6, -0.08), (s * 1.15, 0.45, -0.05), (s * 0.75, 0.55, 0.55), (s * 1.12, 0.4, 0.5)])
path = [(s * 1.25, 0.55, foot - 0.05), (s * 1.6, 0.75, 0.2), (s * 1.45, 0.8, -0.35), (s * 0.95, 0.75, -0.5)]
for a, c in zip(path, path[1:]):
b["rubber"].rod(a, c, 0.06, 8)
return b.done()
# --- the lower body ----------------------------------------------------------------------------------------------------
def pelvis():
"""PELVIS & HIP ASSEMBLY inset: the hip beam; in front a long shield (the codpiece) under a centre block, a
hexagonal wing plate a side; a seat plate behind."""
hz = PF.JOINTS["hip_r"][2]
b = put("PelvisArmour", T((0, PF.JOINTS["hip_r"][1] + 0.05, hz)))
g, k = b["gunmetal"], b["khaki"]
g.hull([(0.95, 0.6, 0.45), (0.95, -0.6, 0.45), (0.95, 0.7, -0.35), (0.95, -0.65, -0.35), (0.6, 0.75, 0.6), (0.6, -0.7, 0.6), (0.55, 0.6, -0.75), (0.55, -0.5, -0.75)], mirror=True)
k.hull([(0.5, 0.78, 0.25), (0.42, 0.74, -1.0), (0.28, 0.76, -1.3), (0.4, 1.05, 0.1), (0.34, 1.12, -0.85), (0.22, 1.0, -1.2), (0.3, 0.95, 0.4)], mirror=True) # the codpiece
k.hull([(0.42, 0.75, 0.3), (0.42, 0.75, 0.82), (0.3, 1.0, 0.36), (0.3, 0.98, 0.74), (0.2, 1.06, 0.55)], mirror=True) # the centre block over it
g.box(T((0, 1.06, -0.55)), (0.34, 0.1, 0.3))
for s in (-1, 1):
k.hull(sided([(0.5, 0.74, 0.2), (0.5, 0.74, 0.75), (1.0, 0.7, 0.95), (1.3, 0.62, 0.7), (1.25, 0.62, 0.3), (0.85, 0.7, 0.05),
(0.6, 0.9, 0.3), (0.6, 0.9, 0.7), (1.0, 0.86, 0.82), (1.18, 0.8, 0.66), (1.15, 0.8, 0.36), (0.85, 0.86, 0.18)], s)) # the wings
k.hull([(0.6, -0.68, 0.5), (0.5, -0.68, -0.6), (0.45, -0.95, 0.3), (0.38, -0.92, -0.45), (0.3, -0.75, -0.85)], mirror=True) # the seat plate
return b.done()
def hip(sx):
"""PELVIS & HIP ASSEMBLY inset: the black ribbed drum between the hip beam and the thigh, on the hip's axis."""
j = PF.JOINTS["hip_r"]
b = put(f"Hip{'L' if sx < 0 else 'R'}", F((sx * 0.9, j[1], j[2]), (sx, 0, 0), UP))
prof, n, L = [(0.0, 0.0), (0.56, 0.0)], 5, 0.5
for i in range(n):
a = L * i / n
prof += [(0.56, a + 0.02), (0.6, a + 0.05), (0.56, a + 0.08), (0.48, a + 0.1)]
prof += [(0.5, L), (0.0, L)]
b["rubber"].lathe(Matrix.Identity(4), prof, 32)
b["machine"].lathe(T((0, 0, L)), [(0.0, 0.0), (0.4, 0.0), (0.4, 0.25), (0.0, 0.25)], 24)
return b.done()
# --- the arms ------------------------------------------------------------------------------------------------------------
def aim(a, b): def aim(a, b):
"""A weapon's frame at a: its y along a to b, its z as near up as that leaves.""" """A weapon's frame at a: its y along a to b, its z as near up as that leaves."""

View file

@ -1,31 +1,31 @@
{ {
"hero": { "hero": {
"C": [ "C": [
3.166359458844853, 5.614148291780706,
18.291375677273702, 44.700490349635146,
5.974887522617769 1.8571274609576252
], ],
"R": [ "R": [
[ [
-0.9954714736026896, -0.9728302716340396,
0.08115547119873885, 0.23150117891287605,
0.049500855929980235 -0.002909768786230698
], ],
[ [
0.07193169063267664, 0.08783216409692861,
0.30264152317512244, 0.3806646900159298,
0.9503862058831489 0.9205324028653886
], ],
[ [
0.06214802592210706, 0.21421198272386857,
0.9496430371169752, 0.8952662162379549,
-0.3071086532959184 -0.3906553833245926
] ]
], ],
"f": 662.9901734726185, "f": 1682.1924689013272,
"c": [ "c": [
130.21617396138112, 387.0739070169202,
-8.096494835726665 -321.09018329016203
], ],
"box": [ "box": [
0, 0,
@ -53,168 +53,181 @@
"battery", "battery",
"ew" "ew"
], ],
"rms": 9.413614568560101, "rms": 11.112046060900926,
"rms_h": null, "rms_h": null,
"median": 7.4647894656702825, "median": 8.596903481561023,
"worst": [ "worst": [
"elbow_l", "elbow_l",
19.36849184371895 24.5230694374321
], ],
"left_out": 13.546097215308682, "left_out": 14.851996229311165,
"model": "free", "model": "free",
"tried": { "tried": {
"upright": {
"rms": 13.326627507554921,
"left_out": 17.544123635906477,
"lens": 289.3776527543492
},
"rolled": {
"rms": 12.918804670610825,
"left_out": 17.23654978068968,
"lens": 470.6904299960795
},
"free": { "free": {
"rms": 9.413614568560101, "rms": 11.112046060900926,
"left_out": 13.546097215308682, "left_out": 14.851996229311165,
"lens": 67.80581319606326 "lens": 172.0424115921812
} }
}, },
"lens": 67.80581319606326, "lens": 172.0424115921812,
"lens_range": [ "lens_range": [
41.12630461015983, 85.43373322551,
136.54413990580977 1040.7959390601275
], ],
"azimuth": -10.104611030137775, "azimuth": -7.214831194853821,
"elevation": -0.12256320906206657, "elevation": -5.4587242646887155,
"distance": 17.599576618585676, "distance": 44.2915048216174,
"roll": 2.9815558772044812, "roll": -0.18110923095308823,
"twist": 0.0, "twist": 0.0,
"horizon": null, "horizon": [
393.0,
392.79123541086733
],
"residuals": { "residuals": {
"waist": [ "waist": [
-3.100717515024485, -1.025548274821091,
6.381766019638803 10.377080365175402
], ],
"hip_r": [ "hip_r": [
-10.256880225845975, -11.681129915101138,
0.9729426056547652 8.294287973771361
], ],
"hip_l": [ "hip_l": [
-13.07068570514491, -9.845833500966933,
3.691232271909911 7.326850290745142
], ],
"knee_r": [ "knee_r": [
-6.339914052849252, -8.13794963278923,
-1.9474494517313587 -0.007983778156130938
], ],
"knee_l": [ "knee_l": [
7.746245524091705, 5.349306744667388,
-3.5552398613211267 -6.462034299672837
], ],
"ankle_r": [ "ankle_r": [
7.461552097820487, 4.468988751356221,
-0.21982278838351021 3.951037786247525
], ],
"ankle_l": [ "ankle_l": [
2.8160587292839523, -0.05805919793118619,
-1.3535641217711145 -2.3494634459045756
], ],
"shoulder_r": [ "shoulder_r": [
11.805185100441605, 8.644666672368373,
-3.2455920283938298 -0.9652669899055013
], ],
"shoulder_l": [ "shoulder_l": [
1.046440049782234, 9.971169926778657,
9.554762163579198 6.3465591435447095
], ],
"elbow_r": [ "elbow_r": [
4.71273710348197, 2.0859710566251692,
1.4689589230843296 7.210405536814164
], ],
"elbow_l": [ "elbow_l": [
19.308119933805187, 24.429440262425317,
-1.5280644364692932 -2.14088371886686
], ],
"muzzle_r": [ "muzzle_r": [
1.3420282081170853, 9.633370916474007,
4.007007253591951 -10.154903717564821
], ],
"wrist_l": [ "wrist_l": [
-12.603986027967153, -15.49132460049293,
3.3310554026264754 -1.0191147468361805
], ],
"lamp": [ "lamp": [
-2.7950268769504873, -4.637443627493013,
-2.8742058071375 -2.0319958600865107
], ],
"visor": [ "visor": [
-1.3709524519653087, 0.33908094016629775,
-9.044443439272825 -8.590213826633885
], ],
"battery": [ "battery": [
-0.8858298796588429, -2.30968720572082,
-6.693660239902719 -5.5001232798583715
], ],
"ew": [ "ew": [
-2.4872678960809935, -3.3335089288172526,
1.5042317151004738 -0.7348346511521981
] ]
}, },
"solved": { "solved": {
"waist": [ "waist": [
0.0, 0.0,
0.05000000074505806, 0.05000000074505806,
6.53479528427124 6.614795207977295
], ],
"hip_r": [ "hip_r": [
1.5047065019607544, 1.5047065019607544,
0.05000000074505806, 0.05000000074505806,
5.368373394012451 5.448373317718506
], ],
"hip_l": [ "hip_l": [
-1.4852867126464844, -1.4852867126464844,
0.05000000074505806, 0.05000000074505806,
5.3662800788879395 5.446280002593994
], ],
"knee_r": [ "knee_r": [
1.7371020317077637, 1.7371020317077637,
0.8613621592521667, 0.8613621592521667,
3.599395275115967 3.6793951988220215
], ],
"knee_l": [ "knee_l": [
-1.635337233543396, -1.635337233543396,
0.8573893308639526, 0.8573893308639526,
3.5866150856018066 3.6666150093078613
], ],
"ankle_r": [ "ankle_r": [
2.078731060028076, 2.078731060028076,
0.14072352647781372, 0.14072352647781372,
0.9989395141601562 1.078939437866211
], ],
"ankle_l": [ "ankle_l": [
-1.8535141944885254, -1.8535141944885254,
0.04823189973831177, 0.04823189973831177,
0.9989395141601562 1.078939437866211
], ],
"shoulder_r": [ "shoulder_r": [
2.863720417022705, 2.861417055130005,
0.30000001192092896, 0.30000001192092896,
8.469656944274902 8.549309730529785
], ],
"shoulder_l": [ "shoulder_l": [
-2.8101675510406494, -2.809788465499878,
0.30000001192092896, 0.30000001192092896,
8.46491813659668 8.544909477233887
], ],
"elbow_r": [ "elbow_r": [
3.138875722885132, 3.1270785331726074,
0.6650422811508179, 0.6493070125579834,
6.677023887634277 6.752115249633789
], ],
"elbow_l": [ "elbow_l": [
-2.85483455657959, -2.8528003692626953,
0.4345642030239105, 0.42835739254951477,
6.620359420776367 6.699869155883789
], ],
"muzzle_r": [ "muzzle_r": [
3.5504469871520996, 3.5282974243164062,
3.397095203399658, 3.3502752780914307,
3.9956448078155518 4.037876129150391
], ],
"wrist_l": [ "wrist_l": [
-2.898378849029541, -2.8949596881866455,
1.1876097917556763, 1.1564668416976929,
4.8221588134765625 4.891395092010498
], ],
"lamp": [ "lamp": [
0.0, 0.0,
@ -239,99 +252,99 @@
}, },
"shift": { "shift": {
"waist": [ "waist": [
-3.100717515024485, -1.025548274821091,
6.381766019638803 10.377080365175402
], ],
"hip_r": [ "hip_r": [
-10.256880225845975, -11.681129915101138,
0.9729426056547652 8.294287973771361
], ],
"hip_l": [ "hip_l": [
-13.07068570514491, -9.845833500966933,
3.691232271909911 7.326850290745142
], ],
"knee_r": [ "knee_r": [
-6.339914052849252, -8.13794963278923,
-1.9474494517313587 -0.007983778156130938
], ],
"knee_l": [ "knee_l": [
7.746245524091705, 5.349306744667388,
-3.5552398613211267 -6.462034299672837
], ],
"ankle_r": [ "ankle_r": [
7.461552097820487, 4.468988751356221,
-0.21982278838351021 3.951037786247525
], ],
"ankle_l": [ "ankle_l": [
2.8160587292839523, -0.05805919793118619,
-1.3535641217711145 -2.3494634459045756
], ],
"shoulder_r": [ "shoulder_r": [
11.805185100441605, 8.644666672368373,
-3.2455920283938298 -0.9652669899055013
], ],
"shoulder_l": [ "shoulder_l": [
1.046440049782234, 9.971169926778657,
9.554762163579198 6.3465591435447095
], ],
"elbow_r": [ "elbow_r": [
4.71273710348197, 2.0859710566251692,
1.4689589230843296 7.210405536814164
], ],
"elbow_l": [ "elbow_l": [
19.308119933805187, 24.429440262425317,
-1.5280644364692932 -2.14088371886686
], ],
"muzzle_r": [ "muzzle_r": [
1.3420282081170853, 9.633370916474007,
4.007007253591951 -10.154903717564821
], ],
"wrist_l": [ "wrist_l": [
-12.603986027967153, -15.49132460049293,
3.3310554026264754 -1.0191147468361805
], ],
"lamp": [ "lamp": [
-2.7950268769504873, -4.637443627493013,
-2.8742058071375 -2.0319958600865107
], ],
"visor": [ "visor": [
-1.3709524519653087, 0.33908094016629775,
-9.044443439272825 -8.590213826633885
], ],
"battery": [ "battery": [
-0.8858298796588429, -2.30968720572082,
-6.693660239902719 -5.5001232798583715
], ],
"ew": [ "ew": [
-2.4872678960809935, -3.3335089288172526,
1.5042317151004738 -0.7348346511521981
] ]
} }
}, },
"rear": { "rear": {
"C": [ "C": [
-22.074827146253003, -30.29616496439471,
-40.54367537122909, -54.69408834889538,
4.880872134117224 1.9245750863480287
], ],
"R": [ "R": [
[ [
0.8803045809036056, 0.8750509038999146,
-0.470549824446539, -0.4811805306580152,
0.06038797523893856 0.05245200186469095
], ],
[ [
-0.054618671581600865, -0.07015680777083319,
0.02591956697507224, -0.01886480406789051,
0.998170815423135 0.9973575795525327
], ],
[ [
-0.47125433213370943, -0.47891955264673525,
-0.8819926523283265, -0.8764185165108911,
-0.002883692781031549 -0.05026575384394426
] ]
], ],
"f": 2046.1791620298611, "f": 2784.619075437834,
"c": [ "c": [
521.0, 521.0,
255.0 255.0
@ -359,151 +372,164 @@
"exch_l", "exch_l",
"exch_r" "exch_r"
], ],
"rms": 9.603166421099951, "rms": 9.897028424272948,
"rms_h": null, "rms_h": null,
"median": 5.674771611102115, "median": 7.360966323878403,
"worst": [ "worst": [
"shoulder_l", "shoulder_l",
21.09784099516896 22.665385023013467
], ],
"left_out": 12.230909619477266, "left_out": 12.415611085690427,
"model": "rolled", "model": "rolled",
"tried": { "tried": {
"upright": {
"rms": 12.093647840751377,
"left_out": 14.781785553709136,
"lens": 191.6016001019942
},
"rolled": { "rolled": {
"rms": 9.603166421099951, "rms": 9.897028424272948,
"left_out": 12.230909619477266, "left_out": 12.415611085690427,
"lens": 217.93624210968937 "lens": 296.5866470880533
},
"free": {
"rms": 7.750614225411807,
"left_out": 14.276982788761433,
"lens": 152.63202270527432
} }
}, },
"lens": 217.93624210968937, "lens": 296.5866470880533,
"lens_range": [ "lens_range": [
88.60626379968123, 120.58313219019499,
1610.343118938627 2191.4953735273725
], ],
"azimuth": 151.70861369186903, "azimuth": 151.21993075323957,
"elevation": -0.935858080298556, "elevation": -3.454810917267296,
"distance": 46.24815059602102, "distance": 62.71128624861954,
"roll": 3.4620969055706596, "roll": 3.0104671663472193,
"twist": 0.0, "twist": 0.0,
"horizon": null, "horizon": [
395.0,
394.9547308857491
],
"residuals": { "residuals": {
"waist": [ "waist": [
-8.911205650679335, -9.580198306124203,
1.697783424377036 0.537231000292735
], ],
"hip_l": [ "hip_l": [
-3.578893315444759, -3.5233227706056027,
3.4697989247594876 1.3971953605049805
], ],
"hip_r": [ "hip_r": [
-3.500524984522599, -3.6163620575576942,
11.057610694004495 10.986328924519853
], ],
"knee_l": [ "knee_l": [
10.538458494388635, 10.530243909713874,
-2.7939850294227426 -3.131804736781646
], ],
"knee_r": [ "knee_r": [
-4.937838229702379, -4.608894141855444,
2.5747254576348837 5.10645282211857
], ],
"ankle_l": [ "ankle_l": [
5.73944830811655, 7.301830000942118,
-0.6897855336575276 -2.863241088090774
], ],
"ankle_r": [ "ankle_r": [
-3.4193736194986286, -1.7129871210553347,
1.2470608122366684 3.891132633840357
], ],
"shoulder_l": [ "shoulder_l": [
-11.699948465380373, -12.108466646777913,
-17.556483149106924 -19.159976871210205
], ],
"shoulder_r": [ "shoulder_r": [
-0.6299309441021705, -1.627773619163122,
2.6063469363401452 2.774096342616815
], ],
"elbow_l": [ "elbow_l": [
-0.19853304887158174, 0.03555886348783588,
2.847328239716802 0.8691414442332075
], ],
"elbow_r": [ "elbow_r": [
9.596606710618062, 9.423179485759306,
-12.948588344128666 -11.317197337022378
], ],
"wrist_l": [ "wrist_l": [
8.851240867757099, 9.323258377935304,
-5.913554093983862 -6.238714224736128
], ],
"exch_l": [ "exch_l": [
-1.5916923900402935, -2.4637956371772134,
0.5415528787390826 1.274568174187408
], ],
"exch_r": [ "exch_r": [
4.060345373902237, 2.464855675252238,
0.20381792846441726 1.4799037836733078
] ]
}, },
"solved": { "solved": {
"waist": [ "waist": [
0.0, 0.0,
0.05000000074505806, 0.05000000074505806,
6.53479528427124 6.614795207977295
], ],
"hip_l": [ "hip_l": [
-1.4852867126464844, -1.4852867126464844,
0.05000000074505806, 0.05000000074505806,
5.3662800788879395 5.446280002593994
], ],
"hip_r": [ "hip_r": [
1.5047065019607544, 1.5047065019607544,
0.05000000074505806, 0.05000000074505806,
5.368373394012451 5.448373317718506
], ],
"knee_l": [ "knee_l": [
-1.635337233543396, -1.635337233543396,
0.8573893308639526, 0.8573893308639526,
3.5866150856018066 3.6666150093078613
], ],
"knee_r": [ "knee_r": [
1.7371020317077637, 1.7371020317077637,
0.8613621592521667, 0.8613621592521667,
3.599395275115967 3.6793951988220215
], ],
"ankle_l": [ "ankle_l": [
-1.8535141944885254, -1.8535141944885254,
0.04823189973831177, 0.04823189973831177,
0.9989395141601562 1.078939437866211
], ],
"ankle_r": [ "ankle_r": [
2.078731060028076, 2.078731060028076,
0.14072352647781372, 0.14072352647781372,
0.9989395141601562 1.078939437866211
], ],
"shoulder_l": [ "shoulder_l": [
-2.8101675510406494, -2.809788465499878,
0.30000001192092896, 0.30000001192092896,
8.46491813659668 8.544909477233887
], ],
"shoulder_r": [ "shoulder_r": [
2.863720417022705, 2.861417055130005,
0.30000001192092896, 0.30000001192092896,
8.469656944274902 8.549309730529785
], ],
"elbow_l": [ "elbow_l": [
-2.85483455657959, -2.8528003692626953,
0.4345642030239105, 0.42835739254951477,
6.620359420776367 6.699869155883789
], ],
"elbow_r": [ "elbow_r": [
3.138875722885132, 3.1270785331726074,
0.6650422811508179, 0.6493070125579834,
6.677023887634277 6.752115249633789
], ],
"wrist_l": [ "wrist_l": [
-2.898378849029541, -2.8949596881866455,
1.1876097917556763, 1.1564668416976929,
4.8221588134765625 4.891395092010498
], ],
"exch_l": [ "exch_l": [
-1.15, -1.15,
@ -518,68 +544,68 @@
}, },
"shift": { "shift": {
"waist": [ "waist": [
-8.911205650679335, -9.580198306124203,
1.697783424377036 0.537231000292735
], ],
"hip_l": [ "hip_l": [
-3.578893315444759, -3.5233227706056027,
3.4697989247594876 1.3971953605049805
], ],
"hip_r": [ "hip_r": [
-3.500524984522599, -3.6163620575576942,
11.057610694004495 10.986328924519853
], ],
"knee_l": [ "knee_l": [
10.538458494388635, 10.530243909713874,
-2.7939850294227426 -3.131804736781646
], ],
"knee_r": [ "knee_r": [
-4.937838229702379, -4.608894141855444,
2.5747254576348837 5.10645282211857
], ],
"ankle_l": [ "ankle_l": [
5.73944830811655, 7.301830000942118,
-0.6897855336575276 -2.863241088090774
], ],
"ankle_r": [ "ankle_r": [
-3.4193736194986286, -1.7129871210553347,
1.2470608122366684 3.891132633840357
], ],
"shoulder_l": [ "shoulder_l": [
-11.699948465380373, -12.108466646777913,
-17.556483149106924 -19.159976871210205
], ],
"shoulder_r": [ "shoulder_r": [
-0.6299309441021705, -1.627773619163122,
2.6063469363401452 2.774096342616815
], ],
"elbow_l": [ "elbow_l": [
-0.19853304887158174, 0.03555886348783588,
2.847328239716802 0.8691414442332075
], ],
"elbow_r": [ "elbow_r": [
9.596606710618062, 9.423179485759306,
-12.948588344128666 -11.317197337022378
], ],
"wrist_l": [ "wrist_l": [
8.851240867757099, 9.323258377935304,
-5.913554093983862 -6.238714224736128
], ],
"exch_l": [ "exch_l": [
-1.5916923900402935, -2.4637956371772134,
0.5415528787390826 1.274568174187408
], ],
"exch_r": [ "exch_r": [
4.060345373902237, 2.464855675252238,
0.20381792846441726 1.4799037836733078
] ]
} }
}, },
"side": { "side": {
"C": [ "C": [
74.22580229606024, 74.38716102391783,
1.0919442264947585, 1.0867354095393869,
3.1052411455157483 3.1905665263986003
], ],
"R": [ "R": [
[ [
@ -588,17 +614,17 @@
0.0 0.0
], ],
[ [
0.027200224236332445, 0.026807534119646575,
-8.327666886778697e-18, -8.20744021316466e-18,
0.9996300054527641 0.9996406134778758
], ],
[ [
0.9996300054527641, 0.9996406134778758,
-3.060484216273447e-16, -3.060516693983443e-16,
-0.027200224236332445 -0.026807534119646575
] ]
], ],
"f": 2919.7828838468417, "f": 2948.5107970655786,
"c": [ "c": [
787.5, 787.5,
255.0 255.0
@ -609,105 +635,105 @@
885.0, 885.0,
510.0 510.0
], ],
"lens": 539.0368400948015, "lens": 544.340454842876,
"lens_band": [ "lens_band": [
89.10219037814785, 89.97887199956014,
4000.0 4000.0
], ],
"lens_at_bound": null, "lens_at_bound": null,
"lens_determined": false, "lens_determined": false,
"planarity": 0.3792378668671132, "planarity": 0.3803437053999393,
"rms": 15.8801286379222, "rms": 15.731784434661295,
"median": 13.848808444460836, "median": 13.050443577754148,
"worst": [ "worst": [
"elbow_r", "waist",
24.03494207571549 24.889856476350324
], ],
"left_out": 25.247651332661736, "left_out": 25.034081386947058,
"model": "square", "model": "square",
"tried": { "tried": {
"square": { "square": {
"rms": 15.8801286379222, "rms": 15.731784434661295,
"left_out": 25.247651332661736, "left_out": 25.034081386947058,
"lens": 539.0368400948015 "lens": 544.340454842876
} }
}, },
"azimuth": -90.07727618296836, "azimuth": -90.075031091139,
"elevation": -2.358974238205676, "elevation": -2.3292904122294646,
"distance": 72.22846781616647, "distance": 72.39295956608372,
"roll": 0.0, "roll": 0.0,
"twist": 0.0, "twist": 0.0,
"plane": null, "plane": null,
"residuals": { "residuals": {
"shoulder_r": [ "shoulder_r": [
-11.848260728081755, -11.878255619995457,
5.248677637534826 3.4512644474176
], ],
"elbow_r": [ "elbow_r": [
11.983137802181659, 11.418361487212792,
20.834655000669528 19.796814144343045
], ],
"muzzle_r": [ "muzzle_r": [
12.734387859403796, 11.69189874446522,
-8.351368649987421 -7.200755696583087
], ],
"knee_r": [ "knee_r": [
-6.7893631168664115, -6.648436325395096,
4.532995703460642 4.220868384057155
], ],
"ankle_r": [ "ankle_r": [
-4.040646791703807, -4.119508123197534,
-10.179161373212764 -9.694296938638217
], ],
"battery": [ "battery": [
6.257884854915687, 6.615788747333909,
-4.439089414332955 -3.5845723406954733
], ],
"waist": [ "waist": [
-18.45012009212894, -18.557546002819777,
-15.388857171879096 -16.586815299102653
], ],
"lamp": [ "lamp": [
9.775359156122022, 10.422459424845442,
11.030673462786325 12.583573803470074
] ]
}, },
"lens_range": [ "lens_range": [
89.10219037814785, 89.97887199956014,
4000.0 4000.0
], ],
"shift": { "shift": {
"shoulder_r": [ "shoulder_r": [
-11.848260728081755, -11.878255619995457,
5.248677637534826 3.4512644474176
], ],
"elbow_r": [ "elbow_r": [
11.983137802181659, 11.418361487212792,
20.834655000669528 19.796814144343045
], ],
"muzzle_r": [ "muzzle_r": [
12.734387859403796, 11.69189874446522,
-8.351368649987421 -7.200755696583087
], ],
"knee_r": [ "knee_r": [
-6.7893631168664115, -6.648436325395096,
4.532995703460642 4.220868384057155
], ],
"ankle_r": [ "ankle_r": [
-4.040646791703807, -4.119508123197534,
-10.179161373212764 -9.694296938638217
], ],
"battery": [ "battery": [
6.257884854915687, 6.615788747333909,
-4.439089414332955 -3.5845723406954733
], ],
"waist": [ "waist": [
-18.45012009212894, -18.557546002819777,
-15.388857171879096 -16.586815299102653
], ],
"lamp": [ "lamp": [
9.775359156122022, 10.422459424845442,
11.030673462786325 12.583573803470074
] ]
} }
} }

View file

@ -1,24 +1,21 @@
"""PALADIN as numbers (concept sheet images/27.webp): the skeleton's targets, the marks on the sheet's three views, """PALADIN as numbers (concept sheet images/27.webp): the skeleton's targets, the marks on the sheet's three views,
the solved cameras, the character line, and the plate edges traced on the views. Plain Python and numpy; no Blender, the solved cameras, the character line, and every hard plate as the faces that bound it. Plain Python and numpy; no
no Pillow. paladin.py builds from it, paladin_sheets.py scores against it. Blender, no Pillow. paladin.py builds from it, paladin_sheets.py scores against it.
Frames. World: x to the mech's right, y forward, z up, metres, origin on the ground under the hips' middle. Torso: Frames. World: x to the mech's right, y forward, z up, metres, origin on the ground under the hips' middle. Torso:
the same axes at WAIST (the waist pin's top). The sheet's pixels are the 1024-wide sheet's own. the same axes at WAIST (the waist pin's top). The sheet's pixels are the 1024-wide sheet's own.
The skeleton is kit parts (bipedkit.py): JOINTS are the targets its limbs are aimed at, and the joints the cameras The skeleton is kit parts (bipedkit.py): JOINTS are the targets its limbs are aimed at, and the joints the cameras
are solved on are read back from the kit as it stands (solve(points)), not from this table. The targets were posed are solved on are read back from the kit as it stands (solve(points)), not from this table.
on the marks: each limb joint moved, across the line of sight only, to where the hero, rear and side marks' sight
lines pass nearest (work/pose_probe.py); the hips and shoulders, which one rigid body carries, are kept symmetric.
The cameras are solved free of any horizon. The first pass held the hero camera's horizon on the row of the The cameras and the horizon (follow-up paladin-hero-horizon-reading). The sheet draws its horizon, the ridge line
soldiers' heads, which stood the eye 1.9 m up and drew the figure from under; the marks alone stand it about and the apron's far edge, at v 393 of the hero's 510: 77% down the frame, a soldier's eye. The first pass held it
5.5 m up, level with the hips, as the sheet draws it (the feet seen from above, the pauldrons' roofs not seen). (eye 1.9 m) and its render's horizon matched the sheet's; the second solved free, stood the eye 6 m up and drew the
horizon 38% down, with the feet seen from above. The marks do not decide the eye (the lens band ran 41 to 137 mm),
the horizon does, so this pass holds it again: HORIZON, in solve().
The character line (BELT) is the chest's knuckle: the hard edge where the sloped glacis under the turret breaks to The character line (BELT) is the chest's knuckle: the hard edge where the sloped glacis under the turret breaks to
the hull's upright band, a shallow chevron in plan with the amber lamp at its stem. the hull's upright band, a shallow chevron in plan with the amber lamp at its stem.
TRACES are plate edges read off the sheet at 8x under a 10 px grid (work/grid.py), a pixel a corner, to about
2 px; corners another plate hides are guessed and named in HIDDEN.
""" """
import json import json
import math import math
@ -42,7 +39,7 @@ JOINTS = {
} }
# The kit skeleton (bipedkit): where the root's pins stand and how long the links are; both sides alike. hip_z is # The kit skeleton (bipedkit): where the root's pins stand and how long the links are; both sides alike. hip_z is
# where the root is first stood: skeleton() sets it down until the soles stand on the ground. # where the root is first stood: skeleton() sets it down until the soles stand on the ground.
KIT = {"hip_span": 2.9, "hip_z": 6.1, "waist_z": 0.75, "hip_drop": 0.42, "pin_r": 0.11, "thigh": 1.96, "shin": 2.72, "ankle_drop": 0.3, "foot": (1.6, 2.0, 0.7), KIT = {"hip_span": 2.9, "hip_z": 6.1, "waist_z": 0.75, "hip_drop": 0.42, "pin_r": 0.11, "thigh": 1.96, "shin": 2.72, "ankle_drop": 0.3, "foot": (2.0, 2.6, 0.78),
"shoulder_sx": 2.8, "shoulder_sz": 2.35, "shoulder_sy": 0.25, "shoulder_drop": 0.42, "arm_pin_r": 0.09, "upper_arm": 1.85, "forearm_l": 1.95, "forearm_r": 1.3} "shoulder_sx": 2.8, "shoulder_sz": 2.35, "shoulder_sy": 0.25, "shoulder_drop": 0.42, "arm_pin_r": 0.09, "upper_arm": 1.85, "forearm_l": 1.95, "forearm_r": 1.3}
# Landmarks that are not joints, world: they hold the cameras where the joints are nearly in one plane. # Landmarks that are not joints, world: they hold the cameras where the joints are nearly in one plane.
LANDMARKS = { LANDMARKS = {
@ -67,7 +64,9 @@ VIEWS = {
"battery": (800, 38), "waist": (765, 215), "lamp": (835, 135)}}, "battery": (800, 38), "waist": (765, 215), "lamp": (835, 135)}},
} }
# --- plate edges traced on the views: {plate: (view, [(u, v) a crown corner, ...])} ------------------------------------ # --- plate edges traced on the views (the second pass's, read at 8x under a 10 px grid to about 2 px) -------------------
# They are NOT fitted to: the second pass lifted them onto its own planes and called that a fit. Here they only score
# the hard plates, whose numbers were read separately: paladin_sheets.py draws them over the built edges.
TRACES = { TRACES = {
"ThighR.Shield": ("hero", [(130, 219), (159, 222), (170, 240), (170, 274), (160, 292), (122, 281), (123, 248)]), "ThighR.Shield": ("hero", [(130, 219), (159, 222), (170, 240), (170, 274), (160, 292), (122, 281), (123, 248)]),
"ThighR.Outer": ("hero", [(120, 189), (133, 187), (129, 218), (108, 262), (96, 262), (104, 225)]), "ThighR.Outer": ("hero", [(120, 189), (133, 187), (129, 218), (108, 262), (96, 262), (104, 225)]),
@ -86,8 +85,10 @@ TRACES = {
"ForearmL.Front": ("hero", [(297, 206), (315, 203), (338, 244), (323, 253)]), "ForearmL.Front": ("hero", [(297, 206), (315, 203), (338, 244), (323, 253)]),
"ForearmL.Outer": ("hero", [(314, 185), (324, 186), (348, 240), (340, 247)]), "ForearmL.Outer": ("hero", [(314, 185), (324, 186), (348, 240), (340, 247)]),
} }
HIDDEN = {"ThighR.Shield": "its lower edge runs under the knee guard", "ThighR.Outer": "its lower corners stand behind the shield", "ThighL.Inner": "its upper corner is in the hip's shadow", # Which built plate each trace is scored against.
"ShinR.Lower": "its foot is behind the ankle block", "PauldronR.Outer": "its rear edge is the silhouette", "ShinL.Inner": "dark on dark: read to about 4 px"} TRACE_OWNER = {"ThighR.Shield": "ThighR.Shield", "ThighR.Outer": "ThighR.Outer", "ThighL.Shield": "ThighL.Shield", "ThighL.Inner": "ThighL.Inner", "ShinR.Upper": "ShinR.Knee", "ShinR.Lower": "ShinR.Greave",
"ShinR.Outer": "ShinR.Outer", "ShinL.Upper": "ShinL.Knee", "ShinL.Lower": "ShinL.Greave", "ShinL.Inner": "ShinL.Inner", "PauldronR.Front": "PauldronR.Front", "PauldronR.Outer": "PauldronR.Outer",
"PauldronL.Front": "PauldronL.Front", "PauldronL.Rear": "PauldronL.Rear", "ForearmL.Front": "ForearmL.Front", "ForearmL.Outer": "ForearmL.Outer"}
# --- the character line ------------------------------------------------------------------------------------------ # --- the character line ------------------------------------------------------------------------------------------
# The belt, torso frame: (x, y) of the knuckle's right half from the stem outboard and round the flank, and its z. # The belt, torso frame: (x, y) of the knuckle's right half from the stem outboard and round the flank, and its z.
@ -113,7 +114,163 @@ TURRET = {"at": (0.0, 0.25, 2.56), "half": 1.3, "front": 1.3, "rear": 0.85, "hei
PAULDRON_AT = (-3.1, 0.3, 1.85) PAULDRON_AT = (-3.1, 0.3, 1.85)
PAULDRON = {"half_y": 1.35, "crown": (0.95, 1.25), "knuckle": (-1.0, -0.15), "foot": (-0.55, -1.05), "inner_foot": (0.75, -0.9), "nose": 0.3} PAULDRON = {"half_y": 1.35, "crown": (0.95, 1.25), "knuckle": (-1.0, -0.15), "foot": (-0.55, -1.05), "inner_foot": (0.75, -0.9), "nose": 0.3}
EXCHANGER = {"x": 1.15, "y": -1.15, "z": (0.75, 3.3), "width": 1.25, "depth": 0.7} EXCHANGER = {"x": 1.15, "y": -1.15, "z": (0.75, 3.3), "width": 1.25, "depth": 0.7}
# The legs' armour, each in a frame along its link (z up the link, y forward, x outboard), lengths in metres.
# --- hard plates (third pass) ----------------------------------------------------------------------------------------
# Every plate of this mech is HARD: the sheet draws each with a faceted outline and none of them curves (KINDS). A
# plate is authored by its faces, the way nibu/fable-bastion-2 does it: slab() is an outline drawn on the plate's
# outer face (a plane through `at` facing `n`), a thickness and a chamfer; house() is a housing of chamfered sections
# down a limb; either becomes a faceted convex solid (massing.hard). On a slab's face `fit` lists what stands on it,
# in the face's own (a, b): a toward `right` (outboard on a front or rear plate, forward on a side plate), b up.
#
# Where the numbers come from, said plainly: they are read by hand off the sheet under a 20 px grid (work/g_*.png),
# to about 3 px, and scaled by the figure's own height in each view (0.0245 m a pixel in the side view, the same
# near the hips in the hero). The hero view gives every width and height; the side view gives the depths of the
# right leg (thigh 1.9 m, the calf block behind the knee); the rear view gives the rear plates. Nothing here is a
# fit: no plate was moved by a solver. The views disagree and the hero wins (mech-lessons-2026-12-03):
# - the side view draws the shin's armour 3.3 m deep (x 708..843); at the hero's turn that would draw 133 px wide
# and the hero draws 83 px (x 67..150). Built 2.15 m deep, which the hero and rear both allow.
# - the hollow triangle is on the right thigh's shield in the hero and on the calf's side block in the side view.
# Built on both.
# - the hero and rear draw the thighs' tops 0.6 m above the hip's pin; the side view hides the thigh behind the gun.
# Limb frames: z up the link from its upper pin, y forward, x outboard (the left side is the right's mirror).
UP, FWD, OUT = (0, 0, 1), (0, 1, 0), (1, 0, 0)
P, P2, CORE = "khaki", "olive_light", "gunmetal"
def slab(at, n, outline, thick, up=UP, right=OUT, taper=0.04, mat=P, clad=True, fit=(), back=1.0, bevel=0.022):
return {"kind": "slab", "at": at, "n": n, "outline": outline, "thick": thick, "up": up, "right": right, "taper": taper, "mat": mat, "clad": clad, "fit": list(fit), "back": back, "bevel": bevel}
def house(sections, mat=CORE, clad=False, bevel=0.02):
return {"kind": "house", "sections": sections, "mat": mat, "clad": clad, "bevel": bevel, "fit": []}
def solid(points, mat=CORE, clad=False, bevel=0.02, mirror=False):
return {"kind": "points", "points": points, "mat": mat, "clad": clad, "bevel": bevel, "fit": [], "mirror": mirror}
def hexa(w, h, c):
"""A rectangle w by h with its four corners cut c: the sheet's commonest plate."""
return [(-w / 2 + c, h / 2), (w / 2 - c, h / 2), (w / 2, h / 2 - c), (w / 2, -h / 2 + c), (w / 2 - c, -h / 2), (-w / 2 + c, -h / 2), (-w / 2, -h / 2 + c), (-w / 2, h / 2 - c)]
# The thigh (hero: the right thigh's shield x 122..175, y 205..292, its outer plate x 92..122; rear: the left thigh's
# rear-outer plate x 432..525, y 195..300). Hip pin at z 0, knee at z -1.96.
THIGH = [
("core", house([(0.4, 0.9, -0.3, 0.5, 0.12), (0.05, 1.2, -0.34, 0.64, 0.18), (-1.45, 1.2, -0.34, 0.64, 0.18), (-1.8, 0.95, -0.3, 0.5, 0.14)])),
("Shield", slab((0.02, 0.90, -0.5), (0.06, 1, 0.05), [(-0.42, 0.98), (0.42, 0.98), (0.66, 0.5), (0.66, -0.52), (0.42, -1.0), (-0.42, -1.0), (-0.66, -0.52), (-0.66, 0.5)], 0.26,
fit=[("mark", 0.0, -0.05), ("bolts", 0.09, 0.3)])),
("Block", slab((0.02, 1.0, 0.12), (0.06, 1, 0.05), hexa(0.56, 0.44, 0.08), 0.16, mat=P2, clad=False, fit=[("slot", 0.0, 0.0, 0.3, 0.16)])),
("Lame", slab((0.02, 0.985, -1.17), (0.06, 1, 0.02), [(-0.52, 0.2), (0.52, 0.2), (0.58, 0.0), (0.4, -0.26), (-0.4, -0.26), (-0.58, 0.0)], 0.14, mat=P2, clad=False,
fit=[("slot", 0.0, -0.02, 0.44, 0.1), ("handle", 0.0, -0.02, 0.4)])),
("Outer", slab((0.86, 0.0, -0.45), (1, 0.08, 0.04), [(-0.5, 1.0), (0.36, 1.05), (0.68, 0.5), (0.68, -0.6), (0.3, -1.02), (-0.5, -0.86), (-0.74, -0.2), (-0.74, 0.5)], 0.24, right=FWD,
fit=[("bolts", 0.09, 0.34)])),
("OuterStep", slab((0.95, -0.02, -0.25), (1, 0.08, 0.04), hexa(0.8, 0.9, 0.2), 0.13, right=FWD, mat=P2, clad=False, fit=[("port", -0.05, 0.12, 0.13), ("vents", 0.0, -0.27, 0.4, 0.035, 2)])),
("Inner", slab((-0.82, 0.05, -0.75), (-1, 0.1, 0), [(-0.55, 0.55), (0.5, 0.55), (0.62, 0.15), (0.5, -0.7), (-0.45, -0.7), (-0.62, -0.15)], 0.2, right=FWD, fit=[("bolts", 0.08, 0.34)])),
("Rear", slab((0, -0.98, -0.25), (0, -1, 0.05), [(-0.46, 0.72), (0.46, 0.72), (0.64, 0.3), (0.64, -0.4), (0.42, -0.72), (-0.42, -0.72), (-0.64, -0.4), (-0.64, 0.3)], 0.22,
fit=[("bolts", 0.09, 0.34), ("handle", 0.0, 0.42, 0.4)])),
("RearStep", slab((0, -1.06, -0.3), (0, -1, 0.05), hexa(0.7, 0.5, 0.1), 0.12, mat=P2, clad=False, fit=[("vents", 0.0, 0.0, 0.42, 0.035, 3)])),
("CornerOut", slab((0.7, 0.7, -0.45), (0.72, 0.7, 0.04), hexa(0.3, 1.5, 0.08), 0.2, clad=False, fit=[("bolts", 0.06, 0.3)])),
("CornerIn", slab((-0.67, 0.7, -0.6), (-0.72, 0.7, 0.03), hexa(0.26, 1.1, 0.07), 0.18, clad=False)),
("Cap", slab((0.0, 0.12, 0.66), (0, 0.3, 1), [(-0.5, -0.5), (0.5, -0.5), (0.6, 0.1), (0.36, 0.44), (-0.36, 0.44), (-0.6, 0.1)], 0.18, up=FWD, fit=[("bolts", 0.08, 0.3), ("eye", 0.0, -0.2)])),
]
# The shin (hero: the knee guard x 104..151, y 285..330, the greave x 100..150, y 320..400, the outer blocks
# x 67..100; side: the calf's side block x 708..800, y 312..398; rear: the calf plate x 440..560, y 320..385).
# Knee pin at z 0, ankle pin at z -2.72.
SHIN = [
("core", house([(-0.3, 0.9, -0.3, 0.5, 0.12), (-0.65, 1.14, -0.34, 0.6, 0.18), (-1.9, 1.06, -0.34, 0.56, 0.18), (-2.5, 0.8, -0.3, 0.4, 0.12)])),
("Knee", slab((0, 1.0, 0.02), (0, 1, 0.22), [(-0.4, 0.56), (0.4, 0.56), (0.62, 0.22), (0.62, -0.3), (0.42, -0.56), (-0.42, -0.56), (-0.62, -0.3), (-0.62, 0.22)], 0.28,
fit=[("bolts", 0.08, 0.3), ("step", hexa(0.6, 0.4, 0.1), 0.0, 0.08, 0.06)])),
("KneeSide", slab((0.7, 0.72, 0.0), (0.75, 0.66, 0.1), hexa(0.34, 0.9, 0.1), 0.2, clad=False, fit=[("bolts", 0.06, 0.3)])),
("KneeSideIn", slab((-0.7, 0.72, 0.0), (-0.75, 0.66, 0.1), hexa(0.34, 0.9, 0.1), 0.2, clad=False)),
("Greave", slab((0, 0.88, -1.3), (0, 1, -0.07), [(-0.5, 0.72), (0.5, 0.72), (0.66, 0.4), (0.6, -0.5), (0.36, -0.95), (-0.36, -0.95), (-0.6, -0.5), (-0.66, 0.4)], 0.28,
fit=[("bolts", 0.09, 0.32)])),
("GreaveStep", slab((0, 0.97, -1.2), (0, 1, -0.07), hexa(0.62, 0.84, 0.12), 0.15, mat=P2, clad=False, fit=[("slot", 0.0, 0.08, 0.3, 0.44), ("handle", 0.0, -0.3, 0.3)])),
("Outer", slab((0.82, -0.2, -1.05), (1, 0.04, 0), [(-0.75, 0.62), (0.34, 0.74), (0.74, 0.36), (0.7, -0.55), (0.28, -0.96), (-0.6, -0.82), (-0.95, -0.1)], 0.26, right=FWD,
fit=[("bolts", 0.09, 0.36)])),
("OuterStep", slab((0.92, -0.2, -1.0), (1, 0.04, 0), [(-0.42, 0.42), (0.2, 0.46), (0.46, 0.2), (0.44, -0.3), (0.16, -0.5), (-0.36, -0.44), (-0.56, -0.05)], 0.13, right=FWD, mat=P2, clad=False,
fit=[("mark2", -0.03, -0.02)])),
("Inner", slab((-0.78, -0.12, -1.1), (-1, 0.04, 0), [(-0.7, 0.55), (0.3, 0.66), (0.66, 0.3), (0.62, -0.5), (0.25, -0.86), (-0.55, -0.74), (-0.85, -0.1)], 0.22, right=FWD,
fit=[("bolts", 0.09, 0.36), ("port", -0.1, 0.0, 0.14)])),
("Calf", slab((0, -1.12, -0.95), (0, -1, 0.1), [(-0.5, 0.62), (0.5, 0.62), (0.68, 0.1), (0.5, -0.62), (-0.5, -0.62), (-0.68, 0.1)], 0.22,
fit=[("bolts", 0.09, 0.34), ("handle", -0.24, 0.3, 0.26), ("handle", 0.24, 0.3, 0.26)])),
("CalfStep", slab((0, -1.2, -1.05), (0, -1, 0.1), hexa(0.72, 0.46, 0.1), 0.12, mat=P2, clad=False, fit=[("vents", 0.0, 0.0, 0.44, 0.035, 3)])),
("Ankle", slab((0, 0.66, -2.42), (0, 1, -0.2), hexa(0.8, 0.52, 0.12), 0.2, mat=P2, fit=[("bolts", 0.07, 0.3)])),
("AnkleSide", slab((0.6, 0.1, -2.35), (1, 0.1, -0.1), hexa(0.7, 0.5, 0.12), 0.16, right=FWD, clad=False, fit=[("bolts", 0.06, 0.3)])),
]
# The pelvis (PELVIS & HIP ASSEMBLY inset, x 400..630, y 745..915: the crown block, a wing a side rising outboard, the
# long codpiece with a stepped lame, the black ribbed hip drums; rear view: a pentagonal seat plate a side, x 530..600,
# y 195..275). The hip beam's frame: origin on the hip axis' middle, x right, y forward, z up. `sided` plates are
# authored on the right.
PELVIS = [
("core", solid([(0.62, 0.62, 0.5), (0.62, -0.6, 0.5), (0.72, 0.7, -0.3), (0.72, -0.62, -0.3), (0.45, 0.7, 0.62), (0.45, -0.66, 0.62), (0.4, 0.55, -0.8), (0.4, -0.45, -0.8)], mirror=True), False),
("Crown", slab((0, 1.0, 0.42), (0, 1, 0.16), [(-0.32, 0.3), (0.32, 0.3), (0.48, 0.04), (0.3, -0.3), (-0.3, -0.3), (-0.48, 0.04)], 0.3, fit=[("bolts", 0.07, 0.3), ("slot", 0.0, 0.02, 0.26, 0.1)]), False),
("Cod", slab((0, 1.06, -0.62), (0, 1, -0.1), [(-0.36, 0.7), (0.36, 0.7), (0.44, 0.3), (0.3, -0.78), (-0.3, -0.78), (-0.44, 0.3)], 0.34, fit=[("bolts", 0.08, 0.3)]), False),
("CodStep", slab((0, 1.17, -0.3), (0, 1, -0.1), hexa(0.5, 0.42, 0.1), 0.14, mat=P2, clad=False, fit=[("slot", 0.0, 0.0, 0.26, 0.2)]), False),
("CodLame", slab((0, 1.15, -1.02), (0, 1, -0.1), hexa(0.42, 0.4, 0.08), 0.13, mat=P2, clad=False, fit=[("handle", 0.0, 0.0, 0.24)]), False),
("Wing", slab((0.92, 0.84, 0.5), (0.3, 1, 0.2), [(-0.46, -0.02), (0.44, 0.36), (0.54, 0.1), (0.44, -0.26), (-0.46, -0.36)], 0.22, fit=[("bolts", 0.07, 0.3)]), True),
("HipGuard", slab((0.62, 0.92, -0.05), (0.2, 1, -0.05), hexa(0.34, 0.5, 0.08), 0.16, mat=P2, clad=False, fit=[("bolts", 0.05, 0.3)]), True),
("Seat", slab((0.56, -0.86, 0.02), (0.22, -1, 0.1), [(-0.5, 0.66), (0.5, 0.72), (0.6, -0.2), (0.2, -0.86), (-0.5, -0.6)], 0.24, fit=[("bolts", 0.09, 0.34), ("handle", 0.0, 0.4, 0.34)]), True),
("SeatStep", slab((0.6, -0.95, 0.1), (0.22, -1, 0.1), hexa(0.56, 0.6, 0.12), 0.12, mat=P2, clad=False, fit=[("vents", 0.0, 0.0, 0.34, 0.035, 3)]), True),
("Tail", slab((0, -0.92, -0.2), (0, -1, -0.05), hexa(0.36, 1.3, 0.1), 0.22, mat=P2, fit=[("bolts", 0.06, 0.3)]), False),
("Roof", slab((0.62, 0.0, 0.7), (0.25, 0, 1), hexa(0.6, 1.1, 0.14), 0.14, up=FWD, clad=False, fit=[("bolts", 0.07, 0.3)]), True),
]
# The abdomen (hero, x 165..245, y 140..200): a ribbed column on the waist ring, an armoured pod a side with a round
# port, a keel plate between them, hose loops outboard. Torso frame (origin at the waist pin's top).
ABDOMEN = [
("Pod", slab((0.82, 1.02, 0.42), (0.45, 1, 0.12), [(-0.34, 0.34), (0.3, 0.4), (0.44, 0.1), (0.36, -0.36), (-0.2, -0.42), (-0.42, -0.1)], 0.3, fit=[("port", 0.0, 0.03, 0.15), ("bolts", 0.06, 0.3)]), True),
("PodSide", slab((1.2, 0.5, 0.42), (1, 0.25, 0.05), hexa(0.7, 0.66, 0.14), 0.22, right=FWD, mat=P2, fit=[("bolts", 0.06, 0.3)]), True),
("Keel", slab((0, 1.18, 0.5), (0, 1, 0.1), [(-0.3, 0.36), (0.3, 0.36), (0.36, 0.1), (0.22, -0.4), (-0.22, -0.4), (-0.36, 0.1)], 0.24, mat=P2, fit=[("vents", 0.0, 0.08, 0.3, 0.035, 3)]), False),
("Back", slab((0, -0.8, 0.5), (0, -1, 0.05), hexa(1.3, 0.8, 0.16), 0.2, fit=[("bolts", 0.08, 0.34)]), False),
]
# A pauldron (hero: the right's front face x 85..121, y 58..126 with the 07, its front-outboard facet x 45..87,
# y 73..123, a lip block under it; rear: the left's rear face x 451..493, y 38..133; side: x 715..790, y 85..150).
# Its own frame at PAULDRON_AT (x outboard).
PAULDRON = [
("core", solid([(-0.9, 1.0, 1.15), (-0.9, -1.0, 1.15), (0.45, 0.95, 0.72), (0.45, -0.95, 0.72), (0.86, 1.0, -0.1), (0.86, -1.0, -0.1), (0.5, 0.8, -0.95), (0.5, -0.8, -0.95),
(-0.8, 0.85, -0.85), (-0.8, -0.85, -0.85), (0.0, 1.22, 0.1), (0.0, -1.22, 0.1), (-0.9, 1.1, 0.2), (-0.9, -1.1, 0.2)])),
("Front", slab((-0.12, 1.36, 0.12), (0.12, 1, 0.24), [(-0.72, 0.98), (0.3, 1.0), (0.62, 0.5), (0.62, -0.5), (0.3, -0.98), (-0.72, -0.7)], 0.28, fit=[("num", 0.0, 0.18), ("bolts", 0.09, 0.34)])),
("FrontLip", slab((-0.1, 1.42, -0.5), (0.12, 1, 0.1), hexa(0.56, 0.4, 0.08), 0.16, mat=P2, clad=False, fit=[("slot", 0.0, 0.0, 0.34, 0.16)])),
("Outer", slab((0.82, 0.86, 0.05), (0.72, 0.62, 0.3), [(-0.36, 0.86), (0.4, 0.62), (0.5, -0.5), (0.1, -0.9), (-0.36, -0.86)], 0.26, fit=[("bolts", 0.08, 0.34), ("mark3", 0.02, -0.1)])),
("Side", slab((1.02, -0.2, 0.08), (1, -0.03, 0.34), [(-0.9, 0.76), (0.62, 0.76), (0.62, -0.5), (0.3, -0.98), (-0.5, -0.98), (-0.98, -0.3)], 0.26, right=FWD,
fit=[("bolts", 0.09, 0.36), ("vents", -0.2, 0.3, 0.44, 0.04, 3), ("port", -0.2, -0.35, 0.14)])),
("SideLame", slab((1.0, -0.2, -0.98), (1, -0.03, 0.12), hexa(1.1, 0.36, 0.1), 0.16, right=FWD, mat=P2, clad=False, fit=[("bolts", 0.05, 0.3)])),
("SideLame2", slab((0.9, -0.2, -1.26), (1, -0.03, 0.05), hexa(0.86, 0.3, 0.08), 0.14, right=FWD, clad=False, fit=[("bolts", 0.05, 0.3)])),
("Rear", slab((-0.12, -1.36, 0.12), (0.12, -1, 0.24), [(-0.72, 0.98), (0.3, 1.0), (0.62, 0.5), (0.62, -0.5), (0.3, -0.98), (-0.72, -0.7)], 0.28, fit=[("bolts", 0.09, 0.34), ("handle", -0.1, 0.5, 0.4)])),
("RearStep", slab((-0.1, -1.44, -0.1), (0.12, -1, 0.24), hexa(0.7, 0.6, 0.12), 0.13, mat=P2, clad=False, fit=[("vents", 0.0, 0.0, 0.4, 0.04, 3)])),
("Roof", slab((-0.2, 0.0, 1.3), (0.3, 0, 1), hexa(1.4, 2.1, 0.2), 0.2, up=FWD, fit=[("bolts", 0.09, 0.4)])),
]
# An upper arm (hero: the right's x 62..100, y 130..175; short, dark and ribbed under the pauldron, an outer plate
# and a front plate). Frame: shoulder pin at z 0, elbow at z -1.85.
UPPER_ARM = [
("Outer", slab((0.52, 0.0, -0.9), (1, 0, 0.04), [(-0.42, 0.52), (0.42, 0.52), (0.5, -0.1), (0.32, -0.6), (-0.32, -0.6), (-0.5, -0.1)], 0.18, right=FWD, fit=[("bolts", 0.07, 0.3), ("port", 0.0, 0.14, 0.1)])),
("OuterLame", slab((0.58, 0.0, -1.2), (1, 0, 0.04), hexa(0.6, 0.28, 0.08), 0.1, right=FWD, mat=P2, clad=False)),
("Front", slab((0, 0.54, -0.9), (0, 1, 0), hexa(0.66, 1.0, 0.12), 0.16, fit=[("bolts", 0.06, 0.3)])),
("Rear", slab((0, -0.54, -0.9), (0, -1, 0), hexa(0.66, 0.9, 0.12), 0.14, mat=P2, fit=[("vents", 0.0, 0.0, 0.34, 0.035, 3)])),
]
# The left forearm (LEFT FOREARM inset and hero x 285..345, y 185..255): a faceted housing from the elbow to the
# wrist, stepped plates down its front and outer faces. Frame: elbow pin at z 0, wrist pin at z -1.95.
FOREARM = [
("house", house([(-0.15, 0.6, -0.34, 0.3, 0.1), (-0.5, 0.84, -0.44, 0.42, 0.14), (-1.75, 0.84, -0.44, 0.42, 0.14), (-2.0, 0.64, -0.34, 0.32, 0.1)])),
("Front", slab((0, 0.56, -1.05), (0, 1, 0.03), hexa(0.74, 1.4, 0.14), 0.16, fit=[("bolts", 0.06, 0.3)])),
("Step0", slab((0, 0.62, -0.62), (0, 1, 0.03), hexa(0.56, 0.34, 0.08), 0.1, mat=P2, clad=False)),
("Step1", slab((0, 0.62, -1.05), (0, 1, 0.03), hexa(0.56, 0.34, 0.08), 0.1, mat=P2, clad=False, fit=[("slot", 0.0, 0.0, 0.3, 0.1)])),
("Step2", slab((0, 0.62, -1.48), (0, 1, 0.03), hexa(0.56, 0.34, 0.08), 0.1, mat=P2, clad=False)),
("Outer", slab((0.56, 0.0, -1.05), (1, 0, 0), hexa(0.8, 1.5, 0.16), 0.16, right=FWD, fit=[("bolts", 0.06, 0.3), ("vents", 0.0, 0.3, 0.3, 0.035, 3), ("num", 0.0, -0.3)])),
("Inner", slab((-0.54, 0.0, -1.05), (-1, 0, 0), hexa(0.74, 1.3, 0.14), 0.14, right=FWD, mat=P2, fit=[("port", 0.0, 0.2, 0.09)])),
("Rear", slab((0, -0.58, -1.05), (0, -1, 0), hexa(0.7, 1.3, 0.14), 0.14, fit=[("bolts", 0.06, 0.3)])),
]
# What the plates' "mark" entries carry, by side: the hero's hollow triangle on the right thigh and the 07 on the left;
# the side view's triangle on the right calf block; the 07 on the right pauldron's front.
MARKS = {("Thigh", "R", "mark"): ("tri", 0.5), ("Thigh", "L", "mark"): ("07", 0.42), ("Shin", "R", "mark2"): ("tri", 0.4), ("Pauldron", "R", "num"): ("07", 0.4),
("Pauldron", "L", "mark3"): ("tri", 0.34), ("Forearm", "L", "num"): ("07", 0.3)}
# Hard or soft, a plate (mech-lessons-2026-12-03): every one is hard. The round forms are turned machinery.
KINDS = {f"{part}.{name}": "hard" for part, table in (("Thigh", THIGH), ("Shin", SHIN), ("Pelvis", PELVIS), ("Abdomen", ABDOMEN), ("Pauldron", PAULDRON), ("UpperArm", UPPER_ARM), ("Forearm", FOREARM))
for name, *_ in table}
# The paint over paint.py's "paladin" preset: the sheet's armour is a grey khaki under an overcast sky, lighter than the preset's olive.
PAINT = {"base_color": (0.088, 0.083, 0.062)}
# The horizon the sheet draws behind the figure (the ridge line and the apron's far edge): the sheet's v, per view.
HORIZON = {"hero": 393.0, "rear": 395.0}
def world(name): def world(name):
@ -126,10 +283,9 @@ def cameras():
def solve(points=None, write=True): def solve(points=None, write=True):
"""The three cameras from the marks and `points` (world, by name: the kit's joints as they stand, the landmarks; """The three cameras from the marks and `points` (world, by name: the kit's joints as they stand, the landmarks;
JOINTS and LANDMARKS where absent). Hero and rear by camsolve with no horizon held (the free model, or the better of upright and JOINTS and LANDMARKS where absent). Hero and rear by camsolve with the sheet's horizon held (HORIZON), the model
rolled where the free one stands the eye under the ground); the side view square-on that predicts left-out marks best; the side view square-on along x by brokkr_reference.core. Each camera carries
along x by brokkr_reference.core. Each camera also carries "shift": per marked name, how far the point as built "shift": per marked name, how far the point as built is drawn from its mark (du, dv)."""
is drawn from its mark (du, dv): what a trace near that joint is moved by before it is fitted."""
import camsolve import camsolve
W_all = {k: list(v) for k, v in (JOINTS | LANDMARKS).items()} W_all = {k: list(v) for k, v in (JOINTS | LANDMARKS).items()}
W_all.update({k: [float(c) for c in v] for k, v in (points or {}).items()}) W_all.update({k: [float(c) for c in v] for k, v in (points or {}).items()})
@ -144,12 +300,11 @@ def solve(points=None, write=True):
cam = core.solve(W, Px, view["box"], model="square") cam = core.solve(W, Px, view["box"], model="square")
cam["lens_range"] = cam["lens_band"] cam["lens_range"] = cam["lens_band"]
else: else:
cam = camsolve.solve(W, Px, view["box"], model="free") cam = camsolve.solve(W, Px, view["box"], horizon=HORIZON[tag])
if cam["C"][2] < 1.0: # a free centre can trade the eye's height away: this one stood under the ground
tried = [camsolve.solve(W, Px, view["box"], model=m) for m in ("upright", "rolled")]
cam = min([c for c in tried if c["C"][2] >= 1.0] or tried, key=lambda c: c["rms"])
cam["shift"] = {k: [float(v) for v in r] for k, r in cam["residuals"].items()} cam["shift"] = {k: [float(v) for v in r] for k, r in cam["residuals"].items()}
out[tag] = cam out[tag] = cam
if cam.get("horizon"):
print(f"CAMERA {tag}: horizon marked at v {cam['horizon'][0]:.0f} ({(cam['horizon'][0] - view['box'][1]) / (view['box'][3] - view['box'][1]):.0%} of the frame), the camera's at {cam['horizon'][1]:.0f}", flush=True)
print(f"CAMERA {tag}: {cam['model']}, lens {cam['lens']:.0f} mm (range {cam['lens_range'][0]:.0f}..{cam['lens_range'][1]:.0f}), azimuth {cam['azimuth']:.1f}, elevation {cam['elevation']:.1f}, " print(f"CAMERA {tag}: {cam['model']}, lens {cam['lens']:.0f} mm (range {cam['lens_range'][0]:.0f}..{cam['lens_range'][1]:.0f}), azimuth {cam['azimuth']:.1f}, elevation {cam['elevation']:.1f}, "
f"distance {cam['distance']:.1f} m, eye {cam['C'][2]:.2f} m up, rms {cam['rms']:.1f} px, left-out {cam['left_out']:.1f} px, worst {cam['worst'][0]} {cam['worst'][1]:.1f}", flush=True) f"distance {cam['distance']:.1f} m, eye {cam['C'][2]:.2f} m up, rms {cam['rms']:.1f} px, left-out {cam['left_out']:.1f} px, worst {cam['worst'][0]} {cam['worst'][1]:.1f}", flush=True)
if write: if write:

View file

@ -0,0 +1,481 @@
"""PALADIN's third pass (concept sheet images/27.webp): the kit skeleton and every limb, the pelvis, the abdomen and
the pauldrons as HARD plates, each authored by its faces (paladin_form's tables; the method of nibu/fable-bastion-2's
bastion_form), with stepped, bolted detail panels on top. Runs inside Blender.
The second pass's limbs were free-cage shells 0.015 m thick lifted from traces; they read thin and their fit did no
work. Nothing of that is kept: a plate here is a convex faceted solid 0.13 to 0.34 m thick (massing.hard), so there
is no wall to fold; its numbers are read off the sheet by hand (paladin_form says how, and where the views disagree).
Tools here, each used by more than one part:
part(prefix, tag, table, frame, host, sx) a table of paladin_form plates built at a frame, mirrored for the left,
clad, fitted and adopted to the kit part that carries them
disc(g, at, r, w) / drum(g, at, r, length) a bearing's stepped, bolted cover; a ribbed drum or bellows
hose(name, host, a, da, b, db, r) mechlib.hose between two world points, adopted to a kit part
clad_mass(prefix, solid, specs) detail panels on a mass's facets, clipped to each plate cut from it
Parts: skeleton, joint_points; leg; pelvis; abdomen; pauldron; upper_arm; forearm_left (handkit's hand, the weapons
library's emitter); hoses.
"""
import math
import random
import bpy
from mathutils import Matrix, Vector
import bipedkit as BK
import massing as MS
import mechlib as M
import paladin_form as PF
from paladin_body import CORE, UP, F, T, aim, freeze, put
KITS = {}
HARD = {} # every hard plate's report: kind, corners, facets
COUNT = {"panels": 0, "fits": 0, "marks": 0, "hoses": 0, "rams": 0, "failed": []}
P, P2 = PF.P, PF.P2
MARKING = {"mark", "mark2", "mark3", "num"}
def skeleton():
"""The kit tree, as the second pass stood it: hipbeam; per leg a cross (hip_splay), a thigh link (hip_pitch), a
shin link (knee), an ankle cross (ankle_pitch, ankle_roll) and feet.paladin_hoof (its toes' pins); trunk on the
waist pin; per arm a cross (shoulder_abduct), an upper arm (shoulder_pitch) and a forearm (elbow). Every
connection is a pivot with limits. The left hand's pins are handkit's (forearm_left)."""
import feet
M.cache_kits()
k, J = PF.KIT, PF.JOINTS
pel = M.place("hipbeam", "Pelvis", mat="gunmetal", span=k["hip_span"], depth=1.0, height=0.7, pin_r=k["pin_r"], waist_r=0.8, waist_z=k["waist_z"])
pel.matrix_world = T((0.0, J["hip_r"][1], k["hip_z"]))
M.update()
legs, feet_ = {}, {}
fw, fl, fd = k["foot"]
for s, sx in (("L", -1), ("R", 1)):
leg_ = BK.limb(f"Leg{s}", pel, f"hip_{s.lower()}", (J[f"knee_{s.lower()}"], J[f"ankle_{s.lower()}"]), (k["thigh"], k["shin"]), [(0.6, 0.7), (0.55, 0.6)], k["pin_r"],
cross=(k["hip_drop"], 0.7), names=("hip_splay", "hip_pitch", "knee"), limits=((-8, 30), (-40, 70), (-5, 100)),
toward=((sx, 0, 0), (0, 1, 0), (0, -1, 0)), mat="gunmetal", splay_at=1)
if legs:
want = M.sockets(legs["L"]["lower"])["clevis"].translation.z
bpy.ops.brokkr_kitbash.reach(object_name=leg_["lower"].name, socket="clevis", height=want, direction_x=0.0, direction_y=0.0, direction_z=1.0)
M.update()
BK.record(leg_["lower"], "knee", -5, 100, toward=(0, -1, 0))
foot = feet.paladin_hoof(f"Foot{s}", None, width=fw, length=fl, drop=fd, pin_r=k["pin_r"])
leg_["ankle"] = BK.ankle(f"Leg{s}", leg_["lower"], foot.core, k["ankle_drop"], k["pin_r"], 0.7)
foot.done()
legs[s], feet_[s] = leg_, foot
M.update()
sole = min((f.core.matrix_world @ Vector((0, 0, fd))).z for f in feet_.values())
pel.matrix_world = T((0.0, J["hip_r"][1], k["hip_z"] - sole))
M.update()
trunk = M.attach(M.place("trunk", "Trunk", mat="gunmetal", waist_r=0.8, pin_r=k["arm_pin_r"], sx=k["shoulder_sx"], sy=k["shoulder_sy"], sz=k["shoulder_sz"], depth=0.9), "base", pel, "waist", 0.0)
BK.record(trunk, "waist_yaw", -50, 50)
arms = {}
for s, sx in (("L", -1), ("R", 1)):
end = J["wrist_l"] if sx < 0 else J["muzzle_r"]
arms[s] = BK.limb(f"Arm{s}", trunk, f"shoulder_{s.lower()}", (J[f"elbow_{s.lower()}"], end), (k["upper_arm"], k["forearm_l"] if sx < 0 else k["forearm_r"]), [(0.5, 0.6), (0.45, 0.5)],
k["arm_pin_r"], cross=(k["shoulder_drop"], 0.6), names=("shoulder_abduct", "shoulder_pitch", "elbow"), limits=((-10, 70), (-60, 150), (-5, 120)),
toward=((sx, 0, 0), (0, 1, 0), (0, 1, 0)), mat="gunmetal")
KITS.update(pelvis=pel, trunk=trunk, legs=legs, arms=arms, feet=feet_)
return KITS
def joint_points():
"""The kit's joints as they stand, world, named as paladin_form names them: what the cameras are solved on."""
M.update()
out = {"waist": KITS["trunk"].matrix_world.translation.copy()}
for s in ("L", "R"):
leg_, arm, t = KITS["legs"][s], KITS["arms"][s], s.lower()
out[f"hip_{t}"] = leg_["upper"].matrix_world.translation.copy()
out[f"knee_{t}"] = leg_["lower"].matrix_world.translation.copy()
out[f"ankle_{t}"] = M.sockets(leg_["lower"])["clevis"].translation
out[f"shoulder_{t}"] = arm["upper"].matrix_world.translation.copy()
out[f"elbow_{t}"] = arm["lower"].matrix_world.translation.copy()
out["wrist_l"] = M.sockets(KITS["arms"]["L"]["lower"])["clevis"].translation
reach = (Vector(PF.JOINTS["muzzle_r"]) - Vector(PF.JOINTS["elbow_r"])).length
out["muzzle_r"] = KITS["arms"]["R"]["lower"].matrix_world @ Vector((0, 0, reach))
return {name: tuple(p) for name, p in out.items()}
# --- tools -----------------------------------------------------------------------------------------------------------
def _mx(v, sx):
return Vector((sx * v[0], v[1], v[2]))
def _flat(obj):
for p in obj.data.polygons:
p.use_smooth = False
return obj
def _fits(spec, PMw, face, geos, key, clad, z0):
"""What stands on a slab's outer face (paladin_form's `fit` entries), at PMw (the face's frame in the world: x the
outline's a, y its b, z out). Geometry goes into geos[material]; marks and handles go through surface.py on
`face` (a massing.Face on the plate)."""
import surface as S
n, b = PMw.col[2].xyz.normalized(), PMw.col[1].xyz.normalized()
at = lambda x, y, z=0.0: PMw @ Vector((x, y, z0 + z)) # noqa: E731
upright = lambda x, y, z=0.0, up=None: M.frame_at(at(x, y, z), n, up or b) # noqa: E731 a right-handed frame on the face
g, dark = geos.setdefault("gunmetal", M.Geo()), geos.setdefault("pit", M.Geo())
rim = geos.setdefault(spec["mat"], M.Geo())
for kind, *a in spec["fit"]:
try:
if kind == "bolts":
inset, spacing = (0.04, a[1]) if clad else a
flat = [Vector(p) for p in spec["outline"]]
ring = M._inset(flat if sum(flat[i].x * flat[(i + 1) % len(flat)].y - flat[(i + 1) % len(flat)].x * flat[i].y for i in range(len(flat))) > 0 else flat[::-1], inset + spec["taper"])
frames = []
for i in range(len(ring)):
p, q = ring[i], ring[(i + 1) % len(ring)]
count = max(1, int((q - p).length / spacing))
frames += [upright(*(p.lerp(q, (j + 0.5) / count)), -z0) for j in range(count)]
S.bolt_row(face, frames, r=0.019, mat="gunmetal")
elif kind == "slot":
x, y, w, h = a
dark.box(upright(x, y, 0.006), (w, h, 0.012))
for dx, dy, sw, sh in ((0, h / 2 + 0.018, w + 0.07, 0.036), (0, -h / 2 - 0.018, w + 0.07, 0.036), (w / 2 + 0.018, 0, 0.036, h), (-w / 2 - 0.018, 0, 0.036, h)):
rim.box(upright(x + dx, y + dy, 0.016), (sw, sh, 0.032))
elif kind == "vents":
x, y, w, h, count = a
pitch = 2.7 * h
for i in range(count):
yy = y + (i - (count - 1) / 2) * pitch
dark.box(upright(x, yy, 0.005), (w, h, 0.01))
rim.box(upright(x, yy + 0.75 * h, 0.014) @ Matrix.Rotation(math.radians(-28), 4, "X"), (w + 0.04, 0.9 * h, 0.012))
elif kind == "port":
x, y, r = a
fr = upright(x, y)
geos.setdefault("machine", M.Geo()).lathe(fr, [(0, 0), (r, 0), (r, 0.035), (0.82 * r, 0.05), (0.82 * r, 0.022), (0.34 * r, 0.022), (0.34 * r, 0.045), (0, 0.045)], 28)
g.bolts(fr @ T((0, 0, 0.035)), 0.91 * r, 8, 0.07 * r, 0.012)
elif kind == "handle":
x, y, length = a
S.grab_handle(face, upright(x, y) @ Matrix.Rotation(math.radians(90), 4, "Z"), length=length, lift=0.075, r=0.018)
elif kind == "eye":
S.lifting_eye(face, upright(a[0], a[1]), size=0.11)
elif kind == "step":
outline, x, y, lift = a
MS.panel(geos.setdefault(P2 if spec["mat"] == P else P, M.Geo()), [at(x + px, y + py) for px, py in outline], lift=lift, inset=0.0, out=n, bolts=g)
elif kind in MARKING:
what = PF.MARKS.get(key + (kind,))
if what is None:
continue
text, height = what
fr = M.frame_at(at(a[0], a[1], 0.003), n, (0, 0, 1)) # a mark stands upright in the world, whatever the plate's lean
if text == "tri":
S.emblem(face, fr, "triangle", height, "marking")
else:
S.numeral(face, fr, text, height, "marking")
COUNT["marks"] += 1
continue
else:
raise ValueError(f"no fit named {kind}")
COUNT["fits"] += 1
except Exception as error: # a fit that fails is listed and left out, not hidden
COUNT["failed"].append(f"{'.'.join(key[:2])} {kind}: {type(error).__name__} {str(error)[:100]}")
def part(prefix, tag, table, frame, host, sx=1, seed=0, only=None):
"""A table of plates [(name, spec[, sided])] built at `frame` (a world matrix: the table's own frame, x outboard on
a limb), mirrored across the frame's x for sx -1, each a massing.hard solid; a slab's outer face is clad (a raised
panel, split in two at uneven lifts where it carries no mark) and takes its fits. Everything is adopted to
`host`. A table row with a third entry is the pelvis's and the abdomen's: True builds it once a side.
Returns {name: object}."""
made, rnd = {}, random.Random(seed)
for row in table:
name, spec = row[0], row[1]
sides = ((1, "R"), (-1, "L")) if len(row) > 2 and row[2] else ((sx, tag),)
for s, t in sides:
full = f"{prefix}{t}.{name}" if t else f"{prefix}.{name}"
if only and not only(full):
continue
if spec["kind"] == "slab":
pts = MS.slab_points(spec["at"], spec["n"], spec["outline"], spec["thick"], spec["taper"], spec["up"], spec["right"], spec["back"])
elif spec["kind"] == "house":
pts = MS.section_points(spec["sections"])
else:
pts = list(spec["points"]) + ([(-x, y, z) for x, y, z in spec["points"] if abs(x) > 1e-6] if spec.get("mirror") else [])
obj = MS.hard(full, [frame @ _mx(p, s) for p in pts], None, spec["mat"], bevel=spec["bevel"])
obj["plate_kind"] = PF.KINDS.get(f"{prefix}.{name}", "hard")
HARD[full] = {"kind": obj["plate_kind"], "corners": len(obj.data.vertices), "facets": len(obj.data.polygons), "thick": spec.get("thick")}
made[full] = obj
if spec["kind"] != "slab":
continue
a, b, n = MS.plane_basis(spec["n"], spec["up"], spec["right"])
PM = Matrix((_mx(a, s), _mx(b, s), _mx(n, s))).transposed().to_4x4()
PM.translation = _mx(spec["at"], s)
PMw = frame @ PM
nw = PMw.col[2].xyz.normalized()
geos, lift = {}, 0.0
marked = any(k[0] in MARKING and PF.MARKS.get((prefix, t, k[0])) for k in spec["fit"])
if spec["clad"]:
lift = 0.05
g = geos.setdefault(P2 if spec["mat"] == P else P, M.Geo())
plain = marked or any(k[0] in ("slot", "port", "vents", "handle", "eye", "step") for k in spec["fit"])
COUNT["panels"] += MS.clad(obj, g, keep=lambda fn, c: fn.dot(nw) > 0.97, min_area=0.2, lifts=(lift, lift) if plain else (0.04, 0.07), inset=0.075, gap=0.045,
split=99.0 if plain else 0.8, seed=rnd.randrange(1 << 20), bolts=geos.setdefault("gunmetal", M.Geo()))
face = MS.Face(obj, "gunmetal")
_fits(spec, PMw, face, geos, (prefix, t), spec["clad"], lift)
face.done()
for mat, g in geos.items():
if len(g.bm.verts):
o = g.to_object(f"{full}.fit.{mat}", mat, obj, 1.0 if mat in (P, P2) else 30.0)
if mat in (P, P2):
mod = o.modifiers.new("Bevel", "BEVEL")
mod.width, mod.segments, mod.limit_method, mod.angle_limit = 0.01, 1, "ANGLE", math.radians(20)
_flat(o)
M.update()
for obj in made.values():
for o in [obj] + list(obj.children):
if o.type == "MESH":
freeze(o)
BK.adopt(host, list(made.values()))
return made
def disc(g, at, r, w, rings=3, bolts=12):
"""A bearing's cover (KNEE & LEG DETAIL inset; the rear view's knee and ankle): a drum along at's z from 0 to w,
its outer face stepped in `rings` rings to a hub, a bolt circle on its rim."""
prof = [(0, 0), (r, 0), (r, 0.72 * w)]
for k in range(rings):
r0, r1 = r * (1 - 0.8 * k / rings), r * (1 - 0.8 * (k + 0.55) / rings)
z = w * (0.72 + 0.28 * (k % 2))
prof += [(r0, z), (r1, z)]
prof += [(0.16 * r, w * 1.05), (0, w * 1.05)]
g.lathe(at, prof, 40)
g.bolts(at @ T((0, 0, 0.72 * w)), 0.9 * r, bolts, 0.04 * r, 0.05 * r)
return g
def drum(g, at, r, length, ribs=5, depth=0.08):
"""A ribbed drum or bellows along at's z (PELVIS & HIP ASSEMBLY inset: the black coils between the hip beam and a
thigh; the abdomen's column)."""
prof = [(0.0, 0.0), (r - depth, 0.0)]
for i in range(ribs):
z = length * i / ribs
step = length / ribs
prof += [(r - depth, z + 0.12 * step), (r, z + 0.3 * step), (r, z + 0.7 * step), (r - depth, z + 0.88 * step)]
prof += [(r - depth, length), (0.0, length)]
g.lathe(at, prof, 36)
return g
def hose(name, host, a, da, b, db, r=0.05, sag=0.0, via=(), stiffness=0.45):
"""mechlib.hose between two world points, leaving along da and arriving against db, with its ferrules, adopted to
`host` (the hose is laid as the figure stands: it does not follow a pose)."""
M.hose(name, a, da, b, db, r, sag=sag, via=via, stiffness=stiffness)
BK.adopt(host, [o for o in (bpy.data.objects.get(name), bpy.data.objects.get(name + ".ferrules")) if o is not None])
COUNT["hoses"] += 1
def machine(name, host, build, mat="machine", smooth=38.0):
g = M.Geo()
build(g)
obj = g.to_object(name, mat, None, smooth)
BK.adopt(host, [obj])
return obj
def clad_mass(prefix, solid, specs, lift=0.045, inset=0.11, min_area=0.3, take=None):
"""Detail plating on a mass whose plates are cut from it by half-spaces (paladin_body.armour's specs): every
facet of the mass, clipped to each plate that takes it, carries a raised panel standing `lift` over that
plate's own height; a panel over 1.4 square metres is split in two at uneven lifts. `take(normal)` picks the
facets. Returns the panels made."""
rnd = random.Random(7)
gp, gb, made = M.Geo(), M.Geo(), 0
for pts, n, area in MS.facets(solid, 0.2):
if take and not take(n):
continue
for name, keep, proud, wall, bevel, *pick in specs:
if pick and not pick[0](n):
continue
poly = list(pts)
for hn, hd in keep:
hn = Vector(hn)
poly = MS._clip(poly, hn * (hd / hn.length_squared), hn.normalized()) if len(poly) >= 3 else poly
if len(poly) < 3:
continue
c = sum(poly, Vector()) / len(poly)
size = 0.5 * sum(((poly[i] - c).cross(poly[(i + 1) % len(poly)] - c)).length for i in range(len(poly)))
if size < min_area:
continue
parts = [poly]
if size > 1.4:
k = max(range(len(poly)), key=lambda i: (poly[(i + 1) % len(poly)] - poly[i]).length)
p, q = poly[k], poly[(k + 1) % len(poly)]
way, cut = (q - p).normalized(), p + (q - p) * rnd.uniform(0.38, 0.62)
parts = [MS._clip(poly, cut - way * 0.03, way), MS._clip(poly, cut + way * 0.03, -way)]
for i, piece in enumerate(parts):
if len(piece) >= 3 and MS.panel(gp, [v + n * proud for v in piece], lift=lift + 0.025 * ((i + made) % 2), inset=inset, out=n, sink=0.5 * proud, bolts=gb) is not None:
made += 1
out = []
for g, mat, tag in ((gp, P2, "panels"), (gb, "gunmetal", "bolts")):
if len(g.bm.verts):
o = g.to_object(f"{prefix}.{tag}", mat, None, 1.0 if mat == P2 else 30.0)
o.matrix_world = solid.matrix_world.copy()
if mat == P2:
mod = o.modifiers.new("Bevel", "BEVEL")
mod.width, mod.segments, mod.limit_method, mod.angle_limit = 0.012, 1, "ANGLE", math.radians(20)
_flat(o)
M.update()
freeze(o)
out.append(o)
COUNT["panels"] += made
return made
# --- legs ------------------------------------------------------------------------------------------------------------
def leg_frames(s):
leg_ = KITS["legs"][s]
return BK.frame(leg_["upper"]), BK.frame(leg_["lower"])
def leg(s, sx):
"""One leg (hero and rear views, the side view for the right's depths; KNEE & LEG DETAIL inset for the knee's
disc): the thigh and the shin as stepped hard blocks over dark cores open to the rear, where the machinery shows:
a ram across the back of the knee seated by the kit (mechlib.joint_ram), bearing covers at knee and ankle, two
struts down the calf to the ankle, ribs between the plates."""
up, lo = KITS["legs"][s]["upper"], KITS["legs"][s]["lower"]
Ft, Fs = leg_frames(s)
Lt, Ls = PF.KIT["thigh"], PF.KIT["shin"]
ram = M.joint_ram(f"Knee{s}", up, lo, 0.1, hub=0.42)
if ram is not None:
COUNT["rams"] += 1
BK.record(ram, "knee_ram", -50, 50) # the ram's own pin: it follows the knee
else:
COUNT["failed"].append(f"Knee{s}: no ram seat fits")
made = part("Thigh", s, PF.THIGH, Ft, up, sx, seed=11)
made.update(part("Shin", s, PF.SHIN, Fs, lo, sx, seed=12))
def thigh_machinery(g):
for z in (-0.25, -0.7, -1.15): # ribs showing in the gaps between the plates
g.box(Ft @ T((0, 0.14, z)), (1.36, 1.16, 0.07))
machine(f"Thigh{s}.ribs", up, thigh_machinery, "machine")
def knee_machinery(g):
g.cylinder(Fs @ Matrix.Rotation(math.radians(90), 4, "Y"), 0.36, 1.34, 36)
for side in (-1, 1):
disc(g, Fs @ M.frame_at((side * 0.67, 0, 0), (side, 0, 0), UP), 0.4, 0.2, rings=3, bolts=12)
machine(f"Knee{s}.bearing", up, knee_machinery, "machine")
def shin_machinery(g):
for z in (-0.95, -1.5, -2.05):
g.box(Fs @ T((0, 0.12, z)), (1.26, 1.0, 0.07))
for side in (-1, 1):
disc(g, Fs @ M.frame_at((side * 0.42, 0, -Ls), (side, 0, 0), UP), 0.38, 0.18, rings=2, bolts=10)
for x in (-0.3, 0.3): # the calf's struts to the ankle (rear view, x 480..540, y 385..425)
g.rod(Fs @ Vector((x, -0.62, -1.55)), Fs @ Vector((x, -0.42, -2.62)), 0.085, 12)
g.cylinder(Fs @ M.frame_at((x - 0.1, -0.62, -1.55), (1, 0, 0), UP), 0.13, 0.2, 14)
g.cylinder(Fs @ M.frame_at((x - 0.1, -0.42, -2.62), (1, 0, 0), UP), 0.11, 0.2, 14)
machine(f"Shin{s}.machinery", lo, shin_machinery, "machine")
machine(f"Shin{s}.rods", lo, lambda g: [g.rod(Fs @ Vector((x, -0.6, -1.2)), Fs @ Vector((x, -0.62, -1.55)), 0.12, 14) for x in (-0.3, 0.3)], "gunmetal")
# hoses (hero: the loop inboard of the left knee, x 212..228, y 295..335; rear: the bundle behind each knee)
for i, (x, r) in enumerate(((-sx * 0.5, 0.055), (-sx * 0.36, 0.04), (sx * 0.5, 0.045))):
hose(f"Knee{s}.hose{i}", up, Ft @ Vector((x, -0.36, -1.2 - 0.1 * i)), Ft.to_3x3() @ Vector((1.2 * (1 if x > 0 else -1), -1, -0.3)),
Fs @ Vector((x, -0.4, -0.7 - 0.08 * i)), Fs.to_3x3() @ Vector((0.8 * (1 if x > 0 else -1), -1, 0.4)), r, stiffness=0.6)
hose(f"Ankle{s}.hose", lo, Fs @ Vector((-sx * 0.3, -0.45, -2.0)), Fs.to_3x3() @ Vector((-sx, -1, -0.2)), Fs @ Vector((-sx * 0.25, -0.5, -Ls - 0.15)), Vector((-sx * 0.3, -1, 0.5)), 0.04, stiffness=0.55)
return made
# --- pelvis and abdomen ------------------------------------------------------------------------------------------------
def pelvis():
"""PELVIS & HIP ASSEMBLY inset, the hero and the rear view: the hip beam's dark block; in front the crown block,
a wing a side, the long codpiece with its step and lame; behind a pentagonal seat plate a side and a tail plate;
a black ribbed drum on the hip's axis between the block and each thigh; hoses from the block to each thigh."""
pel = KITS["pelvis"]
M.update()
Fp = pel.matrix_world.copy()
made = part("Pelvis", "", PF.PELVIS, Fp, pel, seed=21)
span = 0.5 * PF.KIT["hip_span"]
def drums(g):
for sx in (-1, 1):
drum(g, Fp @ M.frame_at((sx * 0.66, 0, 0), (sx, 0, 0), UP), 0.6, span - 0.66 - 0.5, ribs=4, depth=0.09)
machine("Pelvis.hip_drums", pel, drums, "rubber")
machine("Pelvis.hip_collars", pel, lambda g: [g.lathe(Fp @ M.frame_at((sx * (span - 0.52), 0, 0), (sx, 0, 0), UP), [(0.5, 0), (0.66, 0), (0.66, 0.1), (0.5, 0.1)], 36) for sx in (-1, 1)], "machine")
for sx, s in ((-1, "L"), (1, "R")):
Ft = BK.frame(KITS["legs"][s]["upper"])
for i, (y, r) in enumerate(((-0.5, 0.06), (-0.3, 0.045), (0.45, 0.05))):
hose(f"Hip{s}.hose{i}", pel, Fp @ Vector((sx * 0.5, y, 0.56)), Vector((sx * 0.6, -0.3 if y < 0 else 0.3, 1)), Ft @ Vector((-sx * 0.25 + sx * 0.2 * i, y * 0.7, 0.42)), Ft.to_3x3() @ Vector((0, 0, 1)), r, stiffness=0.75)
return made
def abdomen(frame):
"""Hero view under the chest's band (x 165..245, y 140..200) and the rear view: a ribbed column on the waist
ring, an armoured pod a side with a round port, a keel plate, a back plate; hose loops outboard of the pods from
under the band down to the hip block, as the hero draws them at x 115..140, y 155..185."""
trunk, pel = KITS["trunk"], KITS["pelvis"]
foot = PF.FOOT_RING[0][2]
machine("Abdomen.column", trunk, lambda g: drum(g, frame @ T((0, 0.1, 0.0)), 0.92, foot + 0.3, ribs=6, depth=0.12), "rubber")
machine("Abdomen.rings", trunk, lambda g: [g.lathe(frame @ T((0, 0.1, z)), [(0.78, 0), (1.0, 0), (1.0, 0.07), (0.78, 0.07)], 36) for z in (0.0, foot + 0.24)], "machine")
made = part("Abdomen", "", PF.ABDOMEN, frame, trunk, seed=31)
Fp = pel.matrix_world
for sx, s in ((-1, "L"), (1, "R")):
for i, (y, r, reach) in enumerate(((0.75, 0.07, 1.75), (0.45, 0.055, 1.6), (-0.3, 0.06, 1.55))):
hose(f"Waist{s}.hose{i}", trunk, frame @ Vector((sx * 1.35, y, foot + 0.3)), Vector((sx * 0.5, 0.15, -1)), Fp @ Vector((sx * 0.5, y * 0.6, 0.62)), Vector((sx * 0.4, 0, 1)), r,
via=[frame @ Vector((sx * reach, y * 0.9, 0.25))], stiffness=0.5)
return made
# --- pauldrons and arms --------------------------------------------------------------------------------------------------
def pauldron_frame(frame, sx):
at = PF.PAULDRON_AT
return frame @ T((-sx * at[0], at[1], at[2]))
def pauldron(frame, sx):
"""Hero (the right pauldron), rear (the left) and side views: a faceted hood whose roof falls outboard, a hard
shield on its front, its front-outboard facet, its side and its rear, each stepped and bolted; a lip block under
the front shield; two lames stepping down under the side shield; the roof a plate of its own with a grab rail."""
s = "L" if sx < 0 else "R"
Fp = pauldron_frame(frame, sx)
made = part("Pauldron", s, PF.PAULDRON, Fp, KITS["trunk"], sx, seed=41)
def rail(g):
g.rod(Fp @ Vector((-sx * 0.8, -0.8, 1.5)), Fp @ Vector((-sx * 0.8, 0.8, 1.5)), 0.03, 8)
for y in (-0.8, 0.0, 0.8):
g.rod(Fp @ Vector((-sx * 0.8, y, 1.3)), Fp @ Vector((-sx * 0.8, y, 1.5)), 0.03, 8)
machine(f"Pauldron{s}.rail", KITS["trunk"], rail, "gunmetal")
return made
def arm_frames(s):
arm = KITS["arms"][s]
return BK.frame(arm["upper"]), BK.frame(arm["lower"])
def upper_arm(s, sx):
"""Hero view: a short dark upper arm under the pauldron, ribbed; hard plates on its outer, front and rear faces, a
lame on the outer; the elbow's drum on its pin with a bearing cover a side; a hose from the arm to the forearm."""
Fu, Ff = arm_frames(s)
L = PF.KIT["upper_arm"]
host = KITS["arms"][s]["upper"]
def body(g):
g.box(Fu @ T((0, 0, -0.5 * L)), (0.66, 0.76, L))
for i in range(5):
g.box(Fu @ T((0, 0, -0.25 - 0.26 * i)), (0.8, 0.9, 0.08))
g.cylinder(Fu @ T((0, 0, -L)) @ Matrix.Rotation(math.radians(90), 4, "Y"), 0.42, 0.96, 28)
machine(f"UpperArm{s}.body", host, body, "gunmetal")
machine(f"UpperArm{s}.elbow", host, lambda g: [disc(g, Fu @ M.frame_at((side * 0.48, 0, -L), (side, 0, 0), UP), 0.38, 0.14, rings=2, bolts=10) for side in (-1, 1)], "machine")
made = part("UpperArm", s, PF.UPPER_ARM, Fu, host, sx, seed=51)
hose(f"Elbow{s}.hose", host, Fu @ Vector((-sx * 0.2, -0.46, -1.1)), Fu.to_3x3() @ Vector((0, -1, -0.5)), Ff @ Vector((-sx * 0.2, -0.42, -0.5)), Ff.to_3x3() @ Vector((0, -1, 0.6)), 0.045, stiffness=0.6)
return made
def forearm_left():
"""LEFT FOREARM - MANIPULATOR & ENERGY inset and the hero view: a faceted housing from the elbow to the wrist with
stepped plates down its front, the 07 on its outer plate; on the wrist's pin a hand whose knuckles are kit pins
(handkit.hand); beside the housing the emitter (the weapons library's paladin_energy_emitter, class S)."""
import handkit
import weapons_energy
Fu, Ff = arm_frames("L")
L = PF.KIT["forearm_l"]
host = KITS["arms"]["L"]["lower"]
made = part("Forearm", "L", PF.FOREARM, Ff, host, -1, seed=61)
hand = handkit.hand("HandL", host, width=0.74, drop=0.5, depth=0.26, pin_r=PF.KIT["arm_pin_r"])
z, side = Ff.to_3x3() @ Vector((0, 0, 1)), Ff.to_3x3() @ Vector((-1, 0, 0))
E_, W_ = Ff.translation, Ff @ Vector((0, 0, -L))
put("Emitter", aim(E_ + side * 0.86 - z * 0.7, W_ + side * 0.86 - z * 0.7), weapons_energy.paladin_energy_emitter, size="S")
BK.adopt(host, [o for o in bpy.data.objects if o.parent is None and o.name.startswith("Emitter")])
return made, hand

View file

@ -1,522 +0,0 @@
"""PALADIN's second pass (concept sheet images/27.webp): the kit skeleton and the sculpted plates. Runs inside Blender.
The skeleton is kit parts whose every joint is a pin with a record (skeleton(), over bipedkit.py and feet.py's
paladin_hoof). Everything else is built in the world on the kit's frames and parented to the kit part that carries
it (bipedkit.Adopt / adopt), so the build follows brokkr_kitbash.roll.
The limbs' and pauldrons' armour is sculpted plates: free cages of 2N + 1 vertices (platecage.py). The big ones are
blocked by lifting their traced edges (paladin_form.TRACES) onto a plane of the limb and fitted to those traces by
brokkr_reference's fit (plate(trace=...)); a plate the sheet hides on one side is the other side's fitted crown
mirrored (PC.mirrored); the plates under and on them are derived from the fitted crowns (PC.grown, PC.patch), so they
layer as the sheet layers them: a base plate standing back under each shield, blocks and lames proud of it. The
detail pass is surface.Skin on those shells (dress()), after which each shell is frozen.
Tools here, each used by more than one part:
plate(name, frame, ...) one free-cage plate: traced and fitted, or from a crown
on_plane(point, normal, pts) / extent(crown) a crown authored in a plane; a crown's span in its own plane
dress(name, steps) surface.Skin on a plate, features placed in its crown's plane
bolts / inset / port / slots / numeral / line / dings feature makers for dress()
tri_on(name, size) / stowage(b, frame, size)
Parts: skeleton; pauldron_core, pauldron_shields, pauldron_layers; leg_cores, leg_shields, leg_layers, knee;
upper_arm, forearm_left.
"""
import math
import bpy
import numpy as np
from mathutils import Matrix, Vector
import bipedkit as BK
import mechlib as M
import paladin_form as PF
import platecage as PC
from paladin_body import CORE, UP, F, T, aim, freeze, mass, put, sided, triangle
CAMS = {} # the solved cameras, set by paladin.py once the skeleton stands
KITS = {} # the skeleton's parts, by name
DRESS_FAILED = []
DRESSED = [0]
def skeleton():
"""The kit tree: hipbeam; per leg a cross (hip_splay), a thigh link (hip_pitch), a shin link (knee), an ankle
cross (ankle_pitch, ankle_roll) and feet.paladin_hoof (its toes' pitch pins); trunk on the waist pin
(waist_yaw); per arm a cross (shoulder_abduct), an upper arm (shoulder_pitch) and a forearm (elbow). Every
connection is a pivot with limits. The right shin is re-solved (brokkr_kitbash.reach) so both ankle pins stand
at one height, and the root is set down so the soles stand on z = 0."""
import feet
M.cache_kits()
k, J = PF.KIT, PF.JOINTS
pel = M.place("hipbeam", "Pelvis", mat="gunmetal", span=k["hip_span"], depth=1.0, height=0.7, pin_r=k["pin_r"], waist_r=0.8, waist_z=k["waist_z"])
pel.matrix_world = T((0.0, J["hip_r"][1], k["hip_z"]))
M.update()
legs, feet_ = {}, {}
fw, fl, fd = k["foot"]
for s, sx in (("L", -1), ("R", 1)):
leg = BK.limb(f"Leg{s}", pel, f"hip_{s.lower()}", (J[f"knee_{s.lower()}"], J[f"ankle_{s.lower()}"]), (k["thigh"], k["shin"]), [(0.6, 0.7), (0.55, 0.6)], k["pin_r"],
cross=(k["hip_drop"], 0.7), names=("hip_splay", "hip_pitch", "knee"), limits=((-8, 30), (-40, 70), (-5, 100)),
toward=((sx, 0, 0), (0, 1, 0), (0, -1, 0)), mat="gunmetal", splay_at=1)
if legs:
want = M.sockets(legs["L"]["lower"])["clevis"].translation.z
bpy.ops.brokkr_kitbash.reach(object_name=leg["lower"].name, socket="clevis", height=want, direction_x=0.0, direction_y=0.0, direction_z=1.0)
M.update()
BK.record(leg["lower"], "knee", -5, 100, toward=(0, -1, 0))
foot = feet.paladin_hoof(f"Foot{s}", None, width=fw, length=fl, drop=fd, pin_r=k["pin_r"])
leg["ankle"] = BK.ankle(f"Leg{s}", leg["lower"], foot.core, k["ankle_drop"], k["pin_r"], 0.7)
foot.done()
legs[s], feet_[s] = leg, foot
M.update()
sole = min((f.core.matrix_world @ Vector((0, 0, fd))).z for f in feet_.values())
pel.matrix_world = T((0.0, J["hip_r"][1], k["hip_z"] - sole))
M.update()
trunk = M.attach(M.place("trunk", "Trunk", mat="gunmetal", waist_r=0.8, pin_r=k["arm_pin_r"], sx=k["shoulder_sx"], sy=k["shoulder_sy"], sz=k["shoulder_sz"], depth=0.9), "base", pel, "waist", 0.0)
BK.record(trunk, "waist_yaw", -50, 50)
arms = {}
for s, sx in (("L", -1), ("R", 1)):
end = J["wrist_l"] if sx < 0 else J["muzzle_r"]
arms[s] = BK.limb(f"Arm{s}", trunk, f"shoulder_{s.lower()}", (J[f"elbow_{s.lower()}"], end), (k["upper_arm"], k["forearm_l"] if sx < 0 else k["forearm_r"]), [(0.5, 0.6), (0.45, 0.5)],
k["arm_pin_r"], cross=(k["shoulder_drop"], 0.6), names=("shoulder_abduct", "shoulder_pitch", "elbow"), limits=((-10, 70), (-60, 150), (-5, 120)),
toward=((sx, 0, 0), (0, 1, 0), (0, 1, 0)), mat="gunmetal")
KITS.update(pelvis=pel, trunk=trunk, legs=legs, arms=arms, feet=feet_)
return KITS
def joint_points():
"""The kit's joints as they stand, world, named as paladin_form names them: what the cameras are solved on."""
M.update()
out = {"waist": KITS["trunk"].matrix_world.translation.copy()}
for s in ("L", "R"):
leg, arm, t = KITS["legs"][s], KITS["arms"][s], s.lower()
out[f"hip_{t}"] = leg["upper"].matrix_world.translation.copy()
out[f"knee_{t}"] = leg["lower"].matrix_world.translation.copy()
out[f"ankle_{t}"] = M.sockets(leg["lower"])["clevis"].translation
out[f"shoulder_{t}"] = arm["upper"].matrix_world.translation.copy()
out[f"elbow_{t}"] = arm["lower"].matrix_world.translation.copy()
out["wrist_l"] = M.sockets(KITS["arms"]["L"]["lower"])["clevis"].translation
reach = (Vector(PF.JOINTS["muzzle_r"]) - Vector(PF.JOINTS["elbow_r"])).length
out["muzzle_r"] = KITS["arms"]["R"]["lower"].matrix_world @ Vector((0, 0, reach))
return {name: tuple(p) for name, p in out.items()}
# --- plates --------------------------------------------------------------------------------------------------------
def plate(name, frame, trace=None, point=None, normal=None, crown=None, near=(), **kw):
"""One free-cage plate at `frame` (a kit part's authoring frame, world). With `trace` (a key of
paladin_form.TRACES) the crown is blocked by lifting the traced polygon onto the plane (point, normal) of the
frame and fitted to the trace; `near` names the marked joints whose miss at the solved camera the trace is
moved by first, so the plate sits on the limb as built. Otherwise `crown` is the crown, facing `normal`.
Returns the crown as built (frame coordinates)."""
if trace is not None:
view, line = PF.TRACES[trace]
cam = CAMS[view]
misses = [cam["shift"][j] for j in near if j in cam["shift"]]
shift = tuple(np.mean(misses, axis=0)) if misses else (0.0, 0.0)
crown = PC.lift(cam, frame, line, point, normal, shift)
Fm = np.asarray(frame)
sight = PC._unit(np.asarray(cam["C"]) - (Fm[:3, :3] @ crown.mean(0) + Fm[:3, 3]))
square = float(sight @ (Fm[:3, :3] @ PC._unit(normal)))
if square < 0.4:
raise SystemExit(f"plate {name}: its blocking plane stands {math.degrees(math.acos(max(-1.0, square))):.0f} degrees off square-on to the {view} camera; a trace lifted onto it "
"stretches past 2.5 times. Turn the plane to the face the view shows, or author the crown.")
PC.shell(name, crown, frame, facing=normal, trace=line, cam=cam, view=view, shift=shift, **kw)
else:
PC.shell(name, crown, frame, facing=normal, **kw)
return np.array(PC.PLATES[name]["crown"])
def on_plane(point, normal, pts):
"""2D points (across, up: as seen from outside) on the plane through `point` facing `normal`."""
n = PC._unit(normal)
up = np.array([0.0, 0.0, 1.0]) if abs(n[2]) < 0.9 else np.array([0.0, 1.0, 0.0])
e2 = PC._unit(up - n * (up @ n))
e1 = np.cross(e2, n)
return np.array([np.asarray(point, float) + e1 * x + e2 * y for x, y in pts])
def extent(crown):
"""(x0, x1, y0, y1) of a crown in its own plane's coordinates (PC.basis)."""
c, e1, e2, n = PC.basis(crown)
xs, ys = [(np.asarray(p) - c) @ e1 for p in crown], [(np.asarray(p) - c) @ e2 for p in crown]
return min(xs), max(xs), min(ys), max(ys)
def dress(name, steps):
"""The detail pass on one plate: surface.Skin on the shell, each step(skin, at) placing features at plane
coordinates of the plate's crown (at(x, y, roll) is a frame on the skin there). A step that misses is listed
in DRESS_FAILED and left out. The shell is frozen afterwards."""
import surface as S
obj = bpy.data.objects.get(name)
if obj is None:
DRESS_FAILED.append(f"{name}: no such plate")
return
if steps:
crown = np.array(PC.PLATES[name]["crown"])
c, e1, e2, n = PC.basis(crown)
skin = S.Skin(obj)
def at(x, y, roll=0.0):
return skin.at(tuple(c + e1 * x + e2 * y + n * 0.4), tuple(-n), up=tuple(e2), roll=roll)
at.crown, at.c, at.e1, at.e2 = crown, c, e1, e2
for label, step in steps:
try:
step(skin, at)
DRESSED[0] += 1
except Exception as error:
DRESS_FAILED.append(f"{name} {label}: {type(error).__name__} {str(error)[:120]}")
try:
skin.prune()
skin.commit()
except BaseException as error:
DRESS_FAILED.append(f"{name} commit: {type(error).__name__} {str(error)[:120]}")
freeze(obj)
def bolts(inset_=0.07, spacing=0.26, r=0.02, sides=None):
"""A bolt row inside each of the crown's sides (or those named)."""
def step(skin, at):
import surface as S
P, c = at.crown, at.c
frames = []
for i in range(len(P)):
if sides is not None and i not in sides:
continue
a, b = P[i], P[(i + 1) % len(P)]
a, b = a + PC._unit(c - a) * inset_ * 1.6, b + PC._unit(c - b) * inset_ * 1.6
count = max(2, int(np.linalg.norm(b - a) / spacing) + 1)
for t in np.linspace(0.0, 1.0, count)[: count - 1]:
q = a + (b - a) * t - c
frames.append(at(q @ at.e1, q @ at.e2))
S.bolt_row(skin, frames, r=r)
return ("bolts", step)
def inset(x, y, size, **kw):
import surface as S
return ("inset", lambda skin, at: S.inset(skin, at(x, y), size, **kw))
def port(x, y, r=0.07):
import surface as S
return ("port", lambda skin, at: S.access_port(skin, at(x, y), r))
def slots(x, y, count=3, pitch=0.09, width=0.3, height=0.04):
import surface as S
return ("slots", lambda skin, at: S.vent_slots(skin, [at(x, y + (i - (count - 1) / 2) * pitch) for i in range(count)], width, height))
def numeral(x, y, text, height):
import surface as S
return (text, lambda skin, at: S.numeral(skin, at(x, y), text, height, "marking"))
def line(x0, y0, x1, y1):
import surface as S
def step(skin, at):
a, b = at.c + at.e1 * x0 + at.e2 * y0, at.c + at.e1 * x1 + at.e2 * y1
n = np.cross(at.e1, at.e2)
S.panel_line(skin, ("line", tuple(a + n * 0.4), tuple(b + n * 0.4), tuple(-n)), gap=0.022)
return ("line", step)
def dings(seed=1):
import surface as S
return ("dings", lambda skin, at: S.edge_dings(skin, ("rim", 0), count=5, seed=seed))
def tri_on(name, size):
"""The sheet's hollow triangle on a plate's face: a ray down the crown's normal at its middle (the world)."""
obj = bpy.data.objects[name]
c, e1, e2, n = PC.basis(np.array(PC.PLATES[name]["crown"]))
w = obj.matrix_world
return triangle(f"Tri.{name}", w @ Vector(c + n * 0.4), w.to_3x3() @ Vector(-n), size)
def stowage(b, frame, size, mat="khaki"):
"""A strapped stowage box on a frame (z out of the face): the box, a lid step, two straps, a latch."""
w, h, d = size
b[mat].prism(frame, M.rect(w, h, 0.03), d, 0.02)
b[mat].prism(frame @ T((0, 0.04 * h, d)), M.rect(0.92 * w, 0.8 * h, 0.03), 0.025, 0.012)
for x in (-0.28, 0.28):
b["gunmetal"].box(frame @ T((x * w, 0, 0.5 * d + 0.02)), (0.06 * w, 1.04 * h, d + 0.04))
b["machine"].box(frame @ T((0, -0.5 * h, 0.6 * d)), (0.16 * w, 0.03, 0.08))
# --- pauldrons -------------------------------------------------------------------------------------------------------
def pauldron_frame(frame, sx):
at = PF.PAULDRON_AT
return frame @ T((-sx * at[0], at[1], at[2]))
def pauldron_core(frame, sx):
"""The pauldron's dark body under its shields: a faceted hood, its roof falling outboard, its front and rear
faces leaning back to the roof, its foot cut back under the knuckle."""
pts = [(-0.9, 1.0, 1.15), (-0.9, -1.0, 1.15), (0.45, 0.95, 0.72), (0.45, -0.95, 0.72), (0.86, 1.0, -0.1), (0.86, -1.0, -0.1), (0.5, 0.8, -0.95), (0.5, -0.8, -0.95),
(-0.8, 0.85, -0.85), (-0.8, -0.85, -0.85), (0.0, 1.22, 0.1), (0.0, -1.22, 0.1), (-0.9, 1.1, 0.2), (-0.9, -1.1, 0.2)]
return mass(f"Pauldron{'L' if sx < 0 else 'R'}.core", sided(pts, sx), pauldron_frame(frame, sx), CORE)
def pauldron_shields(frame, sx, crowns):
"""The traced shields of one pauldron: the front shield (both sides, hero), the right's front-outboard facet (hero), the
left's rear shield (rear view). Each stands on a sloped plane of the pauldron: the front leans back 17 degrees,
the outboard facet is turned 50 degrees out from it, the rear leans forward. The side shield, which no view but
the square-on side shows, is authored (pauldron_layers): it leans in 20 degrees to the roof."""
s, t = ("L", "l") if sx < 0 else ("R", "r")
Fp = pauldron_frame(frame, sx)
near = (f"shoulder_{t}",)
crowns[s, "Front"] = plate(f"Pauldron{s}.Front", Fp, f"Pauldron{s}.Front", (0, 1.34, 0.1), (sx * 0.22, 1, 0.3), near=near, flare=0.08, drop=0.09, dome=0.03, soft=(3,), thickness=0.015)
if sx > 0:
crowns[s, "Outer"] = plate("PauldronR.Outer", Fp, "PauldronR.Outer", (sx * 0.72, 1.0, 0.0), (sx * 0.75, 0.6, 0.3), near=near, flare=0.08, drop=0.09, dome=0.03, soft=(2,), thickness=0.015)
else:
crowns[s, "Rear"] = plate("PauldronL.Rear", Fp, "PauldronL.Rear", (0, -1.34, 0.1), (sx * 0.2, -1, 0.3), near=near, flare=0.08, drop=0.09, dome=0.03, soft=(3,), thickness=0.015)
def pauldron_layers(frame, sx, crowns):
"""The rest of a pauldron, layered on the shields: the shield the sheet hides on this side from the other side's
fitted crown mirrored; a base plate standing back under each shield and larger than it; the roof, a sloped plate
of its own; lames stepping down under the outer shield; a block and a sunk box on the front shield; bolts."""
s, o = ("L", "R") if sx < 0 else ("R", "L")
Fp = pauldron_frame(frame, sx)
for face in ("Outer", "Rear"):
if (s, face) not in crowns:
crowns[s, face] = plate(f"Pauldron{s}.{face}", Fp, crown=PC.mirrored(crowns[o, face]), normal=(sx * 0.75, 0.6, 0.3) if face == "Outer" else (sx * 0.2, -1, 0.3),
flare=0.08, drop=0.09, dome=0.03, thickness=0.015)
side = on_plane((sx * 0.98, -0.1, 0.05), (sx, -0.05, 0.36), [(-0.95 * sx, 0.72), (-1.0 * sx, -0.2), (-0.45 * sx, -0.95), (0.5 * sx, -0.95), (0.85 * sx, -0.1), (0.7 * sx, 0.72)])
crowns[s, "Side"] = plate(f"Pauldron{s}.Side", Fp, crown=side, normal=(sx, -0.05, 0.36), flare=0.08, drop=0.09, dome=0.04, soft=(2,), thickness=0.015)
for face in ("Front", "Outer", "Rear", "Side"):
cr = crowns[s, face]
plate(f"Pauldron{s}.{face}Base", Fp, crown=PC.grown(cr, 1.13, 0.13, (0.0, 0.04)), normal=PC.basis(cr)[3], flare=0.05, drop=0.08, dome=0.0, soft=(0, 2), thickness=0.015)
roof = sided([(-0.92, -1.08, 1.3), (0.5, -1.0, 0.9), (0.5, 1.0, 0.9), (-0.92, 1.08, 1.3)], sx)
crowns[s, "Roof"] = plate(f"Pauldron{s}.Roof", Fp, crown=roof, normal=(sx * 0.3, 0, 1), flare=0.07, drop=0.08, dome=0.03, thickness=0.015)
x0, x1, y0, y1 = extent(crowns[s, "Side"])
for i in range(2): # lames stepping down under the side shield's foot
plate(f"Pauldron{s}.Lame{i}", Fp, crown=PC.patch(crowns[s, "Side"], (0.0, y0 - 0.1 - 0.3 * i), (0.7 * (x1 - x0) - 0.2 * i, 0.34), -0.1 - 0.07 * i, cut=0.08),
normal=PC.basis(crowns[s, "Side"])[3], flare=0.04, drop=0.05, dome=0.0, soft=(0,), thickness=0.015)
fx0, fx1, fy0, fy1 = extent(crowns[s, "Front"])
plate(f"Pauldron{s}.Block", Fp, crown=PC.patch(crowns[s, "Front"], (0.0, fy1 - 0.3), (0.5 * (fx1 - fx0), 0.36), 0.06, cut=0.06), normal=PC.basis(crowns[s, "Front"])[3],
flare=0.035, drop=0.05, dome=0.0, thickness=0.015)
mid, low = 0.5 * (fy0 + fy1), fy0 + 0.42
dress(f"Pauldron{s}.Front", [bolts(0.08, 0.3), inset(0.05, low, (0.42, 0.26)), line(fx0 + 0.1, mid - 0.2, fx1 - 0.1, mid - 0.2)] + ([numeral(0.0, mid + 0.02, "07", 0.34)] if sx > 0 else []))
dress(f"Pauldron{s}.Outer", [bolts(0.08, 0.34), dings(3)])
dress(f"Pauldron{s}.Side", [bolts(0.08, 0.34), slots(0.0, 0.5 * (y0 + y1) - 0.15, 3, 0.1, 0.4, 0.04), port(0.0, 0.5 * (y0 + y1) + 0.35, 0.08)])
dress(f"Pauldron{s}.Rear", [bolts(0.08, 0.34), port(0.1, 0.1, 0.08), line(-0.4, -0.3, 0.4, -0.3)])
dress(f"Pauldron{s}.Roof", [bolts(0.08, 0.4), inset(0.0, 0.0, (0.5, 0.3))])
for name in (f"Pauldron{s}.FrontBase", f"Pauldron{s}.OuterBase", f"Pauldron{s}.RearBase", f"Pauldron{s}.SideBase", f"Pauldron{s}.Lame0", f"Pauldron{s}.Lame1", f"Pauldron{s}.Block"):
dress(name, [bolts(0.05, 0.3, 0.014)] if "Lame" in name or "Block" in name else [])
if sx < 0:
tri_on("PauldronL.Front", 0.4)
b = put(f"Pauldron{s}.fittings", Fp) # a grab rail along the roof's inner edge
g = b["gunmetal"]
g.rod((-sx * 0.8, -0.8, 1.42), (-sx * 0.8, 0.8, 1.42), 0.03, 8)
for y in (-0.8, 0.0, 0.8):
g.rod((-sx * 0.8, y, 1.25), (-sx * 0.8, y, 1.42), 0.03, 8)
b.done()
# --- legs ------------------------------------------------------------------------------------------------------------
def leg_frames(s):
leg = KITS["legs"][s]
return BK.frame(leg["upper"]), BK.frame(leg["lower"])
def leg_cores(s, sx):
"""The legs' dark bodies round the kit's girders: a deep hexagonal thigh block from above the hip's pin to the
knee, the shin a block that widens to mid-height; the calf's two rams behind; a stowage box on the calf."""
Ft, Fs = leg_frames(s)
Lt, Ls = PF.KIT["thigh"], PF.KIT["shin"]
b = put(f"Thigh{s}.core", Ft)
sec = [(-0.56, 0.6), (0.56, 0.6), (0.72, 0.0), (0.56, -0.54), (-0.56, -0.54), (-0.72, 0.0)]
b[CORE].hull([(x * k, y * k, z) for z, k in ((0.5, 0.7), (0.15, 1.0), (-Lt + 0.5, 1.0), (-Lt + 0.15, 0.72)) for x, y in sec])
for z in (-0.5, -0.95, -1.4): # ribs showing between the plates
b["machine"].box(T((0, 0, z)), (1.1, 1.0, 0.06))
with BK.Adopt(KITS["legs"][s]["upper"]):
b.done()
b = put(f"Shin{s}.core", Fs)
sec = [(-0.5, 0.54), (0.5, 0.54), (0.64, 0.0), (0.5, -0.5), (-0.5, -0.5), (-0.64, 0.0)]
b[CORE].hull([(x * k, y * k, z) for z, k in ((-0.35, 0.75), (-0.8, 1.0), (-Ls + 0.75, 0.95), (-Ls + 0.4, 0.7)) for x, y in sec])
g = b["gunmetal"]
for x in (-0.3, 0.3):
g.rod((x, -0.6, -0.6), (x, -0.68, -Ls + 0.9), 0.11, 12)
b["steel"].rod((x, -0.68, -Ls + 0.9), (x, -0.6, -Ls + 0.3), 0.06, 12)
g.cylinder(F((x, -0.58, -0.55), (1, 0, 0)), 0.14, 0.2, 12)
stowage(b, F((0, -0.5, -1.25), (0, -1, 0), UP), (0.62, 0.5, 0.2))
for z in (-1.0, -1.6):
b["machine"].box(T((0, 0, z)), (0.98, 0.9, 0.06))
with BK.Adopt(KITS["legs"][s]["lower"]):
b.done()
def leg_shields(s, sx, crowns):
"""The traced plates of one leg (hero view): the thigh's front shield; the right thigh's outer plate and the
left's inner; the plate over the knee (Shin.Upper: the sheet draws it centred on the knee) and the shin's front plate under it
(Shin.Lower; on the left leg the sheet shows only a short plate under the knee, the greave being in shadow); the
right shin's front-outboard plate and the left's inner."""
t = s.lower()
Ft, Fs = leg_frames(s)
hip, knee, ankle = f"hip_{t}", f"knee_{t}", f"ankle_{t}"
crowns[s, "Shield"] = plate(f"Thigh{s}.Shield", Ft, f"Thigh{s}.Shield", (0, 0.86, -0.9), (sx * 0.12, 1, 0.08), near=(hip, knee), flare=0.09, drop=0.1, dome=0.04, soft=(4,) if sx > 0 else (3,),
thickness=0.015)
if sx > 0:
crowns[s, "Outer"] = plate("ThighR.Outer", Ft, "ThighR.Outer", (sx * 0.62, 0.5, -0.6), (sx * 0.7, 0.7, 0.1), near=(hip, knee), flare=0.07, drop=0.08, dome=0.03, soft=(3,), thickness=0.015)
crowns[s, "ShinOuter"] = plate("ShinR.Outer", Fs, "ShinR.Outer", (sx * 0.6, 0.35, -1.5), (sx * 0.7, 0.7, 0), near=(knee, ankle), flare=0.06, drop=0.08, dome=0.03, soft=(3,), thickness=0.015)
else:
crowns[s, "Inner"] = plate("ThighL.Inner", Ft, "ThighL.Inner", (-sx * 0.74, 0.25, -1.0), (-sx, 0.55, 0), near=(hip, knee), flare=0.06, drop=0.08, dome=0.03, soft=(2,), thickness=0.015)
crowns[s, "ShinInner"] = plate("ShinL.Inner", Fs, "ShinL.Inner", (-sx * 0.64, 0.1, -1.2), (-sx, 0.5, 0), near=(knee, ankle), flare=0.06, drop=0.08, dome=0.03, soft=(2,), thickness=0.015)
crowns[s, "Upper"] = plate(f"Shin{s}.Upper", Fs, f"Shin{s}.Upper", (0, 0.86, -0.1), (sx * 0.1, 1, 0.1), near=(knee,), flare=0.07, drop=0.09, dome=0.04, soft=(2,), thickness=0.015)
crowns[s, "Lower"] = plate(f"Shin{s}.Lower", Fs, f"Shin{s}.Lower", (0, 0.7, -1.4), (sx * 0.1, 1, -0.08), near=(knee, ankle) if sx > 0 else (knee,), flare=0.07, drop=0.09, dome=0.03, soft=(0,), thickness=0.015)
def leg_layers(s, sx, crowns):
"""The rest of a leg's armour, layered on the fitted plates: the side plate the sheet hides, mirrored from the
other leg's; a base plate under each shield; on the thigh's shield the block over its head and a lame across its
foot; the left shin's greave; rear plates; stowage; bolts, sunk panels, slots and marks."""
o = "R" if s == "L" else "L"
Ft, Fs = leg_frames(s)
for key, F_, pre, n in (("Outer", Ft, "Thigh", (sx * 0.7, 0.7, 0.1)), ("Inner", Ft, "Thigh", (-sx, 0.55, 0)), ("ShinOuter", Fs, "Shin", (sx * 0.7, 0.7, 0)), ("ShinInner", Fs, "Shin", (-sx, 0.5, 0))):
if (s, key) not in crowns:
crowns[s, key] = plate(f"{pre}{s}.{key.replace('Shin', '')}", F_, crown=PC.mirrored(crowns[o, key]), normal=n, flare=0.06, drop=0.08, dome=0.03, thickness=0.015)
sh = crowns[s, "Shield"]
n = PC.basis(sh)[3]
x0, x1, y0, y1 = extent(sh)
plate(f"Thigh{s}.ShieldBase", Ft, crown=PC.grown(sh, 1.12, 0.15, (0.0, 0.06)), normal=n, flare=0.06, drop=0.09, dome=0.0, soft=(1, 4), thickness=0.015)
plate(f"Thigh{s}.Block", Ft, crown=PC.patch(sh, (0.04, y1 - 0.08), (0.52, 0.46), 0.09, cut=0.07), normal=n, flare=0.04, drop=0.07, dome=0.0, thickness=0.015)
plate(f"Thigh{s}.Lame", Ft, crown=PC.patch(sh, (0.0, y0 + 0.2), (0.8 * (x1 - x0), 0.3), 0.05, cut=0.06), normal=n, flare=0.04, drop=0.05, dome=0.0, soft=(0,), thickness=0.015)
plate(f"Thigh{s}.OuterBase", Ft, crown=PC.grown(crowns[s, "Outer"], 1.1, 0.1), normal=PC.basis(crowns[s, "Outer"])[3], flare=0.05, drop=0.07, dome=0.0, soft=(0, 3), thickness=0.015)
plate(f"Thigh{s}.Rear", Ft, crown=on_plane((0, -0.66, -0.85), (0, -1, 0.05), [(-0.5, 0.7), (-0.62, 0.2), (-0.5, -0.75), (0.5, -0.75), (0.62, 0.2), (0.5, 0.7)]), normal=(0, -1, 0.05),
flare=0.07, drop=0.09, dome=0.03, soft=(2,), thickness=0.015)
plate(f"Thigh{s}.Cap", Ft, crown=on_plane((0, 0.05, 0.58), (0, 0.25, 1), [(-0.5, -0.4), (0.5, -0.4), (0.56, 0.2), (0.3, 0.46), (-0.3, 0.46), (-0.56, 0.2)]), normal=(0, 0.25, 1),
flare=0.06, drop=0.08, dome=0.02, thickness=0.015)
up, lo = crowns[s, "Upper"], crowns[s, "Lower"]
nu = PC.basis(up)[3]
plate(f"Shin{s}.UpperBase", Fs, crown=PC.grown(up, 1.12, 0.13), normal=nu, flare=0.05, drop=0.08, dome=0.0, soft=(0, 2), thickness=0.015)
ux0, ux1, uy0, uy1 = extent(up)
if sx < 0: # the left shin's greave is in shadow on the sheet: the right's fitted crown, mirrored
crowns[s, "Greave"] = plate("ShinL.Greave", Fs, crown=PC.mirrored(crowns["R", "Lower"]), normal=(sx * 0.1, 1, -0.08), flare=0.07, drop=0.09, dome=0.03, soft=(0,), thickness=0.015)
lx0, lx1, ly0, ly1 = extent(lo)
plate(f"Shin{s}.LowerBase", Fs, crown=PC.grown(lo, 1.1, 0.12), normal=PC.basis(lo)[3], flare=0.05, drop=0.08, dome=0.0, soft=(1, 3), thickness=0.015)
plate(f"Shin{s}.Step", Fs, crown=PC.patch(lo, (0.0, ly0 + 0.2), (0.7 * (lx1 - lx0), 0.3), 0.05, cut=0.05), normal=PC.basis(lo)[3], flare=0.04, drop=0.05, dome=0.0, thickness=0.015)
plate(f"Shin{s}.Calf", Fs, crown=on_plane((0, -0.62, -2.0), (0, -1, -0.1), [(-0.4, 0.3), (-0.5, -0.1), (-0.36, -0.4), (0.36, -0.4), (0.5, -0.1), (0.4, 0.3)]), normal=(0, -1, -0.1),
flare=0.05, drop=0.07, dome=0.02, thickness=0.015)
mid = 0.5 * (y0 + y1)
dress(f"Thigh{s}.Shield", [bolts(0.09, 0.3), line(x0 + 0.12, y0 + 0.42, x1 - 0.12, y0 + 0.42)] + ([numeral(0.0, mid - 0.05, "07", 0.4)] if sx < 0 else []))
dress(f"Thigh{s}.Block", [inset(0.0, 0.0, (0.3, 0.22))])
dress(f"Thigh{s}.Lame", [slots(0.0, 0.0, 1, 0.1, 0.4, 0.05), bolts(0.05, 0.3, 0.014, sides=(0,))])
dress(f"Thigh{s}.Outer", [bolts(0.08, 0.32), port(0.0, 0.25, 0.08), dings(5)])
dress(f"Thigh{s}.Inner", [bolts(0.08, 0.34)])
dress(f"Thigh{s}.Rear", [bolts(0.08, 0.34), inset(0.0, 0.1, (0.5, 0.3)), slots(0.0, -0.45, 2, 0.1, 0.4, 0.04)])
dress(f"Shin{s}.Upper", [bolts(0.08, 0.3), line(ux0 + 0.1, uy0 + 0.25, ux1 - 0.1, uy0 + 0.25)])
dress(f"Shin{s}.Lower", [bolts(0.08, 0.32), inset(0.0, 0.5 * (ly0 + ly1) + 0.15, (0.4, 0.5)), dings(7)])
if sx < 0:
dress("ShinL.Greave", [bolts(0.08, 0.32), inset(0.0, 0.2, (0.4, 0.5)), dings(9)])
dress(f"Shin{s}.Outer", [bolts(0.07, 0.34), slots(0.0, 0.0, 3, 0.1, 0.3, 0.04)])
dress(f"Shin{s}.Inner", [bolts(0.07, 0.34)])
for name in ("Thigh%s.ShieldBase", "Thigh%s.OuterBase", "Thigh%s.Cap", "Shin%s.UpperBase", "Shin%s.LowerBase", "Shin%s.Step", "Shin%s.Calf"):
dress(name % s, [bolts(0.05, 0.32, 0.014)] if "Step" in name or "Cap" in name or "Calf" in name else [])
if sx > 0:
tri_on("ThighR.Shield", 0.5)
else:
tri_on("ShinL.Lower", 0.3)
b = put(f"Thigh{s}.stowage", Ft) # a stowage box and a rail on the thigh's outer side, behind the outer plate
stowage(b, F((sx * 0.7, -0.3, -1.2), (sx, -0.2, 0), UP), (0.5, 0.42, 0.18))
b["gunmetal"].rod((sx * 0.72, -0.05, -0.2), (sx * 0.72, -0.4, -0.2), 0.035, 8)
b.done()
def knee(s):
"""KNEE & LEG DETAIL inset: the joints library's kneecap_bisector at the knee's bend as the kit stands, for
its carrier ring and the pin's disc at the side. Its limb stubs and its cap are left out: the plate over the knee
is the fitted Shin.Upper."""
import jointlib as J
import joints
leg = KITS["legs"][s]
Ft, Fs = leg_frames(s)
frame = Ft.copy()
frame.translation = Fs.translation
down = frame.to_3x3().inverted() @ (Fs.to_3x3() @ Vector((0, 0, -1)))
angle = math.degrees(math.atan2(down.y, -down.z))
rig = J.Rig(f"Knee{s}", frame, -95.0, 0.0)
joints.kneecap_bisector(rig, angle, r=0.5, cap=(1.15, 1.25), disc=0.34)
objs = list(rig.done())
for o in list(objs):
if o.get("mat") == "khaki": # its limb stubs and its cap: the fitted plate over the knee is this build's
objs.remove(o)
bpy.data.objects.remove(o, do_unlink=True)
BK.adopt(leg["lower"], [o for o in objs if o.get("link") == "shin"])
BK.adopt(leg["upper"], [o for o in objs if o.get("link") != "shin"])
print(f"KNEE {s}: bend {angle:.1f}", flush=True)
return angle
# --- arms ------------------------------------------------------------------------------------------------------------
def arm_frames(s):
arm = KITS["arms"][s]
return BK.frame(arm["upper"]), BK.frame(arm["lower"])
def upper_arm(s, sx):
"""Hero view: a short dark upper arm under the pauldron, ribbed; an outer and a front plate on it, each a free
cage, a lame on the outer plate; the elbow's drum on its pin."""
Fu, Ff = arm_frames(s)
L = PF.KIT["upper_arm"]
b = put(f"UpperArm{s}", Fu)
g = b["gunmetal"]
g.box(T((0, 0, -0.5 * L)), (0.66, 0.76, L))
for i in range(5):
g.box(T((0, 0, -0.25 - 0.26 * i)), (0.78, 0.88, 0.08))
g.lathe(F((-0.5, 0, -L), (1, 0, 0), UP), [(0, 0), (0.4, 0), (0.44, 0.05), (0.44, 0.95), (0.4, 1.0), (0, 1.0)], 24)
for x in (-0.54, 0.54):
b["machine"].cylinder(F((x, 0, -L), (1, 0, 0), UP), 0.28, 0.08, 16)
b.done()
out_ = plate(f"UpperArm{s}.Outer", Fu, crown=on_plane((sx * 0.5, 0, -0.85), (sx, 0, 0.05), [(-0.4, 0.5), (-0.46, -0.1), (-0.3, -0.55), (0.3, -0.55), (0.46, -0.1), (0.4, 0.5)]), normal=(sx, 0, 0.05),
flare=0.05, drop=0.07, dome=0.03, soft=(2,), thickness=0.015)
plate(f"UpperArm{s}.Front", Fu, crown=on_plane((0, 0.5, -0.9), (0, 1, 0), [(-0.3, 0.45), (-0.3, -0.5), (0.3, -0.5), (0.3, 0.45)]), normal=(0, 1, 0), flare=0.05, drop=0.07, dome=0.02, thickness=0.015)
plate(f"UpperArm{s}.Lame", Fu, crown=PC.patch(out_, (0.0, -0.3), (0.5, 0.24), 0.05, cut=0.05), normal=PC.basis(out_)[3], flare=0.035, drop=0.05, dome=0.0, thickness=0.015)
dress(f"UpperArm{s}.Outer", [bolts(0.07, 0.28, 0.016), port(0.0, 0.2, 0.06)])
dress(f"UpperArm{s}.Front", [bolts(0.06, 0.3, 0.016)])
dress(f"UpperArm{s}.Lame", [])
def forearm_left(crowns):
"""LEFT FOREARM - MANIPULATOR & ENERGY inset and the hero view: a dark housing from the elbow to the wrist; a
front plate and an outer plate traced on the hero view, three small stepped plates down the front as the sheet
stacks them, an inner plate; under its end the open hand (the joints library's), beside it the emitter (the
weapons library's paladin_energy_emitter, class S)."""
import jointlib as J
import hands
import weapons_energy
Fu, Ff = arm_frames("L")
L = PF.KIT["forearm_l"]
b = put("ForearmL.core", Ff)
sec = [(-0.36, 0.4), (0.36, 0.4), (0.44, 0.0), (0.36, -0.42), (-0.36, -0.42), (-0.44, 0.0)]
b[CORE].hull([(x * k, y * k, z) for z, k in ((-0.15, 0.7), (-0.5, 1.0), (-L + 0.2, 1.0), (-L - 0.05, 0.75)) for x, y in sec])
for z in (-0.7, -1.1, -1.5):
b["machine"].box(T((0, 0, z)), (0.94, 0.9, 0.05))
b.done()
near = ("elbow_l", "wrist_l")
fr = crowns["L", "ForearmFront"] = plate("ForearmL.Front", Ff, "ForearmL.Front", (0, 0.5, -1.0), (0.12, 1, 0.05), near=near, flare=0.05, drop=0.07, dome=0.02, thickness=0.015)
crowns["L", "ForearmOuter"] = plate("ForearmL.Outer", Ff, "ForearmL.Outer", (-0.36, 0.38, -1.0), (-0.6, 0.8, 0), near=near, flare=0.05, drop=0.07, dome=0.02, thickness=0.015)
n = PC.basis(fr)[3]
x0, x1, y0, y1 = extent(fr)
for i in range(3):
y = y1 - 0.25 - i * (y1 - y0 - 0.3) / 3
plate(f"ForearmL.Step{i}", Ff, crown=PC.patch(fr, (0.0, y), (0.72 * (x1 - x0), 0.3), 0.05 + 0.02 * (2 - i), cut=0.05), normal=n, flare=0.035, drop=0.05, dome=0.0, soft=(0,), thickness=0.015)
plate("ForearmL.Inner", Ff, crown=on_plane((0.5, 0.0, -1.05), (1, 0.2, 0), [(-0.36, 0.55), (-0.36, -0.6), (0.36, -0.6), (0.36, 0.55)]), normal=(1, 0.2, 0), flare=0.05, drop=0.07, dome=0.02, thickness=0.015)
dress("ForearmL.Front", [bolts(0.06, 0.28, 0.014)])
dress("ForearmL.Outer", [bolts(0.06, 0.28, 0.014), slots(0.0, 0.0, 3, 0.09, 0.2, 0.035)])
dress("ForearmL.Inner", [bolts(0.06, 0.3, 0.014), port(0.0, 0.1, 0.06)])
for i in range(3):
dress(f"ForearmL.Step{i}", [bolts(0.045, 0.3, 0.012, sides=(0,))])
z, y = Ff.to_3x3() @ Vector((0, 0, 1)), Ff.to_3x3() @ Vector((1, 0, 0)) # the hand hangs down the forearm, its palm inboard
m = Matrix((y.cross(z), y, z)).transposed().to_4x4()
m.translation = Ff @ Vector((0, 0, -L - 0.25))
rig = J.Rig("HandL", m @ Matrix.Scale(1.55, 4), 0.0, 100.0)
hands.hand(rig, 30.0, plate="khaki")
rig.done()
side = Ff.to_3x3() @ Vector((-1, 0, 0))
E_, W_ = Ff.translation, Ff @ Vector((0, 0, -L))
put("Emitter", aim(E_ + side * 0.8 - z * 0.7, W_ + side * 0.8 - z * 0.7), weapons_energy.paladin_energy_emitter, size="S")

View file

@ -1,13 +1,13 @@
"""Comparison sheets for PALADIN against concept sheet 27. Plain Python (Pillow, numpy); no Blender. """Comparison sheets for PALADIN against concept sheet 27. Plain Python (Pillow, numpy); no Blender.
usage: python paladin_sheets.py [stage] (MECH_OUT, MECH_CONCEPTS as compare.py; stage defaults to full) usage: python paladin_sheets.py [stage] (MECH_OUT, MECH_CONCEPTS as compare.py; stage defaults to full)
Reads MECH_OUT/paladin/ (paladin.py's renders); writes under MECH_OUT/compare/: Reads MECH_OUT/paladin/ (paladin.py's renders); writes under MECH_OUT/compare/:
paladin_camera.png the three solved cameras: the marks (yellow) against the build's points (cyan) paladin_camera.png the three solved cameras: the marks (yellow) against the build's points (cyan); the horizon
paladin_flowlines.png the lines traced on the hero view (red) | our built edges at the same camera (cyan) | scores paladin_flowlines.png the lines traced on the hero view (red) | our built edges at the same camera (cyan) | scores
paladin_vs_concept.png hero, rear and side: concept | ours | the two laid over each other; the silhouettes' overlap paladin_vs_concept.png hero, rear and side: concept | ours | the two laid over each other
paladin_character.png the belt, close: concept | ours with the traced belt and our edges | ours paladin_character.png the belt, close: concept | ours with the traced belt and our edges | ours
paladin_components.png each inset of the sheet beside our part, and the rebuilt plates beside their crops paladin_components.png each inset of the sheet beside our part, and the rebuilt plates beside their crops
paladin_plates.png the traced plate edges (red) on the hero and rear views | our edges | each cage's numbers paladin_plates.png the plate edges traced on the hero (red) | the hard plates' built edges | the plates' numbers
paladin_before_after.png the first pass (MECH_BEFORE/paladin, its own renders) beside this one, view by view paladin_before_after.png the first pass (MECH_BEFORE) and the second (MECH_BEFORE2) beside this one, view by view
Scores go to MECH_OUT/paladin/paladin_scores.json.""" Scores go to MECH_OUT/paladin/paladin_scores.json."""
import json, os, sys import json, os, sys
from pathlib import Path from pathlib import Path
@ -102,9 +102,14 @@ for tag, cam in cams.items():
box, marks, proj = cam["box"], PF.VIEWS[tag]["marks"], report["cameras"][tag]["projected"] box, marks, proj = cam["box"], PF.VIEWS[tag]["marks"], report["cameras"][tag]["projected"]
pts = [(tuple(marks[k]), YELLOW) for k in marks] + [(tuple(proj[k]), CYAN) for k in proj] pts = [(tuple(marks[k]), YELLOW) for k in marks] + [(tuple(proj[k]), CYAN) for k in proj]
c = fit(sheet.crop(tuple(box)), H) c = fit(sheet.crop(tuple(box)), H)
cells.append(label(in_box(c, box, marks=pts), f"{PF.VIEWS[tag]['label']}: marks (yellow), build (cyan); rms {cam['rms']:.1f} px, lens {cam['lens']:.0f} mm, eye {cam['C'][2]:.1f} m")) hz = cam.get("horizon")
cells.append(label(in_box(render(f"{stage}_{tag}.png", size=c.size), box, marks=pts), "ours")) share = lambda v: 100.0 * (v - box[1]) / (box[3] - box[1]) # noqa: E731
scores[f"camera_{tag}"] = {"rms": round(cam["rms"], 2), "left_out": round(cam["left_out"], 2), "lens": round(cam["lens"], 1), "lens_range": [round(v, 1) for v in cam["lens_range"]], "eye": round(cam["C"][2], 2), "model": cam["model"]} note = f"; horizon: sheet {share(hz[0]):.0f}%, ours {share(hz[1]):.0f}% of the frame" if hz else ""
hline = [[(box[0], hz[0]), (box[2], hz[0])]] if hz else []
cells.append(label(in_box(c, box, lines=hline, marks=pts, width=2), f"{PF.VIEWS[tag]['label']}: marks (yellow), build (cyan); rms {cam['rms']:.1f} px, lens {cam['lens']:.0f} mm, eye {cam['C'][2]:.1f} m{note}"))
cells.append(label(in_box(render(f"{stage}_{tag}.png", size=c.size), box, lines=[[(box[0], hz[1]), (box[2], hz[1])]] if hz else [], marks=pts, width=2), "ours; the red line is the camera's horizon"))
scores[f"camera_{tag}"] = {"rms": round(cam["rms"], 2), "left_out": round(cam["left_out"], 2), "lens": round(cam["lens"], 1), "lens_range": [round(v, 1) for v in cam["lens_range"]], "eye": round(cam["C"][2], 2), "model": cam["model"],
"horizon_share": [round(share(v) / 100.0, 3) for v in hz] if hz else None}
row(cells).save(dst / "paladin_camera.png") row(cells).save(dst / "paladin_camera.png")
# vs concept # vs concept
@ -126,10 +131,10 @@ if edges_path.exists():
own = {"belt": ("Torso.",), "visor": ("Turret.", "Visor")} own = {"belt": ("Torso.",), "visor": ("Turret.", "Visor")}
for name, (view, pts) in PF.TRACES.items(): for name, (view, pts) in PF.TRACES.items():
if view == "hero": if view == "hero":
traces[name], own[name] = list(pts) + [pts[0]], (name,) traces[name], own[name] = list(pts) + [pts[0]], (PF.TRACE_OWNER[name],)
fl = {} fl = {}
for k, pts in traces.items(): for k, pts in traces.items():
mine = [e["seg"] for e in edges if e["object"].startswith(own[k])] mine = [e["seg"] for e in edges if e["object"].startswith(own[k]) and (k in ("belt", "visor") or e["object"] == own[k][0])]
fl[k] = {"own": fitshell.along(pts, mine, FIG) if mine else None, "all": fitshell.along(pts, segs, FIG)} fl[k] = {"own": fitshell.along(pts, mine, FIG) if mine else None, "all": fitshell.along(pts, segs, FIG)}
scores["flow"] = fl scores["flow"] = fl
box = cams["hero"]["box"] box = cams["hero"]["box"]
@ -153,30 +158,25 @@ if edges_path.exists():
stack([row([label(in_box(crop, cb, lines=lines, width=5), "sheet 27: the belt and the visor's lip (red)"), label(in_box(ours, cb, lines=lines, segs=torso, width=5), "ours, same camera: the traces (red), the hull's, turret's and pauldrons' edges (cyan). " + note)]), stack([row([label(in_box(crop, cb, lines=lines, width=5), "sheet 27: the belt and the visor's lip (red)"), label(in_box(ours, cb, lines=lines, segs=torso, width=5), "ours, same camera: the traces (red), the hull's, turret's and pauldrons' edges (cyan). " + note)]),
row([label(crop, "sheet 27"), label(ours, "ours")])]).save(dst / "paladin_character.png") row([label(crop, "sheet 27"), label(ours, "ours")])]).save(dst / "paladin_character.png")
# the plates: traces, edges, cages # the plates: the second pass's traces over the hard plates' built edges, and the plates' numbers
if edges_path.exists() and report.get("plates"): if edges_path.exists() and report.get("plates"):
box = cams["hero"]["box"] box = cams["hero"]["box"]
c = fit(sheet.crop(tuple(box)), H) c = fit(sheet.crop(tuple(box)), H)
o = render(f"{stage}_hero.png", size=c.size) o = render(f"{stage}_hero.png", size=c.size)
hero_lines = [list(pts) + [pts[0]] for name, (view, pts) in PF.TRACES.items() if view == "hero"] hero_lines = [list(pts) + [pts[0]] for name, (view, pts) in PF.TRACES.items() if view == "hero"]
plate_segs = [e["seg"] for e in edges if e["object"].split(" ")[0] in report["plates"]] plate_segs = [e["seg"] for e in edges if e["object"] in report["plates"]]
cg = report["cages"] hd, dt = report["hard"], report["detail"]
body = [f"{cg['plates']} free-cage plates, {cg['cage_verts']} cage vertices ({cg['verts_per_plate']} a plate)", f"creased {cg['creased']} of {cg['edges']} edges: {100 * cg['crease_share']:.0f}% (Dexter's hull: 19%)", body = [f"{hd['solids']} hard solids, each authored by its faces", f"({hd['corners']} corners, {hd['facets']} facets); kinds: {hd['kinds']}", f"slab thickness {hd['thinnest']} to {hd['thickest']} m; folded faces {hd['folded']}",
f"poles {cg['poles']} (each a plate's centre)", f"fitted {cg['fitted']}, refused {cg['refused']}; worst reading {cg['worst_unexplained_px']} px (tol 5.2)", "", f"on them: {dt['panels']} stepped panels, {dt['fits']} fits, {dt['marks']} marks", f"{dt['hoses']} hoses, {dt['rams']} kit rams; {len(dt['failed'])} failed", "",
f"{'traced plate':17s} {'v':>2s} {'cr%':>4s} {'p':>1s} {'unexpl':>6s} {'worst':>5s} {'moved':>6s} {'prior':>9s}"] "The numbers are read off the sheet by hand", "(paladin_form). Nothing is fitted. The red", "traces are the second pass's and score the", "plates here; they did not place them.", "",
for name, pl in report["plates"].items(): f"{'traced plate':16s} {'built as':16s} {'on':>5s} {'run':>5s} {'off':>5s}"]
f_ = pl["fit"] for name in PF.TRACES:
if f_ is None: v = fl.get(name, {}).get("own")
continue body.append(f"{name:16s} {PF.TRACE_OWNER[name]:16s} " + (f"{v['on']:5.2f} {v['run']:5.2f} {v['off']:5.2f}" if v else " (rear view)"))
if "refused" in f_: body += ["", "on: share of the trace with one of the plate's", "own built edges within 1% of the figure's", "height, running its way; off: mean distance,", "% of the height"]
body.append(f"{name:17s} {pl['verts']:2d} {100 * pl['crease_share']:4.0f} {pl['poles']:1d} REFUSED") row([label(in_box(c, box, lines=hero_lines, width=3), "sheet 27, hero: plate edges traced in the second pass (red)"), label(in_box(o, box, lines=hero_lines, segs=plate_segs, width=3), "ours: the traces (red), the hard plates' built edges (cyan)"),
else:
body.append(f"{name:17s} {pl['verts']:2d} {100 * pl['crease_share']:4.0f} {pl['poles']:1d} {f_['unexplained_px']:6.2f} {f_['worst_px']:5.1f} {f_['moved_m']:6.3f} {f_['prior_share'][0]:4.2f}-{f_['prior_share'][1]:4.2f}")
body += ["", "v: cage vertices; cr%: creased edges; p: poles", "unexpl: 90th percentile px of the trace from", "its built run; moved: m the fit moved a point", "prior: prior_share (near 1: depth is the", "blocking plane's, one view decides none)",
"", f"{sum(1 for p_ in report['plates'].values() if p_['fit'] is None)} more plates are derived from these", "(mirrored, base, block, lame) or authored"]
row([label(in_box(c, box, lines=hero_lines, width=3), "sheet 27, hero: the traced plate edges (red)"), label(in_box(o, box, lines=hero_lines, segs=plate_segs, width=3), "ours: the traces (red), the plates' built edges (cyan)"),
text_panel(body, 760, H + 34)]).save(dst / "paladin_plates.png") text_panel(body, 760, H + 34)]).save(dst / "paladin_plates.png")
scores["cages"] = cg scores["hard"] = hd
# components # components
INSETS = [("cockpit", (0, 512, 262, 712), "COCKPIT & SENSOR ARRAY"), ("battery", (262, 512, 512, 712), "RIGHT SHOULDER - MISSILE BATTERY"), ("ew", (512, 512, 762, 712), "LEFT SHOULDER - SENSOR / EW MODULE"), INSETS = [("cockpit", (0, 512, 262, 712), "COCKPIT & SENSOR ARRAY"), ("battery", (262, 512, 512, 712), "RIGHT SHOULDER - MISSILE BATTERY"), ("ew", (512, 512, 762, 712), "LEFT SHOULDER - SENSOR / EW MODULE"),
@ -184,7 +184,7 @@ INSETS = [("cockpit", (0, 512, 262, 712), "COCKPIT & SENSOR ARRAY"), ("battery",
("pelvis", (392, 742, 633, 930), "PELVIS & HIP ASSEMBLY"), ("knee", (635, 742, 815, 930), "KNEE & LEG DETAIL"), ("foot", (817, 742, 1024, 930), "FOOT & ANKLE"), ("pelvis", (392, 742, 633, 930), "PELVIS & HIP ASSEMBLY"), ("knee", (635, 742, 815, 930), "KNEE & LEG DETAIL"), ("foot", (817, 742, 1024, 930), "FOOT & ANKLE"),
("pauldron_r", (25, 35, 155, 150), "hero: the right pauldron"), ("pauldron_rear", (385, 20, 515, 150), "rear: the left pauldron"), ("pauldron_side", (690, 60, 885, 190), "side: the pauldron"), ("pauldron_r", (25, 35, 155, 150), "hero: the right pauldron"), ("pauldron_rear", (385, 20, 515, 150), "rear: the left pauldron"), ("pauldron_side", (690, 60, 885, 190), "side: the pauldron"),
("thigh_r", (75, 180, 200, 300), "hero: the right thigh"), ("shin_r", (60, 280, 190, 410), "hero: the right shin"), ("leg_side", (690, 230, 885, 470), "side: the leg"), ("thigh_r", (75, 180, 200, 300), "hero: the right thigh"), ("shin_r", (60, 280, 190, 410), "hero: the right shin"), ("leg_side", (690, 230, 885, 470), "side: the leg"),
("forearm_l", (265, 150, 352, 280), "hero: the left forearm")] ("forearm_l", (265, 150, 352, 280), "hero: the left forearm"), ("abdomen", (140, 125, 270, 215), "hero: the abdomen"), ("leg_rear", (400, 280, 580, 450), "rear: the left shin")]
cells = [] cells = []
for name, box, title in INSETS: for name, box, title in INSETS:
if (src / f"part_{name}.png").exists(): if (src / f"part_{name}.png").exists():
@ -195,22 +195,22 @@ if cells:
cells = [c.crop((0, 0, w, c.height)) if c.width == w else row([c, Image.new("RGB", (w - c.width - 8, c.height), BG)]) for c in cells] cells = [c.crop((0, 0, w, c.height)) if c.width == w else row([c, Image.new("RGB", (w - c.width - 8, c.height), BG)]) for c in cells]
stack([row(cells[i:i + 3]) for i in range(0, len(cells), 3)]).save(dst / "paladin_components.png") stack([row(cells[i:i + 3]) for i in range(0, len(cells), 3)]).save(dst / "paladin_components.png")
# before and after: the first pass's own renders beside this pass's # before and after: the first and second passes' own renders beside this pass's
before = Path(os.environ.get("MECH_BEFORE", "")) passes = [(Path(os.environ[k]), name) for k, name in (("MECH_BEFORE", "first pass (87fd442)"), ("MECH_BEFORE2", "second pass (e688951)")) if os.environ.get(k) and (Path(os.environ[k]) / "paladin" / "full_hero.png").exists()]
if os.environ.get("MECH_BEFORE") and (before / "paladin" / "full_hero.png").exists(): if passes:
def old(stem, size): def old(root, stem, size):
img = Image.open(before / "paladin" / stem).convert("RGBA") img = Image.open(root / "paladin" / stem).convert("RGBA")
return Image.alpha_composite(Image.new("RGBA", img.size, (150, 156, 164, 255)), img).convert("RGB").resize(size, Image.LANCZOS) return Image.alpha_composite(Image.new("RGBA", img.size, (150, 156, 164, 255)), img).convert("RGB").resize(size, Image.LANCZOS)
rows = [] rows = []
for tag, cam in cams.items(): for tag, cam in cams.items():
box = cam["box"] box = cam["box"]
c = fit(sheet.crop(tuple(box)), 900) c = fit(sheet.crop(tuple(box)), 900)
rows.append([label(c, f"sheet 27, {PF.VIEWS[tag]['label']}"), label(old(f"full_{tag}.png", c.size), "first pass (87fd442), its own solved camera"), label(render(f"{stage}_{tag}.png", size=c.size), "second pass, its solved camera")]) rows.append(row([label(c, f"sheet 27, {PF.VIEWS[tag]['label']}")] + [label(old(root, f"full_{tag}.png", c.size), f"{name}, its own camera") for root, name in passes] + [label(render(f"{stage}_{tag}.png", size=c.size), "third pass, horizon held")]))
turns = []
for az in ("035", "090", "180"): for az in ("035", "090", "180"):
if (before / "paladin" / f"full_turn_{az}.png").exists() and (src / f"{stage}_turn_{az}.png").exists(): if (src / f"{stage}_turn_{az}.png").exists():
turns.append(row([label(old(f"full_turn_{az}.png", (760, 760)), f"first pass, turned {int(az)}"), label(render(f"{stage}_turn_{az}.png", size=(760, 760)), f"second pass, turned {int(az)}")], gap=2)) rows.append(row([label(old(root, f"full_turn_{az}.png", (760, 760)), f"{name}, turned {int(az)}") for root, name in passes if (root / "paladin" / f"full_turn_{az}.png").exists()]
stack([row(rows[0] + rows[2]), row(rows[1]), row(turns)] if turns else [row(rows[0] + rows[2]), row(rows[1])]).save(dst / "paladin_before_after.png") + [label(render(f"{stage}_turn_{az}.png", size=(760, 760)), f"third pass, turned {int(az)}")], gap=2))
stack(rows).save(dst / "paladin_before_after.png")
for tag, cam in cams.items(): for tag, cam in cams.items():
box = cam["box"] box = cam["box"]

View file

@ -1,23 +0,0 @@
"""Probe: one free-cage plate under variants of wall thickness, chamfer and pinned corners: folded inner faces and bounds."""
import json, sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
import mechlib as M
from mathutils import Matrix
import bpy, numpy as np
M.setup()
import platecage as PC
crown = np.array([(-0.5, 0, 0.6), (-0.62, 0, 0.1), (-0.4, 0, -0.7), (0.4, 0, -0.7), (0.62, 0, 0.1), (0.5, 0, 0.6)])
k = 0
for thickness in (0.07, 0.03, 0.012):
for flare, drop in ((0.08, 0.09), (0.03, 0.09), (0.12, 0.06)):
for pin_skirt in (True, False):
for offset in (-1.0, 0.0):
doc, N, marks = PC.sheet(crown, flare, drop, 0.03, (), (), (0, -1, 0))
if not pin_skirt:
doc["corners"] = [c for c in doc["corners"] if c[0] < N]
name = f"P{k}"; k += 1
bpy.ops.brokkr_kitbash.shell(object_name=name, sheet=json.dumps(doc), thickness=thickness, offset=offset, levels=2, bevel=0.01, count_folds=True)
rep = json.loads(getattr(bpy.context.window_manager, M.KB.RESULT))
lo, hi = M.bounds([bpy.data.objects[name]])
print("PROBE", name, "t", thickness, "flare", flare, "drop", drop, "skirt pinned", pin_skirt, "offset", offset, "folded", rep["folded"], "bounds", [round(v, 2) for v in (*lo, *hi)], flush=True)

View file

@ -1,210 +0,0 @@
"""Armour plates as minimal free cages whose hard runs are fitted to lines traced on a concept view.
Rulings aetheria-release:ruling:minimal-cages-learned-from-operator (the fewest vertices that hold the form, creases
judicious, every pole declared) and mech-concept-fidelity. The arithmetic of the fit is brokkr_reference's
(core.fit_sheet, what the fit_shell action runs); the cage's one writer is brokkr_kitbash.shell (mechlib.shell_action).
numpy and the two add-ons; shell() runs inside Blender.
A plate is its CROWN: the polygon of its raised face, the line a concept draws as the plate's edge. The cage is the
crown ring, a skirt ring flared out and dropped back from it (the chamfered wall), and one centre vertex (the dome):
2N + 1 vertices for an N-sided plate. The crown's sides are creased 1 except those named soft (a side that rolls
over instead of breaking); crown and skirt corners are pinned except those named round. Every crown vertex then has
valence 4; the one pole is the centre, where the dome turns anyway.
lift(cam, frame, line, point, normal, shift) a traced polygon (the view's pixels) as points of `frame` on a plane
of that frame: the blocking. Depth is the plane's, by eye.
sheet(crown, flare, drop, dome, soft, round) the cage document of a crown (frame coordinates), wound to face
`facing`; returns (document, N)
fit(document, n, frame, cam, line, share, tol) core.fit_sheet on the crown's hard runs against the traced polygon,
one trace a run between pinned corners. Returns (crown as fitted,
report) or (None, report with the refusal).
shell(name, crown, frame, ...) fit if a trace is given, rebuild skirt and dome from the fitted
crown, brokkr_kitbash.shell; the numbers go to PLATES
grown(crown, by, back) / patch(crown, at, size, lift, turn) / mirrored(crown)
layering: a plate under a crown, larger and further back; a small
plate on a crown's face; the crown reflected about x = 0
stats(document) verts, faces, edges, creased, crease_share, poles
PLATES: {shell name: {verts, faces, triangles, edges, creased, crease_share, poles, fit: None | {...}}}.
What it gives up: a crown is one planar-ish polygon with a dome, so a plate that wraps a corner is two plates. The
fit moves crown points across the line of sight; along it they stay on the blocking plane (one view, no mirror
partner: prior_share reads near 1 and is reported, not hidden).
"""
import json
import math
import numpy as np
PLATES = {}
HARD = 1.0
def _unit(v):
v = np.asarray(v, float)
return v / max(np.linalg.norm(v), 1e-12)
def newell(P):
P = np.asarray(P, float)
Q = np.roll(P, -1, axis=0)
return _unit(np.cross(P, Q).sum(0))
def lift(cam, frame, line, point, normal, shift=(0.0, 0.0)):
"""Pixels of a view lifted through its camera onto the plane through `point` with `normal`, both of `frame` (a
4x4 that only turns and moves); `shift` is added to the pixels first (the build's joints stand that far from
the marks the camera was solved on). Returns the points in the frame's coordinates."""
F = np.asarray(frame, float)
R, t = F[:3, :3], F[:3, 3]
p0, n = R @ np.asarray(point, float) + t, R @ _unit(normal)
C, Rc = np.asarray(cam["C"], float), np.asarray(cam["R"], float)
out = []
for u, v in line:
d = np.array([(u + shift[0] - cam["c"][0]) / cam["f"], -(v + shift[1] - cam["c"][1]) / cam["f"], -1.0]) @ Rc
w = C + d * (((p0 - C) @ n) / (d @ n))
out.append(R.T @ (w - t))
return np.array(out)
def sheet(crown, flare=0.06, drop=0.06, dome=0.02, soft=(), round_=(), facing=None):
"""The cage of a crown. Vertices: crown 0..N-1, skirt N..2N-1, centre 2N. `facing` is a direction of the frame
the plate's outer face looks along: the crown is reversed if it winds the other way, and soft / round indices
(which name the crown as given: side i runs from point i to i + 1) follow it."""
P = np.asarray(crown, float)
N = len(P)
soft, round_ = set(soft), set(round_)
if facing is not None and newell(P) @ np.asarray(facing, float) < 0:
P = P[::-1].copy()
soft = {(N - 2 - i) % N for i in soft}
round_ = {N - 1 - i for i in round_}
n, c = newell(P), P.mean(0)
out = np.array([_unit((p - c) - n * ((p - c) @ n)) for p in P])
S = P + out * flare - n * drop
centre = c + n * dome
verts = [[round(float(x), 5) for x in p] for p in list(P) + list(S) + [centre]]
faces = [[i, (i + 1) % N, 2 * N] for i in range(N)] + [[N + i, N + (i + 1) % N, (i + 1) % N, i] for i in range(N)]
creases = [[i, (i + 1) % N, HARD] for i in range(N) if i not in soft]
corners = [[i, 1.0] for i in range(N) if i not in round_] + [[N + i, 1.0] for i in range(N) if i not in round_]
poles = [] if N == 4 else [2 * N]
return {"verts": verts, "faces": faces, "creases": creases, "corners": corners, "poles": poles, "rim": 0.0}, N, (soft, round_)
def runs(N, soft, round_):
"""The crown's hard runs: maximal chains of creased sides between pinned corners (a round corner is a run's
inner point; a soft side breaks the chain). [[v, ...]] in crown indices."""
out = []
starts = [i for i in range(N) if i not in round_]
for a in starts:
if a in soft:
continue
chain, i = [a], a
while True:
j = (i + 1) % N
chain.append(j)
if j not in round_ or j in soft or j == a:
break
i = j
if len(set(chain)) == len(chain) and chain[-1] not in round_:
out.append(chain)
return out
def fit(document, N, marks, frame, cam, line, share=0.1, tol=5.2, shift=(0.0, 0.0)):
"""core.fit_sheet on the crown's hard runs. `line` is the traced polygon, one pixel a crown vertex, in the order
the document's crown ended up in. Returns (fitted crown (N, 3) or None, report)."""
from brokkr_kitbash import core as kit
from brokkr_reference import core as ref
soft, round_ = marks
line = [[u + shift[0], v + shift[1]] for u, v in line]
traces = [{"run": {"verts": chain}, "side": 1, "line": [line[v] for v in chain]} for chain in runs(N, soft, round_)]
if not traces:
return None, {"refused": "no hard run between pinned corners"}
try:
out = ref.fit_sheet(document, kit.sheet(document), [list(map(float, row)) for row in np.asarray(frame)], traces, [cam] * len(traces), share=share, tol=tol)
except ref.ReferenceFitError as refusal:
return None, {"refused": str(refusal)[:300], "runs": len(traces)}
moved = [p["moved_m"] for p in out["points"]]
report = {"runs": len(traces), "unexplained_px": round(max(t["unexplained_px"] for t in out["traces"]), 2), "worst_px": round(max(t["worst_px"] for t in out["traces"]), 2),
"moved_m": round(max(moved), 4), "prior_share": [round(min(p["prior_share"] for p in out["points"]), 3), round(max(p["prior_share"] for p in out["points"]), 3)]}
return np.array(out["sheet"]["verts"][:N], float), report
def stats(document):
edges = {}
for f in document["faces"]:
for a, b in zip(f, f[1:] + f[:1]):
edges[(min(a, b), max(a, b))] = edges.get((min(a, b), max(a, b)), 0) + 1
creased = {(min(a, b), max(a, b)) for a, b, w in document.get("creases", []) if w > 0}
return {"verts": len(document["verts"]), "faces": len(document["faces"]), "triangles": sum(1 for f in document["faces"] if len(f) == 3), "edges": len(edges),
"creased": len(creased), "crease_share": round(len(creased) / len(edges), 3), "poles": len(document.get("poles", []))}
def shell(name, crown, frame, mat="khaki", facing=None, flare=0.06, drop=0.07, dome=0.02, soft=(), round_=(), thickness=0.05, levels=2, bevel=0.0,
trace=None, cam=None, view=None, shift=(0.0, 0.0), share=0.1, tol=5.2):
"""One plate, built in the world at `frame` (parent it afterwards). With `trace` (the polygon in the view's
pixels, a point a crown vertex as given) its crown's hard runs are fitted first; a refused fit keeps the blocking
and says so. Returns the object; PLATES[name] holds the numbers, PLATES[name]["crown"] the crown as built."""
import mechlib as M
from mathutils import Matrix
crown = np.asarray(crown, float)
doc, N, marks = sheet(crown, flare, drop, dome, soft, round_, facing)
report = None
if trace is not None:
line = list(trace)
if not np.allclose(np.asarray(doc["verts"][0]), crown[0], atol=1e-4): # the crown was reversed: the trace follows
line = line[::-1]
fitted, report = fit(doc, N, marks, frame, cam, line, share, tol, shift)
report["view"] = view
if fitted is not None:
doc, N, marks = sheet(fitted, flare, drop, dome, marks[0], marks[1], None)
build = M.Build(name, None, Matrix(np.asarray(frame).tolist()))
obj = M.shell_action(name, doc, build, mat, thickness=thickness, levels=levels, bevel=bevel)
PLATES[name] = dict(stats(doc), fit=report, crown=[list(map(float, p)) for p in doc["verts"][:N]])
span = np.ptp(np.asarray(doc["verts"]), axis=0)
print("PLATE", name, "N", N, "span", [round(float(v), 2) for v in span], "centre", [round(float(v), 2) for v in np.mean(doc["verts"], axis=0)], "FIT " + json.dumps(report) if report else "", flush=True)
return obj
# --- layering -------------------------------------------------------------------------------------------------------
def basis(crown):
"""(centre, e1, e2, n) of a crown: n its normal, e2 the frame's z laid in its plane (or y where the plate lies
flat), e1 = e2 x n."""
P = np.asarray(crown, float)
n, c = newell(P), P.mean(0)
up = np.array([0.0, 0.0, 1.0]) if abs(n[2]) < 0.9 else np.array([0.0, 1.0, 0.0])
e2 = _unit(up - n * (up @ n))
return c, np.cross(e2, n), e2, n
def grown(crown, by=1.12, back=0.08, shift=(0.0, 0.0)):
"""The crown scaled about its centre in its own plane, moved `shift` in the plane and `back` behind it: the
plate under a plate."""
c, e1, e2, n = basis(crown)
return np.array([c + (np.asarray(p) - c) * by + e1 * shift[0] + e2 * shift[1] - n * back for p in crown])
def patch(crown, at=(0.0, 0.0), size=(0.3, 0.2), lift_=0.04, turn=0.0, cut=0.0):
"""A small crown on a crown's face: a rectangle `size` centred `at` (plane coordinates: e1 across, e2 up), turned
`turn` degrees, standing `lift_` proud; `cut` clips its two upper corners (a six-sided lame)."""
c, e1, e2, n = basis(crown)
w, h = size[0] / 2, size[1] / 2
pts = [(-w, -h), (w, -h), (w, h), (-w, h)] if not cut else [(-w, -h), (w, -h), (w, h - cut), (w - cut, h), (-w + cut, h), (-w, h - cut)]
a = math.radians(turn)
return np.array([c + e1 * (at[0] + x * math.cos(a) - y * math.sin(a)) + e2 * (at[1] + x * math.sin(a) + y * math.cos(a)) + n * lift_ for x, y in pts])
def mirrored(crown):
return np.array([[-p[0], p[1], p[2]] for p in crown])[::-1]
def summary():
rows = list(PLATES.values())
if not rows:
return {}
edges, creased = sum(r["edges"] for r in rows), sum(r["creased"] for r in rows)
fits = [r["fit"] for r in rows if r["fit"]]
return {"plates": len(rows), "cage_verts": sum(r["verts"] for r in rows), "verts_per_plate": round(sum(r["verts"] for r in rows) / len(rows), 1), "edges": edges, "creased": creased,
"crease_share": round(creased / edges, 3), "poles": sum(r["poles"] for r in rows), "fitted": sum(1 for f in fits if "refused" not in f),
"refused": sum(1 for f in fits if "refused" in f), "worst_unexplained_px": max((f["unexplained_px"] for f in fits if "refused" not in f), default=None)}

View file

@ -46,6 +46,7 @@ from mathutils import Matrix, Vector
from mathutils.bvhtree import BVHTree from mathutils.bvhtree import BVHTree
import mechlib as M import mechlib as M
from paint import mirrored
T = Matrix.Translation T = Matrix.Translation
RX = lambda deg: Matrix.Rotation(math.radians(deg), 4, "X") # noqa: E731 RX = lambda deg: Matrix.Rotation(math.radians(deg), 4, "X") # noqa: E731
@ -784,7 +785,12 @@ FONT = r"C:\Windows\Fonts\bahnschrift.ttf"
def decal(skin, frame, curve, mat="marking", lift=0.0012, grid=0.03): def decal(skin, frame, curve, mat="marking", lift=0.0012, grid=0.03):
"""A flat 2D curve (in its own xy, metres, centred) laid on the surface along the frame's -z: filled, cut to a """A flat 2D curve (in its own xy, metres, centred) laid on the surface along the frame's -z: filled, cut to a
`grid` so it bends over a curve or a crease, each vertex set `lift` off the face. Becomes <shell>.mark.<n>.""" `grid` so it bends over a curve or a crease, each vertex set `lift` off the face. Becomes <shell>.mark.<n>.
It reads left to right from outside the plate on either side of a mech: where the plate's world matrix and the
frame together reverse handedness (paint.mirrored(): a plate instanced at a negative scale, a frame carried
through a mirroring to_host or written for the other side), the curve's own x is reversed before it is laid.
paint_test.py pins that on a mirrored plate."""
reading = -1.0 if mirrored(skin.obj.matrix_world, frame) else 1.0
holder = bpy.data.objects.new("decal.tmp", curve) holder = bpy.data.objects.new("decal.tmp", curve)
bpy.context.scene.collection.objects.link(holder) bpy.context.scene.collection.objects.link(holder)
M.update() M.update()
@ -803,7 +809,7 @@ def decal(skin, frame, curve, mat="marking", lift=0.0012, grid=0.03):
bmesh.ops.bisect_plane(bm, geom=bm.verts[:] + bm.edges[:] + bm.faces[:], plane_co=normal * (k * grid), plane_no=normal) bmesh.ops.bisect_plane(bm, geom=bm.verts[:] + bm.edges[:] + bm.faces[:], plane_co=normal * (k * grid), plane_no=normal)
k += 1 k += 1
for v in bm.verts: for v in bm.verts:
seat = skin.sub(frame, v.co.x - centre.x, v.co.y - centre.y) seat = skin.sub(frame, reading * (v.co.x - centre.x), v.co.y - centre.y)
v.co = seat.translation + seat.col[2].xyz * lift v.co = seat.translation + seat.col[2].xyz * lift
bmesh.ops.recalc_face_normals(bm, faces=bm.faces[:]) bmesh.ops.recalc_face_normals(bm, faces=bm.faces[:])
probe = next(iter(bm.faces)) probe = next(iter(bm.faces))
@ -848,7 +854,7 @@ def numeral(skin, frame, text="03", height=0.2, mat="marking", font=FONT, spacin
def emblem(skin, frame, kind="wings", height=0.3, mat="marking"): def emblem(skin, frame, kind="wings", height=0.3, mat="marking"):
"""UNIT MARK (SERAPH, 30.webp: "wings", the Union Defense Systems blade between swept wings from the sheet's """UNIT MARK (PALADIN, 27.webp: "triangle", the hollow triangle, point down; SERAPH, 30.webp: "wings", the Union Defense Systems blade between swept wings from the sheet's
margin; "roundel", the ringed swoosh on the pauldron's front shield; BREAKER, 24.webp and R-3: "shield", an margin; "roundel", the ringed swoosh on the pauldron's front shield; BREAKER, 24.webp and R-3: "shield", an
emblem shield with a chevron). Painted, bent with the plate.""" emblem shield with a chevron). Painted, bent with the plate."""
s = height s = height
@ -863,6 +869,9 @@ def emblem(skin, frame, kind="wings", height=0.3, mat="marking"):
inner = [(0.43 * math.cos(2 * math.pi * k / 40), 0.43 * math.sin(2 * math.pi * k / 40)) for k in range(40)][::-1] inner = [(0.43 * math.cos(2 * math.pi * k / 40), 0.43 * math.sin(2 * math.pi * k / 40)) for k in range(40)][::-1]
swoosh = [(-0.3, -0.16), (-0.1, -0.3), (0.14, -0.26), (0.3, -0.08), (0.34, 0.16), (0.22, 0.02), (0.06, -0.08), (-0.1, -0.08), (-0.2, 0.02), (-0.24, 0.2), (-0.1, 0.32), (-0.3, 0.26), (-0.36, 0.06)] swoosh = [(-0.3, -0.16), (-0.1, -0.3), (0.14, -0.26), (0.3, -0.08), (0.34, 0.16), (0.22, 0.02), (0.06, -0.08), (-0.1, -0.08), (-0.2, 0.02), (-0.24, 0.2), (-0.1, 0.32), (-0.3, 0.26), (-0.36, 0.06)]
loops = [outer, inner, swoosh] loops = [outer, inner, swoosh]
elif kind == "triangle": # PALADIN, 27.webp: the hollow triangle, point down, on the thigh's shield and the calf block
outer = [(-0.5, 0.42), (0.5, 0.42), (0.0, -0.5)]
loops = [outer, [(0.72 * x, 0.72 * (y - 0.11) + 0.11) for x, y in outer][::-1]]
else: else:
heater = [(-0.4, 0.5), (0.4, 0.5), (0.4, 0.05), (0.26, -0.28), (0, -0.5), (-0.26, -0.28), (-0.4, 0.05)] heater = [(-0.4, 0.5), (0.4, 0.5), (0.4, 0.05), (0.26, -0.28), (0, -0.5), (-0.26, -0.28), (-0.4, 0.05)]
loops = [heater, [(0.86 * x, 0.86 * y + 0.01) for x, y in heater][::-1], [(-0.24, 0.2), (0, -0.02), (0.24, 0.2), (0.24, 0.02), (0, -0.2), (-0.24, 0.02)]] loops = [heater, [(0.86 * x, 0.86 * y + 0.01) for x, y in heater][::-1], [(-0.24, 0.2), (0, -0.02), (0.24, 0.2), (0.24, 0.02), (0, -0.2), (-0.24, 0.02)]]