Add vehicle specification data model

This commit is contained in:
krustophski 2026-06-18 02:35:47 +03:00
parent 80abed5c98
commit 6f02325597
8 changed files with 819 additions and 1 deletions

View file

@ -0,0 +1,3 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "VehicleSystem/MrPlowVehicleSpecs.h"

View file

@ -0,0 +1,301 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Engine/DataAsset.h"
#include "MrPlowVehicleSpecs.generated.h"
UENUM(BlueprintType)
enum class EMrPlowWheelFormula : uint8
{
FourByTwo UMETA(DisplayName = "4x2"),
FourByFour UMETA(DisplayName = "4x4"),
SixByFour UMETA(DisplayName = "6x4"),
SixBySix UMETA(DisplayName = "6x6"),
EightByFour UMETA(DisplayName = "8x4"),
EightBySix UMETA(DisplayName = "8x6"),
EightByEight UMETA(DisplayName = "8x8")
};
UENUM(BlueprintType)
enum class EMrPlowFuelType : uint8
{
Diesel,
Methane,
Electric,
Hybrid
};
UENUM(BlueprintType)
enum class EMrPlowAttachmentType : uint8
{
DumpBody,
Cargo,
FrontPlow,
SidePlow,
FrontBrush,
MidBrush,
RearBrush,
SolidSpreader,
LiquidSpreader,
WasherBar,
WasherManipulator,
SnowBlower,
VacuumSweeper,
BarrierWasher
};
UENUM(BlueprintType)
enum class EMrPlowMountPoint : uint8
{
Front,
SideLeft,
SideRight,
MidAxle,
Rear,
DumpBody,
Hitch
};
USTRUCT(BlueprintType)
struct FMrPlowEngineSpec
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FName Model;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float DisplacementLiters = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float PowerHp = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float PowerRpm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float TorqueNm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float TorqueRpmMin = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float TorqueRpmMax = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
EMrPlowFuelType FuelType = EMrPlowFuelType::Diesel;
};
USTRUCT(BlueprintType)
struct FMrPlowTransmissionSpec
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FName Model;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
int32 ForwardGears = 0;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
TArray<float> ForwardRatios;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
TArray<float> ReverseRatios;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float FinalDriveRatio = 0.0f;
};
USTRUCT(BlueprintType)
struct FMrPlowAxleSpec
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FName Name;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FName LeftWheelBone;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FName RightWheelBone;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
bool bDriven = false;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
bool bSteerable = false;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
bool bDualTires = false;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float OffsetFromFrontAxleCm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float TrackWidthCm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float MaxLoadKg = 0.0f;
};
USTRUCT(BlueprintType)
struct FMrPlowHydraulicSystemSpec
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float TankVolumeLiters = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float PumpFlowLitersPerMin = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
int32 SectionCount = 0;
UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (ClampMin = "0"))
float SectionFlowLitersPerMin = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
bool bPowerTakeOffFromEngine = true;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
bool bPowerTakeOffFromGearbox = false;
};
USTRUCT(BlueprintType)
struct FMrPlowMountSocketSpec
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly)
EMrPlowMountPoint MountPoint = EMrPlowMountPoint::Front;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FName SocketName;
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FName ParentBoneName = TEXT("Body");
UPROPERTY(EditAnywhere, BlueprintReadOnly)
FTransform LocalTransform = FTransform::Identity;
};
UCLASS(BlueprintType)
class UMrPlowVehicleSpecData : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Identity")
FName VehicleId;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Identity")
FText DisplayName;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Identity")
FString Manufacturer;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Vehicle")
EMrPlowWheelFormula WheelFormula = EMrPlowWheelFormula::SixByFour;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Vehicle")
FMrPlowEngineSpec Engine;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Vehicle")
FMrPlowTransmissionSpec Transmission;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Vehicle")
FMrPlowHydraulicSystemSpec Hydraulics;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Vehicle")
TArray<FMrPlowAxleSpec> Axles;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Vehicle", meta = (ClampMin = "0"))
float EmptyMassKg = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Vehicle", meta = (ClampMin = "0"))
float GrossMassKg = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Vehicle", meta = (ClampMin = "0"))
float PayloadKg = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Dimensions", meta = (ClampMin = "0"))
float LengthCm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Dimensions", meta = (ClampMin = "0"))
float WidthCm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Dimensions", meta = (ClampMin = "0"))
float HeightCm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Dimensions", meta = (ClampMin = "0"))
float WheelRadiusCm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Mounts")
TArray<FMrPlowMountSocketSpec> MountSockets;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Validation")
FString SourceModelPath;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Validation")
TArray<FString> SourceUrls;
};
UCLASS(BlueprintType)
class UMrPlowAttachmentSpecData : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Identity")
FName AttachmentId;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Identity")
FText DisplayName;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Identity")
FString Manufacturer;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Attachment")
EMrPlowAttachmentType AttachmentType = EMrPlowAttachmentType::FrontPlow;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Attachment")
EMrPlowMountPoint MountPoint = EMrPlowMountPoint::Front;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Attachment", meta = (ClampMin = "0"))
float MassKg = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Operation", meta = (ClampMin = "0"))
float WorkingWidthCm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Operation", meta = (ClampMin = "0"))
float WorkingSpeedKmh = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Operation", meta = (ClampMin = "0"))
float HydraulicFlowLitersPerMin = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Operation", meta = (ClampMin = "0"))
float HopperVolumeM3 = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Operation", meta = (ClampMin = "0"))
float WaterFlowLitersPerMin = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Operation", meta = (ClampMin = "0"))
float WaterPressureBar = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Operation", meta = (ClampMin = "0"))
float BrushDiameterCm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Operation", meta = (ClampMin = "0"))
float BrushRpm = 0.0f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Validation")
FString SourceModelPath;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Validation")
TArray<FString> SourceUrls;
};

