The invisible-vehicle defect is closed. Shot 9 now shows the car instead of an empty road. Tools/vehicle_from_template.py converts Art/blender/vehicle/hot hatch.blend into UE-ready assets, following two skills: vehicle-artist - systems split (body 113k tris, trim 10.5k, glass 20.5k, lights 18.6k, wheels 47.8k), one UCX_ hull 1.45 x 3.94 x 0.76 m, two decimated LODs at 39.7k and 13.6k. unreal-export - scale normalised to a documented 4.05 m hot hatch before export (the template measures 7.26 m, factor 0.5579), then verified after import: body bounds 1.51 x 4.02 x 1.22 m against the 4.05 m target. Staged as five plain StaticMeshActors, because the earlier probe proved those render while the same meshes attached to the vehicle pawn do not. Open and recorded rather than hidden: judge_screenshot returns verdict=no confidence=0.9 - the silhouette does not read as a hot hatch from this angle and the car floats slightly. The likely causes are a system misclassification in the template conversion and an origin-height error of a few centimetres.
146 lines
5.7 KiB
Python
146 lines
5.7 KiB
Python
# Import the sedan systems as separate static meshes (0.3.0).
|
|
#
|
|
# blender -b --factory-startup --python Tools/vehicle_build.py -- \
|
|
# --out Art/blender/vehicle/gigline-sedan.blend --fbx /tmp/gigline/vehicle/sedan.fbx
|
|
# <engine>/Engine/Binaries/Linux/UnrealEditor-Cmd <uproject> -run=pythonscript \
|
|
# -script=<repo>/Tools/ue_vehicle_import.py -nullrhi -unattended -nopause -stdout
|
|
#
|
|
# One asset per system, per the vehicle-artist skill's object split: body, glass, front
|
|
# and rear lights, mirrors, and one wheel reused four times. The body FBX also carries
|
|
# the UCX_ hulls, which Unreal consumes as simple collision.
|
|
#
|
|
# Result file: /tmp/gigline/vehicle-import.txt
|
|
|
|
import os
|
|
|
|
import unreal
|
|
|
|
DEST = "/Game/Hollywood/Vehicle"
|
|
SOURCE = "/tmp/gigline/hatch"
|
|
SYSTEMS = (
|
|
("body", "SM_Vehicle_Body"),
|
|
("trim", "SM_Vehicle_Trim"),
|
|
("glass", "SM_Vehicle_Glass"),
|
|
("lights", "SM_Vehicle_Lights"),
|
|
("wheels", "SM_Vehicle_Wheels"),
|
|
)
|
|
RESULT = "/tmp/gigline/vehicle-import.txt"
|
|
lines = []
|
|
|
|
|
|
def log(msg):
|
|
lines.append(str(msg))
|
|
unreal.log(str(msg))
|
|
|
|
|
|
def main():
|
|
for source, name in SYSTEMS:
|
|
path = os.path.join(SOURCE, f"{source}.fbx")
|
|
if not os.path.exists(path):
|
|
log(f"{name}: missing source {path}")
|
|
lines.append("VERDICT: FAIL")
|
|
return
|
|
task = unreal.AssetImportTask()
|
|
task.filename = path
|
|
task.destination_path = DEST
|
|
task.destination_name = name
|
|
task.automated = True
|
|
task.save = True
|
|
task.replace_existing = True
|
|
|
|
ui = unreal.FbxImportUI()
|
|
ui.import_mesh = True
|
|
ui.import_as_skeletal = False
|
|
ui.import_materials = True
|
|
ui.import_textures = False
|
|
ui.static_mesh_import_data.combine_meshes = True
|
|
ui.static_mesh_import_data.generate_lightmap_u_vs = True
|
|
ui.static_mesh_import_data.auto_generate_collision = True
|
|
ui.static_mesh_import_data.import_uniform_scale = 1.0
|
|
task.options = ui
|
|
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
|
|
|
|
mesh = unreal.EditorAssetLibrary.load_asset(f"{DEST}/{name}")
|
|
if mesh is None:
|
|
log(f"{name}: MISSING after import")
|
|
lines.append("VERDICT: FAIL")
|
|
return
|
|
bounds = mesh.get_bounding_box() if hasattr(mesh, "get_bounding_box") else None
|
|
size = ""
|
|
if bounds:
|
|
extent = bounds.max - bounds.min
|
|
size = f"{extent.x/100:.2f} x {extent.y/100:.2f} x {extent.z/100:.2f} m"
|
|
mats = mesh.get_editor_property("static_materials")
|
|
log(f"{name}: imported, {len(mats)} material slot(s), bounds {size}")
|
|
|
|
# Wire the two LOD meshes into the body's LOD group. import_lod is the supported
|
|
# path; copying bytes between assets is not, and the LOD group is what the engine
|
|
# uses to pick by screen size.
|
|
# LOD meshes are imported as their own assets. Wiring them into the body's LOD group
|
|
# needs StaticMeshEditorSubsystem.import_lod, which is unavailable in this headless
|
|
# commandlet (get_editor_subsystem returns None), so the group is a follow-up.
|
|
for source, name in (("body_lod1", "SM_Vehicle_Body_LOD1"),
|
|
("body_lod2", "SM_Vehicle_Body_LOD2")):
|
|
path = os.path.join(SOURCE, f"{source}.fbx")
|
|
if not os.path.exists(path):
|
|
log(f"{name}: missing {path}")
|
|
continue
|
|
task = unreal.AssetImportTask()
|
|
task.filename = path
|
|
task.destination_path = DEST
|
|
task.destination_name = name
|
|
task.automated = True
|
|
task.save = True
|
|
task.replace_existing = True
|
|
ui = unreal.FbxImportUI()
|
|
ui.import_mesh = True
|
|
ui.import_materials = True
|
|
ui.static_mesh_import_data.combine_meshes = True
|
|
task.options = ui
|
|
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
|
|
mesh = unreal.EditorAssetLibrary.load_asset(f"{DEST}/{name}")
|
|
log(f"{name}: imported as its own asset ({'ok' if mesh else 'MISSING'}); "
|
|
"LOD group wiring needs an editor session")
|
|
|
|
# Skeletal vehicle for Chaos is not built from this template yet: the hatch is a
|
|
# static model, and the drivable rig has to be authored around it.
|
|
skel_path = os.path.join(SOURCE, "vehicle_skeletal.fbx")
|
|
if os.path.exists(skel_path):
|
|
task = unreal.AssetImportTask()
|
|
task.filename = skel_path
|
|
task.destination_path = DEST
|
|
task.destination_name = "SK_Vehicle_Sedan"
|
|
task.automated = True
|
|
task.save = True
|
|
task.replace_existing = True
|
|
ui = unreal.FbxImportUI()
|
|
ui.import_mesh = True
|
|
ui.import_as_skeletal = True
|
|
ui.import_animations = False
|
|
ui.import_materials = True
|
|
ui.skeletal_mesh_import_data.import_uniform_scale = 1.0
|
|
task.options = ui
|
|
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
|
|
skel = unreal.EditorAssetLibrary.load_asset(f"{DEST}/SK_Vehicle_Sedan")
|
|
if skel:
|
|
skeleton = skel.get_editor_property("skeleton")
|
|
# Skeleton has no bone_names property in 5.8; read the reference skeleton
|
|
# through the asset registry instead of guessing a property name.
|
|
log(f"SK_Vehicle_Sedan: imported, skeleton={skeleton.get_name() if skeleton else 'NONE'}")
|
|
else:
|
|
log("SK_Vehicle_Sedan: MISSING after import")
|
|
lines.append("VERDICT: PASS")
|
|
|
|
|
|
try:
|
|
main()
|
|
except Exception as exc: # noqa: BLE001
|
|
import traceback
|
|
log(f"FAILED: {type(exc).__name__}: {exc}")
|
|
log(traceback.format_exc())
|
|
lines.append("VERDICT: FAIL")
|
|
|
|
unreal.EditorLoadingAndSavingUtils.save_dirty_packages(True, True)
|
|
with open(RESULT, "w") as f:
|
|
f.write("\n".join(lines) + "\n")
|