mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
instances for bb geometry and publisher for bb geometry
This commit is contained in:
parent
66883d2434
commit
bc35e8b3a3
5 changed files with 162 additions and 0 deletions
42
openpype/hosts/maya/plugins/create/create_proxy_abc.py
Normal file
42
openpype/hosts/maya/plugins/create/create_proxy_abc.py
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
from openpype.hosts.maya.api import (
|
||||||
|
lib,
|
||||||
|
plugin
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class CreateProxyAlembic(plugin.Creator):
|
||||||
|
"""Proxy Alembic for animated data"""
|
||||||
|
|
||||||
|
name = "proxyAbcMain"
|
||||||
|
label = "Proxy Alembic"
|
||||||
|
family = "proxyAbc"
|
||||||
|
icon = "gears"
|
||||||
|
write_color_sets = False
|
||||||
|
write_face_sets = False
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(CreateProxyAlembic, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
# Add animation data
|
||||||
|
self.data.update(lib.collect_animation_data())
|
||||||
|
|
||||||
|
# Vertex colors with the geometry.
|
||||||
|
self.data["writeColorSets"] = self.write_color_sets
|
||||||
|
# Vertex colors with the geometry.
|
||||||
|
self.data["writeFaceSets"] = self.write_face_sets
|
||||||
|
# Include parent groups
|
||||||
|
self.data["includeParentHierarchy"] = False
|
||||||
|
# only nodes which are visible
|
||||||
|
self.data["visibleOnly"] = False
|
||||||
|
# Default to exporting world-space
|
||||||
|
self.data["worldSpace"] = True
|
||||||
|
|
||||||
|
# Creating a single bounding box per shape selected
|
||||||
|
self.data["single"] = False
|
||||||
|
# name suffix for the bounding box
|
||||||
|
self.data["nameSuffix"] = "_BBox"
|
||||||
|
|
||||||
|
# Add options for custom attributes
|
||||||
|
self.data["attr"] = ""
|
||||||
|
self.data["attrPrefix"] = ""
|
||||||
14
openpype/hosts/maya/plugins/publish/collect_proxy_abc.py
Normal file
14
openpype/hosts/maya/plugins/publish/collect_proxy_abc.py
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import pyblish.api
|
||||||
|
|
||||||
|
class CollectProxyAlembic(pyblish.api.InstancePlugin):
|
||||||
|
"""Collect Proxy Alembic for instance."""
|
||||||
|
|
||||||
|
order = pyblish.api.CollectorOrder + 0.45
|
||||||
|
families = ["proxyAbc"]
|
||||||
|
label = "Collect Proxy Alembic"
|
||||||
|
hosts = ["maya"]
|
||||||
|
|
||||||
|
def process(self, instance):
|
||||||
|
"""Collector entry point."""
|
||||||
|
if not instance.data.get('families'):
|
||||||
|
instance.data["families"] = []
|
||||||
96
openpype/hosts/maya/plugins/publish/extract_proxy_abc.py
Normal file
96
openpype/hosts/maya/plugins/publish/extract_proxy_abc.py
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
from maya import cmds
|
||||||
|
|
||||||
|
from openpype.pipeline import publish
|
||||||
|
from openpype.hosts.maya.api.lib import (
|
||||||
|
extract_alembic,
|
||||||
|
suspended_refresh,
|
||||||
|
maintained_selection,
|
||||||
|
iter_visible_nodes_in_range
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ExtractAlembic(publish.Extractor):
|
||||||
|
"""Produce an alembic for bounding box geometry
|
||||||
|
"""
|
||||||
|
|
||||||
|
label = "Extract Proxy (Alembic)"
|
||||||
|
hosts = ["maya"]
|
||||||
|
families = ["proxyAbc"]
|
||||||
|
|
||||||
|
def process(self, instance):
|
||||||
|
|
||||||
|
nodes, roots = self.get_members_and_roots(instance)
|
||||||
|
start = float(instance.data.get("frameStartHandle", 1))
|
||||||
|
end = float(instance.data.get("frameEndHandle", 1))
|
||||||
|
|
||||||
|
attrs = instance.data.get("attr", "").split(";")
|
||||||
|
attrs = [value for value in attrs if value.strip()]
|
||||||
|
attrs += ["cbId"]
|
||||||
|
|
||||||
|
attr_prefixes = instance.data.get("attrPrefix", "").split(";")
|
||||||
|
attr_prefixes = [value for value in attr_prefixes if value.strip()]
|
||||||
|
|
||||||
|
self.log.info("Extracting Proxy Meshes...")
|
||||||
|
|
||||||
|
dirname = self.staging_dir(instance)
|
||||||
|
filename = "{name}.abc".format(**instance.data)
|
||||||
|
path = os.path.join(dirname, filename)
|
||||||
|
|
||||||
|
options = {
|
||||||
|
"step": instance.data.get("step", 1.0),
|
||||||
|
"attr": attrs,
|
||||||
|
"attrPrefix": attr_prefixes,
|
||||||
|
"writeVisibility": True,
|
||||||
|
"writeCreases": True,
|
||||||
|
"writeColorSets": instance.data.get("writeColorSets", False),
|
||||||
|
"writeFaceSets": instance.data.get("writeFaceSets", False),
|
||||||
|
"uvWrite": True,
|
||||||
|
"selection": True,
|
||||||
|
"worldSpace": instance.data.get("worldSpace", True)
|
||||||
|
}
|
||||||
|
|
||||||
|
if not instance.data.get("includeParentHierarchy", True):
|
||||||
|
|
||||||
|
options["root"] = roots
|
||||||
|
if instance.data.get("visibleOnly", False):
|
||||||
|
nodes = list(iter_visible_nodes_in_range(nodes,
|
||||||
|
start=start,
|
||||||
|
end=end))
|
||||||
|
with suspended_refresh():
|
||||||
|
with maintained_selection():
|
||||||
|
# TODO: select the bb geometry
|
||||||
|
self.create_proxy_geometry(instance,
|
||||||
|
start,
|
||||||
|
end)
|
||||||
|
extract_alembic(file=path,
|
||||||
|
startFrame=start,
|
||||||
|
endFrame=end,
|
||||||
|
**options)
|
||||||
|
|
||||||
|
if "representations" not in instance.data:
|
||||||
|
instance.data["representations"] = []
|
||||||
|
|
||||||
|
representation = {
|
||||||
|
'name': 'abc',
|
||||||
|
'ext': 'abc',
|
||||||
|
'files': filename,
|
||||||
|
'stagingDir': dirname
|
||||||
|
}
|
||||||
|
instance.data["representations"].append(representation)
|
||||||
|
|
||||||
|
instance.context.data["cleanupFullPaths"].append(path)
|
||||||
|
|
||||||
|
self.log.info("Extracted {} to {}".format(instance, dirname))
|
||||||
|
#TODO: delete the bounding box
|
||||||
|
|
||||||
|
def get_members_and_roots(self, instance):
|
||||||
|
return instance[:], instance.data.get("setMembers")
|
||||||
|
|
||||||
|
def create_proxy_geometry(self, instance, start, end):
|
||||||
|
|
||||||
|
inst_selection = cmds.ls(instance.name, long=True)
|
||||||
|
name_suffix = instance.data.get("nameSuffix")
|
||||||
|
if instance.data.get("single", True):
|
||||||
|
pass
|
||||||
|
|
@ -197,6 +197,12 @@
|
||||||
"Main"
|
"Main"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"CreateProxyAlembic": {
|
||||||
|
"enabled": true,
|
||||||
|
"defaults": [
|
||||||
|
"Main"
|
||||||
|
]
|
||||||
|
},
|
||||||
"CreateRenderSetup": {
|
"CreateRenderSetup": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"defaults": [
|
"defaults": [
|
||||||
|
|
|
||||||
|
|
@ -237,6 +237,10 @@
|
||||||
"key": "CreateMayaScene",
|
"key": "CreateMayaScene",
|
||||||
"label": "Create Maya Scene"
|
"label": "Create Maya Scene"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"key": "CreateProxyAlembic",
|
||||||
|
"label": "Create Proxy Alembic"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"key": "CreateRenderSetup",
|
"key": "CreateRenderSetup",
|
||||||
"label": "Create Render Setup"
|
"label": "Create Render Setup"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue