@babylonjs-toolkit/agent 1.2.18 → 1.2.21
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 +1 -1
- package/package.json +1 -1
- package/skills/bt-blender/SKILL.md +81 -19
- package/skills/bt-blender/references/hard-surface.md +9 -5
- package/skills/bt-blender/references/vehicles.md +14 -9
- package/skills/bt-blender/scripts/blender/__pycache__/construction_kit.cpython-313.pyc +0 -0
- package/skills/bt-blender/scripts/blender/__pycache__/geometry_nodes_builders.cpython-313.pyc +0 -0
- package/skills/bt-blender/scripts/blender/__pycache__/image_measure.cpython-313.pyc +0 -0
- package/skills/bt-blender/scripts/blender/__pycache__/reference_traces.cpython-313.pyc +0 -0
- package/skills/bt-blender/scripts/blender/blueprint.py +293 -0
- package/skills/bt-blender/scripts/blender/construction_kit.py +61 -1
- package/skills/bt-blender/scripts/blender/coverage_check.py +221 -0
- package/skills/bt-blender/scripts/blender/evidence_sheet.py +243 -0
- package/skills/bt-blender/scripts/blender/image_measure.py +354 -5
- package/skills/bt-blender/scripts/blender/measure_stations.py +11 -1
- package/skills/bt-blender/scripts/blender/overlay_sheet.py +238 -0
- package/skills/bt-blender/scripts/blender/reference_traces.py +344 -0
- package/skills/bt-blender/scripts/blender/trace.py +283 -0
- package/skills/bt-blender/scripts/blender/world_gate.py +17 -5
- package/skills/bt-blender/scripts/bt-blender.mjs +4 -0
- package/skills/bt-execute/SKILL.md +2 -1
- package/skills/bt-gauntlet/SKILL.md +24 -14
- package/skills/bt-gauntlet/references/critic-rubrics.md +37 -5
- package/skills/bt-gauntlet/references/loop-templates.md +23 -3
- package/skills/bt-gauntlet/references/spec-composition.md +7 -1
- package/skills/bt-gauntlet/references/target-images.md +27 -0
- package/skills/bt-gauntlet/references/unity-pipeline.md +24 -3
- package/skills/bt-gauntlet/references/workspace.md +90 -6
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Babylon Toolkit Desktop Agent (1.2.
|
|
1
|
+
# Babylon Toolkit Desktop Agent (1.2.21)
|
|
2
2
|
|
|
3
3
|
The desktop agent owns the entire pipeline end to end — frontend and UI design, gameplay code, shaders, generated art and audio, 3D models in headless Blender, whole game levels and prefabs in a terminal-driven Unity Editor, the interactive glTF export, the web build, the dev server, and visual QA by screenshotting both Unity and the running browser.
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bt-blender
|
|
3
|
-
description: "The Babylon Toolkit Blender Skill models game assets from reference images in headless Blender, measured instead of eyeballed. It writes the brief, checks that the reference views agree with each other, blocks the
|
|
3
|
+
description: "The Babylon Toolkit Blender Skill models game assets from reference images in headless Blender, measured instead of eyeballed. It writes the brief, checks that the reference views agree with each other, sets them up as a blueprint at real scale and traces their outlines and design curves into world coordinates (parts built on the traces are stamped, and the gates fail unstamped parts), checks that every region of the reference belongs to a part, blocks out the whole silhouette first, then builds it with a tested construction kit (rounded sections with real corner radii lofted through measured stations, lathed and traced parts, subdivision cages whose holding loops hit a target radius and whose shrinkage is corrected to the measured sizes, radius-driven bevels, smooth shading with crisp design lines, welds that keep hard edges, moulded parts inflated from one silhouette). Every step is graded against the references: station widths MATCH / CLOSE / WRONG, corner radii (equal depth on the model, circle fit on images), shading continuity, a world-scale silhouette IoU gate, a one-sheet overlay of reference and model outlines in every view (IoU, missing and extra regions), and a render at the asset's real in-game pixel height. Before export it runs an asset QA gate (z-fighting, floating parts, flipped or inside-out normals, topology, UV overlap, empty material slots, skin weights) and an assembly check (gaps, embed depth, required attachments, spec sizes). It exports glTF / GLB for BabylonJS (float bakes converted to sRGB bytes, tangents, Geometry Nodes instances realised or GPU-instanced, optional Draco / meshopt / WebP, Khronos glTF-Validator) or FBX by the Unity case table (static, animated, rigged, Unity-sourced), re-imports to prove the size, and writes JSON evidence for every gate. Eleven domain references with tested helper modules cover hard surface, vehicles, environments, characters, rigging and animation, sculpting and retopology, UVs and PBR bakes, Geometry Nodes, procedural generation, engine export and art style. Use when an asset has to be built or rebuilt in Blender from reference images or a sketch sheet (e.g. `/bt-blender build the moulded housing from refs/housing --length 0.42`, `/bt-blender measure model.blend against refs/spec.json`, `/bt-blender qa build/asset.glb`)."
|
|
4
4
|
allowed-tools: Read, Write, Edit, Glob, Grep, Bash
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ Use the user's message after the skill name as the `arguments`.
|
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Plain words map to steps: "build", "model", "rebuild" run the whole workflow below; "measure", "check against the
|
|
23
|
-
refs" run step
|
|
23
|
+
refs" run step 6; "qa", "is it clean" run step 7; "export", "ship it" run step 8. If the asset's real size is not
|
|
24
24
|
given and cannot be read from the references, ask once; never guess a scale.
|
|
25
25
|
|
|
26
26
|
All tools run through one launcher (Node 18+), which finds Blender the same way bt-unwrap does (`--blender <path>`,
|
|
@@ -48,6 +48,10 @@ The result is the stdout line starting `BT_BLENDER_RESULT `. Your own build scri
|
|
|
48
48
|
| Tool | Script | What it answers |
|
|
49
49
|
|---|---|---|
|
|
50
50
|
| `view-consistency` | `view_consistency.py` | Do the reference views agree with each other and with the known size? |
|
|
51
|
+
| `blueprint` | `blueprint.py` | The reference views as image planes at world scale in their view planes, a camera per view, the known-size box; with `--model`, the model drawn over every reference. |
|
|
52
|
+
| `trace` | `trace.py` | Every view's outline, and named design curves, in pixels and world metres (`traces.json`) for the build to stand on. |
|
|
53
|
+
| `coverage-check` | `coverage_check.py` | Does every region of the reference silhouette belong to a part (unclaimed regions, overlaps)? |
|
|
54
|
+
| `overlay-sheet` | `overlay_sheet.py` | The whole shape in every view on one sheet: both outlines, missing / extra regions, IoU. |
|
|
51
55
|
| `measure-stations` | `measure_stations.py` | Station by station, is the model the reference's size and form? |
|
|
52
56
|
| `world-gate` | `world_gate.py` | Does the whole silhouette overlap the reference at world scale (IoU)? |
|
|
53
57
|
| `review-render` | `review_render.py` | What does it look like: clay / parts / wire sheet, and at its in-game pixel height? |
|
|
@@ -85,7 +89,7 @@ The result is the stdout line starting `BT_BLENDER_RESULT `. Your own build scri
|
|
|
85
89
|
|
|
86
90
|
# Domain references and helpers
|
|
87
91
|
|
|
88
|
-
Read the reference that matches the asset before step
|
|
92
|
+
Read the reference that matches the asset before step 3 (`references/<file>`). Each one has tested recipes,
|
|
89
93
|
measured numbers and a verification checklist. The Agent Reference's `unity-blender-cli.md` stays the
|
|
90
94
|
authority on the CLI, the API and export mechanics.
|
|
91
95
|
|
|
@@ -120,7 +124,8 @@ Helper modules (`scripts/blender/`, importable in a `run` script; every function
|
|
|
120
124
|
| `procedural_generators` | `rock`, `building`, `space_colonization`, `lsystem_skeleton`, `skin_skeleton`, `closed_track_centerline`, `road_ribbon`, `variation_manifest` |
|
|
121
125
|
| `procedural_game_ready` | `lod_chain` (the kit's), `normal_deviation`, `convex_hull_collider`, `box_collider` |
|
|
122
126
|
| `style_palette` | `palette_image`, `palette_material`, `paint_faces`, `value_report`, `silhouette_pixel_height` |
|
|
123
|
-
| `image_measure`, `ortho_views` | masks, line and circle fits, `corner_radius`; registered orthographic views and cameras |
|
|
127
|
+
| `image_measure`, `ortho_views` | masks, regions, traced outlines, line and circle fits, `corner_radius`; registered orthographic views and cameras |
|
|
128
|
+
| `reference_traces`, `evidence_sheet` | the `TraceSet` that `load_traces` returns and the trace-stamp check; labelled evidence sheets |
|
|
124
129
|
|
|
125
130
|
---
|
|
126
131
|
|
|
@@ -136,7 +141,7 @@ Write `brief.md` beside the build script before touching Blender:
|
|
|
136
141
|
it occupies on screen;
|
|
137
142
|
- forward axis, overall length x width x height in metres, and which dimension is known for certain;
|
|
138
143
|
- 3 to 6 primary masses, each with its shape language (rounded / tapered / faceted / moulded / tubular) and the
|
|
139
|
-
kit tool that builds it (see the form table in step
|
|
144
|
+
kit tool that builds it (see the form table in step 5);
|
|
140
145
|
- the hero features that must read at gameplay size, and what can be texture instead of geometry;
|
|
141
146
|
- a face budget, the material list (5 to 8 sampled colours), and the export target (glTF for BabylonJS, FBX for
|
|
142
147
|
Unity).
|
|
@@ -152,26 +157,61 @@ Write `brief.md` beside the build script before touching Blender:
|
|
|
152
157
|
write the decision and the reason into the brief. Fitting a model to views that disagree makes every station
|
|
153
158
|
argue with another one.
|
|
154
159
|
|
|
155
|
-
## 3.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
## 3. Blueprint and trace: mandatory before any geometry
|
|
161
|
+
|
|
162
|
+
Model ON the references, never from numbers typed from them. Professionals set the views up as blueprints at real
|
|
163
|
+
scale, trace the outlines and build the surfaces on the traced curves. Here that is two tools and a stamp:
|
|
164
|
+
|
|
165
|
+
1. `blueprint --spec refs/spec.json --out blueprint.blend`. Every view becomes an image plane in its own view plane,
|
|
166
|
+
at the exact scale and position of its registration, behind the subject, low opacity, visible only in its own
|
|
167
|
+
axis-aligned view. Each view gets an orthographic camera, and a wire box marks the known dimensions. The build
|
|
168
|
+
script starts with `kit.load_blueprint("blueprint.blend")`. With `--model asset.blend` it also writes
|
|
169
|
+
`blueprint_<view>.png`, the model drawn over each reference at world scale.
|
|
170
|
+
2. `trace --spec refs/spec.json --out refs/traces.json [--curves refs/curves.json]`. It writes every view's outline,
|
|
171
|
+
in pixels and in world metres on the view plane, and `trace_<view>.png` previews. Pick the design lines in pixels
|
|
172
|
+
in `curves.json` (top line, shoulder line, plan edge, a flank's crease), and pair a curve with a second view for
|
|
173
|
+
3D points (format in the tool's `--help`). Check the previews: a traced outline that misses the subject is fixed
|
|
174
|
+
here (crop, `background_tolerance`), never later in the model.
|
|
175
|
+
3. The build script reads `traces = kit.load_traces("refs/traces.json")`. Blockout sections, loft stations, cage
|
|
176
|
+
design lines and tube paths come from `traces.curve(name)` and `traces.outline_boundary(view, axis, value,
|
|
177
|
+
side)`, never from hand-typed tables. Then `kit.stamp_traces(parts, "refs/traces.json")`.
|
|
178
|
+
4. Put `"require_traces": "traces.json"` in the spec. From then on `world-gate` and `measure-stations` fail any
|
|
179
|
+
measured part that is not stamped with the current traces file, and re-tracing makes the old stamps stale.
|
|
180
|
+
|
|
181
|
+
**Parts and coverage.** When the asset is built as parts (body, nose, flanks, pods), draw each part's region on
|
|
182
|
+
the whole-asset references in `coverage.json` and pass `coverage-check --reference refs/left.png --reference
|
|
183
|
+
refs/top.png --parts coverage.json --out coverage.png` (99 % of the silhouette by default) before building. Its
|
|
184
|
+
unclaimed regions are the parts nobody was going to build.
|
|
185
|
+
|
|
186
|
+
## 4. Blockout of the whole silhouette, then the primitive gate
|
|
187
|
+
|
|
188
|
+
Block the WHOLE asset first: every primary mass at its traced size, on the traced curves, with the kit's lofts,
|
|
189
|
+
spins and tubes (coarse: 3 to 5 stations, 2 segments per corner). No region of any view may be left for later. Run
|
|
190
|
+
`overlay-sheet --spec refs/spec.json --model blockout.blend --out blockout_sheet.png`, `world-gate` and
|
|
191
|
+
`review-render`. The blockout passes when every view's IoU is at least 0.85, the sheet shows no large missing
|
|
192
|
+
(red) or extra (blue) region in any view, and the proportions read right.
|
|
160
193
|
|
|
161
194
|
**Gate: no new primitives after the blockout.** Record the blockout's object list in the brief. From here on,
|
|
162
195
|
objects are only refined (more stations, radii, cages, bevels, details on existing parts). A new object needs a
|
|
163
196
|
line in the brief that says what it is and why the blockout missed it. Piling primitives onto a failing shape
|
|
164
197
|
hides the real error. Re-measure instead.
|
|
165
198
|
|
|
166
|
-
##
|
|
199
|
+
## 5. Construction with the kit
|
|
167
200
|
|
|
168
201
|
```python
|
|
169
202
|
import construction_kit as kit # run with: node <skill>/scripts/bt-blender.mjs run build_asset.py
|
|
170
203
|
|
|
171
204
|
kit.clear_default_scene() # --factory-startup loads a default Cube; never measure it
|
|
172
|
-
|
|
205
|
+
kit.load_blueprint("blueprint.blend") # the references at world scale (helpers start with "_")
|
|
206
|
+
traces = kit.load_traces("refs/traces.json")
|
|
207
|
+
stations = []
|
|
208
|
+
for y in station_positions: # wherever the traced outlines change
|
|
209
|
+
width = 2 * traces.outline_boundary("top", "y", y, "max")
|
|
210
|
+
height = traces.outline_boundary("left", "y", y, "max")
|
|
211
|
+
stations.append((y, kit.rounded_section(width, height, 0.08, 0.03, segments=6)))
|
|
173
212
|
shell = kit.loft("Shell", stations)
|
|
174
213
|
kit.shade_smooth(shell, design_line_edges=cap_rims)
|
|
214
|
+
kit.stamp_traces([shell], "refs/traces.json")
|
|
175
215
|
```
|
|
176
216
|
|
|
177
217
|
| Form | Build it with |
|
|
@@ -211,14 +251,24 @@ Kit API (`scripts/blender/construction_kit.py`; lengths in metres, every functio
|
|
|
211
251
|
| `world_vertices(obj, evaluated=True)` | world-space vertices; measure with these, never `bound_box` |
|
|
212
252
|
| `section_points(objects, position, axis="Y")` / `section_extent(objects, position, axis="Y", measure_axis="X")` | the exact cross-section at a station |
|
|
213
253
|
| `sdf_inflate(name, mask, pixels_per_metre, width, corner_radius, exponent=2.5, origin_pixel=None, voxel_size=None, rounding_mask=None, recess_depth=None, field_blur_pixels=0.0)` | right-view mask (image right +Y, up +Z) inflated along X into a closed, manifold solid |
|
|
254
|
+
| `load_blueprint(path)` | append the `blueprint` tool's `_Blueprint` collection (image planes, view cameras, reference box) into the scene |
|
|
255
|
+
| `load_traces(path)` | the `trace` tool's `traces.json` as a `TraceSet`: `.curve(name)` / `.curves` ((N, 3) world points), `.outline(view)` (plane coordinates), `.outline_points(view, depth)`, `.outline_boundary(view, axis, value, side="max")` (e.g. the side view's top line at a length station, or the top view's half-width), `.outline_extent(view, axis, value)`, `.extent(view)`, `.sha256` |
|
|
256
|
+
| `stamp_traces(objects, path)` | write the traces file's SHA-256 to each part's `bt_traces` property; the trace gate checks it |
|
|
214
257
|
|
|
215
258
|
Modifier order for subdivision builds: Mirror, then booleans (one cutter object, overlapping on every axis,
|
|
216
259
|
manifold, scale applied), then holding loops / bevel, then Subdivision, then Weighted Normal last if it is used
|
|
217
260
|
at all. Never put face-area weighted normals on a curved surface: they flatten every facet.
|
|
218
261
|
|
|
219
|
-
##
|
|
262
|
+
## 6. Measure
|
|
263
|
+
|
|
264
|
+
Run these after EVERY construction pass. Judge the whole shape in every view on the overlay sheet before any
|
|
265
|
+
detail, then fix the worst WRONG station first:
|
|
220
266
|
|
|
221
|
-
|
|
267
|
+
- **Whole silhouette, every view**: `overlay-sheet --spec refs/spec.json --model asset.blend --out sheet.png`
|
|
268
|
+
(or `--pair name=reference.png,capture.png` for captures from the game's locked cameras, perspective included).
|
|
269
|
+
Each tile shows the reference outline (amber) and the model outline (cyan), missing regions in red and extra
|
|
270
|
+
regions in blue, with IoU, reference-only and model-only percentages and the largest missing / extra regions.
|
|
271
|
+
A big red blob is a region nobody built: fix it before touching anything smaller.
|
|
222
272
|
|
|
223
273
|
- **Stations**: `measure-stations --spec refs/spec.json --model asset.blend`. Each station's silhouette extent is
|
|
224
274
|
graded **MATCH** (<= 3 % or <= 1 cm), **CLOSE** (<= 6 %) or **WRONG** (> 6 %). MISSING means one side has no
|
|
@@ -244,7 +294,7 @@ Run all three after every construction pass, and fix the worst WRONG first:
|
|
|
244
294
|
Grade honestly. Never move a reference registration or a station to make a number pass. Fix the model, or record
|
|
245
295
|
the decision in the brief.
|
|
246
296
|
|
|
247
|
-
##
|
|
297
|
+
## 7. QA
|
|
248
298
|
|
|
249
299
|
- `qa-check --model asset.blend [--profile web|game|render|print] [--allow-floating Decal] [--uv-map UVLightmap|1]
|
|
250
300
|
[--allow-uv-overlap Wall Floor]`. The profile sets which
|
|
@@ -276,7 +326,7 @@ the decision in the brief.
|
|
|
276
326
|
"expect_embedded": [["Bolt*", "Plate"]] }
|
|
277
327
|
```
|
|
278
328
|
|
|
279
|
-
##
|
|
329
|
+
## 8. Export
|
|
280
330
|
|
|
281
331
|
`export --model asset.blend --out build/asset.glb` (or `.gltf`, or `.fbx`; `--format` overrides the extension):
|
|
282
332
|
- **Geometry Nodes instances** are dropped by every exporter, so an object that makes them fails the export
|
|
@@ -303,7 +353,7 @@ the decision in the brief.
|
|
|
303
353
|
export. Without Node or the package, validation is reported as skipped and the export still passes.
|
|
304
354
|
- The report is `<out name>.export.json`. Run `validate-gltf <file>` alone on any glTF.
|
|
305
355
|
|
|
306
|
-
##
|
|
356
|
+
## 9. Traps (re-verified on Blender 5.3.0)
|
|
307
357
|
|
|
308
358
|
| Trap | 5.3.0 result | What the skill does |
|
|
309
359
|
|---|---|---|
|
|
@@ -334,13 +384,15 @@ operators, FBX takes) are in the guide's §6.1 and in each domain reference.
|
|
|
334
384
|
|
|
335
385
|
# Stations spec
|
|
336
386
|
|
|
337
|
-
Paths are relative to the spec file. `measure-stations`, `world-gate
|
|
387
|
+
Paths are relative to the spec file. `measure-stations`, `world-gate`, `view-consistency`, `blueprint`, `trace`
|
|
388
|
+
and `overlay-sheet` share it.
|
|
338
389
|
|
|
339
390
|
```json
|
|
340
391
|
{
|
|
341
392
|
"model": "asset.blend",
|
|
342
393
|
"objects": ["Shell"],
|
|
343
394
|
"known_dimensions": {"x": 0.46, "y": 1.0, "z": 0.30},
|
|
395
|
+
"require_traces": "traces.json",
|
|
344
396
|
"views": [{
|
|
345
397
|
"name": "front", "view": "front", "image": "front.png",
|
|
346
398
|
"pixels_per_metre": 1000, "origin_pixel": [400, 450],
|
|
@@ -356,6 +408,9 @@ Paths are relative to the spec file. `measure-stations`, `world-gate` and `view-
|
|
|
356
408
|
- `stations.axis` is one of the view's two image axes; each station measures the silhouette across it.
|
|
357
409
|
- `frame` (optional) replaces the model render with a capture from the game's own locked camera. Use it to judge
|
|
358
410
|
the asset where it is actually seen.
|
|
411
|
+
- `require_traces` (optional, set once the traces exist): `world-gate` and `measure-stations` fail, without
|
|
412
|
+
measuring, while any measured object lacks a `bt_traces` stamp matching that file's current SHA-256
|
|
413
|
+
(`kit.stamp_traces`). The message names the unstamped and stale parts.
|
|
359
414
|
- `world-gate` also runs on a single view without a spec:
|
|
360
415
|
`--image --view --pixels-per-metre --origin-pixel [--crop]`.
|
|
361
416
|
|
|
@@ -364,6 +419,10 @@ Paths are relative to the spec file. `measure-stations`, `world-gate` and `view-
|
|
|
364
419
|
| Tool | Writes |
|
|
365
420
|
|---|---|
|
|
366
421
|
| `view-consistency` | `view_consistency.json` (spec folder or `--out`) |
|
|
422
|
+
| `blueprint` | the blueprint `.blend`, `<out>.json` (registration per view); with `--model`, `blueprint_<view>.png` |
|
|
423
|
+
| `trace` | `traces.json`, `trace_<view>.png` |
|
|
424
|
+
| `coverage-check` | the picture (`--out`) and `<out>.json`: coverage, unclaimed regions, overlaps per reference |
|
|
425
|
+
| `overlay-sheet` | the sheet (`--out`) and `<out>.json`: IoU, missing / extra percentages and regions per view |
|
|
367
426
|
| `measure-stations` | `stations_evidence/stations.json`, `stations_<view>.png` |
|
|
368
427
|
| `world-gate` | `world_gate/world_gate.json`, `diff_<view>.png` |
|
|
369
428
|
| `review-render` | `review_sheet.png`, `gameplay_<N>px.png`, `gameplay_<N>px_x4.png` |
|
|
@@ -375,7 +434,10 @@ Read the JSON; do not parse the log.
|
|
|
375
434
|
|
|
376
435
|
# Limits
|
|
377
436
|
|
|
378
|
-
- Straight orthographic views only. Perspective and three-quarter references go through
|
|
437
|
+
- Straight orthographic views only for the registered tools. Perspective and three-quarter references go through
|
|
438
|
+
`bt-unwrap --analyze`; `overlay-sheet --pair` compares any locked-camera capture with its reference, unregistered.
|
|
439
|
+
- `trace` follows pixel edges, so a traced outline is as good as the reference image: anti-aliased edges, drop
|
|
440
|
+
shadows and drawn lines move it by their width. Read the previews.
|
|
379
441
|
- Subject masks come from the background colour at the image border. Busy or gradient backgrounds need a `crop`,
|
|
380
442
|
or a clean silhouette image.
|
|
381
443
|
- `qa-check` samples UV overlap on a 128 x 128 raster, so overlaps below one texel can be missed.
|
|
@@ -32,14 +32,18 @@ complete script: save it and run `node <skill>/scripts/bt-blender.mjs run recipe
|
|
|
32
32
|
line.
|
|
33
33
|
In one production vehicle build, a shoulder the reference rolled over about 40 mm was modelled with a
|
|
34
34
|
chine of radius about 0. Five rounds of width fixes followed before anyone measured the radius.
|
|
35
|
-
2. **
|
|
35
|
+
2. **Blueprint and trace, then the whole silhouette.** Set the views up with `blueprint`, `trace` their outlines
|
|
36
|
+
and design lines, and lay the blockout on the traced curves (stamped, SKILL.md step 3). Check the whole
|
|
37
|
+
silhouette in every view with `overlay-sheet` before any cut or bevel: a region of a view no part covers is
|
|
38
|
+
a blockout error, not a detail to add later.
|
|
39
|
+
3. **Primary, secondary, tertiary.** Block the big masses, then the medium forms (panels, steps, housings), then
|
|
36
40
|
the small details (bolts, vents, labels). Every edge and vertex should have a job. Small details go into
|
|
37
41
|
textures, trims or decals unless they change the silhouette at play size (section 8).
|
|
38
|
-
|
|
42
|
+
4. **Choose the production route** (section 2) before the first cut. It decides whether cuts need clean
|
|
39
43
|
quads (subdivision), whether booleans may stay as n-gons (mid-poly), and what the texture does.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
5. **Cut on topology that is ready for the cut** (section 3), or use a boolean the route allows (section 4).
|
|
45
|
+
6. **Finish the edges and normals** (section 5), **then UVs, trims and decals** (section 6).
|
|
46
|
+
7. **Measure and gate** (section 9): the edge radii on sections, stations, the overlay sheet and IoU, qa-check, and a render at
|
|
43
47
|
the in-game pixel height.
|
|
44
48
|
|
|
45
49
|
---
|
|
@@ -28,16 +28,21 @@ Every recipe below is a complete script. Run it with
|
|
|
28
28
|
designed vehicle. Real dimensions beat any blueprint.
|
|
29
29
|
2. **Set up the references and the scale** (section 2). The wheelbase sets every view's scale, so check the
|
|
30
30
|
views agree (`view-consistency`) and settle the disagreements once.
|
|
31
|
-
3. **
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
3. **Blueprint and trace before any geometry** (SKILL.md step 3). `blueprint` puts the views at world scale,
|
|
32
|
+
`trace` turns their outlines and the picked design lines (roof line, belt line, plan edge, flank crease) into
|
|
33
|
+
world curves, and every part is built on them and stamped (`require_traces`). If the body is split into
|
|
34
|
+
parts, `coverage-check` proves every region of the side, top and front views belongs to one.
|
|
35
|
+
4. **Block out the WHOLE silhouette first**: proxy masses on the traced curves plus four wheel cylinders at the
|
|
36
|
+
real dimensions. A vehicle's nose is the whole wedge, its side flanks included, blocked against the side, top
|
|
37
|
+
and front traces before any surfacing. Gate the blockout with `overlay-sheet` (no large red or blue region in
|
|
38
|
+
any view), `world-gate` and `stance_report` before any detail (section 3).
|
|
39
|
+
5. **Wheel arches and wheels first.** Arches and wheels are what the eye locks onto. Experienced vehicle artists
|
|
35
40
|
start the body at the wheel wells and work outwards.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
in ortho.
|
|
41
|
+
6. **Build the body shell** on the traced curves (section 4). Cut panel lines last.
|
|
42
|
+
7. **Model the wheels and the separate moving parts, and set every pivot** (sections 5 and 6).
|
|
43
|
+
8. **Add the interior to what the camera sees** (section 7), then **LODs** (section 8), then export.
|
|
44
|
+
9. **Check in orthographic views as well as perspective.** A body can look right in perspective and be wrong
|
|
45
|
+
in ortho: the overlay sheet shows every view at once, every pass.
|
|
41
46
|
|
|
42
47
|
---
|
|
43
48
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"""
|
|
2
|
+
blueprint -- set the reference views up as a modelling blueprint at real scale, the way modellers start.
|
|
3
|
+
|
|
4
|
+
Every straight view of a stations spec becomes an image empty in its own view plane, sized and placed
|
|
5
|
+
exactly from its pixels_per_metre and origin_pixel: image right / up along the view's world axes, centred
|
|
6
|
+
where the registration puts the image centre, set just behind the subject along the view direction, drawn
|
|
7
|
+
behind geometry, visible only in its own axis-aligned orthographic view and at low opacity. Each view gets
|
|
8
|
+
an orthographic camera that frames its image, and a wire box marks the known dimensions (the traced subject
|
|
9
|
+
extent on any axis the brief leaves open). Everything lives in the "_Blueprint" collection and every name
|
|
10
|
+
starts with "_", so no tool measures or exports it. A build script starts from it with
|
|
11
|
+
`construction_kit.load_blueprint(path)` (or by opening the file).
|
|
12
|
+
|
|
13
|
+
With --model, the model is also rendered through every registered view and drawn over its reference image
|
|
14
|
+
(shaded at half strength, its outline in orange): blueprint_<view>.png shows the model sitting on the
|
|
15
|
+
reference at world scale. The registration used for every view is written to <out>.json.
|
|
16
|
+
|
|
17
|
+
node bt-blender.mjs blueprint --spec refs/spec.json --out blueprint.blend [--opacity 0.35]
|
|
18
|
+
[--model asset.blend] [--render-dir dir]
|
|
19
|
+
"""
|
|
20
|
+
import os
|
|
21
|
+
import sys
|
|
22
|
+
|
|
23
|
+
sys.dont_write_bytecode = True
|
|
24
|
+
SCRIPT_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
|
|
25
|
+
if SCRIPT_DIRECTORY not in sys.path:
|
|
26
|
+
sys.path.insert(0, SCRIPT_DIRECTORY)
|
|
27
|
+
|
|
28
|
+
import bmesh # noqa: E402
|
|
29
|
+
import bpy # noqa: E402
|
|
30
|
+
import numpy as np # noqa: E402
|
|
31
|
+
from mathutils import Matrix, Vector # noqa: E402
|
|
32
|
+
|
|
33
|
+
import construction_kit # noqa: E402
|
|
34
|
+
import evidence_sheet # noqa: E402
|
|
35
|
+
import image_measure # noqa: E402
|
|
36
|
+
import ortho_views # noqa: E402
|
|
37
|
+
import tool_common # noqa: E402
|
|
38
|
+
import view_consistency # noqa: E402
|
|
39
|
+
|
|
40
|
+
TOOL_NAME = "blueprint"
|
|
41
|
+
|
|
42
|
+
DEFAULT_OPACITY = 0.35
|
|
43
|
+
|
|
44
|
+
# Gap between the subject's far side and the image plane set behind it, metres.
|
|
45
|
+
PLANE_GAP_METRES = 0.05
|
|
46
|
+
|
|
47
|
+
# Extra room between a view camera and the subject, metres.
|
|
48
|
+
CAMERA_CLEARANCE_METRES = 1.0
|
|
49
|
+
|
|
50
|
+
REFERENCE_BOX_NAME = "_bp_reference_box"
|
|
51
|
+
|
|
52
|
+
# Overlay drawing: the model's shaded render is blended in at this strength, its outline in this colour.
|
|
53
|
+
MODEL_BLEND = 0.5
|
|
54
|
+
MODEL_OUTLINE_COLOR = (1.0, 0.45, 0.05)
|
|
55
|
+
MODEL_OUTLINE_PIXELS = 2
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def build_parser() -> tool_common.ToolArgumentParser:
|
|
59
|
+
"""The tool's command-line options."""
|
|
60
|
+
parser = tool_common.ToolArgumentParser(prog=TOOL_NAME, description=__doc__.strip().splitlines()[0])
|
|
61
|
+
parser.add_argument("--spec", required=True, help="stations spec JSON: registered straight views")
|
|
62
|
+
parser.add_argument("--out", required=True, help="blueprint .blend to write")
|
|
63
|
+
parser.add_argument("--opacity", type=float, default=DEFAULT_OPACITY, help="reference image opacity 0..1")
|
|
64
|
+
parser.add_argument("--model", help="also draw this model over every reference view (.blend .glb .gltf .fbx .obj)")
|
|
65
|
+
parser.add_argument("--objects", nargs="*", help="model objects to draw (default the spec's, else every visible mesh)")
|
|
66
|
+
parser.add_argument("--render-dir", help="folder for blueprint_<view>.png (default: the --out folder)")
|
|
67
|
+
return parser
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _spec_views(spec: dict) -> list:
|
|
71
|
+
"""The spec's views, each checked to name a straight view."""
|
|
72
|
+
views = spec.get("views") or []
|
|
73
|
+
if not views:
|
|
74
|
+
raise ValueError("the spec has no views")
|
|
75
|
+
for view in views:
|
|
76
|
+
for key in ("name", "view", "image"):
|
|
77
|
+
if key not in view:
|
|
78
|
+
raise ValueError(f"every view needs '{key}'")
|
|
79
|
+
ortho_views.view_basis(view["view"])
|
|
80
|
+
return views
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def subject_extents(views: list, spec_directory: str) -> dict:
|
|
84
|
+
"""
|
|
85
|
+
The subject's world interval on each axis, averaged over the views that show it.
|
|
86
|
+
|
|
87
|
+
:param views: Spec views.
|
|
88
|
+
:param spec_directory: Folder relative paths start from.
|
|
89
|
+
:returns: {axis: [minimum, maximum]} in metres.
|
|
90
|
+
"""
|
|
91
|
+
collected = {}
|
|
92
|
+
for view in views:
|
|
93
|
+
for axis, interval in view_consistency.view_extents(view, spec_directory).items():
|
|
94
|
+
collected.setdefault(axis, []).append(interval)
|
|
95
|
+
return {axis: np.mean(np.array(intervals), axis=0).tolist() for axis, intervals in collected.items()}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _depth_offset(basis: ortho_views.ViewBasis, extents: dict) -> float:
|
|
99
|
+
"""How far along the view direction the image plane sits: just past the subject's far side."""
|
|
100
|
+
axis, sign = ortho_views.axis_of(basis.forward)
|
|
101
|
+
low, high = extents.get(axis, (0.0, 0.0))
|
|
102
|
+
return max(sign * low, sign * high) + PLANE_GAP_METRES
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _view_rotation(basis: ortho_views.ViewBasis) -> Matrix:
|
|
106
|
+
"""Rotation whose local X is image right, local Y image up and local Z points back at the viewer."""
|
|
107
|
+
return Matrix((tuple(basis.right), tuple(basis.up), tuple(-basis.forward))).transposed().to_4x4()
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _image_empty(name: str, image: bpy.types.Image, size: float, opacity: float) -> bpy.types.Object:
|
|
111
|
+
"""An image empty set up as a blueprint: behind geometry, only in its own axis-aligned ortho view."""
|
|
112
|
+
empty = bpy.data.objects.new(name, None)
|
|
113
|
+
empty.empty_display_type = "IMAGE"
|
|
114
|
+
empty.data = image
|
|
115
|
+
empty.empty_display_size = size
|
|
116
|
+
empty.empty_image_offset = (-0.5, -0.5)
|
|
117
|
+
empty.empty_image_depth = "BACK"
|
|
118
|
+
empty.empty_image_side = "FRONT"
|
|
119
|
+
empty.show_empty_image_only_axis_aligned = True
|
|
120
|
+
empty.show_empty_image_orthographic = True
|
|
121
|
+
empty.show_empty_image_perspective = False
|
|
122
|
+
empty.use_empty_image_alpha = True
|
|
123
|
+
empty.color[3] = opacity
|
|
124
|
+
empty.hide_select = True
|
|
125
|
+
return empty
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _view_camera(name: str, frame: ortho_views.PixelFrame, basis: ortho_views.ViewBasis, center: np.ndarray,
|
|
129
|
+
reach: float) -> bpy.types.Object:
|
|
130
|
+
"""An orthographic camera on the view axis that frames the whole reference image."""
|
|
131
|
+
camera = bpy.data.objects.new(name, bpy.data.cameras.new(name))
|
|
132
|
+
camera.data.type = "ORTHO"
|
|
133
|
+
camera.data.sensor_fit = "AUTO"
|
|
134
|
+
camera.data.ortho_scale = max(frame.width, frame.height) / frame.pixels_per_metre
|
|
135
|
+
distance = reach + CAMERA_CLEARANCE_METRES
|
|
136
|
+
camera.data.clip_start = ortho_views.ORTHO_CLIP_START
|
|
137
|
+
camera.data.clip_end = distance + reach + CAMERA_CLEARANCE_METRES
|
|
138
|
+
camera.matrix_world = Matrix.Translation(Vector(center - basis.forward * distance)) @ _view_rotation(basis)
|
|
139
|
+
camera["bt_resolution"] = [frame.width, frame.height]
|
|
140
|
+
return camera
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def place_view(view_spec: dict, spec_directory: str, extents: dict, opacity: float,
|
|
144
|
+
collection: bpy.types.Collection) -> dict:
|
|
145
|
+
"""
|
|
146
|
+
Puts one reference view into the blueprint: its image empty and its camera.
|
|
147
|
+
|
|
148
|
+
:param view_spec: The spec view.
|
|
149
|
+
:param spec_directory: Folder relative paths start from.
|
|
150
|
+
:param extents: Subject extents per axis (for the image depth).
|
|
151
|
+
:param opacity: Image opacity.
|
|
152
|
+
:param collection: The blueprint collection.
|
|
153
|
+
:returns: The registration used, per view.
|
|
154
|
+
"""
|
|
155
|
+
image_path = os.path.normpath(os.path.join(spec_directory, view_spec["image"]))
|
|
156
|
+
image = bpy.data.images.load(image_path, check_existing=True)
|
|
157
|
+
width, height = image.size
|
|
158
|
+
frame = ortho_views.frame_from_spec(view_spec, width, height)
|
|
159
|
+
basis = ortho_views.view_basis(view_spec["view"])
|
|
160
|
+
scale = frame.pixels_per_metre
|
|
161
|
+
plane_center = (basis.right * (width / 2.0 - frame.origin_column) / scale
|
|
162
|
+
+ basis.up * (frame.origin_row - height / 2.0) / scale)
|
|
163
|
+
depth = _depth_offset(basis, extents)
|
|
164
|
+
center = plane_center + basis.forward * depth
|
|
165
|
+
name = view_spec["name"]
|
|
166
|
+
empty = _image_empty(f"_bp_{name}_image", image, max(width, height) / scale, opacity)
|
|
167
|
+
empty.matrix_world = Matrix.Translation(Vector(center)) @ _view_rotation(basis)
|
|
168
|
+
camera = _view_camera(f"_bp_{name}_camera", frame, basis, plane_center, depth + PLANE_GAP_METRES)
|
|
169
|
+
for obj in (empty, camera):
|
|
170
|
+
obj["bt_view"] = view_spec["view"]
|
|
171
|
+
collection.objects.link(obj)
|
|
172
|
+
right_axis, right_sign = ortho_views.axis_of(basis.right)
|
|
173
|
+
up_axis, up_sign = ortho_views.axis_of(basis.up)
|
|
174
|
+
corners = {label: (center + basis.right * (column - width / 2.0) / scale
|
|
175
|
+
+ basis.up * (height / 2.0 - row) / scale).round(5).tolist()
|
|
176
|
+
for label, (column, row) in (("top_left", (0, 0)), ("bottom_right", (width, height)))}
|
|
177
|
+
return {"name": name, "view": view_spec["view"], "image": image_path, "image_size_px": [width, height],
|
|
178
|
+
"pixels_per_metre": scale, "origin_pixel": [frame.origin_column, frame.origin_row],
|
|
179
|
+
"image_right": f"{'+' if right_sign > 0 else '-'}{right_axis}",
|
|
180
|
+
"image_up": f"{'+' if up_sign > 0 else '-'}{up_axis}",
|
|
181
|
+
"world_size_m": [round(width / scale, 5), round(height / scale, 5)],
|
|
182
|
+
"image_center_world": center.round(5).tolist(), "image_corners_world": corners,
|
|
183
|
+
"depth_offset_m": round(depth, 5), "image_object": empty.name, "camera": camera.name}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def reference_box(spec: dict, extents: dict, collection: bpy.types.Collection) -> dict:
|
|
187
|
+
"""
|
|
188
|
+
A wire box at the known dimensions, centred on the traced subject (traced size on axes the brief leaves
|
|
189
|
+
open).
|
|
190
|
+
|
|
191
|
+
:param spec: The spec (its "known_dimensions").
|
|
192
|
+
:param extents: Traced subject extents per axis.
|
|
193
|
+
:param collection: The blueprint collection.
|
|
194
|
+
:returns: {"object", "size_m", "center_m", "size_source"}.
|
|
195
|
+
"""
|
|
196
|
+
known = spec.get("known_dimensions") or {}
|
|
197
|
+
size, center, source = [], [], {}
|
|
198
|
+
for axis in ortho_views.AXIS_NAMES:
|
|
199
|
+
low, high = extents.get(axis, (0.0, 0.0))
|
|
200
|
+
center.append((low + high) / 2.0)
|
|
201
|
+
if axis in known:
|
|
202
|
+
size.append(float(known[axis]))
|
|
203
|
+
source[axis] = "known"
|
|
204
|
+
else:
|
|
205
|
+
size.append(high - low)
|
|
206
|
+
source[axis] = "traced"
|
|
207
|
+
mesh = bpy.data.meshes.new(REFERENCE_BOX_NAME)
|
|
208
|
+
edit_mesh = bmesh.new()
|
|
209
|
+
bmesh.ops.create_cube(edit_mesh, size=1.0)
|
|
210
|
+
bmesh.ops.scale(edit_mesh, vec=Vector(size), verts=edit_mesh.verts)
|
|
211
|
+
bmesh.ops.translate(edit_mesh, vec=Vector(center), verts=edit_mesh.verts)
|
|
212
|
+
edit_mesh.to_mesh(mesh)
|
|
213
|
+
edit_mesh.free()
|
|
214
|
+
box = bpy.data.objects.new(REFERENCE_BOX_NAME, mesh)
|
|
215
|
+
box.display_type = "WIRE"
|
|
216
|
+
box.hide_render = True
|
|
217
|
+
box.hide_select = True
|
|
218
|
+
collection.objects.link(box)
|
|
219
|
+
return {"object": box.name, "size_m": np.round(size, 5).tolist(), "center_m": np.round(center, 5).tolist(),
|
|
220
|
+
"size_source": source}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def build_blueprint(spec: dict, spec_directory: str, out_path: str, opacity: float) -> dict:
|
|
224
|
+
"""
|
|
225
|
+
Builds and saves the blueprint .blend.
|
|
226
|
+
|
|
227
|
+
:returns: {"views": [...], "reference_box": {...}, "blend"}.
|
|
228
|
+
"""
|
|
229
|
+
construction_kit.clear_default_scene()
|
|
230
|
+
views = _spec_views(spec)
|
|
231
|
+
extents = subject_extents(views, spec_directory)
|
|
232
|
+
collection = bpy.data.collections.new(construction_kit.BLUEPRINT_COLLECTION)
|
|
233
|
+
bpy.context.scene.collection.children.link(collection)
|
|
234
|
+
placed = [place_view(view, spec_directory, extents, opacity, collection) for view in views]
|
|
235
|
+
box = reference_box(spec, extents, collection)
|
|
236
|
+
first = placed[0]
|
|
237
|
+
scene = bpy.context.scene
|
|
238
|
+
scene.render.resolution_x, scene.render.resolution_y = first["image_size_px"]
|
|
239
|
+
scene.camera = bpy.data.objects[first["camera"]]
|
|
240
|
+
os.makedirs(os.path.dirname(out_path), exist_ok=True)
|
|
241
|
+
bpy.ops.wm.save_as_mainfile(filepath=out_path)
|
|
242
|
+
return {"views": placed, "reference_box": box, "subject_extents_m": extents, "blend": out_path}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def draw_model_overlays(spec: dict, spec_directory: str, model: str, object_names, render_directory: str) -> list:
|
|
246
|
+
"""
|
|
247
|
+
Renders the model through every registered view and draws it over the reference image.
|
|
248
|
+
|
|
249
|
+
:returns: Per view {"name", "overlay", "model_visible"}.
|
|
250
|
+
"""
|
|
251
|
+
tool_common.load_model(model)
|
|
252
|
+
objects = tool_common.resolve_objects(object_names or spec.get("objects"))
|
|
253
|
+
overlays = []
|
|
254
|
+
for view in _spec_views(spec):
|
|
255
|
+
reference = tool_common.load_image(os.path.normpath(os.path.join(spec_directory, view["image"])))
|
|
256
|
+
height, width = reference.shape[:2]
|
|
257
|
+
frame = ortho_views.frame_from_spec(view, width, height)
|
|
258
|
+
render_path = os.path.join(render_directory, "blueprint_renders", f"{view['name']}_shaded.png")
|
|
259
|
+
shaded = ortho_views.render_view(objects, view["view"], frame, render_path, "shaded")
|
|
260
|
+
mask = shaded[:, :, 3] > 0.5
|
|
261
|
+
picture = reference[:, :, :3].copy()
|
|
262
|
+
picture[mask] = picture[mask] * (1.0 - MODEL_BLEND) + shaded[mask, :3] * MODEL_BLEND
|
|
263
|
+
evidence_sheet.draw_mask_outline(picture, image_measure.dilate(mask, 1), MODEL_OUTLINE_COLOR, MODEL_OUTLINE_PIXELS)
|
|
264
|
+
path = tool_common.save_image(os.path.join(render_directory, f"blueprint_{view['name']}.png"), picture)
|
|
265
|
+
overlays.append({"name": view["name"], "overlay": path, "model_visible": bool(mask.any())})
|
|
266
|
+
return overlays
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def run(options) -> dict:
|
|
270
|
+
"""
|
|
271
|
+
Builds the blueprint, and with --model the overlay renders.
|
|
272
|
+
|
|
273
|
+
:param options: Parsed options.
|
|
274
|
+
:returns: The tool result.
|
|
275
|
+
"""
|
|
276
|
+
if not 0.0 <= options.opacity <= 1.0:
|
|
277
|
+
raise tool_common.OptionsError("--opacity must be within 0..1")
|
|
278
|
+
spec_path = os.path.abspath(options.spec)
|
|
279
|
+
spec_directory = os.path.dirname(spec_path)
|
|
280
|
+
spec = tool_common.load_json(spec_path)
|
|
281
|
+
out_path = os.path.abspath(options.out)
|
|
282
|
+
result = build_blueprint(spec, spec_directory, out_path, options.opacity)
|
|
283
|
+
if options.model:
|
|
284
|
+
render_directory = os.path.abspath(options.render_dir or os.path.dirname(out_path))
|
|
285
|
+
result["overlays"] = draw_model_overlays(spec, spec_directory, os.path.abspath(options.model),
|
|
286
|
+
options.objects, render_directory)
|
|
287
|
+
result["pass"] = True
|
|
288
|
+
result["report_json"] = tool_common.write_json(os.path.splitext(out_path)[0] + ".json", result)
|
|
289
|
+
return result
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
if __name__ == "__main__":
|
|
293
|
+
tool_common.run_tool(TOOL_NAME, build_parser(), run)
|