mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
add ornatrix alembic loader and add all the alembic options
This commit is contained in:
parent
d4e5521229
commit
e25137f137
3 changed files with 106 additions and 8 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -123,8 +123,7 @@ class ReferenceLoader(plugin.ReferenceLoader):
|
|||
"staticMesh",
|
||||
"skeletalMesh",
|
||||
"mvLook",
|
||||
"matchmove",
|
||||
"oxcache",
|
||||
"matchmove"
|
||||
}
|
||||
|
||||
representations = {"ma", "abc", "fbx", "mb"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue