One directory with sixty scripts stopped being navigable, and the grouping is also the sandbox boundary:
Tools/unreal/ commandlets and the two map builders, with ue_common.py and ue_placement.py as the
shared imports (they need the engine)
Tools/blender/ builders, exporters, the FBX preset, the MPFB character pipeline, blender_screenshots
(they need the Blender Flatpak)
Tools/review/ the visual loop: render_screenshots.sh, judge_screenshot.py, hero_compare.py,
build_comparison_md.py, e2e_asset_check.py, hero_iterate.sh, visual_loop.py,
visual_targets.json
Tools/gen/ image and texture generation: the ComfyUI driver, deterministic texture writers,
reference fetching
Tools/input/ OS-level input injection
root _common.py, check-lfs.sh, addon_compat_probe.py, sibling_asset_audit.py, tests/
Every moved script now resolves the repository root as ../.. and puts the tools root plus its siblings on
sys.path, so 'import ue_common' still works from unreal/. The test suite bootstrap does the same for the five
folders. render_screenshots.sh takes the folder as a third argument to run_cmdlet, and the e2e driver,
hero_iterate.sh and the comparison generator were repointed.
51 README rows now link to their new location, the README gains a Layout section naming each folder's
sandbox, and the architecture notes and Blender README follow the moves.
Verified: 108 tests pass, prettier is clean, judge_screenshot.py and hero_compare.py run from their new
homes, and the e2e run was aborted mid-way (it had been rebuilding an empty DemoMap for 15 minutes) and is
being rerun against the new layout.
118 lines
4.5 KiB
Python
118 lines
4.5 KiB
Python
# Unreal-side half of the MPFB character acceptance: imports the skeletal FBX
|
|
# with the named import preset "ue_character_v1" and verifies the result.
|
|
#
|
|
# UnrealEditor-Cmd <uproject> -run=pythonscript -script=<repo>/Tools/unreal/ue_character_import.py \
|
|
# -nullrhi -unattended -nopause -stdout
|
|
|
|
import unreal
|
|
|
|
FBX = "/tmp/gigline/character.fbx"
|
|
DEST = "/Game/Test/Character"
|
|
REPORT = "/tmp/ue-character-result.txt"
|
|
lines = []
|
|
|
|
|
|
def log(msg):
|
|
lines.append(str(msg))
|
|
|
|
|
|
def import_character():
|
|
if unreal.EditorAssetLibrary.does_directory_exist(DEST):
|
|
unreal.EditorAssetLibrary.delete_directory(DEST)
|
|
task = unreal.AssetImportTask()
|
|
task.filename = FBX
|
|
task.destination_path = DEST
|
|
task.automated = True
|
|
task.save = True
|
|
task.replace_existing = True
|
|
|
|
ui = unreal.FbxImportUI()
|
|
ui.import_mesh = True
|
|
ui.import_materials = True
|
|
ui.import_textures = True
|
|
ui.import_as_skeletal = True
|
|
ui.import_animations = False
|
|
|
|
smd = ui.skeletal_mesh_import_data
|
|
smd.import_uniform_scale = 1.0
|
|
smd.convert_scene_unit = False
|
|
smd.force_front_x_axis = False
|
|
smd.normal_import_method = unreal.FBXNormalImportMethod.FBXNIM_IMPORT_NORMALS
|
|
task.options = ui
|
|
|
|
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
|
|
unreal.EditorLoadingAndSavingUtils.save_dirty_packages(True, True)
|
|
|
|
|
|
def import_texture_and_material():
|
|
# Interchange 5.8 does not create material/texture assets for skeletal
|
|
# FBX imports; finish the baked-material chain explicitly.
|
|
task = unreal.AssetImportTask()
|
|
task.filename = "/tmp/gigline/T_Character_Diffuse.png"
|
|
task.destination_path = DEST
|
|
task.automated = True
|
|
task.save = True
|
|
task.replace_existing = True
|
|
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
|
|
|
|
tex = unreal.EditorAssetLibrary.load_asset(f"{DEST}/T_Character_Diffuse")
|
|
log(f"texture: {tex.get_class().get_name() if tex else 'MISSING'}")
|
|
|
|
mat_path = f"{DEST}/M_Character_Export"
|
|
if unreal.EditorAssetLibrary.does_asset_exist(mat_path):
|
|
unreal.EditorAssetLibrary.delete_asset(mat_path)
|
|
mat = unreal.AssetToolsHelpers.get_asset_tools().create_asset(
|
|
"M_Character_Export", DEST, unreal.Material, unreal.MaterialFactoryNew())
|
|
tex_expr = unreal.MaterialEditingLibrary.create_material_expression(
|
|
mat, unreal.MaterialExpressionTextureSample)
|
|
tex_expr.set_editor_property("texture", tex)
|
|
unreal.MaterialEditingLibrary.connect_material_property(
|
|
tex_expr, "RGB", unreal.MaterialProperty.MP_BASE_COLOR)
|
|
unreal.MaterialEditingLibrary.recompile_material(mat)
|
|
|
|
sm = unreal.EditorAssetLibrary.load_asset(f"{DEST}/character")
|
|
entry = unreal.SkeletalMaterial()
|
|
entry.set_editor_property("material_interface", mat)
|
|
entry.set_editor_property("material_slot_name", "M_Character_Export")
|
|
sm.set_editor_property("materials", [entry])
|
|
unreal.EditorAssetLibrary.save_loaded_asset(sm)
|
|
log("material assigned to slot 0 (via SkeletalMaterial.material_interface)")
|
|
unreal.EditorLoadingAndSavingUtils.save_dirty_packages(True, True)
|
|
|
|
|
|
def verify():
|
|
sm = unreal.EditorAssetLibrary.load_asset(f"{DEST}/character")
|
|
if sm is None:
|
|
log(f"MISSING skeletal asset {DEST}/character; assets: {unreal.EditorAssetLibrary.list_assets(DEST)}")
|
|
return
|
|
log(f"class: {sm.get_class().get_name()}")
|
|
try:
|
|
skel = sm.get_editor_property("skeleton")
|
|
tree = skel.get_editor_property("bone_tree")
|
|
log(f"bones: {len(tree)}")
|
|
except Exception as exc: # noqa
|
|
log(f"bone count unavailable: {exc!r}")
|
|
try:
|
|
mats = sm.get_editor_property("materials")
|
|
log(f"material slots: {len(mats)} -> {[m.get_editor_property('material_slot_name') for m in mats]}")
|
|
except Exception as exc: # noqa
|
|
log(f"material slots unavailable: {exc!r}")
|
|
try:
|
|
bounds = sm.get_editor_property("bounds")
|
|
o, e = bounds.origin, bounds.box_extent
|
|
log(f"bounds cm: size=({e.x * 2:.1f}, {e.y * 2:.1f}, {e.z * 2:.1f}) origin=({o.x:.1f}, {o.y:.1f}, {o.z:.1f})")
|
|
except Exception as exc: # noqa
|
|
log(f"bounds unavailable: {exc!r}")
|
|
log(f"assets: {unreal.EditorAssetLibrary.list_assets(DEST)}")
|
|
# materials actually imported as assets?
|
|
for a in unreal.EditorAssetLibrary.list_assets(DEST):
|
|
obj = unreal.EditorAssetLibrary.load_asset(a)
|
|
log(f" {a} : {obj.get_class().get_name()}")
|
|
|
|
|
|
import_character()
|
|
import_texture_and_material()
|
|
verify()
|
|
with open(REPORT, "w") as f:
|
|
f.write("\n".join(lines) + "\n")
|