Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Maya: Enhanced ASS publishing #4196

Merged
merged 22 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a2f1b80
:construction: ground work for extractor
antirotor Oct 4, 2022
a62df3b
Merge remote-tracking branch 'origin/develop' into feature/OP-3924_im…
antirotor Oct 4, 2022
b5a5c72
Comments to resolve.
tokejepsen Dec 2, 2022
687f6da
Merge branch 'develop' into feature/OP-3924_implement-ass-extractor
tokejepsen Dec 5, 2022
9694fd4
Merge branch 'develop' into feature/OP-3924_implement-ass-extractor
tokejepsen Dec 5, 2022
22e664c
Indicate sequence or single frame.
tokejepsen Dec 5, 2022
1fc8528
Remove redundant infected code
tokejepsen Dec 6, 2022
fd63457
Creator settings
tokejepsen Dec 6, 2022
3cf47e2
Collect camera from objectset if present.
tokejepsen Dec 6, 2022
76bf9bf
Working extractor
tokejepsen Dec 6, 2022
3b1f69a
Merge branch 'develop' into feature/OP-3924_implement-ass-extractor
tokejepsen Dec 6, 2022
31d14cb
Remove redundant lib
tokejepsen Dec 6, 2022
b974c67
Refactor
tokejepsen Dec 6, 2022
623d051
Merge branch 'develop' into feature/OP-3924_implement-ass-extractor
antirotor Dec 7, 2022
14e6d0f
Merge remote-tracking branch 'origin/develop' into feature/OP-3924_im…
antirotor Dec 8, 2022
538a6ea
Merge remote-tracking branch 'origin/feature/OP-3924_implement-ass-ex…
antirotor Dec 8, 2022
20400b5
:recycle: remove `exportSequence` flag
antirotor Dec 8, 2022
a209140
:bug: handle single frames
antirotor Dec 8, 2022
db4139f
Remove redundant viewport lib
tokejepsen Dec 8, 2022
8d8753b
Clean up collector
tokejepsen Dec 8, 2022
096cda1
Fix frame flags.
tokejepsen Dec 8, 2022
c34404b
Merge pull request #4197 from tokejepsen/feature/OP-3924_implement-as…
antirotor Dec 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 33 additions & 15 deletions openpype/hosts/maya/plugins/create/create_ass.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from collections import OrderedDict

