RAPTOR, fourth pass (sheet 38, image 43): every plate hard, authored by its faces
The hull is a slim faceted wedge (raptor_form.section, surf): a dark hard core, 25 hard slabs a side each on the plane through its own corners at its own lift (raptor_body.wedge_plate, slab), stepped bolted panels and fittings on top (dress: massing.clad, bolt rows, handles, eyes, louvres, ports), and an open underbody (keel, ribs, pipes, tanks, hoses) instead of the third pass's plated belly. The soft hull cage, its trace fit and the free-cage plates and limb shells are removed. The canopy spans the whole front: flat panes under a dark lattice of hoops, rails and diagonals (paint glass preset "faceted"). Leg armour is hard housings and shields, the shin 1.0 m and the cannon 0.88 m across. The rear is a pack of stepped equipment blocks, stacks, canisters, rails and hoses. The 27 goes through surface.numeral on the cheek and the pauldron with Legibility 1.7. Square-on views stand on plain ground (the mud's noise striped edge on). Standing pose rebalanced: margin 0.315 m (fore 0.35, aft 0.32). 105 hard solids, 216 detail panels, 72 fittings, 18 hoses, 0 soft cages. massing.py and mechlib.py from nibu/fable-paladin-3, paint.py and surface.py from nibu/fable-paint-2. Sheet raptor_vs_passes adds the third pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
a9ec759881
commit
0c271035b8
8 changed files with 1382 additions and 554 deletions
|
|
@ -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):
|
||||
|
||||
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
|
||||
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`
|
||||
|
|
@ -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
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
|
@ -62,6 +83,142 @@ def solid(name, points, faces, frame, mat="khaki", levels=1, flat=True):
|
|||
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):
|
||||
obj = _object(name, bm, "frame", frame)
|
||||
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))
|
||||
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
|
||||
|
||||
|
||||
# --- 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
|
||||
|
|
|
|||
|
|
@ -723,8 +723,9 @@ def _turn_and_stretch(name, to_host):
|
|||
|
||||
|
||||
def shell_action(name, sheet, build, mat, thickness=0.05, offset=-1.0, levels=3, bevel=0.0):
|
||||
"""A faceted, hollow plate by brokkr_kitbash.shell on a Build's host: `sheet` is its document ({rings, closed,
|
||||
mirror, creases, rim, flip}) in the component's frame. The shell is parented to build.host and stands where
|
||||
"""A faceted, hollow plate by brokkr_kitbash.shell on a Build's host: `sheet` is its document, a loft ({rings,
|
||||
closed, mirror, creases, rim, flip}) or a free cage ({verts, faces, creases, corners, poles, mirror, rim, flip}),
|
||||
in the component's frame. The shell is parented to build.host and stands where
|
||||
Build.done puts a Geo: the turn and move of build.to_host are the object's matrix, and its sizes and mirror are
|
||||
written into the ring points, since the kitbash actions cut and rib only an unscaled object. A mirror reverses
|
||||
`flip`, so the wall stays on the plate's inside; on a sheet that is itself mirrored about x it changes nothing. A
|
||||
|
|
@ -736,16 +737,20 @@ def shell_action(name, sheet, build, mat, thickness=0.05, offset=-1.0, levels=3,
|
|||
turn, stretch = _turn_and_stretch(name, Matrix.Identity(4) if build.to_host is None else Matrix(build.to_host))
|
||||
sx, sy, sz = (stretch[k][k] for k in range(3))
|
||||
sheet = dict(sheet)
|
||||
if sheet.get("mirror"):
|
||||
sheet["rings"] = [[[abs(sx) * p[0], sy * p[1], sz * p[2]] for p in ring] for ring in sheet["rings"]] # the cage is its own mirror image about x
|
||||
mx = abs(sx) if sheet.get("mirror") else sx # a mirrored cage is its own mirror image about x
|
||||
if "verts" in sheet:
|
||||
sheet["verts"] = [[mx * p[0], sy * p[1], sz * p[2]] for p in sheet["verts"]]
|
||||
else:
|
||||
sheet["rings"] = [[[sx * p[0], sy * p[1], sz * p[2]] for p in ring] for ring in sheet["rings"]]
|
||||
if sx < 0:
|
||||
sheet["flip"] = not sheet.get("flip", False)
|
||||
sheet["rings"] = [[[mx * p[0], sy * p[1], sz * p[2]] for p in ring] for ring in sheet["rings"]]
|
||||
if mx < 0:
|
||||
sheet["flip"] = not sheet.get("flip", False)
|
||||
result = bpy.ops.brokkr_kitbash.shell(object_name=name, sheet=json.dumps(sheet), thickness=thickness, offset=offset, levels=levels, bevel=bevel, count_folds=True)
|
||||
if "FINISHED" not in result:
|
||||
raise SystemExit(f"shell {name}: {result}")
|
||||
FOLDED[name] = json.loads(getattr(bpy.context.window_manager, KB.RESULT))["folded"]
|
||||
report = json.loads(getattr(bpy.context.window_manager, KB.RESULT))
|
||||
FOLDED[name] = report["folded"]
|
||||
if "verts" in sheet:
|
||||
print("CAGE", name, json.dumps({key: report[key] for key in ("cageVerts", "cageFaces", "triangles", "creases", "poles", "closed", "subdividedFaces", "facing")}), flush=True)
|
||||
if FOLDED[name]:
|
||||
print(f"FOLD {name}: {FOLDED[name]} inner faces of the wall fold at thickness {thickness:g}, levels {levels}", flush=True)
|
||||
obj = bpy.data.objects[name]
|
||||
|
|
@ -759,6 +764,44 @@ def shell_action(name, sheet, build, mat, thickness=0.05, offset=-1.0, levels=3,
|
|||
return obj
|
||||
|
||||
|
||||
def cage_wire(shell, width=0.012):
|
||||
"""Three objects drawn over a shell, children of it, for a picture of its cage: the cage's uncreased edges as dark
|
||||
rods, its creased edges (the rim's included, where the rim carries a weight) as thicker red ones, and a yellow
|
||||
ball on each pole (a vertex whose valence is not 4 off the boundary, or not 2 or 3 on it). Read from the cage mesh
|
||||
and its crease_edge attribute as brokkr_kitbash.shell wrote them. Returns the objects, for the caller to remove."""
|
||||
cage = shell.data
|
||||
weights = cage.attributes["crease_edge"].data
|
||||
made = []
|
||||
for label, color, creased, depth in (("edges", (0.01, 0.01, 0.01), False, width), ("creases", (1.0, 0.02, 0.02), True, 1.6 * width)):
|
||||
curve = bpy.data.curves.new(f"{shell.name}.wire.{label}", "CURVE")
|
||||
curve.dimensions, curve.bevel_depth, curve.bevel_resolution = "3D", depth, 2
|
||||
for edge in cage.edges:
|
||||
if (weights[edge.index].value > 0) == creased:
|
||||
spline = curve.splines.new("POLY")
|
||||
spline.points.add(1)
|
||||
for point, v in zip(spline.points, edge.vertices):
|
||||
point.co = (*cage.vertices[v].co, 1.0)
|
||||
made.append((bpy.data.objects.new(curve.name, curve), color))
|
||||
bm = bmesh.new()
|
||||
bm.from_mesh(cage)
|
||||
balls = bmesh.new()
|
||||
for v in bm.verts:
|
||||
if len(v.link_edges) not in ((2, 3) if v.is_boundary else (4,)):
|
||||
bmesh.ops.create_icosphere(balls, subdivisions=2, radius=3.0 * width, matrix=Matrix.Translation(v.co))
|
||||
bm.free()
|
||||
mesh = bpy.data.meshes.new(f"{shell.name}.wire.poles")
|
||||
balls.to_mesh(mesh)
|
||||
balls.free()
|
||||
made.append((bpy.data.objects.new(mesh.name, mesh), (1.0, 0.8, 0.0)))
|
||||
for obj, color in made:
|
||||
paint = bpy.data.materials.get("wire." + obj.name.rsplit(".", 1)[-1]) or material("wire." + obj.name.rsplit(".", 1)[-1], color, 0.0, 0.6, emission=(color, 1.5))
|
||||
obj.data.materials.append(paint)
|
||||
obj.parent = shell
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
update()
|
||||
return [obj for obj, _ in made]
|
||||
|
||||
|
||||
def shells_sound():
|
||||
"""Every shell shell_action made, as built: the folded inner faces the action counted, and the edges of its whole
|
||||
evaluated stack (wall, cuts, bevel) that do not join exactly two faces. Prints a line a shell and the totals,
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@ The hook, after a mech is built and before it is rendered:
|
|||
|
||||
import paint; paint.apply("seraph")
|
||||
|
||||
apply(preset, ground=0.0, objects=None, scale=1.0, **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,
|
||||
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
|
||||
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, every glass for
|
||||
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).
|
||||
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).
|
||||
|
|
@ -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).
|
||||
material(name, role="armour", preset="seraph", **overrides)
|
||||
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:
|
||||
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).
|
||||
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,
|
||||
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
|
||||
|
|
@ -50,6 +75,7 @@ INPUTS = {
|
|||
"Cover Color": ("NodeSocketColor", (0.2, 0.19, 0.165, 1.0)),
|
||||
"Cover": ("NodeSocketFloat", 0.0),
|
||||
"Cover Wear": ("NodeSocketFloat", 0.5),
|
||||
"Legibility": ("NodeSocketFloat", 0.0),
|
||||
"Grime": ("NodeSocketFloat", 1.0),
|
||||
"Grime Color": ("NodeSocketColor", (0.02, 0.017, 0.013, 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": {"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},
|
||||
"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.
|
||||
"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},
|
||||
"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": {"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)},
|
||||
"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": {"armour": {"base_color": (0.05, 0.052, 0.033), "wear": 0.9, "grime": 0.9, "streaks": 0.9},
|
||||
"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": {"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},
|
||||
"mark": {"cover_wear": 0.5}},
|
||||
"mark": {"cover_color": (0.3, 0.29, 0.25), "cover_wear": 0.5, "legibility": 0.8}},
|
||||
}
|
||||
ROLES = {
|
||||
"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"},
|
||||
"mark": {"stencil", "marking", "marking_fresh"},
|
||||
"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:
|
||||
|
|
@ -163,11 +190,22 @@ class _Net:
|
|||
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():
|
||||
"""The MechPaint node group; built on first call, then the one in the file."""
|
||||
if GROUP in bpy.data.node_groups:
|
||||
return bpy.data.node_groups[GROUP]
|
||||
tree = bpy.data.node_groups.new(GROUP, "ShaderNodeTree")
|
||||
tree = _current(GROUP, INPUTS)
|
||||
if tree.nodes:
|
||||
return tree
|
||||
for name, (kind, default) in INPUTS.items():
|
||||
s = tree.interface.new_socket(name, in_out="INPUT", socket_type=kind)
|
||||
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)))
|
||||
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
|
||||
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))
|
||||
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
|
||||
ao = tree.nodes.new("ShaderNodeAmbientOcclusion")
|
||||
|
|
@ -224,6 +263,8 @@ def group():
|
|||
# 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)
|
||||
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
|
||||
bevel = tree.nodes.new("ShaderNodeBevel")
|
||||
|
|
@ -262,11 +303,195 @@ def group():
|
|||
return tree
|
||||
|
||||
|
||||
def _input_name(key):
|
||||
for name in INPUTS:
|
||||
GLASS_GROUP = "MechGlass"
|
||||
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:
|
||||
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):
|
||||
|
|
@ -298,8 +523,11 @@ def material(name, role="armour", preset="seraph", **overrides):
|
|||
return mat
|
||||
|
||||
|
||||
def apply(preset="seraph", ground=0.0, objects=None, scale=1.0, roles=None, **overrides):
|
||||
"""Repaint a built mech: see the module header. `roles` adds or moves material names, {name: role}."""
|
||||
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}; 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.update(roles or {})
|
||||
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"):
|
||||
continue
|
||||
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:
|
||||
continue
|
||||
if role not in made:
|
||||
made[role] = material(f"paint_{preset}_{role}", role, preset, ground_z=ground, scale=scale, **({} if role == "metal" else overrides))
|
||||
swapped[slot.material.name] = made[role]
|
||||
slot.material = made[role]
|
||||
key = role
|
||||
if role == "glass":
|
||||
key = "lens" if max(obj.dimensions) * scale < lens_below else "pane"
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,21 +1,20 @@
|
|||
"""RAPTOR: the operator's concept sheet (images/38.webp), its second hero (images/43.webp) and its design prompt,
|
||||
built mass first. Third pass.
|
||||
fourth pass: hard plates.
|
||||
|
||||
The character is the body's side profile: one long curve from the nose's low tip up the canopy, over the back and
|
||||
along the raised equipment spine to the tail. raptor_trace.py takes it off the sheet's SIDE view; raptor_solve.py
|
||||
solves the cameras (side, hero, image 43) and the hero views' poses; raptor_form.py blocks the hull's cage under the
|
||||
curve; raptor_body.hull_mass builds it as ONE sculpted mass and fits its dorsal run and its chine to their traces
|
||||
through the solved side camera (brokkr_reference: the trace fit), then laps the plates over it; the legs are
|
||||
digitigrade.py's kit chain (hip, knee, hock, ankle), re-posed for each view; balance.py reads the centre of mass
|
||||
against the feet in the standing pose.
|
||||
The character is the body's side profile: one long line from the nose's low tip up the canopy, over the back and
|
||||
along the raised equipment spine to the tail, over a slim wedge. raptor_trace.py takes it off the sheet's SIDE view;
|
||||
raptor_solve.py solves the cameras (side, hero, image 43) and the hero views' poses; raptor_form.py holds the wedge's
|
||||
sections and its plates; raptor_body builds every plate HARD, by its faces, over a dark core, with an open underbody;
|
||||
the legs are digitigrade.py's kit chain (hip, knee, hock, ankle), re-posed for each view; balance.py reads the centre
|
||||
of mass against the feet in the standing pose.
|
||||
|
||||
RAPTOR_STAGE stops the build early: volume (the fitted mass and the legs' cores alone), plates, full (default).
|
||||
RAPTOR_STAGE stops the build early: volume (the wedge's core and the legs' cores alone), plates, full (default).
|
||||
MECH_QUICK renders by Workbench. RAPTOR_VIEWS names the views to render (side,front,rear,hero,balance,v43);
|
||||
RAPTOR_NO_DETAIL, _NO_EDGES and _NO_PARTS skip the detail pass, the built edges and the components' photographs.
|
||||
Writes under MECH_OUT/raptor/: <stage>_<view>.png (each at its camera, the concept's own pixels), <stage>_sil_<view>.png,
|
||||
<stage>_profile.png, <stage>_edges_side.json, full_edges_v43.json, <stage>_turn_*.png, part_<name>.png,
|
||||
raptor_skeleton.json, raptor_joints.json (the kit's joints reports), raptor_cages.json (the free cages' counts),
|
||||
raptor_fit.json (the trace fit), raptor_plates.json (the plates' outlines as built) and raptor_balance.json."""
|
||||
raptor_skeleton.json, raptor_joints.json (the kit's joints reports), raptor_hard.json (every hard solid, the
|
||||
counts of panels and fittings), raptor_plates.json (the plates' outlines) and raptor_balance.json."""
|
||||
import json, math, os, sys, time
|
||||
from pathlib import Path
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
|
@ -45,30 +44,27 @@ cams = RF.cameras()
|
|||
if "side_solved" in cams:
|
||||
cams["side"] = dict(cams["side"], **{k: cams["side_solved"][k] for k in ("C", "R", "f", "c", "distance", "model", "rms")})
|
||||
cams["side"] = RB.near(cams["side"]) # the solved camera, levelled and drawn in: Blender's lens stops at 5000 mm and the stage's ground hides a camera under it
|
||||
mass = RB.hull_mass(P if AT < 1 else RB.CORE, cam=cams["side"])
|
||||
(OUT / "raptor_fit.json").write_text(json.dumps(RB.FIT, indent=1), encoding="utf-8")
|
||||
core = RB.hull_core(P if AT < 1 else RB.CORE)
|
||||
cores = RB.leg_cores(P if AT < 2 else RB.CORE)
|
||||
body = None
|
||||
if AT >= 1:
|
||||
RB.hull_core()
|
||||
torso = RB.hull_plates() + RB.beak()
|
||||
import surface as S
|
||||
S.materials()
|
||||
torso = RB.hull_plates() + RB.canopy() + RB.beak() + RB.dorsal_spine()
|
||||
(OUT / "raptor_plates.json").write_text(json.dumps(RB.PLATES), encoding="utf-8")
|
||||
if AT >= 2 and not os.environ.get("RAPTOR_NO_DETAIL"):
|
||||
RB.detail()
|
||||
print("detail s", round(time.time() - t0, 1), flush=True)
|
||||
print("FROZEN", RB.freeze(torso + [mass]), "hull plates; s", round(time.time() - t0, 1), flush=True)
|
||||
(OUT / "raptor_cages.json").write_text(json.dumps(RB.CAGES, indent=1), encoding="utf-8")
|
||||
print("FROZEN", RB.freeze(torso), "hull objects; s", round(time.time() - t0, 1), flush=True)
|
||||
if AT >= 2:
|
||||
body = RB.full(cores)
|
||||
(OUT / "raptor_joints.json").write_text(json.dumps(RB.JOINTS, indent=1), encoding="utf-8")
|
||||
(OUT / "raptor_cages.json").write_text(json.dumps(RB.CAGES, indent=1), encoding="utf-8")
|
||||
for root, rep in RB.JOINTS.items():
|
||||
for j in rep.get("joints", []):
|
||||
print(f"JOINT {root}: {j.get('part')} {j.get('mechanism')} {j.get('kind')} value {j.get('value'):.1f} limits {j.get('limits')}", flush=True)
|
||||
if RB.CAGES:
|
||||
hull = [v for k, v in RB.CAGES.items() if k.startswith("Torso.")]
|
||||
print(f"CAGES: {len(RB.CAGES)} free cages; hull {len(hull)} cages, {sum(v['verts'] for v in hull)} vertices, crease share {sum(v['creased'] for v in hull) / sum(v['edges'] for v in hull):.3f}; "
|
||||
f"all {sum(v['creased'] for v in RB.CAGES.values()) / sum(v['edges'] for v in RB.CAGES.values()):.3f}", flush=True)
|
||||
if AT >= 1:
|
||||
kinds = {name: RF.KINDS.get(name.rstrip("LR"), "hard") for name in RB.HARD}
|
||||
(OUT / "raptor_hard.json").write_text(json.dumps({"hard": RB.HARD, "kinds": kinds, "count": RB.COUNT, "soft": [k for k, v in kinds.items() if v != "hard"]}, indent=1), encoding="utf-8")
|
||||
print(f"HARD: {len(RB.HARD)} hard solids, {RB.COUNT['panels']} detail panels, {RB.COUNT['fits']} fittings, {RB.COUNT['marks']} markings, {RB.COUNT['hoses']} hoses; soft plates: 0", flush=True)
|
||||
for f in RB.COUNT["failed"]:
|
||||
print(" FIT FAILED", f, flush=True)
|
||||
M.update()
|
||||
M.reskin({"frame": "gunmetal", "machine": "gunmetal", "structure": "gunmetal", "olive": "khaki"})
|
||||
lo, hi = M.bounds()
|
||||
|
|
@ -95,9 +91,12 @@ if body is not None:
|
|||
(OUT / "raptor_skeleton.json").write_text(json.dumps({"world": {p: {k: list(v) for k, v in RF.joints(p).items()} for p in RF.POSES}, "views": report}, indent=1), encoding="utf-8")
|
||||
if not QUICK:
|
||||
import paint
|
||||
paint.apply("breaker")
|
||||
paint.apply("mcr3", glass="faceted", legibility=1.7) # the 27 is read at figure scale: the marking lifted out of the grime
|
||||
rig, cam, centre, radius = M.stage_field(8 if QUICK else int(os.environ.get("MECH_SAMPLES", 48)))
|
||||
scene = bpy.context.scene
|
||||
GROUND = bpy.data.objects.get("Ground")
|
||||
M.material("ground_flat", (0.17, 0.165, 0.155), 0.0, 0.92)
|
||||
MUD = GROUND.data.materials[0] if GROUND else None
|
||||
|
||||
|
||||
def pose(tag):
|
||||
|
|
@ -121,6 +120,8 @@ VIEWS = [v for v in os.environ.get("RAPTOR_VIEWS", "side,front,rear,hero,balance
|
|||
HULL_BOX = [176, 650, 432, 765]
|
||||
for tag in VIEWS:
|
||||
pose(tag)
|
||||
if GROUND: # a square-on camera 400 m off sees the mud's noise edge on, as stripes: those views stand on plain ground
|
||||
GROUND.data.materials[0] = bpy.data.materials["ground_flat"] if tag in ("side", "balance", "front", "rear") else MUD
|
||||
if tag not in cams:
|
||||
continue
|
||||
cam.data.clip_start = max(0.1, cams[tag]["distance"] - 40.0)
|
||||
|
|
@ -142,6 +143,8 @@ for tag in VIEWS:
|
|||
print("edges s", round(time.time() - t0, 1), flush=True)
|
||||
pose("side")
|
||||
cam.data.clip_start = 0.1
|
||||
if GROUND:
|
||||
GROUND.data.materials[0] = MUD
|
||||
if STAGE == "full" and not os.environ.get("RAPTOR_NO_PARTS"):
|
||||
for name, (target, spanned, az, el) in RB.COMPONENTS.items():
|
||||
M.closeup(rig, cam, Vector(target), spanned, az, el, OUT / f"part_{name}.png", size=(600, 600) if QUICK else (760, 760))
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,16 +1,17 @@
|
|||
"""RAPTOR as numbers: the side view's scale, the traced profile, the hull's cage blocked under it (one mirrored free
|
||||
cage, fitted to the trace by brokkr_reference in raptor_body.hull_mass), the plates' map in the cage's coordinates,
|
||||
"""RAPTOR as numbers: the side view's scale, the traced profile, the hull's wedge under it (sections; hard
|
||||
plates in the wedge's own coordinates),
|
||||
the digitigrade skeleton and its poses (digitigrade.py). Plain Python and numpy; no Blender.
|
||||
|
||||
World: x to the mech's right, y forward, z up, metres at the sheet's 6.8 m, origin on the ground under the hips.
|
||||
The hull keeps its own coordinates (yh, z): the sheet's side view, yh = 0 on the trace's hip column; OFF stands it
|
||||
in the world, SHIFT back.
|
||||
|
||||
Third pass (sheet 38 the turnaround, image 43 the second hero):
|
||||
hull ONE sculpted mass: a mirrored free cage of 12 six-point sections between a nose and a tail vertex, creased
|
||||
down the dorsal line and along one chine a side, nothing else. Its section is the FRONT view's: a narrow
|
||||
deck (1.1 m), flanks flaring to the chine low on the side (2.14 m), the underside tucked to a keel. The
|
||||
second pass read the shoulder pods as hull (2.7 m) and stood a ten-sided box under the curve.
|
||||
Fourth pass (sheet 38 the turnaround, image 43 the second hero):
|
||||
hull a slim faceted WEDGE of hard plates over a dark core (section, surf, hull_plates): a deck, a flank that
|
||||
leans in to it, an upright jaw band down to the chine and a lip tucked under it. The armour ends at the
|
||||
lip; below it the hull is an open keel with its machinery. The third pass built one soft mass down to the
|
||||
belly's traced line and it read as a pod with a deep round belly: that trace is the bottom of the lasers
|
||||
and the machinery, not of the armour.
|
||||
hips the hip is where the far leg's thigh runs up to under the chine (sheet (338, 716), 4.67 m), and the legs'
|
||||
planes stand 2.8 m apart (FRONT view), outside the hull's 2.14 m: the thigh's housing stands under the
|
||||
chine's overhang, clear of the tucked underside. Nothing spreads the hips.
|
||||
|
|
@ -55,39 +56,34 @@ chine = lambda yh: float(np.interp(yh, *_CHINE)) # noqa: E731 the chin
|
|||
NOSE = tuple(float(v) for v in SHEET.world(BOOK["side"]["curve"][0]))
|
||||
TAIL = tuple(float(v) for v in SHEET.world(BOOK["side"]["curve"][-1]))
|
||||
|
||||
# The hull's sections, nose to tail: (station yh, half-widths of the deck edge, the shoulder, the chine, the bilge).
|
||||
# FRONT view: deck 32 px (1.1 m), chine 61 px (2.14 m) at v 705, the underside back in to 1.1 m. REAR view: the spine
|
||||
# 40 px. The bilge is tucked under the chine all the way: at the hips' station it stands 0.5 m inside the thighs.
|
||||
STATIONS = [(5.45, 0.10, 0.20, 0.24, 0.13), (5.0, 0.20, 0.42, 0.50, 0.26), (4.4, 0.34, 0.66, 0.78, 0.40), (3.6, 0.48, 0.88, 1.00, 0.52), (2.8, 0.55, 0.98, 1.07, 0.56), (2.0, 0.57, 1.00, 1.07, 0.56),
|
||||
(1.2, 0.56, 0.96, 1.02, 0.52), (0.5, 0.50, 0.84, 0.90, 0.46), (-0.1, 0.38, 0.56, 0.60, 0.36), (-0.7, 0.32, 0.46, 0.50, 0.30), (-1.5, 0.28, 0.40, 0.43, 0.26), (-2.2, 0.22, 0.30, 0.32, 0.20)]
|
||||
PER = 6 # a section's points: dorsal, deck edge, shoulder, chine, bilge, keel
|
||||
RIDGE, CROWN, FS, FB = 0.05, 0.08, 0.52, 0.34
|
||||
# --- the hull: a slim faceted wedge of hard plates over a dark core ------------------------------------------------------
|
||||
# A section, nose to tail: (station yh, half-widths of the deck edge, the belt, the chine, the lip). FRONT view: deck
|
||||
# 1.2 m, chine 2.14 m at v 705. The armour ends at the lip, 0.16 m under the chine: nothing is plated below it. Under
|
||||
# the lip the hull is the open keel and its machinery (raptor_body.underbody), down to the belly's traced line.
|
||||
STATIONS = [(5.45, 0.14, 0.27, 0.25, 0.14), (5.0, 0.24, 0.50, 0.49, 0.30), (4.4, 0.38, 0.77, 0.76, 0.48), (3.6, 0.52, 0.99, 0.98, 0.62), (2.8, 0.60, 1.08, 1.07, 0.66), (2.0, 0.62, 1.08, 1.07, 0.66),
|
||||
(1.2, 0.60, 1.03, 1.02, 0.62), (0.5, 0.54, 0.91, 0.90, 0.56), (-0.1, 0.42, 0.62, 0.60, 0.42), (-0.7, 0.36, 0.50, 0.48, 0.34), (-1.5, 0.32, 0.43, 0.41, 0.30), (-2.3, 0.26, 0.34, 0.32, 0.24)]
|
||||
COLS = 5 # a section's points: ridge, deck edge, belt, chine, lip (column t = 0..4)
|
||||
CROWN, LIP = 0.07, 0.16
|
||||
|
||||
|
||||
def ring(row):
|
||||
"""One section's six cage points (x, yh, z), dorsal to keel. The dorsal point stands RIDGE over the trace (the
|
||||
cage stands outside its limit curve) and the deck's edge CROWN under it: the raised dorsal line."""
|
||||
yh, wd, ws, wc, wb = row
|
||||
zt, zb = top(yh), bot(yh)
|
||||
zc = min(max(chine(yh), zb + 0.3 * (zt - zb)), zt - 0.3 * (zt - zb))
|
||||
return [(0.0, yh, zt + RIDGE), (wd, yh, zt - CROWN), (ws, yh, zc + FS * (zt - zc)), (wc, yh, zc), (wb, yh, zb + FB * (zc - zb)), (0.0, yh, zb - 0.03)]
|
||||
def section(yh):
|
||||
"""The hull's section at station yh: five points (x, yh, z), ridge to lip. Widths run straight between the
|
||||
stations (the wedge's facets); heights are the traced dorsal line and chine. The belt is the upper edge of the
|
||||
jaw band: the flank above it leans in to the deck, the band below it stands upright."""
|
||||
ys = [r[0] for r in STATIONS]
|
||||
yq = min(max(yh, ys[-1]), ys[0])
|
||||
w = [float(np.interp(-yq, [-y for y in ys], [r[k] for r in STATIONS])) for k in (1, 2, 3, 4)]
|
||||
zt, zc = top(yh), chine(yh)
|
||||
belt = zc + min(0.42, 0.46 * (zt - zc))
|
||||
return [(0.0, yh, zt), (w[0], yh, zt - CROWN), (w[1], yh, belt), (w[2], yh, zc), (w[3], yh, zc - LIP)]
|
||||
|
||||
|
||||
def hull_cage():
|
||||
"""The hull's mass as a mirrored free cage, authored on the right: {"verts", "faces" (wound outward), "creases",
|
||||
"dorsal", "chine" (the two hard runs, nose to tail, by vertex)}. Vertex 0 is the nose's tip, the last the
|
||||
tail's; ring i, point j is 1 + 6 i + j. 74 vertices."""
|
||||
R = len(STATIONS)
|
||||
verts = [(0.0, NOSE[0], NOSE[1])] + [p for row in STATIONS for p in ring(row)] + [(0.0, TAIL[0], TAIL[1] - 0.04)]
|
||||
at = lambda i, j: 1 + PER * i + j # noqa: E731
|
||||
N, T = 0, len(verts) - 1
|
||||
faces = [(N, at(0, j), at(0, j + 1)) for j in range(PER - 1)]
|
||||
faces += [(at(i, j), at(i + 1, j), at(i + 1, j + 1), at(i, j + 1)) for i in range(R - 1) for j in range(PER - 1)]
|
||||
faces += [(at(R - 1, j), T, at(R - 1, j + 1)) for j in range(PER - 1)]
|
||||
run = lambda j: [N] + [at(i, j) for i in range(R)] + [T] # noqa: E731
|
||||
dorsal, ch = run(0), run(3)
|
||||
creases = [(a, b, 1.0) for r in (dorsal, ch) for a, b in zip(r, r[1:])]
|
||||
return {"verts": verts, "faces": faces, "creases": creases, "dorsal": dorsal, "chine": ch}
|
||||
def surf(yh, t):
|
||||
"""(x, yh, z) on the wedge at station yh, column t (0 ridge, 1 deck edge, 2 belt, 3 chine, 4 lip)."""
|
||||
s = section(yh)
|
||||
j = min(int(math.floor(t)), COLS - 2)
|
||||
f = t - j
|
||||
return tuple(a + f * (b - a) for a, b in zip(s[j], s[j + 1]))
|
||||
|
||||
|
||||
def cameras():
|
||||
|
|
@ -102,62 +98,70 @@ def cameras():
|
|||
return out
|
||||
|
||||
|
||||
# --- the hull's plates: free cages on the mass's surface --------------------------------------------------------------
|
||||
Y_CANOPY = 3.55 # hull station of the canopy's brow hoop
|
||||
GLASS, FRAME = 0.035, 0.1 # lifts: the glazing lies on the mass; its frame stands over it
|
||||
# --- the hull's plates: every one HARD (mech-lessons-2026-12-03) --------------------------------------------------------
|
||||
Y_CANOPY = 3.5 # hull station of the canopy's brow hoop
|
||||
P1, P2, DARK = "khaki", "olive_light", "gunmetal"
|
||||
|
||||
|
||||
def P(name, rows, cols, crease=(), mat="khaki", thick=0.06, mirror=False, sided=False):
|
||||
return {"name": name, "rows": rows, "cols": cols, "crease": tuple(crease), "mat": mat, "thick": thick, "mirror": mirror, "sided": sided}
|
||||
def H(name, outline, lift=0.06, thick=0.10, mat=P1, clad=True, split=0.9, fit=(), gap=0.025, back=0.94):
|
||||
"""A hard plate on the wedge: `outline` [(yh, t)] its corners in the wedge's own coordinates, counter-clockwise or
|
||||
not; built as a slab whose outer face is the plane through them, standing `lift` off the wedge, `thick` deep,
|
||||
drawn in `gap` on every edge so a seam shows; `clad` panels its face, splitting it where it is over `split` m2;
|
||||
`fit` is what stands on it: ("num", text, height), ("bolts", spacing), ("handle", u, v, length), ("eye", u, v),
|
||||
("louvres", u, v, w, h, n[, roll]), ("port", u, v, r), in the face's own metres from its middle (u aft to fore, v up)."""
|
||||
return {"name": name, "outline": outline, "lift": lift, "thick": thick, "mat": mat, "clad": clad, "split": split, "fit": tuple(fit), "gap": gap, "back": back}
|
||||
|
||||
|
||||
def hull_plates():
|
||||
"""The hull's armour and glazing: each plate a FREE cage, a grid of rows (station yh, lift, rake: metres of
|
||||
station per column) by columns t on the fitted mass's surface (raptor_body.surf), where t is 0 on the dorsal
|
||||
line, 1 the deck's edge, 2 the shoulder, 3 the chine, 4 the bilge, 5 the keel.
|
||||
"""The wedge's armour, one side (all are built a side): hero views of sheet 38 and image 43, the SIDE view for
|
||||
the stations. Every plate is hard: both concepts draw the hull as flat facets with straight, chamfered edges,
|
||||
lapped and stepped; nothing on it curves but the dorsal line's sweep, which the facets' stations carry.
|
||||
|
||||
The concepts' armour is flat facets lapped over a swept body, so most plates are FOUR vertices: one facet,
|
||||
pinned at its corners, standing off the mass's curve by its own lift; the mass's sweep is carried by where the
|
||||
facets stand, not by bending them. A plate has a third column, creased, only where it wraps the chine or the
|
||||
dorsal line. Rows run aft to fore; the rear edge is lifted over the front edge of the plate behind.
|
||||
|
||||
The cockpit is the whole front: glazing over the crown (GlassTop) and down each flank to above the chine
|
||||
(GlassA, GlassF; these follow the mass's curve, three rows), under a Brow hoop, a Bar and a Pillar a side, over a Sill rail; the NoseCap is the beak,
|
||||
faceted. The Jaw is the long strake that carries the chine from under the canopy to the beak. Behind: Cheek
|
||||
(upper, and the lower that carries the number), Shoulder standing proud over the hip (upper, and the lower
|
||||
round the chine), Flank; the Deck in two either side of the dorsal ridge and a Collar hoop; Bilge and Keel
|
||||
under, the keel open under the chest for the lasers. The boom: three lapped hoods and a tail keel."""
|
||||
Fore to aft: the Jaw band, three thick slabs from the beak back along the chine under the canopy (sheet 38's
|
||||
hero: the heavy strake under the glass); the Collar, a proud hoop behind the canopy; the Cheek, the five-sided
|
||||
plate that carries the number; a Gill of upright louvres between Cheek and Shoulder (sheet 38's hero); the Shoulder, standing proudest, over
|
||||
the hip; decks either side of the dorsal spine; the belt band under them in short plates; three lapped hoods
|
||||
down the boom; the Lip under the chine, tucked in, in short dark plates."""
|
||||
c = Y_CANOPY
|
||||
hoop = dict(crease=[0, 1, 2], mirror=True)
|
||||
return [
|
||||
P("GlassTop", [(c + 0.05, GLASS, 0), (4.05, GLASS, 0), (4.6, GLASS, 0), (5.2, GLASS, 0)], [0, 1], mat="glass", thick=0.04, mirror=True),
|
||||
P("GlassA", [(c + 0.05, GLASS, 0), (4.0, GLASS, 0), (4.45, GLASS, 0)], [1, 1.5, 2, 2.7], mat="glass", thick=0.04, sided=True),
|
||||
P("GlassF", [(4.45, GLASS, 0), (4.85, GLASS, 0), (5.2, GLASS, 0)], [1, 1.5, 2, 2.7], mat="glass", thick=0.04, sided=True),
|
||||
P("Brow", [(c - 0.18, 0.15, 0), (c + 0.13, 0.12, 0)], [0, 1, 2, 2.9], **hoop),
|
||||
P("Bar", [(4.38, FRAME, 0), (4.52, FRAME, 0)], [0, 1, 2, 2.72], thick=0.05, **hoop),
|
||||
P("Pillar", [(c + 0.1, FRAME, 0), (4.45, FRAME, 0), (5.22, FRAME, 0)], [0.86, 1.0, 1.14], crease=[1], thick=0.05, sided=True),
|
||||
P("Sill", [(c - 0.02, 0.10, 0), (4.45, 0.10, 0), (5.24, 0.09, 0)], [2.62, 2.84], thick=0.06, sided=True),
|
||||
P("NoseCap", [(5.14, 0.12, 0), (5.45, 0.08, 0), (5.7, 0.05, 0)], [0, 1, 2, 3, 3.7], crease=[0, 1, 2, 3], mirror=True),
|
||||
P("Jaw", [(3.15, 0.13, 0), (4.3, 0.11, 0), (5.2, 0.08, 0)], [2.78, 3, 3.34], crease=[1], thick=0.07, sided=True),
|
||||
P("Chin", [(3.8, 0.07, 0), (4.5, 0.06, 0), (5.18, 0.05, 0)], [3.4, 4.3, 5], sided=True, mat="gunmetal"),
|
||||
P("CheekU", [(2.3, 0.14, -0.35), (c - 0.12, 0.09, 0)], [1.14, 2.06], thick=0.07, sided=True),
|
||||
P("CheekL", [(2.15, 0.12, -0.35), (c - 0.14, 0.08, 0)], [1.98, 2.97], thick=0.07, sided=True),
|
||||
P("ShoulderU", [(0.7, 0.24, -0.4), (2.45, 0.19, -0.4)], [1.08, 2.08], thick=0.08, mat="olive_light", sided=True),
|
||||
P("ShoulderL", [(0.85, 0.22, -0.4), (2.4, 0.17, -0.4)], [1.98, 3, 3.14], crease=[1], thick=0.08, mat="olive_light", sided=True),
|
||||
P("Flank", [(0.08, 0.11, 0), (0.95, 0.07, -0.2)], [1.2, 2, 3], crease=[1], sided=True),
|
||||
P("DeckA", [(1.95, 0.14, 0), (c - 0.1, 0.08, 0)], [0, 1, 1.2], crease=[0, 1], mirror=True),
|
||||
P("DeckB", [(0.3, 0.14, 0), (2.12, 0.07, 0)], [0, 1, 1.2], crease=[0, 1], mirror=True),
|
||||
P("Collar", [(2.98, 0.22, 0), (c - 0.26, 0.19, 0)], [0, 1, 2, 2.6], thick=0.07, mat="olive_light", **hoop),
|
||||
P("BilgeA", [(2.05, 0.09, 0), (3.4, 0.04, 0)], [3.14, 4, 4.6], crease=[1], sided=True, mat="gunmetal"),
|
||||
P("BilgeB", [(0.2, 0.09, 0), (2.15, 0.04, 0)], [3.2, 4, 4.6], crease=[1], sided=True, mat="gunmetal"),
|
||||
P("Keel", [(0.2, 0.07, 0), (2.0, 0.03, 0)], [4.64, 5], crease=[1], mirror=True, mat="gunmetal"),
|
||||
P("Hood1", [(-0.75, 0.15, 0), (0.36, 0.07, 0)], [0, 1, 2, 3, 3.5], crease=[0, 1, 3], thick=0.07, mirror=True),
|
||||
P("Hood2", [(-1.6, 0.13, 0), (-0.62, 0.06, 0)], [0, 1, 2, 3, 3.5], crease=[0, 1, 3], thick=0.07, mirror=True),
|
||||
P("Hood3", [(-2.36, 0.10, 0), (-1.48, 0.05, 0)], [0, 1, 2, 3, 3.5], crease=[0, 1, 3], thick=0.07, mirror=True),
|
||||
P("TailKeel", [(-2.3, 0.06, 0), (-0.3, 0.05, 0)], [3.6, 4.3, 5], crease=[1], mirror=True, mat="gunmetal"),
|
||||
H("Jaw1", [(5.5, 2), (5.5, 3), (4.75, 3), (4.75, 2)], 0.10, 0.14, split=9, fit=[("bolts", 0.22)]),
|
||||
H("Jaw2", [(4.72, 1.96), (4.72, 3), (3.95, 3), (3.95, 1.9)], 0.13, 0.16, P2, fit=[("bolts", 0.24), ("handle", 0.0, 0.02, 0.3)]),
|
||||
H("Jaw3", [(3.92, 1.9), (3.92, 3), (3.05, 3), (3.25, 2)], 0.10, 0.14, fit=[("bolts", 0.24), ("port", -0.05, 0.0, 0.09)]),
|
||||
H("JawLip1", [(5.4, 3), (5.4, 4), (4.5, 4), (4.5, 3)], 0.04, 0.08, DARK, clad=False),
|
||||
H("JawLip2", [(4.46, 3), (4.46, 4), (3.4, 4), (3.4, 3)], 0.05, 0.08, P1, split=9),
|
||||
H("CollarU", [(c, 0.12), (c, 1), (c - 0.36, 1), (c - 0.42, 0.12)], 0.17, 0.16, P2, split=9, fit=[("bolts", 0.2)]),
|
||||
H("CollarF", [(c, 1), (c, 2), (c - 0.2, 2), (c - 0.36, 1)], 0.16, 0.16, P2, split=9, fit=[("bolts", 0.2)]),
|
||||
H("Cheek", [(3.08, 1.04), (3.24, 1.96), (2.5, 1.96), (2.32, 1.7), (2.32, 1.04)], 0.11, 0.13, clad=False, fit=[("num", "27", 0.5), ("bolts", 0.26)]),
|
||||
H("CheekDeck", [(3.04, 0.12), (3.04, 0.98), (2.0, 0.98), (2.0, 0.12)], 0.07, 0.10, fit=[("handle", 0.2, 0.0, 0.34), ("eye", -0.3, 0.1)]),
|
||||
H("Gill", [(2.28, 1.04), (2.28, 1.96), (1.98, 1.96), (1.98, 1.04)], 0.05, 0.09, DARK, clad=False, fit=[("louvres", 0.0, 0.0, 0.56, 0.2, 4, 90.0)]),
|
||||
H("Shoulder", [(1.94, 1.04), (1.94, 2.0), (0.62, 2.0), (0.42, 1.04)], 0.2, 0.16, P2, split=0.7, fit=[("bolts", 0.24), ("eye", 0.3, 0.2)]),
|
||||
H("ShoulderDeck", [(1.96, 0.12), (1.96, 0.98), (0.44, 0.98), (0.44, 0.12)], 0.09, 0.10, split=0.6, fit=[("handle", -0.4, 0.0, 0.34)]),
|
||||
H("Belt1", [(3.0, 2.04), (3.02, 3), (2.36, 3), (2.36, 2.04)], 0.07, 0.11, fit=[("port", 0.0, 0.0, 0.08)]),
|
||||
H("Belt2", [(2.33, 2.04), (2.33, 3), (1.5, 3), (1.5, 2.04)], 0.11, 0.12, P2, split=9, fit=[("bolts", 0.22)]),
|
||||
H("Belt3", [(1.47, 2.04), (1.47, 3), (0.78, 3), (0.62, 2.04)], 0.08, 0.11, fit=[("louvres", 0.0, 0.0, 0.42, 0.2, 4)], clad=False),
|
||||
H("Lip1", [(3.36, 3), (3.36, 4), (2.4, 4), (2.4, 3)], 0.03, 0.08, DARK, clad=False),
|
||||
H("Lip2", [(2.36, 3), (2.36, 4), (1.3, 4), (1.3, 3)], 0.05, 0.08, P1, split=9),
|
||||
H("Lip3", [(1.26, 3), (1.26, 4), (0.5, 4), (0.5, 3)], 0.03, 0.08, DARK, clad=False),
|
||||
H("Hood1D", [(0.4, 0.12), (0.4, 1), (-0.66, 1), (-0.66, 0.12)], 0.14, 0.11, split=9, fit=[("bolts", 0.22)]),
|
||||
H("Hood1F", [(0.56, 1.04), (0.74, 3), (-0.1, 3), (-0.66, 3), (-0.66, 1.04)], 0.13, 0.12, split=0.5, fit=[("bolts", 0.24)]),
|
||||
H("Hood2D", [(-0.6, 0.12), (-0.6, 1), (-1.5, 1), (-1.5, 0.12)], 0.10, 0.10, P2, split=9),
|
||||
H("Hood2F", [(-0.62, 1.04), (-0.62, 3), (-1.5, 3), (-1.5, 1.04)], 0.09, 0.11, P2, fit=[("louvres", 0.0, 0.0, 0.4, 0.2, 4)], clad=False),
|
||||
H("Hood3D", [(-1.46, 0.12), (-1.46, 1), (-2.3, 1), (-2.3, 0.12)], 0.06, 0.09, split=9, fit=[("bolts", 0.2)]),
|
||||
H("Hood3F", [(-1.46, 1.04), (-1.46, 3), (-2.3, 3), (-2.3, 1.04)], 0.05, 0.10, split=9, fit=[("bolts", 0.22)]),
|
||||
H("HoodLip", [(0.4, 3), (0.4, 4), (-2.2, 4), (-2.2, 3)], 0.03, 0.07, DARK, clad=False),
|
||||
]
|
||||
|
||||
|
||||
# The canopy (RECESSED COCKPIT inset; both heroes): the whole front of the wedge above the jaw band. Its lattice's
|
||||
# nodes are (station, column): hoops at the stations, rails down the ridge, the deck edge and the belt, and a
|
||||
# diagonal across each flank pane, as the inset draws its triangulated panes.
|
||||
CANOPY_Y = [Y_CANOPY, 4.0, 4.5, 4.95, 5.36]
|
||||
CANOPY_T = [0.0, 1.0, 2.0]
|
||||
KINDS = {f"Torso.{p['name']}": "hard" for p in hull_plates()}
|
||||
KINDS.update({"Torso.core": "hard", "Torso.Beak": "hard", "Torso.Canopy.glass": "hard", "Torso.Canopy.frame": "hard", "Torso.Roof": "hard", "Torso.Spine": "hard", "Thigh.house": "hard", "Thigh.shield": "hard",
|
||||
"Shin.house": "hard", "Shin.shield": "hard", "Cannon.house": "hard", "Cannon.shield": "hard", "Pauldron": "hard", "Pack": "hard"}) # nothing on this mech is soft: the round forms are turned machinery
|
||||
|
||||
|
||||
# --- the skeleton -----------------------------------------------------------------------------------------------------
|
||||
HIP = (0.0, float(LEGS.world(HIP_PX)[1])) # (y, z) of the hip's axis: the world's origin is under it
|
||||
HIP_X = 1.4 # FRONT view: the legs' centre planes stand 80 px (2.8 m) apart
|
||||
|
|
@ -175,7 +179,7 @@ def _pose(marks, weights=(1.0, 1.0, 40.0)):
|
|||
|
||||
|
||||
_FIT = {side: _pose(MARKS[side]) for side in ("L", "R")}
|
||||
STAND_Y = -0.45 # the standing pose's ankles, metres ahead of the hips: under the centre of mass (balance.py; raptor_balance.json)
|
||||
STAND_Y = -0.75 # the standing pose's ankles, metres ahead of the hips: under the centre of mass (balance.py; raptor_balance.json)
|
||||
_STAND = _pose({"knee": (STAND_Y + 0.5, 3.36), "hock": (STAND_Y - 0.83, 2.37), "ankle": (STAND_Y, ANKLE_Z)})
|
||||
POSES = {"side": {"L": _FIT["L"][0], "R": _FIT["R"][0]}, "hero": {"L": _FIT["R"][0], "R": _FIT["L"][0]}, "stand": {"L": _STAND[0], "R": _STAND[0]}}
|
||||
_path = HERE / "raptor_cameras.json"
|
||||
|
|
@ -212,5 +216,5 @@ if __name__ == "__main__":
|
|||
print(f"LEG {side}: marked links", [round(v, 2) for v in DG.lengths(MARKS[side])], "fit angles", [round(v, 1) for v in _FIT[side][0]], "misses m (knee, hock, ankle)", [round(v, 2) for v in _FIT[side][1]])
|
||||
print("STAND angles", [round(v, 1) for v in _STAND[0]], "misses", [round(v, 2) for v in _STAND[1]])
|
||||
for row in STATIONS:
|
||||
print("RING", row[0], [tuple(round(v, 2) for v in (p[0], p[2])) for p in ring(row)])
|
||||
print("cage", len(hull_cage()["verts"]), "verts")
|
||||
print("SECTION", row[0], [tuple(round(v, 2) for v in (p[0], p[2])) for p in section(row[0])])
|
||||
print(len(hull_plates()), "hull plates a side")
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Reads MECH_OUT/raptor/ (raptor.py's renders per stage); writes under MECH_OUT/co
|
|||
raptor_character.png the same line close up on the nose and canopy, sheet | ours
|
||||
raptor_vs_concept.png hero and side, then front and rear: concept | ours | laid over; then image 43 | ours at its
|
||||
solved camera | laid over, and 43's traced roof and jaw lines against our built edges there
|
||||
raptor_vs_pass2.png each view: concept | the second pass (3ced828) | this pass
|
||||
raptor_vs_passes.png each view: concept | the second pass (3ced828) | the third (a9ec759) | this pass
|
||||
raptor_balance.png the standing pose from the side with the centre of mass (uniform density, balance.py) and the
|
||||
feet's contact under it; the same in plan; the masses
|
||||
raptor_flowlines.png the curve and the chines against the hull's built edges at the side camera
|
||||
|
|
@ -35,6 +35,7 @@ if "side_solved" in cams:
|
|||
cams["side"]["px_per_m"] = cams["side"]["f"] / cams["side"]["distance"]
|
||||
second = Image.open(Path(os.environ["MECH_CONCEPTS"]) / spec["second"]["sheet"]).convert("RGB")
|
||||
PASS2 = Path(os.environ.get("RAPTOR_PASS2", r"F:\aeth-wt\fable-raptor-2\out\raptor"))
|
||||
PASS3 = Path(os.environ.get("RAPTOR_PASS3", r"F:\aeth-wt\fable-raptor-3\out\raptor"))
|
||||
SIDE = spec["side"]
|
||||
HULL = [176, 650, 432, 765]
|
||||
FIG = SIDE["ground"] - SIDE["top"]
|
||||
|
|
@ -155,27 +156,29 @@ W = 1200
|
|||
# --- the profile sheet -------------------------------------------------------------------------------------------------
|
||||
crop = fitw(view(HULL), W)
|
||||
chine = [("green", [tuple(p) for p in SIDE["chine"]])]
|
||||
cells = [label(in_box(crop, HULL, lines=curve + chine, width=3), "sheet 38, SIDE view: the character curve (red) and the chine (green) as traced: the two runs the mass is fitted to")]
|
||||
names = {"volume": "ours BEFORE plating: ONE sculpted mass, its dorsal run and chine fitted to the traces (red, green)", "plates": "ours AFTER plating: free cages lapped over the mass, the same lines", "full": "ours AFTER plating, in the build: the same curve (red)"}
|
||||
cells = [label(in_box(crop, HULL, lines=curve + chine, width=3), "sheet 38, SIDE view: the character curve (red) and the chine (green) as traced: the wedge's dorsal line and the armour's lower edge")]
|
||||
names = {"volume": "ours BEFORE plating: the wedge's hard core, sections on the two traces (red, green), the keel under the chine", "plates": "ours AFTER plating: hard slabs, each on its own plane, and the framed canopy; the same lines", "full": "ours AFTER plating, in the build: the same curve (red)"}
|
||||
notes = []
|
||||
for stage in ("volume", "plates", "full"):
|
||||
if (src / f"{stage}_profile.png").exists():
|
||||
scores[stage] = v = curve_miss(stage)
|
||||
cells.append(label(in_box(fitw(render(f"{stage}_profile.png"), W), HULL, lines=curve + (chine if stage == "volume" else []), width=3), names[stage]))
|
||||
notes.append(f"{stage:7s} mean {v['mean_px']:.2f} px ({100 * v['mean_m']:.1f} cm) p90 {v['p90_px']:.2f} max {v['max_px']:.2f} px ({100 * v['max_m']:.1f} cm) over {v['share_scored']:.2f} of the curve")
|
||||
low = [label(in_box(crop, HULL, lines=curve + seam_lines(), width=2), "the plate map: each free cage's outline as built on the mass (green) and its creases (yellow)")]
|
||||
low = [label(in_box(crop, HULL, lines=curve + seam_lines(), width=2), "the plate map: each hard plate's corners on the wedge (green), one side")]
|
||||
segs = []
|
||||
if (src / "full_edges_side.json").exists():
|
||||
segs = [e["seg"] for e in json.loads((src / "full_edges_side.json").read_text(encoding="utf-8"))]
|
||||
low.append(label(in_box(Image.new("RGB", crop.size, (30, 32, 36)), HULL, lines=curve, segs=segs, width=3), "our built plate edges at the side camera (cyan) under the curve (red)"))
|
||||
scores["curve_on_built_edges"] = on = fitshell.along([tuple(p) for p in SIDE["curve"]], segs, FIG)
|
||||
notes += ["", f"curve on built edges (fitshell.along): on {on['on']:.2f}, run {on['run']:.2f}, off {on['off']:.2f}% H"]
|
||||
fitrep = json.loads((src / "raptor_fit.json").read_text(encoding="utf-8")) if (src / "raptor_fit.json").exists() else {}
|
||||
scores["trace_fit"] = {k: fitrep.get(k) for k in ("traces", "moved_max_m", "moved_mean_m")}
|
||||
hard = json.loads((src / "raptor_hard.json").read_text(encoding="utf-8")) if (src / "raptor_hard.json").exists() else {"hard": {}, "count": {}, "soft": []}
|
||||
scores["hard"] = {"solids": len(hard["hard"]), "soft": len(hard["soft"]), **{k: v for k, v in hard["count"].items() if k != "failed"}, "failed": hard["count"].get("failed", [])}
|
||||
sc = cams["side"]
|
||||
body = ["the traced curve against our silhouette's upper edge,", f"side camera, sheet pixels (1 px = {100 / RF.K:.1f} cm):", ""] + notes + ["", "TRACE FIT (brokkr_reference fit_sheet, tol 5.2 px):"] + [f" {t['run']:7s} unexplained {t['unexplained_px']:.2f} px, worst {t['worst_px']:.2f} px" for t in fitrep.get("traces", [])] + [
|
||||
f" cage points moved {100 * fitrep.get('moved_mean_m', 0):.0f} cm mean, {100 * fitrep.get('moved_max_m', 0):.0f} cm max", " the dorsal run is on the mirror plane: decided.", " the chine's half-width is the blocking's", " (one trace, square-on: prior_share 1.0).", "",
|
||||
f"The side camera is SOLVED ({sc.get('model')}): rms {sc.get('rms') or 0:.2f} px", f"over 10 marks, {sc['px_per_m']:.2f} px a metre (set: {RF.K:.2f}).", f"The hull is on the sheet's pixels; the hips stand", f"{RF.BACK} m ahead of the sheet's (image 43).",
|
||||
hc = hard["count"]
|
||||
body = ["the traced curve against our silhouette's upper edge,", f"side camera, sheet pixels (1 px = {100 / RF.K:.1f} cm):", ""] + notes + ["", "HARD PLATES (raptor_hard.json):", f" {len(hard['hard'])} hard solids, 0 soft cages",
|
||||
f" {hc.get('panels', 0)} stepped detail panels, {hc.get('fits', 0)} fittings,", f" {hc.get('marks', 0)} markings, {hc.get('hoses', 0)} hoses; {len(hc.get('failed', []))} fits failed", " Each hull plate's corners (station, column) are",
|
||||
" read off the views by hand; its plane is the", " least-squares plane through them: my own", " plane, not a fit to a trace.", "",
|
||||
f"The side camera is SOLVED ({sc.get('model')}): rms {sc.get('rms') or 0:.2f} px", f"over 10 marks, {sc['px_per_m']:.2f} px a metre (set: {RF.K:.2f}).", "The hull is on the sheet's pixels; the hips stand", f"{RF.BACK} m ahead of the sheet's (image 43).",
|
||||
"In the full build the dorsal banks and the", "cooling stacks stand on the curve: not scored."]
|
||||
low.append(text_panel(body, W, crop.height + 34))
|
||||
stack([row(cells[:2]), row(cells[2:]), row(low[:2]), row(low[2:])]).save(dst / "raptor_profile.png")
|
||||
|
|
@ -223,7 +226,7 @@ rows = []
|
|||
for tag in ("hero", "side", "front", "rear", "v43"):
|
||||
c = fit(second if tag == "v43" else view(cams[tag]["box"]), 760)
|
||||
cells = [label(c, "image 43" if tag == "v43" else f"sheet 38, {tag} view")]
|
||||
for root, name in ((PASS2, "second pass (3ced828)" + (", its view set by eye" if tag == "v43" else "")), (src, "THIS pass")):
|
||||
for root, name in ((PASS2, "second pass (3ced828)" + (", its view set by eye" if tag == "v43" else "")), (PASS3, "third pass (a9ec759)"), (src, "THIS pass (fourth)")):
|
||||
if (root / f"full_{tag}.png").exists():
|
||||
img = Image.open(root / f"full_{tag}.png").convert("RGBA")
|
||||
img = Image.alpha_composite(Image.new("RGBA", img.size, (150, 156, 164, 255)), img).convert("RGB")
|
||||
|
|
@ -231,7 +234,7 @@ for tag in ("hero", "side", "front", "rear", "v43"):
|
|||
img = img.crop((round(0.2 * img.width), round(0.2 * img.height), round(0.88 * img.width), round(0.88 * img.height)))
|
||||
cells.append(label(fit(img, 760), name))
|
||||
rows.append(row(cells))
|
||||
stack(rows).save(dst / "raptor_vs_pass2.png")
|
||||
stack(rows).save(dst / "raptor_vs_passes.png")
|
||||
|
||||
# --- balance -------------------------------------------------------------------------------------------------------------
|
||||
if (src / "raptor_balance.json").exists() and (src / "full_balance.png").exists():
|
||||
|
|
@ -312,12 +315,6 @@ for name, box in crops.items():
|
|||
o = Image.open(src / f"part_{name}.png").convert("RGB")
|
||||
m = round(o.width * 0.2)
|
||||
cells.append(label(row([fit(view(box), 460), fit(o.crop((m, m, o.width - m, o.height - m)), 460)], 4), f"{labels[name]}: sheet 38 | ours"))
|
||||
cages = json.loads((src / "raptor_cages.json").read_text(encoding="utf-8")) if (src / "raptor_cages.json").exists() else {}
|
||||
if cages:
|
||||
hullc = [v for k, v in cages.items() if k.startswith("Torso.")]
|
||||
share = lambda rows: sum(v["creased"] for v in rows) / sum(v["edges"] for v in rows) # noqa: E731
|
||||
scores["cages"] = {"count": len(cages), "hull": len(hullc), "hull_verts": sum(v["verts"] for v in hullc), "hull_crease_share": round(share(hullc), 3), "all_crease_share": round(share(list(cages.values())), 3),
|
||||
"poles": {k: v["poles"] for k, v in cages.items() if v["poles"]}, "limbs": {k: {"verts": v["verts"], "share": v["share"]} for k, v in cages.items() if not k.startswith("Torso.")}}
|
||||
if cells:
|
||||
stack([row(cells[i:i + 2]) for i in range(0, len(cells), 2)]).save(dst / "raptor_components.png")
|
||||
(src / "raptor_scores.json").write_text(json.dumps(scores, indent=1), encoding="utf-8")
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ from mathutils import Matrix, Vector
|
|||
from mathutils.bvhtree import BVHTree
|
||||
|
||||
import mechlib as M
|
||||
from paint import mirrored
|
||||
|
||||
T = Matrix.Translation
|
||||
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):
|
||||
"""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)
|
||||
bpy.context.scene.collection.objects.link(holder)
|
||||
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)
|
||||
k += 1
|
||||
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
|
||||
bmesh.ops.recalc_face_normals(bm, faces=bm.faces[:])
|
||||
probe = next(iter(bm.faces))
|
||||
|
|
|
|||
Loading…
Reference in a new issue