## Extracts baked ArrayMesh resources out of the per-part ship/ball glb files ## into standalone .res files, which is what ship.tscn/ball.tscn actually ## reference (see gen_ship.py/gen_ball.py for why: a fresh glTF import's ## PackedScene wraps its single mesh object in a synthetic Node3D root, so ## the mesh itself needs pulling out to be usable as a direct MeshInstance3D ## child of Ship/Ball). ## ## Run after re-exporting the glbs from Blender (gen_ship.py / gen_ball.py): ## godot --headless --path Game --script ../tools/blender/extract_meshes.gd ## (from the repo root; adjust the relative --script path to wherever you run ## the command from). Overwrites the existing ship_*.res / ball.res files. extends SceneTree const SOURCES = { "res://assets/models/ship_hull.glb": "res://assets/models/ship_hull.res", "res://assets/models/ship_nose.glb": "res://assets/models/ship_nose.res", "res://assets/models/ship_canopy.glb": "res://assets/models/ship_canopy.res", "res://assets/models/ship_tailfin.glb": "res://assets/models/ship_tailfin.res", "res://assets/models/ship_engine_l.glb": "res://assets/models/ship_engine_l.res", "res://assets/models/ship_engine_r.glb": "res://assets/models/ship_engine_r.res", "res://assets/models/ball.glb": "res://assets/models/ball.res", } func _initialize() -> void: for glb_path in SOURCES: var res_path: String = SOURCES[glb_path] var packed: PackedScene = load(glb_path) var instance: Node = packed.instantiate() var mesh_node: MeshInstance3D = instance.get_child(0) var err := ResourceSaver.save(mesh_node.mesh, res_path) print("%s -> %s (err=%d)" % [glb_path, res_path, err]) instance.free() quit()