diff --git a/tools/vehicles/build_anvil.py b/tools/vehicles/build_anvil.py new file mode 100644 index 0000000..e7d4370 --- /dev/null +++ b/tools/vehicles/build_anvil.py @@ -0,0 +1,465 @@ +"""Build the Anvil (Heavy Quad-Track Siege Tank) chassis GLB, manifest.json, and preview.""" +from __future__ import annotations + +import math +import sys +from pathlib import Path + +import bmesh +from mathutils import Matrix + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import vehicle_common as vc # noqa: E402 + + +def _build_quad_track_pod(name: str, side: float, y_center: float, is_front: bool, parent) -> None: + """Build one heavy articulated armored quad-track pod grounded at Z = 0.""" + pod_x = side * 1.56 + pod = vc.make_empty(name, parent=parent, location=(pod_x, y_center, 0.0)) + + rw_r = 0.27 + rw_z = rw_r + 0.045 + rw_ys = (-0.54, 0.0, 0.54) + front_y, front_z, front_r = -0.98, 0.54, 0.24 + rear_y, rear_z, rear_r = 0.98, 0.54, 0.24 + track_w = 0.62 + + # 3 roadwheels + front/rear sprockets + for i, ry in enumerate(rw_ys): + vc.make_tube_part( + f"{name}_rw_tire_{i}", rw_r, rw_r, track_w * 0.84, segments=14, + mat_name="rubber_dark", parent=pod, location=(-track_w * 0.42, ry, rw_z), rotation_deg=(0.0, 90.0, 0.0), + ) + vc.make_tube_part( + f"{name}_rw_hub_{i}", rw_r * 0.64, rw_r * 0.64, track_w * 0.90, segments=10, + mat_name="olive_armor", parent=pod, location=(-track_w * 0.45, ry, rw_z), rotation_deg=(0.0, 90.0, 0.0), + ) + vc.make_tube_part( + f"{name}_sproc_f", front_r, front_r, track_w * 0.80, segments=12, + mat_name="gunmetal", parent=pod, location=(-track_w * 0.40, front_y, front_z), rotation_deg=(0.0, 90.0, 0.0), + ) + vc.make_tube_part( + f"{name}_sproc_r", rear_r, rear_r, track_w * 0.80, segments=12, + mat_name="gunmetal", parent=pod, location=(-track_w * 0.40, rear_y, rear_z), rotation_deg=(0.0, 90.0, 0.0), + ) + + # Track loop polyline in (y, z) + loop_yz: list[tuple[float, float]] = [] + for k in range(6): + ang = math.radians(100.0 + 135.0 * (k / 5.0)) + loop_yz.append((front_y + math.cos(ang) * (front_r + 0.03), front_z + math.sin(ang) * (front_r + 0.03))) + loop_yz.append((-0.54, 0.025)) + loop_yz.append((0.54, 0.025)) + for k in range(6): + ang = math.radians(-55.0 + 135.0 * (k / 5.0)) + loop_yz.append((rear_y + math.cos(ang) * (rear_r + 0.03), rear_z + math.sin(ang) * (rear_r + 0.03))) + loop_yz.append((0.46, 0.83)) + loop_yz.append((-0.46, 0.83)) + + path_3d = [[0.0, y, z] for (y, z) in loop_yz] + vc.make_swept_profile( + f"{name}_track_band", + "box", + 0.034, + track_w * 0.92, + 0.034, + path_3d, + up=[1.0, 0.0, 0.0], + mat_name="rubber_dark", + parent=pod, + closed=True, + ) + + pts = loop_yz + [loop_yz[0]] + segs = [math.hypot(pts[i + 1][0] - pts[i][0], pts[i + 1][1] - pts[i][1]) for i in range(len(loop_yz))] + total_len = sum(segs) + n_shoes = 28 + + def build_shoes(bm: bmesh.types.BMesh) -> None: + for s_idx in range(n_shoes): + target_d = (s_idx / n_shoes) * total_len + acc = 0.0 + for i, sl in enumerate(segs): + if acc + sl >= target_d or i == len(segs) - 1: + t = (target_d - acc) / max(sl, 1e-6) + y0, z0 = pts[i] + y1, z1 = pts[i + 1] + py = y0 + (y1 - y0) * t + pz = z0 + (z1 - z0) * t + ang = math.atan2(z1 - z0, y1 - y0) + m = ( + Matrix.Translation((0.0, py, pz)) + @ Matrix.Rotation(ang, 4, "X") + @ Matrix.Diagonal((track_w, 0.11, 0.034, 1.0)) + ) + bmesh.ops.create_cube(bm, size=1.0, matrix=m) + break + acc += sl + + vc.make_bmesh_object(f"{name}_shoes", build_shoes, "gunmetal", parent=pod) + + # Heavy sloped armored pod housing (top deck + chamfered nose/tail + outer bolted side skirts) + vc.make_box(f"{name}_cover_top", (track_w + 0.12, 1.98, 0.14), "olive_armor", parent=pod, location=(0.0, 0.0, 0.92), bevel=0.012) + vc.make_box(f"{name}_cover_f", (track_w + 0.12, 0.42, 0.14), "olive_armor", parent=pod, location=(0.0, -1.14, 0.80), rotation_deg=(36.0, 0.0, 0.0), bevel=0.01) + vc.make_box(f"{name}_cover_r", (track_w + 0.12, 0.42, 0.14), "olive_armor", parent=pod, location=(0.0, 1.14, 0.80), rotation_deg=(-36.0, 0.0, 0.0), bevel=0.01) + # Outer bolted track pod side skirt + skirt_pts = [ + [side * (track_w * 0.5 + 0.04), -1.12, 0.72], + [side * (track_w * 0.5 + 0.04), 1.12, 0.72], + [side * (track_w * 0.5 + 0.04), 0.98, 0.94], + [side * (track_w * 0.5 + 0.04), -0.98, 0.94], + [side * (track_w * 0.5 + 0.04), -0.74, 0.34], + [side * (track_w * 0.5 + 0.04), 0.74, 0.34], + [side * (track_w * 0.5 + 0.04), 1.12, 0.56], + [side * (track_w * 0.5 + 0.04), -1.12, 0.56], + ] + # Use clean trapezoidal slab for outer pod skirt with bolts + vc.make_plates( + { + "schema": "brokkr.plates.v0", + "plates": [ + { + "name": f"{name}_outer_skirt", + "mat": "olive_armor", + "bevel": 0.008, + "sides": "one", + "mirror": False, + "slab": { + "at": [side * (track_w * 0.5 + 0.04), 0.0, 0.64], + "normal": [side, 0.0, 0.0], + "up": [0.0, 0.0, 1.0], + "right": [0.0, -side, 0.0], + "outline": [[-1.08, -0.08], [-0.74, -0.32], [0.74, -0.32], [1.08, -0.08], [0.96, 0.28], [-0.96, 0.28]], + "thick": 0.055, + "taper": 0.012, + "back": 0.92, + }, + "fits": [ + {"kind": "bolts", "inset": 0.025, "spacing": 0.34, "mat": "gunmetal", "params": "r=0.014"}, + ], + } + ], + }, + parent=pod, + ) + # Inner pod cheek & front headlight block + vc.make_box(f"{name}_inner_cheek", (0.06, 1.84, 0.48), "gunmetal", parent=pod, location=(-side * (track_w * 0.5 + 0.02), 0.0, 0.64), bevel=0.008) + if is_front: + vc.make_box(f"{name}_headlight_pod", (0.28, 0.20, 0.14), "gunmetal", parent=pod, location=(0.0, -1.04, 1.00), bevel=0.008) + vc.make_box(f"{name}_headlight_lens", (0.20, 0.05, 0.08), "smoked_glass", parent=pod, location=(0.0, -1.14, 1.00), bevel=0.004) + + +def build_anvil() -> dict: + vc.reset_scene() + vc.ensure_materials() + + root = vc.make_empty("AnvilRoot") + chassis = vc.make_empty("Chassis", parent=root) + + # --- 1. Central Lower Belly Tub, Ribbed Prow & Pod Outrigger Beams --- + vc.make_box("lower_tub", (2.14, 4.78, 0.64), "gunmetal", parent=chassis, location=(0.0, 0.04, 0.74), bevel=0.016) + # Corrugated lower prow armor ribs + vc.make_box("lower_prow_plate", (2.06, 0.44, 0.52), "olive_armor", parent=chassis, location=(0.0, -2.32, 0.74), rotation_deg=(24.0, 0.0, 0.0), bevel=0.012) + for rx in (-0.84, -0.56, -0.28, 0.0, 0.28, 0.56, 0.84): + vc.make_box(f"prow_rib_{rx:.2f}", (0.08, 0.14, 0.48), "gunmetal", parent=chassis, location=(rx, -2.50, 0.72), rotation_deg=(24.0, 0.0, 0.0), bevel=0.006) + # Outrigger pod axle beams + suspension rams + for p_tag, py in (("f", -1.48), ("r", 1.48)): + vc.make_box(f"pod_crossbeam_{p_tag}", (3.08, 0.58, 0.32), "gunmetal", parent=chassis, location=(0.0, py, 0.62), bevel=0.012) + for side in (-1.0, 1.0): + s_tag = "L" if side > 0 else "R" + vc.make_ram_span( + f"pod_strut_{p_tag}_{s_tag}", + [side * 1.04, py, 1.02], + [side * 1.38, py, 0.74], + body_r=0.048, + rod_r=0.026, + parent=chassis, + mat_barrel="gunmetal", + mat_rod="copper_rad", + ) + + # --- 2. Wide Sloped Composite Hull & Tall Casemate Superstructure (Brokkr plate.v0) --- + hull_pts = [ + # Lower hull belt above track pods + [-1.18, -2.38, 0.96], [1.18, -2.38, 0.96], + [-1.22, -0.50, 1.02], [1.22, -0.50, 1.02], + [-1.22, 2.58, 1.02], [1.22, 2.58, 1.02], + # Tall casemate roof (y = -0.48 .. +1.28, z = 1.98) + [-1.16, -0.48, 1.98], [1.16, -0.48, 1.98], + [-1.18, 1.28, 1.98], [1.18, 1.28, 1.98], + # Stepped rear engine deck (y = +1.30 .. +2.64, z = 1.70) + [-1.18, 1.32, 1.70], [1.18, 1.32, 1.70], + [-1.14, 2.64, 1.68], [1.14, 2.64, 1.68], + ] + plates_doc = { + "schema": "brokkr.plates.v0", + "plates": [ + { + "name": "anvil_hull", + "mat": "olive_armor", + "bevel": 0.016, + "sides": "one", + "mirror": False, + "points": hull_pts, + "clad": { + "mat": "olive_armor", + "facets": [{"n": [0.0, -0.45, 0.89], "cos": 0.86}], + "min_area": 0.22, + "lifts": [0.008, 0.015], + "inset": 0.07, + "gap": 0.020, + "split": 0.88, + "seed": 901, + "bolt_r": 0.014, + "bolt_mat": "gunmetal", + "bevel": 0.004, + }, + }, + # Heavy bolted forward superstructure cheek plates + { + "name": "anvil_casemate_cheek", + "mat": "olive_armor", + "bevel": 0.010, + "sides": "both", + "mirror": False, + "slab": { + "at": [1.20, 0.42, 1.54], + "normal": [1.0, 0.0, 0.0], + "up": [0.0, 0.0, 1.0], + "right": [0.0, -1.0, 0.0], + "outline": [[-0.86, -0.34], [0.86, -0.34], [0.78, 0.36], [-0.52, 0.36]], + "thick": 0.055, + "taper": 0.014, + "back": 0.92, + }, + "fits": [ + {"kind": "bolts", "inset": 0.03, "spacing": 0.34, "mat": "gunmetal", "params": "r=0.014"}, + ], + }, + ], + } + vc.make_plates(plates_doc, parent=chassis) + + # Sponson weapon shelves (left/right forward flanks) + rear radiator housing + driver periscope + vc.make_box("driver_periscope", (0.58, 0.18, 0.11), "smoked_glass", parent=chassis, location=(0.0, -0.78, 1.84), rotation_deg=(-24.0, 0.0, 0.0), bevel=0.006) + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + vc.make_box(f"sponson_shelf_{tag}", (0.48, 0.72, 0.24), "gunmetal", parent=chassis, location=(side * 1.24, -0.76, 1.42), bevel=0.01) + vc.make_box(f"rad_housing_{tag}", (0.16, 1.18, 0.62), "olive_armor", parent=chassis, location=(side * 1.20, 1.50, 1.42), bevel=0.01) + vc.make_box(f"tow_shackle_{tag}", (0.09, 0.16, 0.16), "signal_orange", parent=chassis, location=(side * 0.68, -2.54, 0.64), bevel=0.006) + + # --- 3. 4 Articulated Quad-Track Pods --- + _build_quad_track_pod("pod_fl", 1.0, -1.48, True, chassis) + _build_quad_track_pod("pod_fr", -1.0, -1.48, True, chassis) + _build_quad_track_pod("pod_rl", 1.0, 1.48, False, chassis) + _build_quad_track_pod("pod_rr", -1.0, 1.48, False, chassis) + + # --- 4. Towering Rear Exhaust Stacks --- + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + for s_idx, sy in enumerate((2.40, 2.62)): + vc.make_swept_tube( + f"exhaust_stack_{tag}_{s_idx}", + [ + [side * 0.96, sy - 0.14, 1.48], + [side * 1.04, sy, 1.66], + [side * 1.04, sy, 2.86], + [side * 1.04, sy + 0.14, 2.98], + ], + 0.072, + segments=12, + mat_name="gunmetal", + parent=chassis, + fillet_r=0.06, + ) + vc.make_tube_part( + f"exhaust_shroud_{tag}_{s_idx}", + 0.105, + 0.105, + 0.68, + segments=10, + inner0=0.09, + inner1=0.09, + mat_name="olive_armor", + parent=chassis, + location=(side * 1.04, sy, 1.76), + ) + + # --- 5. Broad Reinforced Siege Turret (joint.turret_yaw) --- + turret_pivot = vc.make_empty("joint.turret_yaw", parent=chassis, location=(0.0, 0.04, 1.98)) + vc.tag_joint(turret_pivot, "joint.turret_yaw", [0.0, 1.0, 0.0], -180.0, 180.0) + joints_manifest = [{"id": "joint.turret_yaw", "axis": [0.0, 1.0, 0.0], "min": -180.0, "max": 180.0}] + + vc.make_tube_part("turret_race", 0.88, 0.94, 0.10, segments=24, mat_name="gunmetal", parent=turret_pivot) + + turret_pts = [ + [-0.76, -0.92, 0.10], [0.76, -0.92, 0.10], + [0.98, -0.22, 0.10], [0.88, 1.04, 0.10], + [-0.88, 1.04, 0.10], [-0.98, -0.22, 0.10], + [-0.58, -0.70, 0.62], [0.58, -0.70, 0.62], + [0.76, -0.14, 0.62], [0.68, 0.86, 0.62], + [-0.68, 0.86, 0.62], [-0.76, -0.14, 0.62], + ] + turret_doc = { + "schema": "brokkr.plates.v0", + "plates": [ + { + "name": "anvil_turret_shell", + "mat": "olive_armor", + "bevel": 0.016, + "sides": "one", + "mirror": False, + "points": turret_pts, + }, + { + "name": "anvil_turret_cheek", + "mat": "olive_armor", + "bevel": 0.008, + "sides": "both", + "mirror": False, + "slab": { + "at": [0.86, 0.16, 0.34], + "normal": [0.94, 0.0, 0.34], + "up": [-0.34, 0.0, 0.94], + "right": [0.0, -1.0, 0.0], + "outline": [[-0.58, -0.18], [0.58, -0.18], [0.46, 0.18], [-0.46, 0.18]], + "thick": 0.055, + "taper": 0.014, + "back": 0.92, + }, + "fits": [ + {"kind": "bolts", "inset": 0.025, "spacing": 0.26, "mat": "gunmetal", "params": "r=0.013"}, + ], + }, + ], + } + vc.make_plates(turret_doc, parent=turret_pivot) + + vc.make_box("turret_mantlet_bar", (1.12, 0.22, 0.24), "gunmetal", parent=turret_pivot, location=(0.0, -0.84, 0.34), bevel=0.012) + vc.make_box("turret_bustle", (1.28, 0.46, 0.38), "olive_armor", parent=turret_pivot, location=(0.0, 1.10, 0.38), bevel=0.012) + vc.make_tube_part("commander_cupola", 0.22, 0.24, 0.11, segments=14, mat_name="olive_armor", parent=turret_pivot, location=(0.0, 0.48, 0.62)) + vc.make_box("turret_optic", (0.20, 0.22, 0.16), "smoked_glass", parent=turret_pivot, location=(0.0, -0.46, 0.68), bevel=0.008) + + # --- 6. Visible Exterior Hardpoints (5x6 Dorsal Grid) --- + # 1) hp.armor.front (0,0, 5x1) on steep front glacis + vc.add_hardpoint_slot( + "hp.armor.front", + "armor", + parent=chassis, + location=(0.0, -1.48, 1.46), + rotation_deg=(-62.0, 0.0, 0.0), + size=(1.88, 0.42, 0.10), + ) + # 2 & 3) hp.weapon.sponson_l (0,1, 1x2) & hp.weapon.sponson_r (4,1, 1x2) + vc.add_hardpoint_slot( + "hp.weapon.sponson_l", + "weapon", + parent=chassis, + location=(1.26, -0.76, 1.54), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.50, 0.50, 0.09), + ) + vc.add_hardpoint_slot( + "hp.weapon.sponson_r", + "weapon", + parent=chassis, + location=(-1.26, -0.76, 1.54), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.50, 0.50, 0.09), + ) + # 4 & 5) hp.weapon.siege_l (1,1, 1x2) & hp.weapon.siege_r (3,1, 1x2) on turret roof + vc.add_hardpoint_slot( + "hp.weapon.siege_l", + "weapon", + parent=turret_pivot, + location=(0.42, -0.04, 0.63), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.62, 0.62, 0.11), + ) + vc.add_hardpoint_slot( + "hp.weapon.siege_r", + "weapon", + parent=turret_pivot, + location=(-0.42, -0.04, 0.63), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.62, 0.62, 0.11), + ) + # 6) hp.armor.sides (2,1, 1x2) on right (-X) casemate cheek + vc.add_hardpoint_slot( + "hp.armor.sides", + "armor", + parent=chassis, + location=(-1.26, 0.42, 1.54), + rotation_deg=(90.0, 0.0, -90.0), + size=(1.12, 0.34, 0.10), + ) + # 7) hp.engine.rear (1,3, 3x2) + vc.add_hardpoint_slot( + "hp.engine.rear", + "engine", + parent=chassis, + location=(0.0, 1.98, 1.70), + rotation_deg=(0.0, 0.0, 0.0), + size=(1.42, 0.96, 0.15), + ) + # 8 & 9) hp.radiator.l (0,4, 1x2) & hp.radiator.r (4,4, 1x2) + vc.add_hardpoint_slot( + "hp.radiator.l", + "radiator", + parent=chassis, + location=(1.28, 1.50, 1.42), + rotation_deg=(90.0, 0.0, 90.0), + size=(1.04, 0.52, 0.13), + ) + vc.add_hardpoint_slot( + "hp.radiator.r", + "radiator", + parent=chassis, + location=(-1.28, 1.50, 1.42), + rotation_deg=(90.0, 0.0, -90.0), + size=(1.04, 0.52, 0.13), + ) + + # --- 7. Export GLB, Manifest & Preview --- + glb_path = vc.ASSETS_VEHICLES_DIR / "anvil" / "anvil.glb" + manifest_path = vc.ASSETS_VEHICLES_DIR / "anvil" / "manifest.json" + preview_path = vc.PREVIEWS_DIR / "anvil_preview.png" + + tri_count, bounds = vc.export_vehicle_glb(glb_path, root=root) + vc.write_manifest( + manifest_path, + vehicle_id="anvil", + name="Anvil", + vehicle_class="Heavy Quad-Track Siege Tank", + grid_width=5, + grid_height=6, + mask=[ + "#####", + "#####", + "#####", + "#####", + "#####", + "#####", + ], + hardpoints=[ + {"id": "hp.armor.front", "kind": "armor", "x": 0, "y": 0, "w": 5, "h": 1, "modelNodeId": "hp.armor.front"}, + {"id": "hp.weapon.sponson_l", "kind": "weapon", "x": 0, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.weapon.sponson_l"}, + {"id": "hp.weapon.siege_l", "kind": "weapon", "x": 1, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.weapon.siege_l"}, + {"id": "hp.armor.sides", "kind": "armor", "x": 2, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.armor.sides"}, + {"id": "hp.weapon.siege_r", "kind": "weapon", "x": 3, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.weapon.siege_r"}, + {"id": "hp.weapon.sponson_r", "kind": "weapon", "x": 4, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.weapon.sponson_r"}, + {"id": "hp.engine.rear", "kind": "engine", "x": 1, "y": 3, "w": 3, "h": 2, "modelNodeId": "hp.engine.rear"}, + {"id": "hp.radiator.l", "kind": "radiator", "x": 0, "y": 4, "w": 1, "h": 2, "modelNodeId": "hp.radiator.l"}, + {"id": "hp.radiator.r", "kind": "radiator", "x": 4, "y": 4, "w": 1, "h": 2, "modelNodeId": "hp.radiator.r"}, + ], + joints=joints_manifest, + bounds=bounds, + tri_count=tri_count, + ) + vc.render_four_panel_preview(preview_path) + print(f"[anvil] tris={tri_count} bounds={bounds} glb={glb_path}") + return {"id": "anvil", "tris": tri_count, "bounds": bounds} + + +if __name__ == "__main__": + build_anvil() diff --git a/tools/vehicles/build_condor.py b/tools/vehicles/build_condor.py new file mode 100644 index 0000000..2980316 --- /dev/null +++ b/tools/vehicles/build_condor.py @@ -0,0 +1,506 @@ +"""Build the Condor (Heavy Quad-Thruster Assault VTOL) chassis GLB, manifest.json, and preview.""" +from __future__ import annotations + +import math +import sys +from pathlib import Path + +import bmesh +from mathutils import Matrix + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import vehicle_common as vc # noqa: E402 + + +def _build_jet_nacelle( + name: str, + joint_id: str, + rotor_id: str, + side: float, + location: tuple[float, float, float], + scale: float, + tilt_deg: float, + parent, + joints_manifest: list[dict], +) -> None: + """Build a pivoting vectored-thrust armored jet nacelle with copper exhaust skirt and spinning turbine.""" + nacelle_pivot = vc.make_empty( + joint_id, + parent=parent, + location=location, + rotation_deg=(tilt_deg, 0.0, 0.0), + ) + vc.tag_joint(nacelle_pivot, joint_id, [1.0, 0.0, 0.0], -45.0, 75.0) + joints_manifest.append({"id": joint_id, "axis": [1.0, 0.0, 0.0], "min": -45.0, "max": 75.0}) + + r_in = 0.31 * scale + r_out = 0.43 * scale + # Armored olive intake shroud + jet housing + shroud_prof = [ + [r_in, -0.18 * scale], + [r_out * 0.96, -0.18 * scale], + [r_out * 1.05, 0.02 * scale], + [r_out * 1.05, 0.34 * scale], + [r_out * 0.92, 0.44 * scale], + [r_in * 1.02, 0.44 * scale], + [r_in * 0.96, 0.26 * scale], + [r_in, -0.18 * scale], + ] + vc.make_lathe_part( + f"{name}_shroud", + shroud_prof[:-1], + segments=20, + loop=True, + smooth=True, + mat_name="olive_armor", + parent=nacelle_pivot, + ) + # Vectored copper thermal exhaust nozzle petals + nozzle_prof = [ + [r_in * 0.92, -0.44 * scale], + [r_out * 0.86, -0.44 * scale], + [r_out * 0.96, -0.18 * scale], + [r_in, -0.18 * scale], + ] + vc.make_lathe_part( + f"{name}_nozzle", + nozzle_prof, + segments=20, + loop=True, + smooth=True, + mat_name="copper_rad", + parent=nacelle_pivot, + ) + # Inner gunmetal stator vanes + outer hinge trunnion lug + for ang_deg in (0.0, 90.0): + vc.make_box( + f"{name}_stator_{int(ang_deg)}", + (r_in * 1.92, 0.04 * scale, 0.06 * scale), + "gunmetal", + parent=nacelle_pivot, + location=(0.0, 0.0, -0.16 * scale), + rotation_deg=(0.0, 0.0, ang_deg), + bevel=0.004, + ) + vc.make_box( + f"{name}_trunnion_lug", + (0.18 * scale, 0.28 * scale, 0.20 * scale), + "gunmetal", + parent=nacelle_pivot, + location=(-side * (r_out * 0.98), 0.0, 0.12 * scale), + bevel=0.008, + ) + + # Spinning axial turbine rotor + rotor_pivot = vc.make_empty(rotor_id, parent=nacelle_pivot, location=(0.0, 0.0, 0.14 * scale)) + vc.tag_joint(rotor_pivot, rotor_id, [0.0, 1.0, 0.0], -360.0, 360.0) + joints_manifest.append({"id": rotor_id, "axis": [0.0, 1.0, 0.0], "min": -360.0, "max": 360.0}) + + spinner_prof = [ + [0.0, -0.06 * scale], + [0.11 * scale, -0.06 * scale], + [0.11 * scale, 0.08 * scale], + [0.06 * scale, 0.22 * scale], + [0.0, 0.30 * scale], + ] + vc.make_lathe_part(f"{name}_spinner", spinner_prof, segments=12, loop=False, smooth=True, mat_name="gunmetal", parent=rotor_pivot) + + def build_blades(bm: bmesh.types.BMesh) -> None: + for i in range(6): + a = i * math.pi / 3.0 + m = ( + Matrix.Rotation(a, 4, "Z") + @ Matrix.Translation((0.19 * scale, 0.0, 0.02 * scale)) + @ Matrix.Rotation(math.radians(26.0), 4, "X") + @ Matrix.Diagonal((0.20 * scale, 0.072 * scale, 0.014 * scale, 1.0)) + ) + bmesh.ops.create_cube(bm, size=1.0, matrix=m) + + vc.make_bmesh_object(f"{name}_blades", build_blades, "gunmetal", parent=rotor_pivot) + + +def build_condor() -> dict: + vc.reset_scene() + vc.ensure_materials() + + root = vc.make_empty("CondorRoot") + chassis = vc.make_empty("Chassis", parent=root) + + # --- 1. 4 Stubby Hydraulic Landing Legs (grounded at Z = 0) --- + # Front twin nose/cheek wheel-legs at y = -1.56, x = +/- 0.42 + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + vc.make_ram_span( + f"gear_front_strut_{tag}", + [side * 0.34, -1.52, 0.64], + [side * 0.44, -1.60, 0.16], + body_r=0.052, + rod_r=0.030, + parent=chassis, + mat_barrel="gunmetal", + mat_rod="copper_rad", + ) + vc.make_ram_span( + f"gear_front_drag_{tag}", + [side * 0.30, -1.16, 0.58], + [side * 0.44, -1.58, 0.18], + body_r=0.030, + rod_r=0.018, + parent=chassis, + mat_barrel="gunmetal", + mat_rod="gunmetal", + ) + vc.make_knobby_wheel( + f"gear_front_wheel_{tag}", + radius=0.16, + width=0.14, + parent=chassis, + location=(side * 0.46, -1.60, 0.16), + tread_lugs=10, + rim_segments=12, + side_sign=int(side), + ) + # Rear splayed outrigger hydraulic legs with armored ski-pads at y = +1.08 + vc.make_box(f"gear_rear_sponson_{tag}", (0.26, 0.46, 0.24), "olive_armor", parent=chassis, location=(side * 0.78, 1.06, 0.68), bevel=0.01) + vc.make_ram_span( + f"gear_rear_strut_{tag}", + [side * 0.78, 1.06, 0.64], + [side * 1.04, 1.08, 0.08], + body_r=0.058, + rod_r=0.032, + parent=chassis, + mat_barrel="gunmetal", + mat_rod="copper_rad", + ) + vc.make_ram_span( + f"gear_rear_brace_{tag}", + [side * 0.62, 0.68, 0.56], + [side * 1.02, 1.06, 0.10], + body_r=0.032, + rod_r=0.020, + parent=chassis, + mat_barrel="gunmetal", + mat_rod="gunmetal", + ) + # Articulated ski-pad foot + small bogie wheel grounded at Z = 0 + vc.make_box(f"gear_rear_ski_{tag}", (0.26, 0.66, 0.055), "gunmetal", parent=chassis, location=(side * 1.04, 1.08, 0.028), bevel=0.008) + vc.make_box(f"gear_rear_ski_tip_{tag}", (0.26, 0.16, 0.055), "gunmetal", parent=chassis, location=(side * 1.04, 0.72, 0.065), rotation_deg=(28.0, 0.0, 0.0), bevel=0.006) + + # --- 2. Brutalist Angular Bolted Fuselage & Canopy (Brokkr plate.v0) --- + hull_pts = [ + # Nose prow (y = -2.78) + [-0.38, -2.78, 0.84], [0.38, -2.78, 0.84], + [-0.44, -2.72, 1.06], [0.44, -2.72, 1.06], + # Forward cabin shoulder (y = -1.54) + [-0.78, -1.54, 0.56], [0.78, -1.54, 0.56], + [-0.86, -1.42, 1.24], [0.86, -1.42, 1.24], + [-0.58, -1.24, 1.62], [0.58, -1.24, 1.62], + # Mid troop bay (y = +1.12) + [-0.78, 1.12, 0.56], [0.78, 1.12, 0.56], + [-0.88, 1.12, 1.28], [0.88, 1.12, 1.28], + [-0.64, 1.12, 1.66], [0.64, 1.12, 1.66], + # Tapered rear tail boom (y = +2.78) + [-0.36, 2.78, 1.08], [0.36, 2.78, 1.08], + [-0.38, 2.78, 1.48], [0.38, 2.78, 1.48], + ] + canopy_pts = [ + [-0.42, -2.42, 1.06], [0.42, -2.42, 1.06], + [-0.56, -1.36, 1.26], [0.56, -1.36, 1.26], + [-0.48, -1.20, 1.66], [0.48, -1.20, 1.66], + [-0.40, -1.86, 1.62], [0.40, -1.86, 1.62], + ] + plates_doc = { + "schema": "brokkr.plates.v0", + "plates": [ + { + "name": "condor_fuselage", + "mat": "olive_armor", + "bevel": 0.016, + "sides": "one", + "mirror": False, + "points": hull_pts, + }, + { + "name": "condor_canopy", + "mat": "smoked_glass", + "bevel": 0.008, + "sides": "one", + "mirror": False, + "points": canopy_pts, + }, + # Bolted side troop-bay armor plates + crew doors + { + "name": "condor_flank_armor", + "mat": "olive_armor", + "bevel": 0.010, + "sides": "both", + "mirror": False, + "slab": { + "at": [0.86, -0.14, 0.94], + "normal": [0.98, 0.0, -0.18], + "up": [0.18, 0.0, 0.98], + "right": [0.0, -1.0, 0.0], + "outline": [[-1.18, -0.32], [1.18, -0.32], [1.08, 0.34], [-1.08, 0.34]], + "thick": 0.05, + "taper": 0.014, + "back": 0.92, + }, + "clad": { + "mat": "olive_armor", + "facets": "outer", + "min_area": 0.14, + "lifts": [0.008, 0.014], + "inset": 0.05, + "gap": 0.016, + "split": 0.72, + "seed": 1001, + "bolt_r": 0.013, + "bolt_mat": "gunmetal", + "bevel": 0.004, + }, + "fits": [ + {"kind": "bolts", "inset": 0.025, "spacing": 0.34, "mat": "gunmetal", "params": "r=0.013"}, + {"kind": "part", "part": "handle", "at": [0.32, 0.02], "roll": 0.0, "mat": "gunmetal", "params": "length=0.22;lift=0.045;r=0.012"}, + ], + }, + ], + } + vc.make_plates(plates_doc, parent=chassis) + + # Canopy structural armor ribs + dorsal radiator spine housing + rear APU jet nozzle + V-tail stabilizers + vc.make_swept_tube( + "canopy_spine", + [[0.0, -2.44, 1.06], [0.0, -1.86, 1.64], [0.0, -1.18, 1.68]], + 0.028, segments=6, mat_name="olive_armor", parent=chassis, fillet_r=0.04, + ) + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + vc.make_swept_tube( + f"canopy_rib_{tag}", + [[side * 0.40, -2.40, 1.06], [side * 0.42, -1.84, 1.62], [side * 0.48, -1.20, 1.66]], + 0.022, segments=6, mat_name="olive_armor", parent=chassis, fillet_r=0.04, + ) + # Side weapon sponson boxes on forward cheek flanks + vc.make_box(f"weapon_sponson_box_{tag}", (0.24, 0.76, 0.36), "olive_armor", parent=chassis, location=(side * 0.92, -1.16, 0.96), bevel=0.01) + # Fore nacelle shoulder sponsons (y = -0.86) + vc.make_box(f"fore_wing_{tag}", (0.64, 0.44, 0.22), "olive_armor", parent=chassis, location=(side * 0.86, -0.86, 1.48), rotation_deg=(0.0, side * -6.0, 0.0), bevel=0.012) + # Aft main high-mounted swept wings (y = +0.74) + vc.make_box(f"aft_wing_{tag}", (1.06, 0.72, 0.22), "olive_armor", parent=chassis, location=(side * 1.18, 0.74, 1.60), rotation_deg=(0.0, side * -5.0, side * -8.0), bevel=0.014) + # Tilt actuator rams for fore & aft nacelles + vc.make_ram_span( + f"tilt_ram_f_{tag}", + [side * 0.68, -1.04, 1.54], + [side * 1.06, -0.86, 1.50], + body_r=0.032, + rod_r=0.018, + parent=chassis, + mat_barrel="gunmetal", + mat_rod="copper_rad", + ) + vc.make_ram_span( + f"tilt_ram_r_{tag}", + [side * 1.18, 0.50, 1.68], + [side * 1.56, 0.74, 1.66], + body_r=0.038, + rod_r=0.020, + parent=chassis, + mat_barrel="gunmetal", + mat_rod="copper_rad", + ) + # Canted twin tail stabilizers + ventral strakes + vc.make_box( + f"tail_fin_{tag}", + (0.06, 0.66, 0.94), + "olive_armor", + parent=chassis, + location=(side * 0.56, 2.58, 1.72), + rotation_deg=(24.0, side * -32.0, 0.0), + bevel=0.01, + ) + vc.make_box( + f"tail_horiz_{tag}", + (0.46, 0.54, 0.07), + "olive_armor", + parent=chassis, + location=(side * 0.44, 2.54, 1.34), + rotation_deg=(0.0, side * 10.0, side * -12.0), + bevel=0.008, + ) + + # Dorsal radiator spine ridge (runs behind canopy to tail root) + vc.make_box("dorsal_spine_core", (0.78, 2.48, 0.26), "olive_armor", parent=chassis, location=(0.0, 0.28, 1.70), bevel=0.014) + vc.make_box("dorsal_spine_cap", (0.48, 2.38, 0.14), "gunmetal", parent=chassis, location=(0.0, 0.28, 1.84), bevel=0.01) + + # Rear tail APU / main jet exhaust cone + rear_nozzle_prof = [ + [0.18, 0.0], + [0.27, 0.0], + [0.29, 0.18], + [0.24, 0.36], + [0.16, 0.36], + [0.18, 0.0], + ] + vc.make_lathe_part( + "rear_jet_nozzle", + rear_nozzle_prof[:-1], + segments=18, + loop=True, + smooth=True, + mat_name="copper_rad", + parent=chassis, + location=(0.0, 2.74, 1.28), + rotation_deg=(-90.0, 0.0, 0.0), + ) + + # --- 3. 4 Pivoting Vectored-Thrust Jet Nacelles (joint.nacelle_fl/fr/rl/rr) --- + joints_manifest: list[dict] = [] + # Fore nacelles + for side, j_tag in ((1.0, "fl"), (-1.0, "fr")): + _build_jet_nacelle( + f"nacelle_{j_tag}", + f"joint.nacelle_{j_tag}", + f"joint.rotor_{j_tag}", + side, + location=(side * 1.42, -0.86, 1.48), + scale=0.82, + tilt_deg=-16.0, + parent=chassis, + joints_manifest=joints_manifest, + ) + # Aft main nacelles (larger vectored jet pods) + for side, j_tag in ((1.0, "rl"), (-1.0, "rr")): + _build_jet_nacelle( + f"nacelle_{j_tag}", + f"joint.nacelle_{j_tag}", + f"joint.rotor_{j_tag}", + side, + location=(side * 1.88, 0.74, 1.62), + scale=1.06, + tilt_deg=-14.0, + parent=chassis, + joints_manifest=joints_manifest, + ) + + # --- 4. Heavy Nose Chin Turret (joint.turret_yaw) --- + turret_pivot = vc.make_empty("joint.turret_yaw", parent=chassis, location=(0.0, -2.26, 0.74)) + vc.tag_joint(turret_pivot, "joint.turret_yaw", [0.0, 1.0, 0.0], -180.0, 180.0) + joints_manifest.append({"id": "joint.turret_yaw", "axis": [0.0, 1.0, 0.0], "min": -180.0, "max": 180.0}) + + vc.make_tube_part("chin_turret_ring", 0.28, 0.30, 0.10, segments=16, mat_name="gunmetal", parent=turret_pivot, location=(0.0, 0.0, -0.04)) + vc.make_box("chin_turret_housing", (0.44, 0.48, 0.22), "olive_armor", parent=turret_pivot, location=(0.0, 0.0, -0.14), bevel=0.012) + vc.make_box("chin_optics", (0.20, 0.10, 0.10), "smoked_glass", parent=turret_pivot, location=(0.0, -0.24, -0.10), bevel=0.005) + + # --- 5. Visible Exterior Hardpoints (5x6 Masked Dorsal Grid) --- + # 1) hp.weapon.nose (1,0, 2x1) under chin turret + vc.add_hardpoint_slot( + "hp.weapon.nose", + "weapon", + parent=turret_pivot, + location=(0.0, 0.0, -0.25), + rotation_deg=(0.0, 180.0, 0.0), + size=(0.46, 0.46, 0.08), + ) + # 2) hp.armor.hull (3,0, 1x1) on sloped upper nose glacis in front of canopy + vc.add_hardpoint_slot( + "hp.armor.hull", + "armor", + parent=chassis, + location=(0.0, -2.56, 1.13), + rotation_deg=(-69.0, 0.0, 0.0), + size=(0.64, 0.26, 0.09), + ) + # 3 & 4) hp.weapon.sponson_l (0,1, 1x2) & hp.weapon.sponson_r (4,1, 1x2) on cheek weapon sponsons + vc.add_hardpoint_slot( + "hp.weapon.sponson_l", + "weapon", + parent=chassis, + location=(1.04, -1.16, 0.96), + rotation_deg=(0.0, 90.0, 0.0), + size=(0.44, 0.44, 0.08), + ) + vc.add_hardpoint_slot( + "hp.weapon.sponson_r", + "weapon", + parent=chassis, + location=(-1.04, -1.16, 0.96), + rotation_deg=(0.0, -90.0, 0.0), + size=(0.44, 0.44, 0.08), + ) + # 5) hp.weapon.dorsal (2,1, 1x1) on forward dorsal spine behind cockpit + vc.add_hardpoint_slot( + "hp.weapon.dorsal", + "weapon", + parent=chassis, + location=(0.0, -0.78, 1.91), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.54, 0.54, 0.09), + ) + # 6) hp.engine.core (1,2, 3x2) central dorsal turbine bay + vc.add_hardpoint_slot( + "hp.engine.core", + "engine", + parent=chassis, + location=(0.0, 0.36, 1.88), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.98, 1.18, 0.14), + ) + # 7 & 8) hp.radiator.spine_l (0,3, 1x2) & hp.radiator.spine_r (4,3, 1x2) along canted dorsal spine flanks + vc.add_hardpoint_slot( + "hp.radiator.spine_l", + "radiator", + parent=chassis, + location=(0.56, 1.02, 1.68), + rotation_deg=(0.0, 56.0, 0.0), + size=(0.40, 1.04, 0.11), + ) + vc.add_hardpoint_slot( + "hp.radiator.spine_r", + "radiator", + parent=chassis, + location=(-0.56, 1.02, 1.68), + rotation_deg=(0.0, -56.0, 0.0), + size=(0.40, 1.04, 0.11), + ) + + # --- 6. Export GLB, Manifest & Preview --- + glb_path = vc.ASSETS_VEHICLES_DIR / "condor" / "condor.glb" + manifest_path = vc.ASSETS_VEHICLES_DIR / "condor" / "manifest.json" + preview_path = vc.PREVIEWS_DIR / "condor_preview.png" + + tri_count, bounds = vc.export_vehicle_glb(glb_path, root=root) + vc.write_manifest( + manifest_path, + vehicle_id="condor", + name="Condor", + vehicle_class="Heavy Quad-Thruster Assault VTOL", + grid_width=5, + grid_height=6, + mask=[ + ".###.", + "#####", + "#####", + "#####", + "#####", + "..#..", + ], + hardpoints=[ + {"id": "hp.weapon.nose", "kind": "weapon", "x": 1, "y": 0, "w": 2, "h": 1, "modelNodeId": "hp.weapon.nose"}, + {"id": "hp.armor.hull", "kind": "armor", "x": 3, "y": 0, "w": 1, "h": 1, "modelNodeId": "hp.armor.hull"}, + {"id": "hp.weapon.sponson_l", "kind": "weapon", "x": 0, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.weapon.sponson_l"}, + {"id": "hp.weapon.dorsal", "kind": "weapon", "x": 2, "y": 1, "w": 1, "h": 1, "modelNodeId": "hp.weapon.dorsal"}, + {"id": "hp.weapon.sponson_r", "kind": "weapon", "x": 4, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.weapon.sponson_r"}, + {"id": "hp.engine.core", "kind": "engine", "x": 1, "y": 2, "w": 3, "h": 2, "modelNodeId": "hp.engine.core"}, + {"id": "hp.radiator.spine_l", "kind": "radiator", "x": 0, "y": 3, "w": 1, "h": 2, "modelNodeId": "hp.radiator.spine_l"}, + {"id": "hp.radiator.spine_r", "kind": "radiator", "x": 4, "y": 3, "w": 1, "h": 2, "modelNodeId": "hp.radiator.spine_r"}, + ], + joints=joints_manifest, + bounds=bounds, + tri_count=tri_count, + ) + vc.render_four_panel_preview(preview_path) + print(f"[condor] tris={tri_count} bounds={bounds} glb={glb_path}") + return {"id": "condor", "tris": tri_count, "bounds": bounds} + + +if __name__ == "__main__": + build_condor() diff --git a/tools/vehicles/build_ironclad.py b/tools/vehicles/build_ironclad.py new file mode 100644 index 0000000..308710a --- /dev/null +++ b/tools/vehicles/build_ironclad.py @@ -0,0 +1,422 @@ +"""Build the Ironclad (Medium Tracked Battle Tank) chassis GLB, manifest.json, and preview.""" +from __future__ import annotations + +import math +import sys +from pathlib import Path + +import bmesh +from mathutils import Matrix + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import vehicle_common as vc # noqa: E402 + + +def _build_mbt_track_pod(name: str, side: float, parent) -> None: + """Build one wide MBT track assembly with 5 double roadwheels, idler, sprocket, shoes, and bolted side skirt.""" + pod_x = side * 1.12 + pod = vc.make_empty(name, parent=parent, location=(pod_x, 0.0, 0.0)) + + rw_r = 0.28 + rw_z = rw_r + 0.045 + rw_ys = (-1.28, -0.64, 0.0, 0.64, 1.28) + idler_y, idler_z, idler_r = -1.94, 0.56, 0.25 + sproc_y, sproc_z, sproc_r = 1.92, 0.58, 0.26 + track_w = 0.48 + + # Roadwheels (5) + 3 return rollers + Front Idler + Rear Drive Sprocket + for i, ry in enumerate(rw_ys): + vc.make_tube_part( + f"{name}_rw_tire_{i}", rw_r, rw_r, track_w * 0.84, segments=16, + mat_name="rubber_dark", parent=pod, location=(-track_w * 0.42, ry, rw_z), rotation_deg=(0.0, 90.0, 0.0), + ) + vc.make_tube_part( + f"{name}_rw_dish_{i}", rw_r * 0.68, rw_r * 0.68, track_w * 0.90, segments=12, + mat_name="olive_armor", parent=pod, location=(-track_w * 0.45, ry, rw_z), rotation_deg=(0.0, 90.0, 0.0), + ) + vc.make_tube_part( + f"{name}_rw_cap_{i}", rw_r * 0.28, rw_r * 0.28, track_w * 0.94, segments=10, + mat_name="gunmetal", parent=pod, location=(-track_w * 0.47, ry, rw_z), rotation_deg=(0.0, 90.0, 0.0), + ) + for j, rry in enumerate((-0.96, 0.0, 0.96)): + vc.make_tube_part( + f"{name}_ret_{j}", 0.09, 0.09, track_w * 0.68, segments=10, + mat_name="gunmetal", parent=pod, location=(-track_w * 0.34, rry, 0.78), rotation_deg=(0.0, 90.0, 0.0), + ) + vc.make_tube_part( + f"{name}_idler", idler_r, idler_r, track_w * 0.80, segments=14, + mat_name="gunmetal", parent=pod, location=(-track_w * 0.40, idler_y, idler_z), rotation_deg=(0.0, 90.0, 0.0), + ) + vc.make_tube_part( + f"{name}_sprocket", sproc_r, sproc_r, track_w * 0.84, segments=14, + mat_name="gunmetal", parent=pod, location=(-track_w * 0.42, sproc_y, sproc_z), rotation_deg=(0.0, 90.0, 0.0), + ) + + # Track loop polyline in (y, z) + loop_yz: list[tuple[float, float]] = [] + for k in range(7): + ang = math.radians(95.0 + 145.0 * (k / 6.0)) + loop_yz.append((idler_y + math.cos(ang) * (idler_r + 0.03), idler_z + math.sin(ang) * (idler_r + 0.03))) + loop_yz.append((-1.28, 0.025)) + loop_yz.append((1.28, 0.025)) + for k in range(7): + ang = math.radians(-65.0 + 145.0 * (k / 6.0)) + loop_yz.append((sproc_y + math.cos(ang) * (sproc_r + 0.03), sproc_z + math.sin(ang) * (sproc_r + 0.03))) + loop_yz.append((0.60, 0.89)) + loop_yz.append((-0.60, 0.89)) + + path_3d = [[0.0, y, z] for (y, z) in loop_yz] + vc.make_swept_profile( + f"{name}_track_band", + "box", + 0.034, + track_w * 0.92, + 0.034, + path_3d, + up=[1.0, 0.0, 0.0], + mat_name="rubber_dark", + parent=pod, + closed=True, + ) + + # Articulated steel grouser shoes + pts = loop_yz + [loop_yz[0]] + segs = [math.hypot(pts[i + 1][0] - pts[i][0], pts[i + 1][1] - pts[i][1]) for i in range(len(loop_yz))] + total_len = sum(segs) + n_shoes = 46 + + def build_shoes(bm: bmesh.types.BMesh) -> None: + for s_idx in range(n_shoes): + target_d = (s_idx / n_shoes) * total_len + acc = 0.0 + for i, sl in enumerate(segs): + if acc + sl >= target_d or i == len(segs) - 1: + t = (target_d - acc) / max(sl, 1e-6) + y0, z0 = pts[i] + y1, z1 = pts[i + 1] + py = y0 + (y1 - y0) * t + pz = z0 + (z1 - z0) * t + ang = math.atan2(z1 - z0, y1 - y0) + m = ( + Matrix.Translation((0.0, py, pz)) + @ Matrix.Rotation(ang, 4, "X") + @ Matrix.Diagonal((track_w, 0.095, 0.030, 1.0)) + ) + bmesh.ops.create_cube(bm, size=1.0, matrix=m) + break + acc += sl + + vc.make_bmesh_object(f"{name}_shoes", build_shoes, "gunmetal", parent=pod) + + # Full-length top track fender + front/rear mudflaps + vc.make_box(f"{name}_fender_top", (track_w + 0.08, 4.18, 0.065), "olive_armor", parent=pod, location=(0.0, -0.02, 0.96), bevel=0.01) + vc.make_box(f"{name}_fender_front", (track_w + 0.08, 0.36, 0.06), "olive_armor", parent=pod, location=(0.0, -2.20, 0.84), rotation_deg=(38.0, 0.0, 0.0), bevel=0.008) + vc.make_box(f"{name}_fender_rear", (track_w + 0.08, 0.34, 0.06), "olive_armor", parent=pod, location=(0.0, 2.16, 0.84), rotation_deg=(-38.0, 0.0, 0.0), bevel=0.008) + + +def build_ironclad() -> dict: + vc.reset_scene() + vc.ensure_materials() + + root = vc.make_empty("IroncladRoot") + chassis = vc.make_empty("Chassis", parent=root) + + # --- 1. Lower Armored Tub & Welded Angular MBT Hull (Brokkr plate.v0) --- + vc.make_box("lower_tub", (1.74, 4.10, 0.52), "gunmetal", parent=chassis, location=(0.0, -0.02, 0.56), bevel=0.014) + + hull_pts = [ + [-0.87, -2.26, 0.52], [0.87, -2.26, 0.52], + [-0.90, -2.24, 0.74], [0.90, -2.24, 0.74], + [-0.92, -1.16, 1.16], [0.92, -1.16, 1.16], + [-0.92, 0.96, 1.16], [0.92, 0.96, 1.16], + [-0.88, 2.18, 0.96], [0.88, 2.18, 0.96], + [-0.86, 2.16, 0.54], [0.86, 2.16, 0.54], + ] + plates_doc = { + "schema": "brokkr.plates.v0", + "plates": [ + { + "name": "ironclad_hull", + "mat": "olive_armor", + "bevel": 0.015, + "sides": "one", + "mirror": False, + "points": hull_pts, + "clad": { + "mat": "olive_armor", + "facets": [{"n": [0.0, -0.36, 0.93], "cos": 0.88}], + "min_area": 0.16, + "lifts": [0.008, 0.014], + "inset": 0.06, + "gap": 0.018, + "split": 0.88, + "seed": 701, + "bolt_r": 0.013, + "bolt_mat": "gunmetal", + "bevel": 0.004, + }, + }, + # Heavy bolted forward/mid track skirts (leaves rear flank clear for radiator bays) + { + "name": "ironclad_track_skirt", + "mat": "olive_armor", + "bevel": 0.008, + "sides": "both", + "mirror": False, + "slab": { + "at": [1.39, -0.44, 0.68], + "normal": [1.0, 0.0, 0.0], + "up": [0.0, 0.0, 1.0], + "right": [0.0, -1.0, 0.0], + "outline": [[-1.34, -0.26], [1.44, -0.26], [1.26, 0.28], [-1.34, 0.28]], + "thick": 0.048, + "taper": 0.010, + "back": 0.92, + }, + "clad": { + "mat": "olive_armor", + "facets": "outer", + "min_area": 0.10, + "lifts": [0.008, 0.014], + "inset": 0.04, + "gap": 0.016, + "split": 0.72, + "seed": 702, + "bolt_r": 0.013, + "bolt_mat": "gunmetal", + "bevel": 0.004, + }, + "fits": [ + {"kind": "bolts", "inset": 0.025, "spacing": 0.34, "mat": "gunmetal", "params": "r=0.013"}, + ], + }, + # Sloped upper hull sponson shoulders + { + "name": "ironclad_sponson", + "mat": "olive_armor", + "bevel": 0.008, + "sides": "both", + "mirror": False, + "slab": { + "at": [1.08, 0.16, 1.04], + "normal": [0.76, 0.0, 0.65], + "up": [-0.65, 0.0, 0.76], + "right": [0.0, -1.0, 0.0], + "outline": [[-1.72, -0.18], [1.72, -0.18], [1.56, 0.18], [-1.56, 0.18]], + "thick": 0.05, + "taper": 0.014, + "back": 0.92, + }, + "fits": [ + {"kind": "bolts", "inset": 0.02, "spacing": 0.36, "mat": "gunmetal", "params": "r=0.012"}, + ], + }, + ], + } + vc.make_plates(plates_doc, parent=chassis) + + # Rear flank armored housings for radiator bays + driver periscope + headlights + tow shackles + vc.make_box("driver_periscope", (0.42, 0.14, 0.09), "smoked_glass", parent=chassis, location=(-0.30, -1.32, 1.18), bevel=0.005) + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + vc.make_box(f"headlight_box_{tag}", (0.18, 0.14, 0.12), "gunmetal", parent=chassis, location=(side * 1.08, -2.06, 1.04), bevel=0.008) + vc.make_box(f"headlight_lens_{tag}", (0.12, 0.04, 0.07), "smoked_glass", parent=chassis, location=(side * 1.08, -2.13, 1.04), bevel=0.003) + vc.make_box(f"tow_shackle_{tag}", (0.07, 0.12, 0.12), "signal_orange", parent=chassis, location=(side * 0.56, -2.28, 0.62), bevel=0.006) + # Rear flank radiator mounting box + exhaust armor box + vc.make_box(f"rear_rad_housing_{tag}", (0.18, 1.04, 0.50), "olive_armor", parent=chassis, location=(side * 1.28, 1.36, 0.78), bevel=0.01) + vc.make_box(f"rear_exhaust_box_{tag}", (0.42, 0.34, 0.24), "gunmetal", parent=chassis, location=(side * 0.62, 2.08, 0.86), bevel=0.01) + vc.make_swept_tube( + f"exhaust_pipe_{tag}", + [[side * 0.62, 2.12, 0.86], [side * 0.72, 2.26, 0.88], [side * 0.72, 2.34, 0.78]], + 0.042, + segments=10, + mat_name="copper_rad", + parent=chassis, + fillet_r=0.03, + ) + # External cylindrical stern fuel drums (signature Ironclad silhouette; tank extends along local +Z) + vc.make_kit_part( + f"stern_fuel_drum_{tag}", + "mechanical", + "tank", + {"radius": 0.17, "length": 0.76, "segments": 14}, + mat_name="olive_armor", + parent=chassis, + location=(side * 0.06, 2.24, 1.04), + rotation_deg=(0.0, side * 90.0, 0.0), + ) + + # --- 2. Wide Articulated MBT Track Pods --- + _build_mbt_track_pod("track_pod_L", 1.0, chassis) + _build_mbt_track_pod("track_pod_R", -1.0, chassis) + + # --- 3. Faceted Central MBT Turret (joint.turret_yaw) --- + turret_pivot = vc.make_empty("joint.turret_yaw", parent=chassis, location=(0.0, -0.18, 1.16)) + vc.tag_joint(turret_pivot, "joint.turret_yaw", [0.0, 1.0, 0.0], -180.0, 180.0) + joints_manifest = [{"id": "joint.turret_yaw", "axis": [0.0, 1.0, 0.0], "min": -180.0, "max": 180.0}] + + vc.make_tube_part("turret_race", 0.76, 0.82, 0.08, segments=24, mat_name="gunmetal", parent=turret_pivot) + + turret_pts = [ + [-0.58, -0.84, 0.08], [0.58, -0.84, 0.08], + [0.86, -0.20, 0.08], [0.76, 0.88, 0.08], + [-0.76, 0.88, 0.08], [-0.86, -0.20, 0.08], + [-0.46, -0.60, 0.50], [0.46, -0.60, 0.50], + [0.64, -0.10, 0.50], [0.58, 0.76, 0.50], + [-0.58, 0.76, 0.50], [-0.64, -0.10, 0.50], + ] + turret_doc = { + "schema": "brokkr.plates.v0", + "plates": [ + { + "name": "ironclad_turret_shell", + "mat": "olive_armor", + "bevel": 0.014, + "sides": "one", + "mirror": False, + "points": turret_pts, + }, + { + "name": "ironclad_turret_cheek", + "mat": "olive_armor", + "bevel": 0.008, + "sides": "both", + "mirror": False, + "slab": { + "at": [0.62, -0.52, 0.28], + "normal": [0.64, -0.68, 0.35], + "up": [-0.24, 0.25, 0.94], + "right": [-0.73, -0.68, 0.0], + "outline": [[-0.28, -0.16], [0.28, -0.16], [0.22, 0.16], [-0.22, 0.16]], + "thick": 0.05, + "taper": 0.012, + "back": 0.92, + }, + "fits": [ + {"kind": "bolts", "inset": 0.02, "spacing": 0.20, "mat": "gunmetal", "params": "r=0.011"}, + ], + }, + ], + } + vc.make_plates(turret_doc, parent=turret_pivot) + + # Turret mantlet, bustle rack, commander cupola, CITV optic, smoke dischargers & coax bracket + vc.make_box("turret_mantlet", (0.52, 0.24, 0.26), "gunmetal", parent=turret_pivot, location=(0.0, -0.82, 0.28), bevel=0.01) + vc.make_box("turret_bustle", (1.10, 0.44, 0.32), "olive_armor", parent=turret_pivot, location=(0.0, 0.98, 0.32), bevel=0.01) + vc.make_tube_part("commander_cupola", 0.17, 0.19, 0.09, segments=14, mat_name="olive_armor", parent=turret_pivot, location=(-0.36, 0.46, 0.50)) + vc.make_box("turret_citv_pod", (0.18, 0.20, 0.16), "gunmetal", parent=turret_pivot, location=(0.34, -0.32, 0.56), bevel=0.008) + vc.make_box("turret_citv_lens", (0.12, 0.05, 0.09), "smoked_glass", parent=turret_pivot, location=(0.34, -0.42, 0.57), bevel=0.004) + vc.make_box("coax_bracket", (0.36, 0.42, 0.10), "gunmetal", parent=turret_pivot, location=(0.64, -0.22, 0.34), bevel=0.008) + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + for k in range(3): + vc.make_tube_part( + f"smoke_tube_{tag}_{k}", 0.030, 0.030, 0.17, segments=8, + mat_name="gunmetal", parent=turret_pivot, + location=(side * 0.80, 0.36 + k * 0.10, 0.30), rotation_deg=(-58.0, 0.0, side * 22.0), + ) + + # --- 4. Visible Exterior Hardpoints (4x5 Dorsal Grid) --- + # 1) hp.armor.front (0,0, 4x1) + vc.add_hardpoint_slot( + "hp.armor.front", + "armor", + parent=chassis, + location=(0.0, -1.72, 0.94), + rotation_deg=(-68.0, 0.0, 0.0), + size=(1.46, 0.36, 0.09), + ) + # 2) hp.weapon.main (1,1, 2x2) + vc.add_hardpoint_slot( + "hp.weapon.main", + "weapon", + parent=turret_pivot, + location=(0.0, -0.02, 0.51), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.82, 0.82, 0.11), + ) + # 3) hp.weapon.coax (0,1, 1x1) on left turret cheek bracket + vc.add_hardpoint_slot( + "hp.weapon.coax", + "weapon", + parent=turret_pivot, + location=(0.66, -0.22, 0.39), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.38, 0.38, 0.08), + ) + # 4) hp.armor.skirts (3,1, 1x2) on right (-X) track skirt + vc.add_hardpoint_slot( + "hp.armor.skirts", + "armor", + parent=chassis, + location=(-1.42, -0.38, 0.68), + rotation_deg=(90.0, 0.0, -90.0), + size=(1.28, 0.32, 0.09), + ) + # 5) hp.engine.rear (1,3, 2x2) + vc.add_hardpoint_slot( + "hp.engine.rear", + "engine", + parent=chassis, + location=(0.0, 1.48, 1.08), + rotation_deg=(-9.0, 0.0, 0.0), + size=(1.08, 0.92, 0.13), + ) + # 6 & 7) hp.radiator.l (0,3, 1x2) & hp.radiator.r (3,3, 1x2) + vc.add_hardpoint_slot( + "hp.radiator.l", + "radiator", + parent=chassis, + location=(1.36, 1.36, 0.78), + rotation_deg=(90.0, 0.0, 90.0), + size=(0.94, 0.44, 0.12), + ) + vc.add_hardpoint_slot( + "hp.radiator.r", + "radiator", + parent=chassis, + location=(-1.36, 1.36, 0.78), + rotation_deg=(90.0, 0.0, -90.0), + size=(0.94, 0.44, 0.12), + ) + + # --- 5. Export GLB, Manifest & Preview --- + glb_path = vc.ASSETS_VEHICLES_DIR / "ironclad" / "ironclad.glb" + manifest_path = vc.ASSETS_VEHICLES_DIR / "ironclad" / "manifest.json" + preview_path = vc.PREVIEWS_DIR / "ironclad_preview.png" + + tri_count, bounds = vc.export_vehicle_glb(glb_path, root=root) + vc.write_manifest( + manifest_path, + vehicle_id="ironclad", + name="Ironclad", + vehicle_class="Medium Tracked Battle Tank", + grid_width=4, + grid_height=5, + mask=[ + "####", + "####", + "####", + "####", + "####", + ], + hardpoints=[ + {"id": "hp.armor.front", "kind": "armor", "x": 0, "y": 0, "w": 4, "h": 1, "modelNodeId": "hp.armor.front"}, + {"id": "hp.weapon.coax", "kind": "weapon", "x": 0, "y": 1, "w": 1, "h": 1, "modelNodeId": "hp.weapon.coax"}, + {"id": "hp.weapon.main", "kind": "weapon", "x": 1, "y": 1, "w": 2, "h": 2, "modelNodeId": "hp.weapon.main"}, + {"id": "hp.armor.skirts", "kind": "armor", "x": 3, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.armor.skirts"}, + {"id": "hp.radiator.l", "kind": "radiator", "x": 0, "y": 3, "w": 1, "h": 2, "modelNodeId": "hp.radiator.l"}, + {"id": "hp.engine.rear", "kind": "engine", "x": 1, "y": 3, "w": 2, "h": 2, "modelNodeId": "hp.engine.rear"}, + {"id": "hp.radiator.r", "kind": "radiator", "x": 3, "y": 3, "w": 1, "h": 2, "modelNodeId": "hp.radiator.r"}, + ], + joints=joints_manifest, + bounds=bounds, + tri_count=tri_count, + ) + vc.render_four_panel_preview(preview_path) + print(f"[ironclad] tris={tri_count} bounds={bounds} glb={glb_path}") + return {"id": "ironclad", "tris": tri_count, "bounds": bounds} + + +if __name__ == "__main__": + build_ironclad() diff --git a/tools/vehicles/build_mammoth.py b/tools/vehicles/build_mammoth.py new file mode 100644 index 0000000..de50375 --- /dev/null +++ b/tools/vehicles/build_mammoth.py @@ -0,0 +1,459 @@ +"""Build the Mammoth (Heavy 8x8 Armored Fire Support Rig) chassis GLB, manifest.json, and preview.""" +from __future__ import annotations + +import math +import sys +from pathlib import Path + +import bmesh +from mathutils import Matrix + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import vehicle_common as vc # noqa: E402 + + +def build_mammoth() -> dict: + vc.reset_scene() + vc.ensure_materials() + + root = vc.make_empty("MammothRoot") + chassis = vc.make_empty("Chassis", parent=root) + + # Dimensions (Blender: -Y forward, +Z up, +X left) + axle_ys = [ + ("f1", -1.90, True), + ("f2", -0.74, True), + ("r1", 0.74, False), + ("r2", 1.90, False), + ] + track_x = 1.24 + wheel_r = 0.52 + wheel_w = 0.38 + axle_z = wheel_r + + # --- 1. Heavy Armored Lower Tub, Frame Rails, Axles & Suspension --- + vc.make_box("lower_tub", (1.64, 4.94, 0.62), "gunmetal", parent=chassis, location=(0.0, -0.02, 0.82), bevel=0.015) + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + vc.make_box(f"frame_rail_{tag}", (0.14, 5.10, 0.20), "gunmetal", parent=chassis, location=(side * 0.68, -0.04, 0.62), bevel=0.01) + # Side fuel tank / battery box tucked between front and rear tandem wheel pairs + vc.make_box(f"side_stowage_{tag}", (0.42, 0.72, 0.44), "olive_armor", parent=chassis, location=(side * 1.08, 0.0, 0.86), bevel=0.01) + # Crew entry door + boarding ladder step on mid-hull flank + vc.make_box(f"crew_step_{tag}", (0.16, 0.44, 0.06), "gunmetal", parent=chassis, location=(side * 1.32, 0.0, 0.62), bevel=0.006) + vc.make_box(f"crew_door_{tag}", (0.06, 0.56, 0.78), "olive_armor", parent=chassis, location=(side * 1.28, 0.0, 1.24), bevel=0.008) + + for idx, (a_tag, y_ax, _) in enumerate(axle_ys): + vc.make_tube_part( + f"axle_tube_{a_tag}", + 0.075, + 0.075, + track_x * 1.68, + segments=10, + mat_name="gunmetal", + parent=chassis, + location=(-track_x * 0.84, y_ax, axle_z), + rotation_deg=(0.0, 90.0, 0.0), + ) + vc.make_box(f"diff_{a_tag}", (0.34, 0.34, 0.28), "gunmetal", parent=chassis, location=(0.0, y_ax, axle_z), bevel=0.012) + for side in (-1.0, 1.0): + s_tag = "L" if side > 0 else "R" + vc.make_ram_span( + f"strut_{a_tag}_{s_tag}", + [side * 0.74, y_ax, 1.02], + [side * 0.98, y_ax, axle_z + 0.02], + body_r=0.040, + rod_r=0.022, + parent=chassis, + mat_barrel="gunmetal", + mat_rod="copper_rad", + coil_rings=0, + ) + + # --- 2. Faceted 8x8 Armored Hull & Bolted Sponson Plates (Brokkr plate.v0) --- + hull_pts = [ + # Lower hull belt above wheel arches (z = 1.14) + [-1.34, -2.26, 1.14], [1.34, -2.26, 1.14], + [-1.36, 2.26, 1.14], [1.36, 2.26, 1.14], + # Lower nose & lower tail bevel + [-1.08, -2.62, 1.02], [1.08, -2.62, 1.02], + [-1.12, 2.64, 1.12], [1.12, 2.64, 1.12], + # Roof deck (z = 1.66) + [-1.14, -1.78, 1.66], [1.14, -1.78, 1.66], + [-1.16, 1.88, 1.66], [1.16, 1.88, 1.66], + ] + plates_doc = { + "schema": "brokkr.plates.v0", + "plates": [ + { + "name": "mammoth_hull", + "mat": "olive_armor", + "bevel": 0.016, + "sides": "one", + "mirror": False, + "points": hull_pts, + "clad": { + "mat": "olive_armor", + "facets": [{"n": [0.0, -0.55, 0.83], "cos": 0.85}, {"n": [0.0, 0.0, 1.0], "cos": 0.95}], + "min_area": 0.18, + "lifts": [0.008, 0.014], + "inset": 0.06, + "gap": 0.018, + "split": 0.88, + "seed": 801, + "bolt_r": 0.014, + "bolt_mat": "gunmetal", + "bevel": 0.004, + }, + }, + # Sloped upper side cheek armor with bolted applique panels + { + "name": "mammoth_side_cheek", + "mat": "olive_armor", + "bevel": 0.010, + "sides": "both", + "mirror": False, + "slab": { + "at": [1.26, -0.04, 1.40], + "normal": [0.92, 0.0, 0.38], + "up": [-0.38, 0.0, 0.92], + "right": [0.0, -1.0, 0.0], + "outline": [[-1.92, -0.24], [1.92, -0.24], [1.72, 0.24], [-1.72, 0.24]], + "thick": 0.055, + "taper": 0.015, + "back": 0.92, + }, + "clad": { + "mat": "olive_armor", + "facets": "outer", + "min_area": 0.14, + "lifts": [0.008, 0.014], + "inset": 0.05, + "gap": 0.016, + "split": 0.72, + "seed": 802, + "bolt_r": 0.013, + "bolt_mat": "gunmetal", + "bevel": 0.004, + }, + "fits": [ + {"kind": "bolts", "inset": 0.025, "spacing": 0.36, "mat": "gunmetal", "params": "r=0.013"}, + ], + }, + ], + } + vc.make_plates(plates_doc, parent=chassis) + + # Heavy flared wheel arches over all 4 wheel stations on each side + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + for a_tag, y_ax, _ in axle_ys: + # Top arch cap + angled front/rear lip flaps + vc.make_box(f"arch_top_{tag}_{a_tag}", (0.44, 0.68, 0.07), "olive_armor", parent=chassis, location=(side * 1.24, y_ax, 1.14), bevel=0.008) + vc.make_box(f"arch_f_{tag}_{a_tag}", (0.44, 0.32, 0.07), "olive_armor", parent=chassis, location=(side * 1.24, y_ax - 0.44, 1.02), rotation_deg=(36.0, 0.0, 0.0), bevel=0.008) + vc.make_box(f"arch_r_{tag}_{a_tag}", (0.44, 0.32, 0.07), "olive_armor", parent=chassis, location=(side * 1.24, y_ax + 0.44, 1.02), rotation_deg=(-36.0, 0.0, 0.0), bevel=0.008) + + # Front nose recessed grille, armored headlights, driver slit & rearview mirrors + vc.make_box("front_grille", (1.22, 0.14, 0.34), "socket_bay", parent=chassis, location=(0.0, -2.58, 0.96), bevel=0.008) + for k in range(4): + vc.make_box(f"grille_slat_{k}", (1.16, 0.06, 0.03), "gunmetal", parent=chassis, location=(0.0, -2.64, 0.86 + k * 0.07), bevel=0.003) + vc.make_box("driver_periscope", (0.56, 0.16, 0.10), "smoked_glass", parent=chassis, location=(-0.38, -1.96, 1.60), rotation_deg=(-22.0, 0.0, 0.0), bevel=0.005) + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + vc.make_box(f"headlight_box_{tag}", (0.24, 0.16, 0.16), "gunmetal", parent=chassis, location=(side * 0.88, -2.54, 1.06), bevel=0.008) + vc.make_box(f"headlight_lens_{tag}", (0.16, 0.04, 0.09), "smoked_glass", parent=chassis, location=(side * 0.88, -2.62, 1.06), bevel=0.003) + vc.make_box(f"tow_shackle_{tag}", (0.08, 0.14, 0.14), "signal_orange", parent=chassis, location=(side * 0.48, -2.66, 0.72), bevel=0.006) + # Rear corner tail light housing + vc.make_box(f"taillight_{tag}", (0.18, 0.12, 0.14), "gunmetal", parent=chassis, location=(side * 1.04, 2.58, 1.12), bevel=0.006) + + # --- 3. Reinforced Front Dozer Ram Plow --- + plow_root = vc.make_empty("dozer_plow", parent=chassis, location=(0.0, -2.86, 0.56)) + def build_plow_blade(bm: bmesh.types.BMesh) -> None: + # Curved multi-segment scoop profile extruded across width X = [-1.34, +1.34] + prof = [ + (-0.34, -0.34), # bottom cutting lip + (-0.22, -0.14), + (-0.04, 0.06), + (0.02, 0.26), + (-0.14, 0.42), # upper curved spill lip + (0.04, 0.42), + (0.14, 0.22), + (0.08, -0.12), + (-0.18, -0.34), + ] + hw = 1.34 + verts_l = [bm.verts.new((hw, y, z)) for (y, z) in prof] + verts_r = [bm.verts.new((-hw, y, z)) for (y, z) in prof] + n = len(prof) + for i in range(n): + j = (i + 1) % n + bm.faces.new([verts_l[i], verts_l[j], verts_r[j], verts_r[i]]) + bm.faces.new(verts_l) + bm.faces.new(list(reversed(verts_r))) + + vc.make_bmesh_object("plow_moldboard", build_plow_blade, "olive_armor", parent=plow_root, bevel=0.012) + vc.make_box("plow_cutting_edge", (2.72, 0.16, 0.07), "gunmetal", parent=plow_root, location=(0.0, -0.28, -0.32), rotation_deg=(16.0, 0.0, 0.0), bevel=0.006) + for gx in (-0.98, -0.48, 0.0, 0.48, 0.98): + vc.make_box(f"plow_rib_{gx:.2f}", (0.07, 0.18, 0.62), "gunmetal", parent=plow_root, location=(gx, 0.12, 0.06), bevel=0.006) + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + vc.make_box(f"plow_wing_{tag}", (0.12, 0.48, 0.68), "olive_armor", parent=plow_root, location=(side * 1.36, -0.10, 0.04), bevel=0.008) + # Hydraulic push arms + tilt rams + vc.make_box(f"plow_pusharm_{tag}", (0.12, 0.72, 0.14), "gunmetal", parent=chassis, location=(side * 0.66, -2.56, 0.56), bevel=0.008) + vc.make_ram_span( + f"plow_ram_{tag}", + [side * 0.66, -2.42, 0.90], + [side * 0.66, -2.80, 0.76], + body_r=0.042, + rod_r=0.024, + parent=chassis, + mat_barrel="gunmetal", + mat_rod="copper_rad", + ) + + # --- 4. Rear Diesel Exhaust Stacks --- + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + vc.make_swept_tube( + f"exhaust_stack_{tag}", + [ + [side * 1.02, 2.24, 1.36], + [side * 1.06, 2.46, 1.56], + [side * 1.06, 2.46, 2.18], + [side * 1.06, 2.60, 2.30], + ], + 0.062, + segments=12, + mat_name="gunmetal", + parent=chassis, + fillet_r=0.06, + ) + vc.make_tube_part( + f"exhaust_shield_{tag}", + 0.09, + 0.09, + 0.52, + segments=10, + inner0=0.078, + inner1=0.078, + mat_name="copper_rad", + parent=chassis, + location=(side * 1.06, 2.46, 1.62), + ) + + # --- 5. 8x8 Wheels & Front 4 Steering Knuckles --- + joints_manifest: list[dict] = [] + for a_tag, y_ax, steerable in axle_ys: + for side, s_tag in ((1.0, "l"), (-1.0, "r")): + j_suffix = f"{a_tag[0]}{s_tag}{a_tag[1]}" # fl1, fr1, fl2, fr2, rl1, rr1, rl2, rr2 + if steerable: + steer_id = f"joint.steer_{j_suffix}" + steer_node = vc.make_empty(steer_id, parent=chassis, location=(side * 0.98, y_ax, axle_z)) + vc.tag_joint(steer_node, steer_id, [0.0, 1.0, 0.0], -28.0, 28.0) + joints_manifest.append({"id": steer_id, "axis": [0.0, 1.0, 0.0], "min": -28.0, "max": 28.0}) + vc.make_box(f"knuckle_{j_suffix}", (0.10, 0.14, 0.22), "gunmetal", parent=steer_node, bevel=0.006) + wheel_parent = steer_node + wheel_loc = (side * (track_x - 0.98), 0.0, 0.0) + else: + vc.make_box(f"hub_carrier_{j_suffix}", (0.12, 0.16, 0.22), "gunmetal", parent=chassis, location=(side * 0.98, y_ax, axle_z), bevel=0.006) + wheel_parent = chassis + wheel_loc = (side * track_x, y_ax, axle_z) + + wheel_id = f"joint.wheel_{j_suffix}" + wheel_pivot = vc.make_knobby_wheel( + wheel_id, + radius=wheel_r, + width=wheel_w, + parent=wheel_parent, + location=wheel_loc, + tread_lugs=14, + rim_segments=16, + side_sign=int(side), + ) + wheel_pivot.name = wheel_id + vc.tag_joint(wheel_pivot, wheel_id, [1.0, 0.0, 0.0], -360.0, 360.0) + joints_manifest.append({"id": wheel_id, "axis": [1.0, 0.0, 0.0], "min": -360.0, "max": 360.0}) + + # --- 6. Broad Angular Central Turret (joint.turret_yaw) --- + turret_pivot = vc.make_empty("joint.turret_yaw", parent=chassis, location=(0.0, -0.18, 1.66)) + vc.tag_joint(turret_pivot, "joint.turret_yaw", [0.0, 1.0, 0.0], -180.0, 180.0) + joints_manifest.append({"id": "joint.turret_yaw", "axis": [0.0, 1.0, 0.0], "min": -180.0, "max": 180.0}) + + vc.make_tube_part("turret_race", 0.74, 0.80, 0.08, segments=24, mat_name="gunmetal", parent=turret_pivot) + turret_pts = [ + [-0.64, -0.78, 0.08], [0.64, -0.78, 0.08], + [0.84, -0.22, 0.08], [0.76, 0.94, 0.08], + [-0.76, 0.94, 0.08], [-0.84, -0.22, 0.08], + [-0.50, -0.60, 0.56], [0.50, -0.60, 0.56], + [0.64, -0.14, 0.56], [0.58, 0.78, 0.56], + [-0.58, 0.78, 0.56], [-0.64, -0.14, 0.56], + ] + turret_doc = { + "schema": "brokkr.plates.v0", + "plates": [ + { + "name": "mammoth_turret_shell", + "mat": "olive_armor", + "bevel": 0.015, + "sides": "one", + "mirror": False, + "points": turret_pts, + }, + { + "name": "mammoth_turret_cheek", + "mat": "olive_armor", + "bevel": 0.008, + "sides": "both", + "mirror": False, + "slab": { + "at": [0.74, 0.14, 0.30], + "normal": [0.94, 0.0, 0.34], + "up": [-0.34, 0.0, 0.94], + "right": [0.0, -1.0, 0.0], + "outline": [[-0.52, -0.16], [0.52, -0.16], [0.42, 0.16], [-0.42, 0.16]], + "thick": 0.045, + "taper": 0.012, + "back": 0.92, + }, + "fits": [ + {"kind": "bolts", "inset": 0.02, "spacing": 0.24, "mat": "gunmetal", "params": "r=0.012"}, + ], + }, + ], + } + vc.make_plates(turret_doc, parent=turret_pivot) + + # Turret bustle stowage rack, commander hatch, optics & smoke launchers + vc.make_box("turret_bustle", (1.08, 0.42, 0.34), "gunmetal", parent=turret_pivot, location=(0.0, 0.98, 0.34), bevel=0.01) + vc.make_tube_part("commander_cupola", 0.22, 0.24, 0.10, segments=14, mat_name="olive_armor", parent=turret_pivot, location=(-0.28, 0.34, 0.56)) + vc.make_box("turret_sight", (0.20, 0.22, 0.14), "smoked_glass", parent=turret_pivot, location=(0.24, -0.38, 0.62), bevel=0.008) + vc.make_box("turret_mantlet_bar", (0.94, 0.18, 0.18), "gunmetal", parent=turret_pivot, location=(0.0, -0.70, 0.30), bevel=0.01) + for side in (-1.0, 1.0): + tag = "L" if side > 0 else "R" + for k in range(3): + vc.make_tube_part( + f"smoke_tube_{tag}_{k}", + 0.032, + 0.032, + 0.18, + segments=8, + mat_name="gunmetal", + parent=turret_pivot, + location=(side * 0.78, 0.42 + k * 0.10, 0.34), + rotation_deg=(-58.0, 0.0, side * 22.0), + ) + + # --- 7. Visible Exterior Hardpoints (4x6 Dorsal Grid) --- + # 1) hp.armor.glacis (0,0, 4x1) + vc.add_hardpoint_slot( + "hp.armor.glacis", + "armor", + parent=chassis, + location=(0.0, -2.20, 1.36), + rotation_deg=(-53.0, 0.0, 0.0), + size=(1.54, 0.38, 0.10), + ) + # 2) hp.weapon.bow (0,1, 1x1) on front-left bow deck + vc.make_box("bow_weapon_plinth", (0.48, 0.50, 0.12), "gunmetal", parent=chassis, location=(0.88, -1.48, 1.62), bevel=0.008) + vc.add_hardpoint_slot( + "hp.weapon.bow", + "weapon", + parent=chassis, + location=(0.88, -1.48, 1.68), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.46, 0.46, 0.09), + ) + # 3) hp.weapon.turret_l (1,1, 1x2) & 4) hp.weapon.turret_r (2,1, 1x2) on turret roof + vc.add_hardpoint_slot( + "hp.weapon.turret_l", + "weapon", + parent=turret_pivot, + location=(0.36, -0.10, 0.57), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.56, 0.56, 0.10), + ) + vc.add_hardpoint_slot( + "hp.weapon.turret_r", + "weapon", + parent=turret_pivot, + location=(-0.36, -0.10, 0.57), + rotation_deg=(0.0, 0.0, 0.0), + size=(0.56, 0.56, 0.10), + ) + # 5) hp.armor.flanks (3,1, 1x2) on right (-X) upper cheek + vc.add_hardpoint_slot( + "hp.armor.flanks", + "armor", + parent=chassis, + location=(-1.32, -0.16, 1.38), + rotation_deg=(90.0, 0.0, -90.0), + size=(1.12, 0.32, 0.10), + ) + # 6) hp.engine.rear (1,3, 2x2) + vc.add_hardpoint_slot( + "hp.engine.rear", + "engine", + parent=chassis, + location=(0.0, 1.34, 1.66), + rotation_deg=(0.0, 0.0, 0.0), + size=(1.14, 1.04, 0.14), + ) + # 7 & 8) hp.radiator.l (0,4, 1x2) & hp.radiator.r (3,4, 1x2) + vc.add_hardpoint_slot( + "hp.radiator.l", + "radiator", + parent=chassis, + location=(1.28, 1.40, 1.38), + rotation_deg=(90.0, 0.0, 90.0), + size=(0.98, 0.44, 0.12), + ) + vc.add_hardpoint_slot( + "hp.radiator.r", + "radiator", + parent=chassis, + location=(-1.28, 1.40, 1.38), + rotation_deg=(90.0, 0.0, -90.0), + size=(0.98, 0.44, 0.12), + ) + + # --- 8. Export GLB, Manifest & Preview --- + glb_path = vc.ASSETS_VEHICLES_DIR / "mammoth" / "mammoth.glb" + manifest_path = vc.ASSETS_VEHICLES_DIR / "mammoth" / "manifest.json" + preview_path = vc.PREVIEWS_DIR / "mammoth_preview.png" + + tri_count, bounds = vc.export_vehicle_glb(glb_path, root=root) + vc.write_manifest( + manifest_path, + vehicle_id="mammoth", + name="Mammoth", + vehicle_class="Heavy 8x8 Armored Fire Support Rig", + grid_width=4, + grid_height=6, + mask=[ + "####", + "####", + "####", + "####", + "####", + "####", + ], + hardpoints=[ + {"id": "hp.armor.glacis", "kind": "armor", "x": 0, "y": 0, "w": 4, "h": 1, "modelNodeId": "hp.armor.glacis"}, + {"id": "hp.weapon.bow", "kind": "weapon", "x": 0, "y": 1, "w": 1, "h": 1, "modelNodeId": "hp.weapon.bow"}, + {"id": "hp.weapon.turret_l", "kind": "weapon", "x": 1, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.weapon.turret_l"}, + {"id": "hp.weapon.turret_r", "kind": "weapon", "x": 2, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.weapon.turret_r"}, + {"id": "hp.armor.flanks", "kind": "armor", "x": 3, "y": 1, "w": 1, "h": 2, "modelNodeId": "hp.armor.flanks"}, + {"id": "hp.engine.rear", "kind": "engine", "x": 1, "y": 3, "w": 2, "h": 2, "modelNodeId": "hp.engine.rear"}, + {"id": "hp.radiator.l", "kind": "radiator", "x": 0, "y": 4, "w": 1, "h": 2, "modelNodeId": "hp.radiator.l"}, + {"id": "hp.radiator.r", "kind": "radiator", "x": 3, "y": 4, "w": 1, "h": 2, "modelNodeId": "hp.radiator.r"}, + ], + joints=joints_manifest, + bounds=bounds, + tri_count=tri_count, + ) + vc.render_four_panel_preview(preview_path) + print(f"[mammoth] tris={tri_count} bounds={bounds} glb={glb_path}") + return {"id": "mammoth", "tris": tri_count, "bounds": bounds} + + +if __name__ == "__main__": + build_mammoth() diff --git a/tools/vehicles/verify_glbs.py b/tools/vehicles/verify_glbs.py index 84d1dc2..51d2d7e 100644 --- a/tools/vehicles/verify_glbs.py +++ b/tools/vehicles/verify_glbs.py @@ -14,7 +14,7 @@ REPO_ROOT = Path(__file__).resolve().parents[2] VEHICLES_DIR = REPO_ROOT / "assets" / "vehicles" GEAR_DIR = REPO_ROOT / "assets" / "gear" -EXPECTED_VEHICLES = ("jackal", "mule", "ferret", "hornet") +EXPECTED_VEHICLES = ("jackal", "mule", "ferret", "hornet", "mammoth", "ironclad", "anvil", "condor") EXPECTED_GEAR = ("mg_762", "autocannon", "recoilless", "copper_rad", "gilded_lance", "gold_radiator")