From 9845824a1b169b5ab4157aea29f10aa635a9bf7b Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 31 Jul 2024 17:52:05 +0800 Subject: [PATCH 1/8] align the loaded frame range to db --- .../plugins/load/load_skeletalmesh_abc.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py b/client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py index 21a5c500..f2073cc2 100644 --- a/client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py +++ b/client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py @@ -72,6 +72,8 @@ def get_task(filename, asset_dir, asset_name, replace, loaded_options): options.set_editor_property( 'import_type', unreal.AlembicImportType.SKELETAL) + options.sampling_settings.frame_start = loaded_options.get("frameStart", 1) + options.sampling_settings.frame_end = loaded_options.get("frameEnd", 1) if loaded_options.get("abc_material_settings") == "create_materials": mat_settings.set_editor_property("create_materials", True) @@ -95,6 +97,7 @@ def get_task(filename, asset_dir, asset_name, replace, loaded_options): flip_u=False, flip_v=False, rotation=[0.0, 0.0, 0.0], scale=[1.0, 1.0, 1.0]) + options.conversion_settings = conversion_settings options.material_settings = mat_settings @@ -159,8 +162,9 @@ def load(self, context, name, namespace, options): list(str): list of container content """ # Create directory for asset and ayon container - folder_path = context["folder"]["path"] - folder_name = context["folder"]["name"] + folder_entity = context["folder"] + folder_path = folder_entity["path"] + folder_name = folder_entity["name"] suffix = "_CON" asset_name = f"{folder_name}_{name}" if folder_name else f"{name}" version = context["version"]["version"] @@ -173,7 +177,9 @@ def load(self, context, name, namespace, options): loaded_options = { "default_conversion": options.get("default_conversion", False), "abc_conversion_preset": options.get("abc_conversion_preset", "maya"), - "abc_material_settings": options.get("abc_material_settings", "no_material") + "abc_material_settings": options.get("abc_material_settings", "no_material"), + "frameStart": folder_entity["attrib"]["frameStart"], + "frameEnd": folder_entity["attrib"]["frameEnd"] } tools = unreal.AssetToolsHelpers().get_asset_tools() From 6790c237e30b424632bbdaacda71513ce0ad8560 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 31 Jul 2024 17:56:12 +0800 Subject: [PATCH 2/8] align the loaded frame range to db --- client/ayon_unreal/plugins/load/load_geometrycache_abc.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/ayon_unreal/plugins/load/load_geometrycache_abc.py b/client/ayon_unreal/plugins/load/load_geometrycache_abc.py index 1262ade9..7f1507f9 100644 --- a/client/ayon_unreal/plugins/load/load_geometrycache_abc.py +++ b/client/ayon_unreal/plugins/load/load_geometrycache_abc.py @@ -47,6 +47,8 @@ def get_task( options.set_editor_property( 'import_type', unreal.AlembicImportType.GEOMETRY_CACHE) + options.sampling_settings.frame_start = frame_start + options.sampling_settings.frame_end = frame_end gc_settings.set_editor_property('flatten_tracks', False) From 504b51362e7960322313774103c0a0d56fdd59d5 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 2 Aug 2024 22:56:50 +0800 Subject: [PATCH 3/8] make sure the start frame is at the start frame in the setting --- client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py b/client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py index f2073cc2..2e2abeb0 100644 --- a/client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py +++ b/client/ayon_unreal/plugins/load/load_skeletalmesh_abc.py @@ -72,8 +72,8 @@ def get_task(filename, asset_dir, asset_name, replace, loaded_options): options.set_editor_property( 'import_type', unreal.AlembicImportType.SKELETAL) - options.sampling_settings.frame_start = loaded_options.get("frameStart", 1) - options.sampling_settings.frame_end = loaded_options.get("frameEnd", 1) + options.sampling_settings.frame_start = loaded_options.get("frameStart") + options.sampling_settings.frame_end = loaded_options.get("frameEnd") if loaded_options.get("abc_material_settings") == "create_materials": mat_settings.set_editor_property("create_materials", True) From c2da0380e69ebaee42ee223d7d444b6b76f84acb Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 7 Aug 2024 22:55:13 +0800 Subject: [PATCH 4/8] add missing maya presets options in load alembic animation('avoid conflict') --- .../plugins/load/load_alembic_animation.py | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/client/ayon_unreal/plugins/load/load_alembic_animation.py b/client/ayon_unreal/plugins/load/load_alembic_animation.py index 109daf86..290c13cb 100644 --- a/client/ayon_unreal/plugins/load/load_alembic_animation.py +++ b/client/ayon_unreal/plugins/load/load_alembic_animation.py @@ -2,6 +2,7 @@ """Load Alembic Animation.""" import os +from ayon_core.lib import EnumDef from ayon_core.pipeline import ( get_representation_path, AYON_CONTAINER_ID @@ -20,15 +21,37 @@ class AnimationAlembicLoader(plugin.Loader): icon = "cube" color = "orange" - def get_task(self, filename, asset_dir, asset_name, replace): + @classmethod + def get_options(cls, contexts): + return [ + EnumDef( + "abc_conversion_preset", + label="Alembic Conversion Preset", + items={ + "custom": "custom", + "maya": "maya" + }, + default="maya" + ) + ] + + def get_task(self, filename, asset_dir, asset_name, replace, loaded_options=None): task = unreal.AssetImportTask() options = unreal.AbcImportSettings() sm_settings = unreal.AbcStaticMeshSettings() - conversion_settings = unreal.AbcConversionSettings( - preset=unreal.AbcConversionPreset.CUSTOM, - flip_u=False, flip_v=False, - rotation=[0.0, 0.0, 0.0], - scale=[1.0, 1.0, -1.0]) + abc_conversion_preset = loaded_options.get("abc_conversion_preset") + if abc_conversion_preset == "maya": + conversion_settings = unreal.AbcConversionSettings( + preset= unreal.AbcConversionPreset.MAYA) + else: + conversion_settings = unreal.AbcConversionSettings( + preset=unreal.AbcConversionPreset.CUSTOM, + flip_u=False, flip_v=False, + rotation=[0.0, 0.0, 0.0], + scale=[1.0, 1.0, 1.0]) + + options.sampling_settings.frame_start = loaded_options.get("frameStart") + options.sampling_settings.frame_end = loaded_options.get("frameEnd") task.set_editor_property('filename', filename) task.set_editor_property('destination_path', asset_dir) @@ -46,7 +69,7 @@ def get_task(self, filename, asset_dir, asset_name, replace): return task - def load(self, context, name, namespace, data): + def load(self, context, name, namespace, options): """Load and containerise representation into Content Browser. This is two step process. First, import FBX to temporary path and @@ -70,6 +93,7 @@ def load(self, context, name, namespace, data): # Create directory for asset and ayon container root = unreal_pipeline.AYON_ASSET_DIR + folder_entity = context["folder"] folder_name = context["folder"]["name"] folder_path = context["folder"]["path"] product_type = context["product"]["productType"] @@ -93,9 +117,16 @@ def load(self, context, name, namespace, data): if not unreal.EditorAssetLibrary.does_directory_exist(asset_dir): unreal.EditorAssetLibrary.make_directory(asset_dir) + loaded_options = { + "abc_conversion_preset": options.get("abc_conversion_preset", "maya"), + "frameStart": folder_entity["attrib"]["frameStart"], + "frameEnd": folder_entity["attrib"]["frameEnd"] + } path = self.filepath_from_context(context) - task = self.get_task(path, asset_dir, asset_name, False) + task = self.get_task( + path, asset_dir, asset_name, False, loaded_options + ) asset_tools = unreal.AssetToolsHelpers.get_asset_tools() asset_tools.import_asset_tasks([task]) From c440c70b151fe0e4c0f54ec101a21abe760c5176 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 27 Aug 2024 16:11:19 +0800 Subject: [PATCH 5/8] make sure converting the metadata of frame range value from str to int --- client/ayon_unreal/plugins/load/load_alembic_animation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_unreal/plugins/load/load_alembic_animation.py b/client/ayon_unreal/plugins/load/load_alembic_animation.py index 4239e607..9b391eda 100644 --- a/client/ayon_unreal/plugins/load/load_alembic_animation.py +++ b/client/ayon_unreal/plugins/load/load_alembic_animation.py @@ -181,8 +181,8 @@ def update(self, container, context): destination_path = container["namespace"] loaded_options = { "abc_conversion_preset": self.abc_conversion_preset, - "frameStart": container.get("frameStart", 1), - "frameEnd": container.get("frameEnd", 1) + "frameStart": int(container.get("frameStart", "1")), + "frameEnd": int(container.get("frameEnd", "1")) } task = self.get_task( source_path, destination_path, folder_name, True, loaded_options From 47c82da3a3ae9660c0caf5d1f53c4bfb185dbc16 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 27 Aug 2024 16:28:20 +0800 Subject: [PATCH 6/8] ruff cosmetic fix --- client/ayon_unreal/plugins/load/load_alembic_animation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_unreal/plugins/load/load_alembic_animation.py b/client/ayon_unreal/plugins/load/load_alembic_animation.py index 37e9e787..5c9e046e 100644 --- a/client/ayon_unreal/plugins/load/load_alembic_animation.py +++ b/client/ayon_unreal/plugins/load/load_alembic_animation.py @@ -140,7 +140,6 @@ def load(self, context, name, namespace, options): """ # Create directory for asset and ayon container - root = unreal_pipeline.AYON_ASSET_DIR folder_entity = context["folder"] folder_name = context["folder"]["name"] folder_path = context["folder"]["path"] From b75c73f6b0934e265d8f16883135638627a4cddc Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 27 Aug 2024 21:33:28 +0800 Subject: [PATCH 7/8] add ayon_asset_dir into load alembic animation --- client/ayon_unreal/plugins/load/load_alembic_animation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/client/ayon_unreal/plugins/load/load_alembic_animation.py b/client/ayon_unreal/plugins/load/load_alembic_animation.py index 5c9e046e..5156ce2a 100644 --- a/client/ayon_unreal/plugins/load/load_alembic_animation.py +++ b/client/ayon_unreal/plugins/load/load_alembic_animation.py @@ -21,6 +21,7 @@ class AnimationAlembicLoader(plugin.Loader): icon = "cube" color = "orange" abc_conversion_preset = "maya" + root = unreal_pipeline.AYON_ASSET_DIR @classmethod def apply_settings(cls, project_settings): From c87e0a6445075baa9172f8c05827d0e839362009 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Tue, 27 Aug 2024 21:59:54 +0800 Subject: [PATCH 8/8] remove duplicated loaded options --- .../ayon_unreal/plugins/load/load_alembic_animation.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/client/ayon_unreal/plugins/load/load_alembic_animation.py b/client/ayon_unreal/plugins/load/load_alembic_animation.py index 5156ce2a..9a20b1e2 100644 --- a/client/ayon_unreal/plugins/load/load_alembic_animation.py +++ b/client/ayon_unreal/plugins/load/load_alembic_animation.py @@ -223,11 +223,6 @@ def update(self, container, context): # Create directory for folder and Ayon container suffix = "_CON" source_path = get_representation_path(repre_entity) - loaded_options = { - "abc_conversion_preset": self.abc_conversion_preset, - "frameStart": int(container.get("frameStart", "1")), - "frameEnd": int(container.get("frameEnd", "1")) - } ext = os.path.splitext(source_path)[-1].lstrip(".") asset_name = product_name @@ -247,7 +242,9 @@ def update(self, container, context): if not unreal.EditorAssetLibrary.does_directory_exist(asset_dir): loaded_options = { - "abc_conversion_preset": self.abc_conversion_preset + "abc_conversion_preset": self.abc_conversion_preset, + "frameStart": int(container.get("frameStart", "1")), + "frameEnd": int(container.get("frameEnd", "1")) } self.import_and_containerize( source_path, asset_dir, asset_name, container_name, loaded_options