#!/usr/bin/env python3 """Render the 23 L119 camera poses with the L126 candidate.""" from __future__ import annotations import importlib.util import json import math import os from pathlib import Path ROOT = Path(__file__).resolve().parents[4] RESEARCH = Path(__file__).resolve().parent CAPTURES = RESEARCH / "captures" SAVED = ROOT / "Saved/Linux/l126/captures" BASELINE_INDEX = (ROOT / "Standalone/Research/WorldAssemblerM3/Linux119" / "captures/L119/capture-index.json") LAYOUT = ROOT / "Saved/Linux/l126/hashes/owner4-surface-world-w12-clang.layout.json" CLANG = ROOT / os.environ.get("L126_CAPTURE_CLANG", "Saved/Linux/l126/design2/bin/VoxelForgeCoreHeadless-l126-design2-clang") RENDERER = ROOT / os.environ.get("L126_CAPTURE_RENDERER", "Saved/Linux/l126/design2/bin/VoxelForgeOffscreenCapture-l126-design2-clang") HELPER_PATH = ROOT / "Standalone/Research/WorldAssemblerM3/Linux113/RunL113Captures.py" SPEC = importlib.util.spec_from_file_location("l113_capture_helpers", HELPER_PATH) if SPEC is None or SPEC.loader is None: raise SystemExit("cannot load the verified L113 capture helpers") HELPERS = importlib.util.module_from_spec(SPEC) SPEC.loader.exec_module(HELPERS) HELPERS.RESEARCH = RESEARCH HELPERS.CAPTURES = CAPTURES HELPERS.SAVED = SAVED HELPERS.BINARIES = {"L126": CLANG} HELPERS.RENDERERS = {"L126": RENDERER} def main() -> int: if any(not path.is_file() for path in (BASELINE_INDEX, LAYOUT, CLANG, RENDERER)): raise SystemExit("missing L119 camera set, L126 layout, or capture binary") baseline = json.loads(BASELINE_INDEX.read_text(encoding="utf-8")) layout = json.loads(LAYOUT.read_text(encoding="utf-8")) rows = [] CAPTURES.mkdir(parents=True, exist_ok=True) SAVED.mkdir(parents=True, exist_ok=True) for view in baseline["captures"]: row = HELPERS.capture("L126", view, layout) row["variant"] = "L126-v225" if view["kind"] == "rock-floor-close": scene = ROOT / row["scene"] anchor = HELPERS.nearest_surface_anchor(scene, view["target"], margin_m=5.0, preferred_normal=(0.0, 0.0, 1.0), minimum_alignment=0.85) alignment = HELPERS.dot(anchor["normal"], (0.0, 0.0, 1.0)) camera_distance = math.dist(row["camera_actual_m"], anchor["position_m"]) row.update({"floor_anchor_position_m": anchor["position_m"], "floor_anchor_normal": anchor["normal"], "closeup_camera_to_floor_distance_m": camera_distance, "closeup_floor_normal_alignment": alignment, "verified_upward_floor_normal": alignment >= 0.85}) if (not row["verified"] or not 2.0 <= camera_distance <= 3.2 or anchor["distance_m"] > 0.25 or alignment < 0.85 or row["drawn_triangles"] <= 0 or row["pixel_quality_status"] not in ("pass", "low_contrast_geometry_visible")): raise RuntimeError(f"L126 floor close-up failed at {view['name']}") rows.append(row) if len(rows) != len(baseline["captures"]) or len(rows) != 23: raise RuntimeError(f"expected all 23 L119 views, captured {len(rows)}") index = CAPTURES / "L126" / "capture-index.json" index.parent.mkdir(parents=True, exist_ok=True) index.write_text(json.dumps({"captures": rows}, indent=2) + "\n", encoding="utf-8") html = ["", "
{row['kind']} · L119 {old['pixel_quality_status']} · " f"L126 {row['pixel_quality_status']}
", "