View file

@ -24,6 +24,7 @@ public class mrPlow58 : ModuleRules
"mrPlow58",
"mrPlow58/SportsCar",
"mrPlow58/OffroadCar",
"mrPlow58/VehicleSystem",
"mrPlow58/Variant_OffRoad",
"mrPlow58/Variant_TimeTrial",
"mrPlow58/Variant_TimeTrial/UI"

View file

@ -4,6 +4,12 @@ Goal: KAMAZ is not imported as a loose mesh. It becomes a Chaos Vehicle skeletal
## Source Assets
All source working models must be saved in:
- `C:/Users/post/Documents/mrPlow/in`
Do not treat exported FBX files as source of truth. FBX files under `VehicleExports/` are generated artifacts for Unreal import.
- `C:/Users/post/Documents/mrPlow/in/kamaz_65115.blend`
- `C:/Users/post/Documents/mrPlow/in/kraz_6322 .blend`
@ -70,6 +76,24 @@ Example:
& "C:/Program Files/Blender Foundation/Blender 5.1/blender.exe" --background --python "C:/Users/post/Documents/mrPlow/mrPlow58/Tools/VehiclePipeline/prepare_vehicle_exports.py" -- --input-root "C:/Users/post/Documents/mrPlow/in" --output-root "C:/Users/post/Documents/mrPlow/mrPlow58/VehicleExports"
```
## Scale And Axis Validation
Before importing a vehicle into Unreal, run:
```powershell
& "C:/Program Files/Blender Foundation/Blender 5.1/blender.exe" --background --python "C:/Users/post/Documents/mrPlow/mrPlow58/Tools/VehiclePipeline/audit_blend_scale.py" -- --input-root "C:/Users/post/Documents/mrPlow/in" --spec "C:/Users/post/Documents/mrPlow/mrPlow58/Tools/VehiclePipeline/Specs/vehicle_specs_seed.json" --output "C:/Users/post/Documents/mrPlow/mrPlow58/VehicleExports/model_scale_audit.json"
```
Unreal convention for all vehicle imports:
- `X` forward
- `Y` right
- `Z` up
- Unreal units are centimeters
- Blender source units are meters
- after import, asset scale must be `1, 1, 1`
- `Root` bone must be at world origin
Next Unreal steps:
1. Import `SK_Kamaz_Chassis.fbx` as Skeletal Mesh.
@ -78,4 +102,3 @@ Next Unreal steps:
4. Create Chaos wheel classes for front/rear or each axle group.
5. Create `BP_KamazBase` with `ChaosWheeledVehicleMovementComponent`.
6. Attach module meshes to sockets from data assets.

View file

@ -0,0 +1,120 @@
{
"version": 1,
"units": {
"length": "cm",
"speed": "kmh",
"flow": "litersPerMin",
"pressure": "bar"
},
"attachments": [
{
"attachmentId": "kamaz_kuzov",
"displayName": "KAMAZ KUZOV",
"attachmentType": "dumpBody",
"mountPoint": "dumpBody",
"sourceModelPath": "C:/Users/post/Documents/mrPlow/in/kamaz_65115.blend",
"sourceObjectName": "KUZOV"
},
{
"attachmentId": "kamaz_gruz",
"displayName": "KAMAZ GRUZ",
"attachmentType": "cargo",
"mountPoint": "dumpBody",
"sourceModelPath": "C:/Users/post/Documents/mrPlow/in/kamaz_65115.blend",
"sourceObjectName": "GRUZ"
},
{
"attachmentId": "kraz_body_for_bulk",
"displayName": "KrAZ body for bulk",
"attachmentType": "dumpBody",
"mountPoint": "rear",
"sourceModelPath": "C:/Users/post/Documents/mrPlow/in/kraz_6322 .blend",
"sourceObjectName": "body for bulk"
},
{
"attachmentId": "kraz_blade_bucket",
"displayName": "KrAZ blade bucket",
"attachmentType": "frontPlow",
"mountPoint": "front",
"sourceModelPath": "C:/Users/post/Documents/mrPlow/in/kraz_6322 .blend",
"sourceObjectName": "blade bucket"
},
{
"attachmentId": "merkator_front_plow_fsm_3400r",
"displayName": "Merkator FSM-3400R front plow",
"attachmentType": "frontPlow",
"mountPoint": "front",
"workingWidthCm": [275, 294],
"workingSpeedKmh": 40,
"sourceUrls": ["https://merkatorgroup.ru/equipment/navesnoe-oborudovanie/pluzhnoe-oborudovanie/"]
},
{
"attachmentId": "merkator_side_plow_aa29",
"displayName": "Merkator AA29 side plow",
"attachmentType": "sidePlow",
"mountPoint": "sideRight",
"workingWidthCm": 200,
"angleOpenDeg": 40,
"sourceUrls": ["https://merkatorgroup.ru/equipment/navesnoe-oborudovanie/pluzhnoe-oborudovanie/"]
},
{
"attachmentId": "merkator_mid_brush_mpo",
"displayName": "Merkator MPO mid brush",
"attachmentType": "midBrush",
"mountPoint": "midAxle",
"brushDiameterCm": [40, 55],
"workingSpeedKmh": 30,
"sourceUrls": ["https://merkatorgroup.ru/equipment/navesnoe-oborudovanie/shchetochnoe-oborudovanie/"]
},
{
"attachmentId": "merkator_rear_brush_zpo_268_55",
"displayName": "Merkator ZPO 268-55 rear brush",
"attachmentType": "rearBrush",
"mountPoint": "rear",
"brushRpm": 300,
"workingSpeedKmh": 30,
"downforceKg": 500,
"sourceUrls": ["https://merkatorgroup.ru/equipment/navesnoe-oborudovanie/shchetochnoe-oborudovanie/"]
},
{
"attachmentId": "merkator_solid_spreader_uh",
"displayName": "Merkator UH solid material spreader",
"attachmentType": "solidSpreader",
"mountPoint": "rear",
"hopperVolumeM3": [4, 16],
"spreadingWidthCm": [200, 1200],
"sourceUrls": ["https://merkatorgroup.ru/equipment/navesnoe-oborudovanie/raspredeliteli-tverdykh-protivogololednykh-materialov/"]
},
{
"attachmentId": "merkator_liquid_spreader_cr",
"displayName": "Merkator CR liquid material spreader",
"attachmentType": "liquidSpreader",
"mountPoint": "rear",
"waterFlowLitersPerMin": 800,
"workingSpeedKmh": 60,
"spreadingWidthCm": 1400,
"sourceUrls": ["https://merkatorgroup.ru/equipment/navesnoe-oborudovanie/raspredeliteli-zhidkikh-materialov/"]
},
{
"attachmentId": "merkator_washer_fmo_10_600",
"displayName": "Merkator FMO 10-600 washer bar",
"attachmentType": "washerBar",
"mountPoint": "front",
"waterFlowLitersPerMin": 600,
"waterPressureBar": 10,
"workingSpeedKmh": [8, 16],
"sourceUrls": ["https://merkatorgroup.ru/equipment/navesnoe-oborudovanie/polivomoechnoe-oborudovanie/"]
},
{
"attachmentId": "merkator_snow_blower_rs_400",
"displayName": "Merkator RS-400 rotary snow blower",
"attachmentType": "snowBlower",
"mountPoint": "front",
"capacityTonnesPerHour": 1300,
"throwDistanceM": 30,
"workingWidthCm": 250,
"loadingHeightCm": 400,
"sourceUrls": ["https://merkatorgroup.ru/equipment/navesnoe-oborudovanie/avtonomnoe-snegoochistitelnoe-oborudovanie/"]
}
]
}

View file

@ -0,0 +1,150 @@
{
"version": 1,
"units": {
"length": "cm",
"mass": "kg",
"speed": "kmh",
"torque": "Nm"
},
"vehicles": [
{
"vehicleId": "kamaz_65115",
"displayName": "KAMAZ 65115",
"manufacturer": "KAMAZ",
"sourceModelPath": "C:/Users/post/Documents/mrPlow/in/kamaz_65115.blend",
"wheelFormula": "6x4",
"fuelType": "diesel",
"emptyMassKg": 10125,
"grossMassKg": 25200,
"payloadKg": 15000,
"dimensionsCm": {
"length": 698,
"width": 255,
"height": 286.5
},
"wheelbaseCm": [315, 132],
"wheelRadiusCm": 50,
"engine": {
"model": "KAMAZ-667.511-300 / Cummins ISB6.7 class",
"displacementLiters": 6.7,
"powerHp": 298,
"powerRpm": 2500,
"torqueNm": 1097,
"torqueRpmMin": 1400,
"torqueRpmMax": 1400
},
"transmission": {
"model": "ZF 9S1310TO / 1310TO class",
"forwardGears": 9,
"forwardRatios": [],
"reverseRatios": [],
"finalDriveRatio": 5.94,
"needsExactRatios": true
},
"hydraulics": {
"tankVolumeLiters": 160,
"pumpFlowLitersPerMin": 140,
"sectionCountMin": 4,
"sectionCountMax": 8,
"sectionFlowLitersPerMin": 90,
"powerTakeOff": ["engine", "gearbox"]
},
"axles": [
{
"name": "front",
"leftWheelBone": "Phys_Wheel_FL",
"rightWheelBone": "Phys_Wheel_FR",
"driven": false,
"steerable": true,
"dualTires": false
},
{
"name": "rear_1",
"leftWheelBone": "Phys_Wheel_ML1",
"rightWheelBone": "Phys_Wheel_MR1",
"driven": true,
"steerable": false,
"dualTires": true
},
{
"name": "rear_2",
"leftWheelBone": "Phys_Wheel_RL1",
"rightWheelBone": "Phys_Wheel_RR1",
"driven": true,
"steerable": false,
"dualTires": true
}
],
"mountSockets": [
{"mountPoint": "front", "socketName": "Socket_FrontBlade", "parentBoneName": "Body"},
{"mountPoint": "midAxle", "socketName": "Socket_Broom", "parentBoneName": "Body"},
{"mountPoint": "rear", "socketName": "Socket_RearModule", "parentBoneName": "Body"},
{"mountPoint": "dumpBody", "socketName": "Socket_Cargo", "parentBoneName": "Body"},
{"mountPoint": "hitch", "socketName": "Socket_Hitch", "parentBoneName": "Body"}
],
"sourceUrls": [
"https://td-kama.ru/catalog/samosvaly/kamaz65115/",
"https://merkatorgroup.ru/equipment/dorozhno-kommunalnaya-tekhnika/kombinirovannye-dorozhnye-mashiny/"
],
"notes": [
"KAMAZ 65115 has many modifications. Exact gearbox ratios must be confirmed for the selected chassis.",
"Source model may include KDM equipment, so Blender bounds can be longer than bare dump truck passport length."
]
},
{
"vehicleId": "kraz_6322",
"displayName": "KrAZ 6322",
"manufacturer": "KrAZ",
"sourceModelPath": "C:/Users/post/Documents/mrPlow/in/kraz_6322 .blend",
"wheelFormula": "6x6",
"fuelType": "diesel",
"emptyMassKg": 0,
"grossMassKg": 0,
"payloadKg": 12000,
"dimensionsCm": {
"length": 0,
"width": 0,
"height": 0
},
"wheelRadiusCm": 58,
"engine": {
"model": "YaMZ-238D / YaMZ-238DE2 class",
"displacementLiters": 14.86,
"powerHp": 330,
"powerRpm": 2100,
"torqueNm": 1225,
"torqueRpmMin": 1200,
"torqueRpmMax": 1400
},
"transmission": {
"model": "YaMZ-238B two-range manual",
"forwardGears": 8,
"forwardRatios": [7.30, 4.86, 3.50, 2.48, 2.09, 1.39, 1.00, 0.71],
"reverseRatios": [10.46, 2.99],
"finalDriveRatio": 0,
"needsExactRatios": true
},
"hydraulics": {
"tankVolumeLiters": 0,
"pumpFlowLitersPerMin": 0,
"sectionCountMin": 0,
"sectionCountMax": 0,
"sectionFlowLitersPerMin": 0,
"powerTakeOff": []
},
"axles": [
{"name": "front", "driven": true, "steerable": true, "dualTires": false},
{"name": "rear_1", "driven": true, "steerable": false, "dualTires": true},
{"name": "rear_2", "driven": true, "steerable": false, "dualTires": true}
],
"sourceUrls": [
"https://petertraktor.ru/catalog/product/shassi-vysokoj-prohodimosti-kraz-6322-kraz-63221/",
"https://www.avtomash.ru/pred/kraz/kr6322.htm"
],
"notes": [
"Dimensions and exact final drive are intentionally left for verification from a primary/passport source.",
"Current KrAZ file is used first as module donor: body for bulk and blade bucket."
]
}
]
}

View file

@ -0,0 +1,128 @@
import argparse
import json
import sys
from pathlib import Path
import bpy
from mathutils import Vector
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--input-root", required=True)
parser.add_argument("--spec", required=True)
parser.add_argument("--output", required=True)
argv = sys.argv
if "--" in argv:
argv = argv[argv.index("--") + 1:]
else:
argv = []
return parser.parse_args(argv)
def mesh_objects():
return [obj for obj in bpy.context.scene.objects if obj.type == "MESH"]
def world_bounds(objects):
points = []
for obj in objects:
for corner in obj.bound_box:
points.append(obj.matrix_world @ Vector(corner))
if not points:
return Vector((0, 0, 0)), Vector((0, 0, 0))
return (
Vector((min(p.x for p in points), min(p.y for p in points), min(p.z for p in points))),
Vector((max(p.x for p in points), max(p.y for p in points), max(p.z for p in points))),
)
def pct_error(actual, expected):
if not expected:
return None
return round(((actual - expected) / expected) * 100.0, 2)
def audit_vehicle(vehicle, input_root):
source_path = Path(vehicle["sourceModelPath"])
if not source_path.is_absolute():
source_path = input_root / source_path
result = {
"vehicleId": vehicle["vehicleId"],
"sourceModelPath": str(source_path),
"exists": source_path.exists(),
"issues": [],
}
if not source_path.exists():
result["issues"].append("Source blend file is missing")
return result
bpy.ops.wm.open_mainfile(filepath=str(source_path))
objects = mesh_objects()
min_v, max_v = world_bounds(objects)
size_m = max_v - min_v
size_cm = {
"lengthX": round(size_m.x * 100.0, 2),
"widthY": round(size_m.y * 100.0, 2),
"heightZ": round(size_m.z * 100.0, 2),
}
result["meshObjectCount"] = len(objects)
result["boundsCm"] = size_cm
result["boundsMinM"] = [round(min_v.x, 4), round(min_v.y, 4), round(min_v.z, 4)]
result["boundsMaxM"] = [round(max_v.x, 4), round(max_v.y, 4), round(max_v.z, 4)]
result["sceneUnitSystem"] = bpy.context.scene.unit_settings.system
result["sceneScaleLength"] = bpy.context.scene.unit_settings.scale_length
dims = vehicle.get("dimensionsCm", {})
result["passportDimensionsCm"] = dims
result["dimensionErrorPct"] = {
"lengthX": pct_error(size_cm["lengthX"], dims.get("length", 0)),
"widthY": pct_error(size_cm["widthY"], dims.get("width", 0)),
"heightZ": pct_error(size_cm["heightZ"], dims.get("height", 0)),
}
if size_cm["lengthX"] < size_cm["widthY"]:
result["issues"].append("X is not the longest dimension; verify forward axis")
if bpy.context.scene.unit_settings.scale_length not in (0.0, 1.0):
result["issues"].append("Scene unit scale is not 1.0")
negative_scale = [
obj.name for obj in objects
if obj.scale.x < 0 or obj.scale.y < 0 or obj.scale.z < 0
]
non_unit_scale = [
obj.name for obj in objects
if any(abs(v - 1.0) > 0.001 for v in (obj.scale.x, obj.scale.y, obj.scale.z))
]
result["negativeScaleObjects"] = negative_scale
result["nonUnitScaleObjectCount"] = len(non_unit_scale)
if negative_scale:
result["issues"].append("Negative scale objects must be applied before final export")
if non_unit_scale:
result["issues"].append("Non-unit scale objects must be applied before final export")
return result
def main():
args = parse_args()
input_root = Path(args.input_root)
spec = json.loads(Path(args.spec).read_text(encoding="utf-8"))
results = {
"axisConvention": {
"unrealForward": "X",
"unrealRight": "Y",
"unrealUp": "Z",
"unrealUnits": "cm",
"blenderUnits": "m",
},
"vehicles": [audit_vehicle(vehicle, input_root) for vehicle in spec["vehicles"]],
}
output = Path(args.output)
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(json.dumps(results, indent=2), encoding="utf-8")
if __name__ == "__main__":
main()

View file

@ -0,0 +1,92 @@
{
"axisConvention": {
"unrealForward": "X",
"unrealRight": "Y",
"unrealUp": "Z",
"unrealUnits": "cm",
"blenderUnits": "m"
},
"vehicles": [
{
"vehicleId": "kamaz_65115",
"sourceModelPath": "C:\\Users\\post\\Documents\\mrPlow\\in\\kamaz_65115.blend",
"exists": true,
"issues": [
"Negative scale objects must be applied before final export",
"Non-unit scale objects must be applied before final export"
],
"meshObjectCount": 63,
"boundsCm": {
"lengthX": 848.2,
"widthY": 313.41,
"heightZ": 329.19
},
"boundsMinM": [
-3.7202,
-1.6072,
-0.3397
],
"boundsMaxM": [
4.7618,
1.5268,
2.9522
],
"sceneUnitSystem": "METRIC",
"sceneScaleLength": 1.0,
"passportDimensionsCm": {
"length": 698,
"width": 255,
"height": 286.5
},
"dimensionErrorPct": {
"lengthX": 21.52,
"widthY": 22.91,
"heightZ": 14.9
},
"negativeScaleObjects": [
"fuel_tank_other",
"bolt013",
"bolt012"
],
"nonUnitScaleObjectCount": 63
},
{
"vehicleId": "kraz_6322",
"sourceModelPath": "C:\\Users\\post\\Documents\\mrPlow\\in\\kraz_6322 .blend",
"exists": true,
"issues": [
"Non-unit scale objects must be applied before final export"
],
"meshObjectCount": 25,
"boundsCm": {
"lengthX": 1019.57,
"widthY": 396.15,
"heightZ": 309.03
},
"boundsMinM": [
-5.1013,
-1.9807,
-1.5452
],
"boundsMaxM": [
5.0944,
1.9807,
1.5451
],
"sceneUnitSystem": "METRIC",
"sceneScaleLength": 1.0,
"passportDimensionsCm": {
"length": 0,
"width": 0,
"height": 0
},
"dimensionErrorPct": {
"lengthX": null,
"widthY": null,
"heightZ": null
},
"negativeScaleObjects": [],
"nonUnitScaleObjectCount": 25
}
]
}