From b2cf8ded10bd3f335b5d4177a3eb362e597d5ddc Mon Sep 17 00:00:00 2001 From: krustophski Date: Thu, 18 Jun 2026 07:02:31 +0300 Subject: [PATCH] Import empty KAMAZ chassis --- .../Vehicles/Kamaz/SK_Kamaz_Chassis.uasset | 3 + .../Kamaz/SK_Kamaz_Chassis_Skeleton.uasset | 3 + Tools/Unreal/import_kamaz_chassis.py | 106 ++++++++++++++++++ .../unreal_import_kamaz_chassis_report.json | 28 +++++ 4 files changed, 140 insertions(+) create mode 100644 Content/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis.uasset create mode 100644 Content/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis_Skeleton.uasset create mode 100644 Tools/Unreal/import_kamaz_chassis.py create mode 100644 VehicleExports/unreal_import_kamaz_chassis_report.json diff --git a/Content/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis.uasset b/Content/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis.uasset new file mode 100644 index 0000000..40eadec --- /dev/null +++ b/Content/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed8b660a29a9eadcc1020330f3044180d0fbeca4e77ff98870b3578d6d53a45c +size 121290533 diff --git a/Content/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis_Skeleton.uasset b/Content/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis_Skeleton.uasset new file mode 100644 index 0000000..7e25810 --- /dev/null +++ b/Content/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis_Skeleton.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5186d33bf037e6bcf028c8fc802ca08ed9d73e35b49ed835359292887f8c06b0 +size 4611 diff --git a/Tools/Unreal/import_kamaz_chassis.py b/Tools/Unreal/import_kamaz_chassis.py new file mode 100644 index 0000000..0ba692c --- /dev/null +++ b/Tools/Unreal/import_kamaz_chassis.py @@ -0,0 +1,106 @@ +import json +from pathlib import Path + +import unreal + + +PROJECT_ROOT = Path(r"C:/Users/post/Documents/mrPlow/mrPlow58") +SOURCE_FBX = PROJECT_ROOT / "VehicleExports" / "SK_Kamaz_Chassis.fbx" +DESTINATION_PATH = "/Game/MrPlow/Vehicles/Kamaz" +ASSET_NAME = "SK_Kamaz_Chassis" +REPORT_PATH = PROJECT_ROOT / "VehicleExports" / "unreal_import_kamaz_chassis_report.json" + + +def set_if_present(obj, property_name, value): + try: + obj.set_editor_property(property_name, value) + return True + except Exception: + return False + + +def import_chassis(): + if not SOURCE_FBX.exists(): + raise FileNotFoundError(f"Missing source FBX: {SOURCE_FBX}") + + unreal.EditorAssetLibrary.make_directory(DESTINATION_PATH) + + options = unreal.FbxImportUI() + options.set_editor_property("import_mesh", True) + options.set_editor_property("import_as_skeletal", True) + options.set_editor_property("import_materials", False) + options.set_editor_property("import_textures", False) + options.set_editor_property("create_physics_asset", True) + options.set_editor_property("mesh_type_to_import", unreal.FBXImportType.FBXIT_SKELETAL_MESH) + + skeletal_data = options.get_editor_property("skeletal_mesh_import_data") + if skeletal_data: + set_if_present(skeletal_data, "import_uniform_scale", 1.0) + set_if_present(skeletal_data, "convert_scene", True) + set_if_present(skeletal_data, "convert_scene_unit", True) + set_if_present(skeletal_data, "force_front_x_axis", False) + set_if_present(skeletal_data, "import_meshes_in_bone_hierarchy", True) + set_if_present(skeletal_data, "use_t0_as_ref_pose", True) + + task = unreal.AssetImportTask() + task.set_editor_property("filename", str(SOURCE_FBX)) + task.set_editor_property("destination_path", DESTINATION_PATH) + task.set_editor_property("destination_name", ASSET_NAME) + task.set_editor_property("automated", True) + task.set_editor_property("replace_existing", True) + task.set_editor_property("save", True) + task.set_editor_property("options", options) + + unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task]) + imported_paths = list(task.get_editor_property("imported_object_paths") or []) + if not imported_paths: + raise RuntimeError("KAMAZ chassis import produced no assets") + + skeletal_mesh = unreal.load_asset(f"{DESTINATION_PATH}/{ASSET_NAME}.{ASSET_NAME}") + if not skeletal_mesh: + raise RuntimeError(f"Could not load imported skeletal mesh {DESTINATION_PATH}/{ASSET_NAME}") + + skeleton = skeletal_mesh.get_editor_property("skeleton") + physics_asset = None + try: + physics_asset = skeletal_mesh.get_editor_property("physics_asset") + except Exception: + physics_asset = None + + if not skeleton: + raise RuntimeError(f"{skeletal_mesh.get_path_name()} has no skeleton") + bone_names = [str(name) for name in skeleton.get_reference_pose().get_bone_names()] + + expected_bones = [ + "Root", + "Body", + "Phys_Wheel_FL", + "Phys_Wheel_FR", + "Phys_Wheel_ML1", + "Phys_Wheel_ML2", + "Phys_Wheel_MR1", + "Phys_Wheel_MR2", + "Phys_Wheel_RL1", + "Phys_Wheel_RL2", + "Phys_Wheel_RR1", + "Phys_Wheel_RR2", + ] + missing_bones = [name for name in expected_bones if name not in bone_names] + + report = { + "sourceFbx": str(SOURCE_FBX), + "destinationPath": DESTINATION_PATH, + "assetName": ASSET_NAME, + "importedObjectPaths": imported_paths, + "skeletalMesh": skeletal_mesh.get_path_name(), + "skeleton": skeleton.get_path_name() if skeleton else None, + "physicsAsset": physics_asset.get_path_name() if physics_asset else None, + "boneNames": bone_names, + "missingExpectedBones": missing_bones, + "ok": len(missing_bones) == 0, + } + REPORT_PATH.write_text(json.dumps(report, indent=2) + "\n", encoding="utf-8") + unreal.log(f"Imported KAMAZ chassis: {json.dumps(report)}") + + +import_chassis() diff --git a/VehicleExports/unreal_import_kamaz_chassis_report.json b/VehicleExports/unreal_import_kamaz_chassis_report.json new file mode 100644 index 0000000..baa2017 --- /dev/null +++ b/VehicleExports/unreal_import_kamaz_chassis_report.json @@ -0,0 +1,28 @@ +{ + "sourceFbx": "C:\\Users\\post\\Documents\\mrPlow\\mrPlow58\\VehicleExports\\SK_Kamaz_Chassis.fbx", + "destinationPath": "/Game/MrPlow/Vehicles/Kamaz", + "assetName": "SK_Kamaz_Chassis", + "importedObjectPaths": [ + "/Game/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis.SK_Kamaz_Chassis" + ], + "skeletalMesh": "/Game/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis.SK_Kamaz_Chassis", + "skeleton": "/Game/MrPlow/Vehicles/Kamaz/SK_Kamaz_Chassis_Skeleton.SK_Kamaz_Chassis_Skeleton", + "physicsAsset": null, + "boneNames": [ + "SK_Kamaz_Chassis_Armature", + "Root", + "Body", + "Phys_Wheel_FL", + "Phys_Wheel_FR", + "Phys_Wheel_ML1", + "Phys_Wheel_ML2", + "Phys_Wheel_MR1", + "Phys_Wheel_MR2", + "Phys_Wheel_RL1", + "Phys_Wheel_RL2", + "Phys_Wheel_RR1", + "Phys_Wheel_RR2" + ], + "missingExpectedBones": [], + "ok": true +}