LifePlay-Revival/Tools/ImportQuaternius.py

41 lines
1.7 KiB
Python
Raw Normal View History

# Importe le mannequin et les animations CC0 de Quaternius (Universal Animation Library, sans root motion).
#
# Usage :
# UnrealEditor-Cmd.exe <projet> -run=pythonscript "-script=<projet>/Tools/ImportQuaternius.py" -unattended -nopause -nosplash
# Sortie : lignes "QUATERNIUS" du journal.
import unreal
glb = "D:/Game/Universal Animation Library[Standard]/Unreal-Godot/UAL1_Standard.glb"
dest = "/Game/Quaternius/UAL"
task = unreal.AssetImportTask()
task.filename = glb
task.destination_path = dest
task.automated = True
task.replace_existing = True
task.save = True
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])
reported = list(task.imported_object_paths)
unreal.log_warning("QUATERNIUS tache %d objet(s)" % len(reported))
for path in reported:
unreal.log_warning("QUATERNIUS PATH %s" % path)
if not unreal.EditorAssetLibrary.does_directory_exist(dest):
unreal.log_error("QUATERNIUS dossier absent %s" % dest)
else:
unreal.EditorAssetLibrary.save_directory(dest, False, True)
assets = unreal.EditorAssetLibrary.list_assets(dest, True, False)
unreal.log_warning("QUATERNIUS dossier %d asset(s)" % len(assets))
for path in assets:
asset = unreal.load_asset(path)
kind = asset.get_class().get_name() if asset else "null"
extra = ""
if isinstance(asset, unreal.SkeletalMesh):
box = asset.get_bounds()
extra = " origin=(%.1f %.1f %.1f) extent=(%.1f %.1f %.1f)" % (
box.origin.x, box.origin.y, box.origin.z,
box.box_extent.x, box.box_extent.y, box.box_extent.z)
unreal.log_warning("QUATERNIUS ASSET %s %s%s" % (kind, path, extra))