agent-manifesto-kit 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -1
- package/collection/bundles/blender-3d/README.md +41 -0
- package/collection/bundles/blender-3d/agents/visual-reviewer.md +51 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/SKILL.md +96 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/check_motion.py +162 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/export_gltf_clip.py +71 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/godot_verify.py +87 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/inspect_motion_source.py +107 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/render_frames.py +117 -0
- package/collection/bundles/blender-3d/skills/blender-mocap-retarget/scripts/verify_gltf.py +44 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/SKILL.md +83 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/colors.py +50 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/compare.py +77 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/contact_sheet.py +51 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/diff_renders.py +58 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/edges.py +54 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/measure_ref.py +137 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/mesh_report.py +67 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/refspec.py +91 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/render_views.py +99 -0
- package/collection/bundles/blender-3d/skills/blender-reference-model/scripts/zoom.py +47 -0
- package/collection/bundles/kit-adopt/README.md +1 -1
- package/collection/bundles/kit-adopt/skills/kit-adopt/SKILL.md +2 -2
- package/dist/agent-format.js +218 -0
- package/dist/catalog.js +13 -13
- package/dist/cli.js +57 -2
- package/dist/commands/adopt.js +13 -3
- package/dist/commands/ingest.js +120 -0
- package/dist/commands/sync.js +201 -0
- package/dist/portability.js +19 -2
- package/dist/providers.js +12 -2
- package/package.json +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""Measure a turnaround reference and draft or inspect its ref_spec.json.
|
|
2
|
+
|
|
3
|
+
Draft a spec (views are found as column groups separated by background):
|
|
4
|
+
python3 measure_ref.py character.png --height-m 1.80 --out ref_spec.json
|
|
5
|
+
|
|
6
|
+
Print a view's silhouette profile in metres, for building geometry from measurements:
|
|
7
|
+
python3 measure_ref.py --spec ref_spec.json --profile front [--step 6]
|
|
8
|
+
|
|
9
|
+
Drafted view names and cameras are guesses (widest group = front; the others are named right,
|
|
10
|
+
left, back in left-to-right order):
|
|
11
|
+
check them against the sheet's labels, and adjust center_px for side views if the model's
|
|
12
|
+
origin is not the silhouette centre.
|
|
13
|
+
"""
|
|
14
|
+
import argparse
|
|
15
|
+
import json
|
|
16
|
+
import os
|
|
17
|
+
import sys
|
|
18
|
+
|
|
19
|
+
import numpy as np
|
|
20
|
+
from PIL import Image
|
|
21
|
+
|
|
22
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
23
|
+
from refspec import background_colour, load_reference, load_spec, reference_mask, row_extents # noqa: E402
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def runs(flags, min_gap):
|
|
27
|
+
"""[start, end) runs of True, bridging gaps shorter than min_gap."""
|
|
28
|
+
idx = np.flatnonzero(flags)
|
|
29
|
+
if idx.size == 0:
|
|
30
|
+
return []
|
|
31
|
+
out, start, prev = [], idx[0], idx[0]
|
|
32
|
+
for i in idx[1:]:
|
|
33
|
+
if i - prev > min_gap:
|
|
34
|
+
out.append((int(start), int(prev) + 1))
|
|
35
|
+
start = i
|
|
36
|
+
prev = i
|
|
37
|
+
out.append((int(start), int(prev) + 1))
|
|
38
|
+
return out
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def draft(args):
|
|
42
|
+
arr = np.asarray(Image.open(args.reference).convert("RGB")).astype(int)
|
|
43
|
+
bg = background_colour(arr)
|
|
44
|
+
mask = np.abs(arr - bg).sum(2) > args.bg_threshold
|
|
45
|
+
groups = [g for g in runs(mask.any(0), args.min_gap) if g[1] - g[0] >= args.min_width]
|
|
46
|
+
if not groups:
|
|
47
|
+
raise SystemExit("no foreground found; lower --bg-threshold")
|
|
48
|
+
found = []
|
|
49
|
+
for x0, x1 in groups:
|
|
50
|
+
rows = runs(mask[:, x0:x1].any(1), 3)
|
|
51
|
+
y0, y1 = max(rows, key=lambda r: r[1] - r[0]) # tallest run = the figure, not its label
|
|
52
|
+
found.append({"x0": x0, "x1": x1, "y0": y0, "y1": y1})
|
|
53
|
+
ground = int(np.median([f["y1"] for f in found])) # soft shadows can extend single views
|
|
54
|
+
widest = max(found, key=lambda f: f["x1"] - f["x0"])
|
|
55
|
+
top = widest["y0"]
|
|
56
|
+
label_rows = [r for x0, x1 in groups for r in runs(mask[:, x0:x1].any(1), 3) if r[0] >= ground]
|
|
57
|
+
ignore_below = min((r[0] for r in label_rows), default=None)
|
|
58
|
+
|
|
59
|
+
order = sorted(range(len(found)), key=lambda i: found[i]["x1"] - found[i]["x0"], reverse=True)
|
|
60
|
+
guesses = ["front", "right", "left", "back"]
|
|
61
|
+
views = {}
|
|
62
|
+
for rank, i in enumerate(sorted(order[:1]) + sorted(order[1:])):
|
|
63
|
+
f = found[i]
|
|
64
|
+
name = guesses[rank] if rank < len(guesses) else f"view{rank + 1}"
|
|
65
|
+
views[name] = {
|
|
66
|
+
"crop": [f["x0"] - args.pad if f["x0"] >= args.pad else 0, 0,
|
|
67
|
+
min(f["x1"] + args.pad, arr.shape[1]), arr.shape[0] if ignore_below is None else int(ignore_below)],
|
|
68
|
+
"camera": name if name in guesses else "",
|
|
69
|
+
"center_px": round((f["x0"] + f["x1"]) / 2, 1),
|
|
70
|
+
"silhouette_px": [f["x0"], f["y0"], f["x1"], f["y1"]],
|
|
71
|
+
}
|
|
72
|
+
height_px = ground - top
|
|
73
|
+
spec = {
|
|
74
|
+
"reference": os.path.relpath(args.reference, os.path.dirname(os.path.abspath(args.out or "."))),
|
|
75
|
+
"meters_per_px": round(args.height_m / height_px, 6) if args.height_m else None,
|
|
76
|
+
"ground_px": float(ground),
|
|
77
|
+
"bg_threshold": args.bg_threshold,
|
|
78
|
+
"views": views,
|
|
79
|
+
}
|
|
80
|
+
if ignore_below is not None:
|
|
81
|
+
spec["ignore_below_px"] = int(ignore_below)
|
|
82
|
+
print(f"background RGB {bg.astype(int).tolist()}, front figure height {height_px} px, ground row {ground}")
|
|
83
|
+
for name, v in views.items():
|
|
84
|
+
print(f" {name:6s} silhouette {v['silhouette_px']} center_px {v['center_px']}")
|
|
85
|
+
if not args.height_m:
|
|
86
|
+
print("meters_per_px left empty: pass --height-m with the intended character height")
|
|
87
|
+
text = json.dumps(spec, indent=2) + "\n"
|
|
88
|
+
if args.out:
|
|
89
|
+
with open(args.out, "w") as f:
|
|
90
|
+
f.write(text)
|
|
91
|
+
print(f"wrote {args.out}; verify view names and cameras before use")
|
|
92
|
+
else:
|
|
93
|
+
print(text)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def profile(args):
|
|
97
|
+
spec = load_spec(args.spec)
|
|
98
|
+
_, arr = load_reference(spec)
|
|
99
|
+
view = spec["views"][args.profile]
|
|
100
|
+
x0, y0 = view["crop"][:2]
|
|
101
|
+
mpp, ground, c = spec["meters_per_px"], spec["ground_px"], view["center_px"]
|
|
102
|
+
ext = row_extents(reference_mask(spec, arr, args.profile))
|
|
103
|
+
print(f"{args.profile}: z = height above ground; left/right = world offset of silhouette edges (m)")
|
|
104
|
+
print(" row z left right width")
|
|
105
|
+
for r in range(0, len(ext), args.step):
|
|
106
|
+
if ext[r] is None:
|
|
107
|
+
continue
|
|
108
|
+
a, b = ext[r][0] + x0, ext[r][1] + x0
|
|
109
|
+
z = (ground - (r + y0 + 0.5)) * mpp
|
|
110
|
+
print(f" {r + y0:4d} {z:6.3f} {(a - c) * mpp:+7.3f} {(b - c) * mpp:+7.3f} {(b - a) * mpp:6.3f}")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def main():
|
|
114
|
+
p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
115
|
+
p.add_argument("reference", nargs="?")
|
|
116
|
+
p.add_argument("--height-m", type=float, help="intended character height in metres")
|
|
117
|
+
p.add_argument("--out", help="write the drafted spec here")
|
|
118
|
+
p.add_argument("--bg-threshold", type=int, default=30)
|
|
119
|
+
p.add_argument("--min-gap", type=int, default=20, help="background columns that separate views")
|
|
120
|
+
p.add_argument("--min-width", type=int, default=20, help="ignore narrower column groups")
|
|
121
|
+
p.add_argument("--pad", type=int, default=10, help="crop padding around each silhouette")
|
|
122
|
+
p.add_argument("--spec", help="existing spec, for --profile")
|
|
123
|
+
p.add_argument("--profile", help="view name to print row extents for")
|
|
124
|
+
p.add_argument("--step", type=int, default=6)
|
|
125
|
+
args = p.parse_args()
|
|
126
|
+
if args.profile:
|
|
127
|
+
if not args.spec:
|
|
128
|
+
p.error("--profile needs --spec")
|
|
129
|
+
profile(args)
|
|
130
|
+
elif args.reference:
|
|
131
|
+
draft(args)
|
|
132
|
+
else:
|
|
133
|
+
p.error("pass a reference image, or --spec with --profile")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
if __name__ == "__main__":
|
|
137
|
+
main()
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Per-object mesh health and cost report for a saved .blend (read-only).
|
|
2
|
+
|
|
3
|
+
blender -b model.blend --python mesh_report.py -- [--collection NAME] [--exclude-prefix SRC_] [--json out.json] [--strict]
|
|
4
|
+
|
|
5
|
+
Reports evaluated triangles, vertices, non-manifold edges, zero-area faces, loose vertices,
|
|
6
|
+
empty material slots, origin and dimensions. Non-manifold edges are acceptable on deliberately
|
|
7
|
+
open shells (hems, cards); treat them as findings to explain, not automatic failures.
|
|
8
|
+
--strict exits non-zero when any object has degenerate faces, loose vertices or empty slots.
|
|
9
|
+
"""
|
|
10
|
+
import argparse
|
|
11
|
+
import json
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
import bmesh
|
|
15
|
+
import bpy
|
|
16
|
+
|
|
17
|
+
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
|
18
|
+
p = argparse.ArgumentParser()
|
|
19
|
+
p.add_argument("--collection")
|
|
20
|
+
p.add_argument("--exclude-prefix", default="")
|
|
21
|
+
p.add_argument("--json")
|
|
22
|
+
p.add_argument("--strict", action="store_true")
|
|
23
|
+
args = p.parse_args(argv)
|
|
24
|
+
|
|
25
|
+
if args.collection:
|
|
26
|
+
col = bpy.data.collections.get(args.collection)
|
|
27
|
+
if col is None:
|
|
28
|
+
raise SystemExit(f"no collection named {args.collection}")
|
|
29
|
+
objects = [o for o in col.all_objects if o.type == "MESH"]
|
|
30
|
+
else:
|
|
31
|
+
objects = [o for o in bpy.context.scene.objects if o.type == "MESH"]
|
|
32
|
+
objects = [o for o in objects if not (args.exclude_prefix and o.name.startswith(args.exclude_prefix))]
|
|
33
|
+
|
|
34
|
+
dg = bpy.context.evaluated_depsgraph_get()
|
|
35
|
+
rows, problems = [], 0
|
|
36
|
+
for ob in sorted(objects, key=lambda o: o.name):
|
|
37
|
+
ev = ob.evaluated_get(dg)
|
|
38
|
+
me = ev.to_mesh()
|
|
39
|
+
bm = bmesh.new()
|
|
40
|
+
bm.from_mesh(me)
|
|
41
|
+
row = {
|
|
42
|
+
"object": ob.name,
|
|
43
|
+
"tris": sum(len(f.verts) - 2 for f in bm.faces),
|
|
44
|
+
"verts": len(bm.verts),
|
|
45
|
+
"non_manifold_edges": sum(1 for e in bm.edges if not e.is_manifold),
|
|
46
|
+
"degenerate_faces": sum(1 for f in bm.faces if f.calc_area() < 1e-10),
|
|
47
|
+
"loose_verts": sum(1 for v in bm.verts if not v.link_edges),
|
|
48
|
+
"empty_material_slots": sum(1 for s in ob.material_slots if s.material is None) + (0 if ob.material_slots else 1),
|
|
49
|
+
"origin": [round(c, 4) for c in ob.matrix_world.translation],
|
|
50
|
+
"dimensions": [round(c, 4) for c in ob.dimensions],
|
|
51
|
+
}
|
|
52
|
+
bm.free()
|
|
53
|
+
ev.to_mesh_clear()
|
|
54
|
+
problems += bool(row["degenerate_faces"] or row["loose_verts"] or row["empty_material_slots"])
|
|
55
|
+
rows.append(row)
|
|
56
|
+
|
|
57
|
+
print(f"{'object':24s} {'tris':>6s} {'verts':>6s} {'nonman':>6s} {'degen':>5s} {'loose':>5s} {'nomat':>5s} origin")
|
|
58
|
+
for r in rows:
|
|
59
|
+
print(f"{r['object'][:24]:24s} {r['tris']:6d} {r['verts']:6d} {r['non_manifold_edges']:6d} {r['degenerate_faces']:5d} "
|
|
60
|
+
f"{r['loose_verts']:5d} {r['empty_material_slots']:5d} {tuple(r['origin'])}")
|
|
61
|
+
total = sum(r["tris"] for r in rows)
|
|
62
|
+
print(f"TOTAL {len(rows)} objects, {total} triangles; {problems} object(s) with degenerate faces, loose vertices or empty slots")
|
|
63
|
+
if args.json:
|
|
64
|
+
with open(args.json, "w") as f:
|
|
65
|
+
json.dump({"objects": rows, "total_tris": total}, f, indent=2)
|
|
66
|
+
if args.strict and problems:
|
|
67
|
+
sys.exit(1)
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Shared helpers for the reference-matching scripts (system Python 3 with Pillow and numpy).
|
|
2
|
+
|
|
3
|
+
A reference spec (ref_spec.json) maps each view of a turnaround sheet to a crop and a camera:
|
|
4
|
+
|
|
5
|
+
{
|
|
6
|
+
"reference": "character.png", # path relative to the spec file
|
|
7
|
+
"meters_per_px": 0.004, # world size of one reference pixel
|
|
8
|
+
"ground_px": 471.0, # image row (continuous coords) of the ground line
|
|
9
|
+
"bg_threshold": 30, # summed RGB distance from the background colour
|
|
10
|
+
"ignore_below_px": 475, # optional: rows at or below this are labels, not model
|
|
11
|
+
"views": {
|
|
12
|
+
"front": {"crop": [0, 0, 600, 519], "camera": "front", "center_px": 299.5},
|
|
13
|
+
"right": {"crop": [600, 0, 850, 519], "camera": "right", "center_px": 727.0}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
camera is one of front | back | right | left (the character faces -Y, its left side is +X).
|
|
18
|
+
center_px is the image column that maps to world 0 on that view's horizontal axis.
|
|
19
|
+
"""
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
|
|
23
|
+
import numpy as np
|
|
24
|
+
from PIL import Image
|
|
25
|
+
|
|
26
|
+
CAMERAS = ("front", "back", "right", "left")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def load_spec(path):
|
|
30
|
+
with open(path) as f:
|
|
31
|
+
spec = json.load(f)
|
|
32
|
+
base = os.path.dirname(os.path.abspath(path))
|
|
33
|
+
spec["reference"] = os.path.join(base, spec["reference"])
|
|
34
|
+
for key in ("meters_per_px", "ground_px", "views"):
|
|
35
|
+
if spec.get(key) in (None, {}):
|
|
36
|
+
raise SystemExit(f"{path}: '{key}' is not set")
|
|
37
|
+
for name, view in spec["views"].items():
|
|
38
|
+
if view.get("camera") not in CAMERAS:
|
|
39
|
+
raise SystemExit(f"{path}: view '{name}' needs camera in {CAMERAS}")
|
|
40
|
+
if "center_px" not in view or len(view.get("crop", [])) != 4:
|
|
41
|
+
raise SystemExit(f"{path}: view '{name}' needs crop [x0,y0,x1,y1] and center_px")
|
|
42
|
+
spec.setdefault("bg_threshold", 30)
|
|
43
|
+
return spec
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def load_reference(spec):
|
|
47
|
+
img = Image.open(spec["reference"]).convert("RGB")
|
|
48
|
+
return img, np.asarray(img).astype(int)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def background_colour(arr):
|
|
52
|
+
"""Median colour of the image border."""
|
|
53
|
+
border = np.concatenate([arr[0], arr[-1], arr[:, 0], arr[:, -1]])
|
|
54
|
+
return np.median(border, axis=0)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def reference_mask(spec, arr, view_name):
|
|
58
|
+
"""Foreground mask of one view's crop, labels removed."""
|
|
59
|
+
x0, y0, x1, y1 = spec["views"][view_name]["crop"]
|
|
60
|
+
mask = np.abs(arr - background_colour(arr)).sum(2) > spec["bg_threshold"]
|
|
61
|
+
cut = spec.get("ignore_below_px")
|
|
62
|
+
if cut is not None:
|
|
63
|
+
mask[int(cut):, :] = False
|
|
64
|
+
return mask[y0:y1, x0:x1]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def render_image(render_dir, view_name, size):
|
|
68
|
+
"""Load a transparent render, resized to the crop size when rendered at another scale."""
|
|
69
|
+
img = Image.open(os.path.join(render_dir, f"{view_name}.png")).convert("RGBA")
|
|
70
|
+
if img.size != size:
|
|
71
|
+
img = img.resize(size, Image.LANCZOS)
|
|
72
|
+
return img
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def render_mask(img):
|
|
76
|
+
return np.asarray(img)[..., 3] > 128
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def composite(img, colour):
|
|
80
|
+
bg = Image.new("RGBA", img.size, tuple(int(c) for c in colour) + (255,))
|
|
81
|
+
bg.alpha_composite(img)
|
|
82
|
+
return bg.convert("RGB")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def row_extents(mask):
|
|
86
|
+
"""Outermost filled column per row, or None for empty rows."""
|
|
87
|
+
out = []
|
|
88
|
+
for row in mask:
|
|
89
|
+
xs = np.flatnonzero(row)
|
|
90
|
+
out.append((int(xs[0]), int(xs[-1]) + 1) if xs.size else None)
|
|
91
|
+
return out
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Render each spec view orthographically at the reference's pixel scale (transparent background).
|
|
2
|
+
|
|
3
|
+
blender -b model.blend --python render_views.py -- ref_spec.json OUTDIR [--scale 2] [--hide A,B] [--pose]
|
|
4
|
+
|
|
5
|
+
Adds a temporary camera, lights and world; never saves the .blend. The character faces -Y with
|
|
6
|
+
its left side on +X, so front = camera on -Y, right = camera on -X, left = +X, back = +Y.
|
|
7
|
+
Armatures render in their rest pose unless --pose is given, so a rigged model is compared in the
|
|
8
|
+
pose the reference shows. Output: OUTDIR/<view>.png, sized crop * scale.
|
|
9
|
+
"""
|
|
10
|
+
import argparse
|
|
11
|
+
import json
|
|
12
|
+
import math
|
|
13
|
+
import os
|
|
14
|
+
import sys
|
|
15
|
+
|
|
16
|
+
import bpy
|
|
17
|
+
|
|
18
|
+
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
|
|
19
|
+
p = argparse.ArgumentParser()
|
|
20
|
+
p.add_argument("spec")
|
|
21
|
+
p.add_argument("outdir")
|
|
22
|
+
p.add_argument("--scale", type=float, default=1.0)
|
|
23
|
+
p.add_argument("--hide", default="", help="comma-separated object names to exclude from renders")
|
|
24
|
+
p.add_argument("--pose", action="store_true", help="keep armatures in their current animated pose")
|
|
25
|
+
args = p.parse_args(argv)
|
|
26
|
+
|
|
27
|
+
with open(args.spec) as f:
|
|
28
|
+
spec = json.load(f)
|
|
29
|
+
mpp, ground = spec["meters_per_px"], spec["ground_px"]
|
|
30
|
+
os.makedirs(args.outdir, exist_ok=True)
|
|
31
|
+
|
|
32
|
+
# camera: (rotation, horizontal world axis, sign of image-right along that axis, depth location)
|
|
33
|
+
CAMERAS = {
|
|
34
|
+
"front": ((90, 0, 0), "x", 1, (None, -20.0)),
|
|
35
|
+
"back": ((90, 0, 180), "x", -1, (None, 20.0)),
|
|
36
|
+
"right": ((90, 0, -90), "y", -1, (-20.0, None)),
|
|
37
|
+
"left": ((90, 0, 90), "y", 1, (20.0, None)),
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
scene = bpy.context.scene
|
|
41
|
+
engines = {i.identifier for i in scene.render.bl_rna.properties["engine"].enum_items}
|
|
42
|
+
scene.render.engine = next(e for e in ("BLENDER_EEVEE", "BLENDER_EEVEE_NEXT", "BLENDER_WORKBENCH") if e in engines)
|
|
43
|
+
scene.render.film_transparent = True
|
|
44
|
+
scene.render.image_settings.file_format = "PNG"
|
|
45
|
+
scene.render.image_settings.color_mode = "RGBA"
|
|
46
|
+
scene.view_settings.view_transform = "Standard"
|
|
47
|
+
scene.view_settings.look = "None"
|
|
48
|
+
scene.render.resolution_percentage = 100
|
|
49
|
+
|
|
50
|
+
for name in filter(None, args.hide.split(",")):
|
|
51
|
+
ob = bpy.data.objects.get(name)
|
|
52
|
+
if ob is None:
|
|
53
|
+
raise SystemExit(f"--hide: no object named {name}")
|
|
54
|
+
ob.hide_render = True
|
|
55
|
+
|
|
56
|
+
if not args.pose:
|
|
57
|
+
for arm in bpy.data.armatures:
|
|
58
|
+
arm.pose_position = "REST"
|
|
59
|
+
|
|
60
|
+
world = bpy.data.worlds.new("RefViewsWorld")
|
|
61
|
+
scene.world = world
|
|
62
|
+
world.use_nodes = True
|
|
63
|
+
world.node_tree.nodes["Background"].inputs["Color"].default_value = (0.16, 0.16, 0.16, 1)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def sun(name, energy):
|
|
67
|
+
data = bpy.data.lights.new(name, "SUN")
|
|
68
|
+
data.energy = energy
|
|
69
|
+
data.angle = math.radians(8)
|
|
70
|
+
ob = bpy.data.objects.new(name, data)
|
|
71
|
+
scene.collection.objects.link(ob)
|
|
72
|
+
return ob
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
key, fill = sun("RefKey", 3.2), sun("RefFill", 0.8)
|
|
76
|
+
cam_data = bpy.data.cameras.new("RefCam")
|
|
77
|
+
cam_data.type = "ORTHO"
|
|
78
|
+
cam = bpy.data.objects.new("RefCam", cam_data)
|
|
79
|
+
scene.collection.objects.link(cam)
|
|
80
|
+
scene.camera = cam
|
|
81
|
+
|
|
82
|
+
for name, view in spec["views"].items():
|
|
83
|
+
rot, axis, sign, depth = CAMERAS[view["camera"]]
|
|
84
|
+
x0, y0, x1, y1 = view["crop"]
|
|
85
|
+
w, h = x1 - x0, y1 - y0
|
|
86
|
+
lateral = sign * ((x0 + x1) / 2 - view["center_px"]) * mpp
|
|
87
|
+
z = (ground - (y0 + y1) / 2) * mpp
|
|
88
|
+
cam.location = (lateral if axis == "x" else depth[0], lateral if axis == "y" else depth[1], z)
|
|
89
|
+
cam.rotation_euler = tuple(math.radians(a) for a in rot)
|
|
90
|
+
cam_data.ortho_scale = max(w, h) * mpp
|
|
91
|
+
cam_data.clip_end = 100
|
|
92
|
+
scene.render.resolution_x = round(w * args.scale)
|
|
93
|
+
scene.render.resolution_y = round(h * args.scale)
|
|
94
|
+
# keep the key light at the camera's upper left for every view
|
|
95
|
+
key.rotation_euler = (math.radians(50), 0, math.radians(rot[2] - 30))
|
|
96
|
+
fill.rotation_euler = (math.radians(70), 0, math.radians(rot[2] + 150))
|
|
97
|
+
scene.render.filepath = os.path.join(args.outdir, f"{name}.png")
|
|
98
|
+
bpy.ops.render.render(write_still=True)
|
|
99
|
+
print(f"RENDERED {name} {scene.render.resolution_x}x{scene.render.resolution_y}")
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Side-by-side magnified crop of the reference and the render for one region.
|
|
2
|
+
|
|
3
|
+
python3 zoom.py ref_spec.json RENDERDIR front 240,20,360,130 --out head_front.png [--zoom 4]
|
|
4
|
+
|
|
5
|
+
The region is x0,y0,x1,y1 in reference image pixels and must lie inside the view's crop.
|
|
6
|
+
Render at --scale 2 or more in render_views.py for sharper detail; the crop is resampled
|
|
7
|
+
from whatever resolution the render has.
|
|
8
|
+
"""
|
|
9
|
+
import argparse
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
from PIL import Image
|
|
14
|
+
|
|
15
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
16
|
+
from refspec import background_colour, composite, load_reference, load_spec # noqa: E402
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main():
|
|
20
|
+
p = argparse.ArgumentParser()
|
|
21
|
+
p.add_argument("spec")
|
|
22
|
+
p.add_argument("render_dir")
|
|
23
|
+
p.add_argument("view")
|
|
24
|
+
p.add_argument("region")
|
|
25
|
+
p.add_argument("--out", required=True)
|
|
26
|
+
p.add_argument("--zoom", type=int, default=4)
|
|
27
|
+
args = p.parse_args()
|
|
28
|
+
spec = load_spec(args.spec)
|
|
29
|
+
ref, arr = load_reference(spec)
|
|
30
|
+
cx0, cy0, cx1, cy1 = spec["views"][args.view]["crop"]
|
|
31
|
+
x0, y0, x1, y1 = (int(v) for v in args.region.split(","))
|
|
32
|
+
if not (cx0 <= x0 < x1 <= cx1 and cy0 <= y0 < y1 <= cy1):
|
|
33
|
+
raise SystemExit(f"region {args.region} is outside the {args.view} crop {[cx0, cy0, cx1, cy1]}")
|
|
34
|
+
ren = composite(Image.open(os.path.join(args.render_dir, f"{args.view}.png")).convert("RGBA"), background_colour(arr))
|
|
35
|
+
sx, sy = ren.size[0] / (cx1 - cx0), ren.size[1] / (cy1 - cy0)
|
|
36
|
+
a = ref.crop((x0, y0, x1, y1))
|
|
37
|
+
b = ren.crop((round((x0 - cx0) * sx), round((y0 - cy0) * sy), round((x1 - cx0) * sx), round((y1 - cy0) * sy)))
|
|
38
|
+
w, h = (x1 - x0) * args.zoom, (y1 - y0) * args.zoom
|
|
39
|
+
out = Image.new("RGB", (w * 2 + 10, h), (20, 20, 20))
|
|
40
|
+
out.paste(a.resize((w, h), Image.LANCZOS), (0, 0))
|
|
41
|
+
out.paste(b.resize((w, h), Image.LANCZOS), (w + 10, 0))
|
|
42
|
+
out.save(args.out)
|
|
43
|
+
print(f"reference | render -> {args.out}")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
if __name__ == "__main__":
|
|
47
|
+
main()
|
|
@@ -23,7 +23,7 @@ capabilities (such as the SDD bundle) to any project.
|
|
|
23
23
|
- Rewrites bundle-relative paths to the target layout and substitutes declared placeholders
|
|
24
24
|
(project name, docs root) with consumer-provided values.
|
|
25
25
|
- Registers the installed capabilities in the target's instruction entrypoint
|
|
26
|
-
(`AGENTS.md`,
|
|
26
|
+
(`AGENTS.md`, or the tool's equivalent root contract).
|
|
27
27
|
- Verifies the copied assets are portable and registered.
|
|
28
28
|
- Offers a bundle's recommended companions (declared in its `RECOMMENDS.md` per the
|
|
29
29
|
`recommended-companions` convention) as opt-in follow-ups after install.
|
|
@@ -14,8 +14,8 @@ description: Installs a kit bundle or an individual capability into a target pro
|
|
|
14
14
|
## Required Environment
|
|
15
15
|
|
|
16
16
|
- The kit source tree containing the bundle or item to install.
|
|
17
|
-
- A target project with an instruction entrypoint (
|
|
18
|
-
|
|
17
|
+
- A target project with an instruction entrypoint (`AGENTS.md`, or the tool's equivalent root
|
|
18
|
+
contract) and a capability area to receive the assets.
|
|
19
19
|
- The `capability-portability` concept: copied assets work in the target after consumer-
|
|
20
20
|
declared configuration (paths, project vocabulary) is supplied, without other source edits.
|
|
21
21
|
|