Skip to content

Commit

Permalink
add ornatrix alembic loader and add all the alembic options
Browse files Browse the repository at this point in the history
  • Loading branch information
moonyuet committed Jun 28, 2024
1 parent d4e5521 commit e25137f
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lib,
plugin
)
from ayon_core.lib import BoolDef, NumberDef
from ayon_core.lib import BoolDef, NumberDef, EnumDef


class CreateOxCache(plugin.MayaCreator):
Expand All @@ -21,16 +21,28 @@ def get_instance_attr_defs(self):
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 "
"switched to render mode and dense hair "
"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),
Expand Down Expand Up @@ -61,9 +73,9 @@ def get_instance_attr_defs(self):
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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ class ReferenceLoader(plugin.ReferenceLoader):
"staticMesh",
"skeletalMesh",
"mvLook",
"matchmove",
"oxcache",
"matchmove"
}

representations = {"ma", "abc", "fbx", "mb"}
Expand Down

0 comments on commit e25137f

Please sign in to comment.