Files
gig-line/Tools/blender/export_north_buildings.py
T
zwitschi 4d27109668 refactor(tools): group the sixty scripts by what they talk to
One directory with sixty scripts stopped being navigable, and the grouping is also the sandbox boundary:

  Tools/unreal/    commandlets and the two map builders, with ue_common.py and ue_placement.py as the
                   shared imports (they need the engine)
  Tools/blender/   builders, exporters, the FBX preset, the MPFB character pipeline, blender_screenshots
                   (they need the Blender Flatpak)
  Tools/review/    the visual loop: render_screenshots.sh, judge_screenshot.py, hero_compare.py,
                   build_comparison_md.py, e2e_asset_check.py, hero_iterate.sh, visual_loop.py,
                   visual_targets.json
  Tools/gen/       image and texture generation: the ComfyUI driver, deterministic texture writers,
                   reference fetching
  Tools/input/     OS-level input injection
  root             _common.py, check-lfs.sh, addon_compat_probe.py, sibling_asset_audit.py, tests/

Every moved script now resolves the repository root as ../.. and puts the tools root plus its siblings on
sys.path, so 'import ue_common' still works from unreal/. The test suite bootstrap does the same for the five
folders. render_screenshots.sh takes the folder as a third argument to run_cmdlet, and the e2e driver,
hero_iterate.sh and the comparison generator were repointed.

51 README rows now link to their new location, the README gains a Layout section naming each folder's
sandbox, and the architecture notes and Blender README follow the moves.

Verified: 108 tests pass, prettier is clean, judge_screenshot.py and hero_compare.py run from their new
homes, and the e2e run was aborted mid-way (it had been rebuilding an empty DemoMap for 15 minutes) and is
being rerun against the new layout.
2026-11-10 12:40:30 +01:00

66 lines
2.5 KiB
Python

# Export the two in-scope north-side background buildings from the OSM blockout.
#
# blender -b --factory-startup Art/blender/blockout/blockout-2026-11-06.blend \
# --python Tools/blender/export_north_buildings.py -- --out /tmp/gigline/north
#
# The blockout is already in the shared project frame (metres, X east / Y north /
# Z up, origin Hollywood x Highland), so exporting each object at its own world
# position preserves the offset from the hero facade. The site export preset
# (`ue_metric_v1`) is reused verbatim so the metre->centimetre mapping matches.
import argparse
import os
import sys
import bpy
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import fbx_export_preset as fbx_preset # noqa: E402
BUILDINGS = ("TCL Chinese Theatre", "Madame Tussaud's")
def main():
argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
ap = argparse.ArgumentParser()
ap.add_argument("--out", default="/tmp/gigline/north")
args = ap.parse_args(argv)
os.makedirs(args.out, exist_ok=True)
print(f"[north] scene objects: {len(bpy.data.objects)}")
for name in BUILDINGS:
obj = bpy.data.objects.get(name)
if obj is None or obj.type != "MESH":
print(f"[north] MISSING {name}")
continue
bpy.ops.object.select_all(action="DESELECT")
obj.select_set(True)
bpy.context.view_layer.objects.active = obj
mesh = obj.data
if not mesh.materials:
mat = bpy.data.materials.new(f"M_{name.replace(' ', '_')}")
mat.diffuse_color = (0.75, 0.72, 0.68, 1.0)
mat.use_nodes = False
mesh.materials.append(mat)
# No copy and no Y mirror: the FBX preset already lands Blender +Y
# (north) on Unreal -Y, and UE north is -Y here (north sidewalk
# Y -1912..-1053). The old mirror put both buildings on the south side.
new_obj = obj
new_mesh = mesh
bpy.ops.object.select_all(action="DESELECT")
new_obj.select_set(True)
bpy.context.view_layer.objects.active = new_obj
path = os.path.join(args.out, name.replace(" ", "_").replace("'", "") + ".fbx")
fbx_preset.export_static(path, selection=True)
world = new_obj.matrix_world
zs = [(world @ v.co).z for v in new_mesh.vertices]
print(f"[north] {name:22} verts {len(new_mesh.vertices):5} z {min(zs):+.2f}..{max(zs):+.2f} m "
f"-> {path}")
bpy.data.objects.remove(new_obj, do_unlink=True)
print(f"[north] done")
main()