Cut 6b: Brokkr drop_pod.glb, petal blow-off, retro VFX/audio/juice, drop HUD/camera, and GL3 Sion captures

This commit is contained in:
Meta Vens 2026-12-05 11:45:04 +01:00
commit 5af5d87e06
15 changed files with 1847 additions and 94 deletions

View file

@ -0,0 +1,407 @@
"""Build the Brokkr-powered Imperial Orbital Drop Pod GLB into assets/vehicles/drop_pod/drop_pod.glb."""
from __future__ import annotations
import math
import sys
from pathlib import Path
import bmesh
import bpy
import numpy as np
from mathutils import Matrix, Vector
sys.path.insert(0, str(Path(__file__).resolve().parent))
import vehicle_common as vc # noqa: E402
def _add_prism_wedge(
bm: bmesh.types.BMesh,
x0_bot: float,
x1_bot: float,
x0_top: float,
x1_top: float,
hw_bot: float,
hw_top: float,
z0: float,
z1: float,
mat_idx: int,
taper_edge: float = 0.14,
) -> None:
"""Create a tapered trapezoidal armored hull plate oriented with outward face along +X."""
# Inner face (4 corners), outer face beveled slightly narrower for crisp chamfers
v_in_bl = bm.verts.new((x0_bot, -hw_bot, z0))
v_in_br = bm.verts.new((x0_bot, hw_bot, z0))
v_in_tr = bm.verts.new((x0_top, hw_top, z1))
v_in_tl = bm.verts.new((x0_top, -hw_top, z1))
hw_ob = max(0.05, hw_bot - taper_edge)
hw_ot = max(0.05, hw_top - taper_edge)
v_out_bl = bm.verts.new((x1_bot, -hw_ob, z0 + 0.05))
v_out_br = bm.verts.new((x1_bot, hw_ob, z0 + 0.05))
v_out_tr = bm.verts.new((x1_top, hw_ot, z1 - 0.05))
v_out_tl = bm.verts.new((x1_top, -hw_ot, z1 - 0.05))
quads = [
(v_out_bl, v_out_br, v_out_tr, v_out_tl), # outer (+X)
(v_in_br, v_in_bl, v_in_tl, v_in_tr), # inner (-X)
(v_in_bl, v_out_bl, v_out_tl, v_in_tl), # -Y flank
(v_out_br, v_in_br, v_in_tr, v_out_tr), # +Y flank
(v_in_bl, v_in_br, v_out_br, v_out_bl), # bottom (-Z)
(v_out_tl, v_out_tr, v_in_tr, v_in_tl), # top (+Z)
]
for q in quads:
f = bm.faces.new(q)
f.material_index = mat_idx
def _add_local_box(
bm: bmesh.types.BMesh,
center: tuple[float, float, float],
size: tuple[float, float, float],
rot_deg: tuple[float, float, float],
mat_idx: int,
) -> None:
rot_m = (
Matrix.Rotation(math.radians(rot_deg[2]), 4, "Z")
@ Matrix.Rotation(math.radians(rot_deg[1]), 4, "Y")
@ Matrix.Rotation(math.radians(rot_deg[0]), 4, "X")
)
mat = Matrix.Translation(center) @ rot_m @ Matrix.Diagonal((size[0], size[1], size[2], 1.0))
ret = bmesh.ops.create_cube(bm, size=1.0, matrix=mat)
verts_set = set(ret["verts"])
for f in bm.faces:
if all(v in verts_set for v in f.verts):
f.material_index = mat_idx
def _build_petal_mesh(name: str, mats: dict[str, bpy.types.Material]) -> tuple[bpy.types.Mesh, Vector]:
"""Build a single armored blow-off hull petal with local origin at its exact geometric centroid.
Authored in local radial coordinates where +X is outward, Y is tangential width, Z is vertical.
Returns (mesh, world_centroid_offset_in_radial_XZ).
"""
mat_order = ("olive_armor", "signal_orange", "gunmetal", "socket_bay")
bm = bmesh.new()
# World-space radial placement before centroid centering:
# Pod petal spans Z = 0.56..3.32m, leaning inward from r ~ 1.32m (bottom) to 0.94m (top).
z0, z1 = 0.56, 3.32
x0_b, x1_b = 1.04, 1.34
x0_t, x1_t = 0.72, 0.96
hw_b, hw_t = 0.54, 0.37
# 0: Main armored outer shell (olive_armor)
_add_prism_wedge(bm, x0_b, x1_b, x0_t, x1_t, hw_b, hw_t, z0, z1, mat_idx=0, taper_edge=0.11)
# 3: Recessed dark inner liner plate (socket_bay)
_add_prism_wedge(bm, x0_b - 0.04, x0_b + 0.01, x0_t - 0.04, x0_t + 0.01, hw_b - 0.09, hw_t - 0.07, z0 + 0.14, z1 - 0.14, mat_idx=3, taper_edge=0.02)
# Mid-slope angle for surface-aligned ribs and chevron plates
dx = x1_t - x1_b
dz = z1 - z0
pitch_deg = math.degrees(math.atan2(-dx, dz)) # tilt inward toward +Z
# 0: Heavy vertical central blast rib (olive_armor)
mid_x = 0.5 * (x1_b + x1_t) + 0.04
mid_z = 0.5 * (z0 + z1)
_add_local_box(bm, (mid_x, 0.0, mid_z), (0.14, 0.22, 2.24), (0.0, pitch_deg, 0.0), mat_idx=0)
# 1: Imperial accent chevron / hazard stripe band near upper third (signal_orange)
stripe_z = 2.48
t_s = (stripe_z - z0) / dz
stripe_x = x1_b + dx * t_s + 0.025
_add_local_box(bm, (stripe_x, 0.0, stripe_z), (0.08, 0.54, 0.22), (0.0, pitch_deg, 0.0), mat_idx=1)
_add_local_box(bm, (x1_b + dx * 0.22 + 0.025, 0.0, 1.15), (0.07, 0.68, 0.14), (0.0, pitch_deg, 0.0), mat_idx=1)
# 2: Explosive bolt hinge lugs at base & top clamp collar (gunmetal)
for side in (-1.0, 1.0):
_add_local_box(bm, (x1_b - 0.04, side * 0.34, z0 + 0.16), (0.14, 0.12, 0.20), (0.0, pitch_deg, 0.0), mat_idx=2)
_add_local_box(bm, (x1_t - 0.03, side * 0.22, z1 - 0.15), (0.12, 0.10, 0.18), (0.0, pitch_deg, 0.0), mat_idx=2)
# Bevel crisp armor edges slightly
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
bmesh.ops.bevel(
bm,
geom=list(bm.edges),
offset=0.015,
segments=1,
affect="EDGES",
clamp_overlap=True,
)
bmesh.ops.recalc_face_normals(bm, faces=bm.faces)
# Compute exact AABB centroid of the petal and shift all vertices so local origin == centroid!
coords = np.array([v.co[:] for v in bm.verts], dtype=np.float64)
c_min = coords.min(axis=0)
c_max = coords.max(axis=0)
centroid = Vector(((c_min[0] + c_max[0]) * 0.5, (c_min[1] + c_max[1]) * 0.5, (c_min[2] + c_max[2]) * 0.5))
bmesh.ops.translate(bm, verts=bm.verts, vec=-centroid)
mesh = bpy.data.meshes.new(name)
bm.to_mesh(mesh)
bm.free()
for m_name in mat_order:
mesh.materials.append(mats[m_name])
sharp = mesh.attributes.get("sharp_face") or mesh.attributes.new("sharp_face", "BOOLEAN", "FACE")
sharp.data.foreach_set("value", np.ones(len(mesh.polygons), dtype=bool))
mesh.update()
return mesh, centroid
def build_drop_pod() -> Path:
vc.reset_scene()
mats = vc.ensure_materials()
root = vc.make_empty("DropPodRoot")
body_empty = vc.make_empty("CoreBody", parent=root)
# 1. Heavy Octagonal Ablative Heatshield Base (Z = 0.00 .. 0.62, width ~2.80m)
shield_prof = [
[0.00, 0.00],
[1.12, 0.00],
[1.36, 0.14],
[1.40, 0.34],
[1.24, 0.56],
[0.98, 0.64],
[0.00, 0.64],
]
vc.make_lathe_part(
"HeatshieldBase",
shield_prof,
segments=8,
loop=False,
smooth=False,
mat_name="gunmetal",
parent=body_empty,
rotation_deg=(0.0, 0.0, 22.5),
bevel=0.015,
)
# Armored lower skirt bumper ring
skirt_prof = [
[1.33, 0.22],
[1.43, 0.25],
[1.42, 0.42],
[1.28, 0.50],
]
vc.make_lathe_part(
"HeatshieldSkirt",
skirt_prof,
segments=8,
loop=True,
smooth=False,
mat_name="olive_armor",
parent=body_empty,
rotation_deg=(0.0, 0.0, 22.5),
bevel=0.012,
)
# Central ventral retro-exhaust port
vc.make_tube_part(
"RetroNozzle",
0.34,
0.46,
0.18,
segments=12,
inner0=0.22,
inner1=0.32,
smooth=False,
mat_name="copper_rad",
parent=body_empty,
location=(0.0, 0.0, 0.01),
)
# 2. Inner Armored Pressure Core (Gunmetal + dark bulkhead ribs inside the 4 petals)
core_prof = [
[0.86, 0.58],
[0.84, 1.45],
[0.78, 2.55],
[0.72, 3.35],
[0.82, 3.55],
[0.00, 3.55],
]
vc.make_lathe_part(
"PressureVessel",
core_prof,
segments=8,
loop=False,
smooth=False,
mat_name="gunmetal",
parent=body_empty,
rotation_deg=(0.0, 0.0, 22.5),
bevel=0.012,
)
for ring_z, ring_r in ((1.20, 0.87), (2.05, 0.83), (2.90, 0.77)):
vc.make_tube_part(
f"BulkheadRing_{ring_z:.1f}",
ring_r,
ring_r,
0.16,
segments=8,
smooth=False,
mat_name="socket_bay",
parent=body_empty,
location=(0.0, 0.0, ring_z),
rotation_deg=(0.0, 0.0, 22.5),
)
# 3. Four Structural Spine Buttresses + Retro-Thruster Pods at 0, 90, 180, 270 deg
nozzle_prof = [
[0.14, 0.00],
[0.24, 0.00],
[0.19, 0.16],
[0.13, 0.34],
[0.17, 0.42],
[0.08, 0.42],
[0.11, 0.14],
]
for i in range(4):
ang_deg = i * 90.0
ang = math.radians(ang_deg)
ca, sa = math.cos(ang), math.sin(ang)
# Vertical structural spine rib between petals
vc.make_box(
f"SpineButtress_{i}",
(0.40, 0.28, 2.86),
"gunmetal",
parent=body_empty,
location=(0.94 * ca, 0.94 * sa, 1.98),
rotation_deg=(0.0, 10.5, ang_deg),
bevel=0.014,
)
vc.make_box(
f"SpineStripe_{i}",
(0.10, 0.22, 0.56),
"signal_orange",
parent=body_empty,
location=(1.04 * ca, 1.04 * sa, 2.42),
rotation_deg=(0.0, 10.5, ang_deg),
bevel=0.006,
)
# Retro-thruster housing & flared copper bell nozzle
vc.make_box(
f"ThrusterPod_{i}",
(0.46, 0.40, 0.72),
"olive_armor",
parent=body_empty,
location=(1.18 * ca, 1.18 * sa, 0.68),
rotation_deg=(0.0, -14.0, ang_deg),
bevel=0.014,
)
vc.make_lathe_part(
f"RetroNozzle_{i}",
nozzle_prof,
segments=12,
loop=True,
smooth=False,
mat_name="copper_rad",
parent=body_empty,
location=(1.26 * ca, 1.26 * sa, 0.12),
rotation_deg=(0.0, -14.0, ang_deg),
)
# 4. Upper Drogue Collar, Airbrake Fins & Ballistic Crown (Z = 3.34 .. 4.60)
crown_prof = [
[0.00, 3.34],
[0.98, 3.34],
[1.04, 3.55],
[0.88, 3.92],
[0.64, 4.30],
[0.44, 4.54],
[0.24, 4.60],
[0.00, 4.60],
]
vc.make_lathe_part(
"DrogueCrown",
crown_prof,
segments=8,
loop=False,
smooth=False,
mat_name="olive_armor",
parent=body_empty,
rotation_deg=(0.0, 0.0, 22.5),
bevel=0.015,
)
vc.make_tube_part(
"DrogueCapRim",
0.48,
0.34,
0.28,
segments=8,
smooth=False,
mat_name="gunmetal",
parent=body_empty,
location=(0.0, 0.0, 4.32),
rotation_deg=(0.0, 0.0, 22.5),
bevel=0.010,
)
vc.make_tube_part(
"DrogueChuteWell",
0.24,
0.24,
0.10,
segments=12,
smooth=False,
mat_name="socket_bay",
parent=body_empty,
location=(0.0, 0.0, 4.52),
)
for i in range(4):
ang_deg = i * 90.0
ang = math.radians(ang_deg)
ca, sa = math.cos(ang), math.sin(ang)
vc.make_box(
f"AeroFin_{i}",
(0.44, 0.12, 0.62),
"gunmetal",
parent=body_empty,
location=(0.94 * ca, 0.94 * sa, 3.96),
rotation_deg=(0.0, 22.0, ang_deg),
bevel=0.010,
)
vc.make_box(
f"CrownChevron_{i}",
(0.14, 0.34, 0.16),
"signal_orange",
parent=body_empty,
location=(0.86 * ca, 0.86 * sa, 3.82),
rotation_deg=(0.0, 24.0, ang_deg),
bevel=0.006,
)
vc.make_box(
f"BeaconNode_{i}",
(0.08, 0.12, 0.08),
"cyan_coil",
parent=body_empty,
location=(0.56 * ca, 0.56 * sa, 4.36),
rotation_deg=(0.0, 0.0, ang_deg),
bevel=0.004,
)
# 5. Four Distinct Armored Petals (Petal_0..3) at 45, 135, 225, 315 deg
# Each petal has its own mesh datablock with origin at its EXACT geometric centroid!
for i in range(4):
ang_deg = 45.0 + i * 90.0
ang = math.radians(ang_deg)
petal_mesh, centroid_local = _build_petal_mesh(f"PetalMesh_{i}", mats)
p_obj = bpy.data.objects.new(f"Petal_{i}", petal_mesh)
world_loc = (
centroid_local.x * math.cos(ang) - centroid_local.y * math.sin(ang),
centroid_local.x * math.sin(ang) + centroid_local.y * math.cos(ang),
centroid_local.z,
)
vc._link_object(p_obj, parent=root, location=world_loc, rotation_deg=(0.0, 0.0, ang_deg))
glb_path = vc.ASSETS_VEHICLES_DIR / "drop_pod" / "drop_pod.glb"
tris, bounds = vc.export_vehicle_glb(glb_path, root=root)
print(f"[drop_pod] tris={tris} bounds={bounds} glb={glb_path}")
return glb_path
if __name__ == "__main__":
build_drop_pod()

