From e25137f13763e96db0f1cf262f2abc960d447f1a Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 28 Jun 2024 23:14:07 +0800 Subject: [PATCH] add ornatrix alembic loader and add all the alembic options --- .../plugins/create/create_ornatrix_cache.py | 24 +++-- .../plugins/load/load_ornatrix_alembic.py | 87 +++++++++++++++++++ .../ayon_maya/plugins/load/load_reference.py | 3 +- 3 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 server_addon/maya/client/ayon_maya/plugins/load/load_ornatrix_alembic.py diff --git a/server_addon/maya/client/ayon_maya/plugins/create/create_ornatrix_cache.py b/server_addon/maya/client/ayon_maya/plugins/create/create_ornatrix_cache.py index db615f1173..13cf6d41bf 100644 --- a/server_addon/maya/client/ayon_maya/plugins/create/create_ornatrix_cache.py +++ b/server_addon/maya/client/ayon_maya/plugins/create/create_ornatrix_cache.py @@ -2,7 +2,7 @@ from ayon_maya.api import ( lib, plugin ) -from ayon_core.lib import BoolDef, NumberDef +from ayon_core.lib import BoolDef, NumberDef, EnumDef class CreateOxCache(plugin.MayaCreator): @@ -21,6 +21,13 @@ class CreateOxCache(plugin.MayaCreator): if attr_def.key not in remove] defs.extend( [ + EnumDef("format", + items={ + 0: "Ogawa", + 1: "HDF5", + }, + label="Format", + default=0), BoolDef("renderVersion", label="Use Render Version", tooltip="When on, hair in the scene will be " @@ -28,9 +35,14 @@ class CreateOxCache(plugin.MayaCreator): "strands will be exported. Otherwise, what " "is seen in the viewport will be exported.", default=True), - BoolDef("upDirection", + EnumDef("upDirection", + items={ + 0: "X", + 1: "Y", + 2: "Z" + }, label="Up Direction", - default=True), + default=1), BoolDef("useWorldCoordinates", label="Use World Coordinates", default=False), @@ -61,9 +73,9 @@ class CreateOxCache(plugin.MayaCreator): BoolDef("exportNormals", label="Export Normals", default=False), - BoolDef("velocityIntervalCenter", - label="Velocity Interval Center", - default=False), + NumberDef("velocityIntervalCenter", + label="Velocity Interval Center", + default=0.0), NumberDef("velocityIntervalLength", label="Velocity Interval Length", default=0.5), diff --git a/server_addon/maya/client/ayon_maya/plugins/load/load_ornatrix_alembic.py b/server_addon/maya/client/ayon_maya/plugins/load/load_ornatrix_alembic.py new file mode 100644 index 0000000000..b6bbc0eefa --- /dev/null +++ b/server_addon/maya/client/ayon_maya/plugins/load/load_ornatrix_alembic.py @@ -0,0 +1,87 @@ +from maya import cmds +from ayon_core.pipeline import get_representation_path +from ayon_maya.api import plugin +from ayon_maya.api.lib import unique_namespace, maintained_selection +from ayon_core.lib import EnumDef + + + +class OxAlembicLoader(plugin.ReferenceLoader): + """Ornatrix Alembic Loader""" + + product_types = {"oxcache"} + representations = {"abc"} + + label = "Ornatrix Alembic Loader" + order = -10 + icon = "code-fork" + color = "orange" + + @classmethod + def get_options(cls, contexts): + return cls.options + [ + EnumDef( + "import_options", + items={ + 0: "Hair", + 1: "Guides" + }, + default=0 + ) + ] + + def process_reference( + self, context, name=None, namespace=None, options=None + ): + cmds.loadPlugin("Ornatrix", quiet=True) + folder_name = context["folder"]["name"] + namespace = namespace or unique_namespace( + folder_name + "_", + prefix="_" if folder_name[0].isdigit() else "", + suffix="_", + ) + + attach_to_root = options.get("attach_to_root", True) + group_name = options["group_name"] + + # no group shall be created + if not attach_to_root: + group_name = namespace + + path = self.filepath_from_context(context) + ox_import_options = "; importAs={}".format( + options.get("import_options")) + + with maintained_selection(): + file_url = self.prepare_root_value( + path, context["project"]["name"] + ) + nodes = cmds.file( + file_url, + type="Ornatrix Alembic Import", + namespace=namespace, + groupName=group_name, + options=ox_import_options + ) + color = plugin.get_load_color_for_product_type("oxacache") + if color is not None: + red, green, blue = color + cmds.setAttr(group_name + ".useOutlinerColor", 1) + cmds.setAttr( + group_name + ".outlinerColor", red, green, blue + ) + + self[:] = nodes + + return nodes + + def update(self, container, context): + repre_entity = context["representation"] + path = get_representation_path(repre_entity) + members = cmds.sets(container['objectName'], query=True) + ox_nodes = cmds.ls(members, type="BakedHairNode", long=True) + for node in ox_nodes: + cmds.setAttr(f"{node}.sourceFilePath1", path, type="string") + + def switch(self, container, context): + self.update(container, context) diff --git a/server_addon/maya/client/ayon_maya/plugins/load/load_reference.py b/server_addon/maya/client/ayon_maya/plugins/load/load_reference.py index 583fd251e6..6394f65ec6 100644 --- a/server_addon/maya/client/ayon_maya/plugins/load/load_reference.py +++ b/server_addon/maya/client/ayon_maya/plugins/load/load_reference.py @@ -123,8 +123,7 @@ class ReferenceLoader(plugin.ReferenceLoader): "staticMesh", "skeletalMesh", "mvLook", - "matchmove", - "oxcache", + "matchmove" } representations = {"ma", "abc", "fbx", "mb"}