from openpype.hosts.maya.api import (
lib,
plugin
Expand All @@ -9,30 +7,54 @@


class CreateAss(plugin.Creator):
"""Arnold Archive"""
"""Arnold Scene Source"""

name = "ass"
label = "Ass StandIn"
label = "Arnold Scene Source"
family = "ass"
icon = "cube"
expandProcedurals = False
motionBlur = True
motionBlurKeys = 2
motionBlurLength = 0.5
maskOptions = False
maskCamera = False
maskLight = False
maskShape = False
maskShader = False
maskOverride = False
maskDriver = False
maskFilter = False
maskColor_manager = False
maskOperator = False

def __init__(self, *args, **kwargs):
super(CreateAss, self).__init__(*args, **kwargs)

# Add animation data
self.data.update(lib.collect_animation_data())

# Vertex colors with the geometry
self.data["exportSequence"] = False
self.data["expandProcedurals"] = self.expandProcedurals
self.data["motionBlur"] = self.motionBlur
self.data["motionBlurKeys"] = self.motionBlurKeys
self.data["motionBlurLength"] = self.motionBlurLength

# Masks
self.data["maskOptions"] = self.maskOptions
self.data["maskCamera"] = self.maskCamera
self.data["maskLight"] = self.maskLight
self.data["maskShape"] = self.maskShape
self.data["maskShader"] = self.maskShader
self.data["maskOverride"] = self.maskOverride
self.data["maskDriver"] = self.maskDriver
self.data["maskFilter"] = self.maskFilter
self.data["maskColor_manager"] = self.maskColor_manager
self.data["maskOperator"] = self.maskOperator

def process(self):
instance = super(CreateAss, self).process()

# data = OrderedDict(**self.data)



nodes = list()
nodes = []

if (self.options or {}).get("useSelection"):
nodes = cmds.ls(selection=True)
Expand All @@ -42,7 +64,3 @@ def process(self):
assContent = cmds.sets(name="content_SET")
assProxy = cmds.sets(name="proxy_SET", empty=True)
cmds.sets([assContent, assProxy], forceElement=instance)

# self.log.info(data)
#
# self.data = data
19 changes: 18 additions & 1 deletion openpype/hosts/maya/plugins/publish/collect_ass.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from maya import cmds
from openpype.pipeline.publish import KnownPublishError

import pyblish.api


class CollectAssData(pyblish.api.InstancePlugin):
"""Collect Ass data."""

# Offset to be after renderable camera collection.
order = pyblish.api.CollectorOrder + 0.2
label = 'Collect Ass'
families = ["ass"]
Expand All @@ -23,8 +25,23 @@ def process(self, instance):
instance.data['setMembers'] = members
self.log.debug('content members: {}'.format(members))
elif objset.startswith("proxy_SET"):
assert len(members) == 1, "You have multiple proxy meshes, please only use one"
if len(members) != 1:
msg = "You have multiple proxy meshes, please only use one"
raise KnownPublishError(msg)
instance.data['proxy'] = members
self.log.debug('proxy members: {}'.format(members))

# Use camera in object set if present else default to render globals
# camera.
cameras = cmds.ls(type="camera", long=True)
renderable = [c for c in cameras if cmds.getAttr("%s.renderable" % c)]
camera = renderable[0]
for node in instance.data["setMembers"]:
camera_shapes = cmds.listRelatives(
node, shapes=True, type="camera"
)
if camera_shapes:
camera = node
instance.data["camera"] = camera

self.log.debug("data: {}".format(instance.data))
126 changes: 70 additions & 56 deletions openpype/hosts/maya/plugins/publish/extract_ass.py
Original file line number Diff line number Diff line change
@@ -1,91 +1,105 @@
import os

from maya import cmds
import arnold

from openpype.pipeline import publish
from openpype.hosts.maya.api.lib import maintained_selection
from openpype.hosts.maya.api.lib import maintained_selection, attribute_values


class ExtractAssStandin(publish.Extractor):
"""Extract the content of the instance to a ass file
"""Extract the content of the instance to a ass file"""

Things to pay attention to:
- If animation is toggled, are the frames correct
-
"""

label = "Ass Standin (.ass)"
label = "Arnold Scene Source (.ass)"
hosts = ["maya"]
families = ["ass"]
asciiAss = False

def process(self, instance):

sequence = instance.data.get("exportSequence", False)

staging_dir = self.staging_dir(instance)
filename = "{}.ass".format(instance.name)
filenames = list()
filenames = []
file_path = os.path.join(staging_dir, filename)

# Mask
mask = arnold.AI_NODE_ALL

node_types = {
"options": arnold.AI_NODE_OPTIONS,
"camera": arnold.AI_NODE_CAMERA,
"light": arnold.AI_NODE_LIGHT,
"shape": arnold.AI_NODE_SHAPE,
"shader": arnold.AI_NODE_SHADER,
"override": arnold.AI_NODE_OVERRIDE,
"driver": arnold.AI_NODE_DRIVER,
"filter": arnold.AI_NODE_FILTER,
"color_manager": arnold.AI_NODE_COLOR_MANAGER,
"operator": arnold.AI_NODE_OPERATOR
}

for key in node_types.keys():
if instance.data.get("mask" + key.title()):
mask = mask ^ node_types[key]

# Motion blur
values = {
"defaultArnoldRenderOptions.motion_blur_enable": instance.data.get(
"motionBlur", True
),
"defaultArnoldRenderOptions.motion_steps": instance.data.get(
"motionBlurKeys", 2
),
"defaultArnoldRenderOptions.motion_frames": instance.data.get(
"motionBlurLength", 0.5
)
}

# Write out .ass file
kwargs = {
"filename": file_path,
"startFrame": instance.data.get("frameStartHandle", 1),
"endFrame": instance.data.get("frameEndHandle", 1),
"frameStep": instance.data.get("step", 1),
"selected": True,
"asciiAss": self.asciiAss,
"shadowLinks": True,
"lightLinks": True,
"boundingBox": True,
"expandProcedurals": instance.data.get("expandProcedurals", False),
"camera": instance.data["camera"],
"mask": mask
}

self.log.info("Writing: '%s'" % file_path)
with maintained_selection():
self.log.info("Writing: {}".format(instance.data["setMembers"]))
cmds.select(instance.data["setMembers"], noExpand=True)

if sequence:
self.log.info("Extracting ass sequence")

# Collect the start and end including handles
start = instance.data.get("frameStartHandle", 1)
end = instance.data.get("frameEndHandle", 1)
step = instance.data.get("step", 0)

exported_files = cmds.arnoldExportAss(filename=file_path,
selected=True,
asciiAss=self.asciiAss,
shadowLinks=True,
lightLinks=True,
boundingBox=True,
startFrame=start,
endFrame=end,
frameStep=step
)
with attribute_values(values):
with maintained_selection():
self.log.info(
"Writing: {}".format(instance.data["setMembers"])
)
cmds.select(instance.data["setMembers"], noExpand=True)

self.log.info(
"Extracting ass sequence with: {}".format(kwargs)
)

exported_files = cmds.arnoldExportAss(**kwargs)

for file in exported_files:
filenames.append(os.path.split(file)[1])

self.log.info("Exported: {}".format(filenames))
else:
self.log.info("Extracting ass")
cmds.arnoldExportAss(filename=file_path,
selected=True,
asciiAss=False,
shadowLinks=True,
lightLinks=True,
boundingBox=True
)
self.log.info("Extracted {}".format(filename))
filenames = filename
optionals = [
"frameStart", "frameEnd", "step", "handles",
"handleEnd", "handleStart"
]
for key in optionals:
instance.data.pop(key, None)

if "representations" not in instance.data:
instance.data["representations"] = []

representation = {
'name': 'ass',
'ext': 'ass',
'files': filenames,
"stagingDir": staging_dir
'files': filenames if len(filenames) > 1 else filenames[0],
"stagingDir": staging_dir,
'frameStart': kwargs["startFrame"]
}

if sequence:
representation['frameStart'] = start

instance.data["representations"].append(representation)

self.log.info("Extracted instance '%s' to: %s"
Expand Down
18 changes: 16 additions & 2 deletions openpype/settings/defaults/project_settings/maya.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,21 @@
"enabled": true,
"defaults": [
"Main"
]
],
"expandProcedurals": false,
"motionBlur": true,
"motionBlurKeys": 2,
"motionBlurLength": 0.5,
"maskOptions": false,
"maskCamera": false,
"maskLight": false,
"maskShape": false,
"maskShader": false,
"maskOverride": false,
"maskDriver": false,
"maskFilter": false,
"maskColor_manager": false,
"maskOperator": false
},
"CreateAssembly": {
"enabled": true,
Expand Down Expand Up @@ -1007,4 +1021,4 @@
"ValidateNoAnimation": false
}
}
}
}
Loading