View file

@ -462,9 +462,71 @@ def validate_gear(gid: str) -> dict[str, Any]:
}
def validate_drop_pod() -> dict[str, Any]:
glb_path = VEHICLES_DIR / "drop_pod" / "drop_pod.glb"
if not glb_path.is_file():
raise AssertionError(f"Missing drop_pod GLB: {glb_path}")
gltf, bin_blob = parse_glb(glb_path)
tri_total, g_min, g_max = compute_glb_stats(gltf, bin_blob)
if tri_total < 400 or tri_total > 12000:
raise AssertionError(f"drop_pod: unexpected tri count {tri_total}")
if abs(float(g_min[1])) > 0.02:
raise AssertionError(f"drop_pod: not grounded at minY=0 (got {g_min[1]:.4f})")
size = g_max - g_min
if size[1] < 4.0 or size[1] > 5.2 or size[0] < 2.2 or size[0] > 3.4:
raise AssertionError(f"drop_pod: unexpected dimensions {size}")
nodes = gltf.get("nodes", [])
meshes = gltf.get("meshes", [])
accessors = gltf.get("accessors", [])
buffer_views = gltf.get("bufferViews", [])
node_names = {n.get("name", ""): n for n in nodes}
for req in ("DropPodRoot", "CoreBody", "RetroNozzle"):
if req not in node_names:
raise AssertionError(f"drop_pod: missing required node {req!r}")
petal_centroids = []
for i in range(4):
pname = f"Petal_{i}"
if pname not in node_names or "mesh" not in node_names[pname]:
raise AssertionError(f"drop_pod: missing mesh node {pname!r}")
p_mesh = meshes[node_names[pname]["mesh"]]
p_min = np.array([math.inf, math.inf, math.inf], dtype=np.float64)
p_max = np.array([-math.inf, -math.inf, -math.inf], dtype=np.float64)
for prim in p_mesh.get("primitives", []):
attrs = prim.get("attributes", {})
if "COLOR_0" not in attrs:
raise AssertionError(f"drop_pod: {pname} primitive missing COLOR_0 weathering")
pts = _read_accessor(accessors, buffer_views, bin_blob, attrs["POSITION"])
p_min = np.minimum(p_min, pts.min(axis=0))
p_max = np.maximum(p_max, pts.max(axis=0))
local_center = (p_min + p_max) * 0.5
offset = float(np.linalg.norm(local_center))
if offset > 0.03:
raise AssertionError(f"drop_pod: {pname} local origin not at centroid (offset={offset:.4f}m)")
petal_centroids.append(round(offset, 5))
for m_idx, mesh in enumerate(meshes):
for prim in mesh.get("primitives", []):
if "COLOR_0" not in prim.get("attributes", {}):
raise AssertionError(f"drop_pod: mesh[{m_idx}] missing COLOR_0 weathering")
return {
"id": "drop_pod",
"tris": tri_total,
"bytes": glb_path.stat().st_size,
"minY": round(float(g_min[1]), 4),
"size": [round(float(v), 3) for v in size],
"petalOffsets": petal_centroids,
}
def main() -> int:
v_reports = [validate_vehicle(v) for v in EXPECTED_VEHICLES]
g_reports = [validate_gear(g) for g in EXPECTED_GEAR]
pod_report = validate_drop_pod()
print("=== VEHICLE GLB VALIDATION PASSED ===")
for r in v_reports:
mech_tag = f" | dofs={r['mechanisms']}" if r["mechanisms"] else ""
@ -472,6 +534,8 @@ def main() -> int:
print("=== GEAR GLB VALIDATION PASSED ===")
for r in g_reports:
print(f" {r['id']:14s} | tris={r['tris']:4d} | size={r['size']} | {r['bytes']/1024:.1f} KiB")
print("=== DROP POD GLB VALIDATION PASSED ===")
print(f" {pod_report['id']:10s} | tris={pod_report['tris']:5d} | size={pod_report['size']} | minY={pod_report['minY']} | petalPivotOffsets={pod_report['petalOffsets']} | {pod_report['bytes']/1024:.1f} KiB")
return 0