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

Feature/multiverse #4046

Merged
merged 37 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
893a845
add new render product for 3delight
zhoub Mar 18, 2022
e85ef95
improve 3delight render product class and return it
zhoub Mar 18, 2022
3ec621a
add method _set_3delight_settings to render creator
zhoub Mar 18, 2022
5ce1e24
Merge pull request #4 from pypeclub/develop
dmo-j-cube Jun 14, 2022
87c697b
Rewrote large portions of the file to handle different nodes that may
dmo-j-cube Jun 22, 2022
e1ec86a
Merge branch 'pypeclub:develop' into feature/multiverse
dmo-j-cube Jun 22, 2022
2007c75
Reverting `mvUsd` family back to `usd` so that other software can create
dmo-j-cube Jun 24, 2022
ab1c86a
Do not lock nodes, it's not needed and it makes things much harder.
dmo-j-cube Jun 28, 2022
c5fd2a9
I was incorrectly globing into an array of arrays instead of single l…
dmo-j-cube Jun 28, 2022
044946e
Strip UsdComp namespaces.
dmo-j-cube Jun 28, 2022
274499b
Merge branch 'pypeclub:develop' into develop
dmo-j-cube Jun 30, 2022
cb82e66
Naming suffixes can be overridden in project settings, lets print out…
dmo-j-cube Jul 6, 2022
56f13bf
Move alembic publishing options around.
dmo-j-cube Jul 6, 2022
53f5685
Subclass ExtractMultiverseUsd as ExtractMultiverseUsdAnim to enable
dmo-j-cube Jul 6, 2022
cdf165e
The mvLook should skip namespaces.
dmo-j-cube Jul 6, 2022
559210f
If there's a mixed-attribute on the node, this will fail, just skip it
dmo-j-cube Jul 6, 2022
ae062b6
Merge branch 'pypeclub:develop' into develop
dmo-j-cube Jul 6, 2022
6959425
Merge branch 'pypeclub:develop' into feature/multiverse
dmo-j-cube Jul 6, 2022
432bd1a
Merge remote-tracking branch 'origin/feature/multiverse' into feature…
dmo-j-cube Jul 6, 2022
d59dbe0
Merge branch 'develop' into feature/3delight
dmo-j-cube Jul 13, 2022
e51fc66
Merge branch 'feature/multiverse' into feature/3delight
dmo-j-cube Jul 13, 2022
0ed3f66
Merge branch 'develop' into feature/multiverse
dmo-j-cube Jul 14, 2022
c54ba20
Merge branch 'feature/multiverse' into feature/3delight
dmo-j-cube Jul 14, 2022
bade497
Merge branch 'pypeclub:develop' into develop
dmo-j-cube Jul 15, 2022
b1cf3f1
Merge branch 'develop' into feature/multiverse
dmo-j-cube Jul 15, 2022
137a9a6
Merge branch 'feature/3delight' into feature/multiverse
dmo-j-cube Jul 15, 2022
77c45e2
Animation should also write out UsdAttributes.
dmo-j-cube Jul 20, 2022
3c47baf
Merge branch 'pypeclub:develop' into develop
dmo-j-cube Jul 20, 2022
dda1819
Merge branch 'pypeclub:develop' into develop
dmo-j-cube Aug 30, 2022
2feb77c
Merge branch 'pypeclub:develop' into develop
dmo-j-cube Sep 6, 2022
0e00b74
Merge branch 'pypeclub:develop' into develop
dmo-j-cube Oct 10, 2022
7fe64a9
Merge branch 'pypeclub:develop' into develop
dmo-j-cube Oct 28, 2022
a892754
Merge branch 'develop' into feature/multiverse
dmo-j-cube Oct 31, 2022
aeee2a4
Fixed commit for adding proper layered support for USD overrides.
dmo-j-cube Oct 31, 2022
c62527a
Removing bad merge.
dmo-j-cube Oct 31, 2022
422a3c4
Removed wrongly-staged `extract_animation.py`
dmo-j-cube Oct 31, 2022
046ed72
Addressing valid hound concerns.
dmo-j-cube Oct 31, 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
3 changes: 3 additions & 0 deletions openpype/hosts/maya/plugins/create/create_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ def __init__(self, *args, **kwargs):
# Default to not send to farm.
self.data["farm"] = False
self.data["priority"] = 50

# Default to write normals.
self.data["writeNormals"] = True
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CreateMultiverseUsd(plugin.Creator):

name = "mvUsdMain"
label = "Multiverse USD Asset"
family = "mvUsd"
family = "usd"
icon = "cubes"

def __init__(self, *args, **kwargs):
Expand Down
37 changes: 28 additions & 9 deletions openpype/hosts/maya/plugins/load/load_multiverse_usd.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
import maya.cmds as cmds
from maya import mel
import os

from openpype.pipeline import (
load,
Expand All @@ -11,12 +13,13 @@
unique_namespace
)
from openpype.hosts.maya.api.pipeline import containerise
from openpype.client import get_representation_by_id


class MultiverseUsdLoader(load.LoaderPlugin):
"""Read USD data in a Multiverse Compound"""

families = ["model", "mvUsd", "mvUsdComposition", "mvUsdOverride",
families = ["model", "usd", "mvUsdComposition", "mvUsdOverride",
"pointcache", "animation"]
representations = ["usd", "usda", "usdc", "usdz", "abc"]

Expand All @@ -26,30 +29,27 @@ class MultiverseUsdLoader(load.LoaderPlugin):
color = "orange"

def load(self, context, name=None, namespace=None, options=None):

asset = context['asset']['name']
namespace = namespace or unique_namespace(
asset + "_",
prefix="_" if asset[0].isdigit() else "",
suffix="_",
)

# Create the shape
# Make sure we can load the plugin
cmds.loadPlugin("MultiverseForMaya", quiet=True)
import multiverse

# Create the shape
shape = None
transform = None
with maintained_selection():
cmds.namespace(addNamespace=namespace)
with namespaced(namespace, new=False):
import multiverse
shape = multiverse.CreateUsdCompound(self.fname)
transform = cmds.listRelatives(
shape, parent=True, fullPath=True)[0]

# Lock the shape node so the user cannot delete it.
cmds.lockNode(shape, lock=True)

nodes = [transform, shape]
self[:] = nodes

Expand All @@ -70,15 +70,34 @@ def update(self, container, representation):
shapes = cmds.ls(members, type="mvUsdCompoundShape")
assert shapes, "Cannot find mvUsdCompoundShape in container"

path = get_representation_path(representation)
project_name = representation["context"]["project"]["name"]
prev_representation_id = cmds.getAttr("{}.representation".format(node))
prev_representation = get_representation_by_id(project_name,
prev_representation_id)
prev_path = os.path.normpath(prev_representation["data"]["path"])

# Make sure we can load the plugin
cmds.loadPlugin("MultiverseForMaya", quiet=True)
import multiverse

for shape in shapes:
multiverse.SetUsdCompoundAssetPaths(shape, [path])

asset_paths = multiverse.GetUsdCompoundAssetPaths(shape)
asset_paths = [os.path.normpath(p) for p in asset_paths]

assert asset_paths.count(prev_path) == 1, \
"Couldn't find matching path (or too many)"
prev_path_idx = asset_paths.index(prev_path)

path = get_representation_path(representation)
asset_paths[prev_path_idx] = path

multiverse.SetUsdCompoundAssetPaths(shape, asset_paths)

cmds.setAttr("{}.representation".format(node),
str(representation["_id"]),
type="string")
mel.eval('refreshEditorTemplates;')

def switch(self, container, representation):
self.update(container, representation)
Expand Down
132 changes: 132 additions & 0 deletions openpype/hosts/maya/plugins/load/load_multiverse_usd_over.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# -*- coding: utf-8 -*-
import maya.cmds as cmds
from maya import mel
import os

import qargparse

from openpype.pipeline import (
load,
get_representation_path
)
from openpype.hosts.maya.api.lib import (
maintained_selection
)
from openpype.hosts.maya.api.pipeline import containerise
from openpype.client import get_representation_by_id


class MultiverseUsdOverLoader(load.LoaderPlugin):
"""Reference file"""

families = ["mvUsdOverride"]
representations = ["usda", "usd", "udsz"]

label = "Load Usd Override into Compound"
order = -10
icon = "code-fork"
color = "orange"

options = [
qargparse.String(
"Which Compound",
label="Compound",
help="Select which compound to add this as a layer to."
)
]

def load(self, context, name=None, namespace=None, options=None):
current_usd = cmds.ls(selection=True,
type="mvUsdCompoundShape",
dag=True,
long=True)
if len(current_usd) != 1:
self.log.error("Current selection invalid: '{}', "
"must contain exactly 1 mvUsdCompoundShape."
"".format(current_usd))
return

# Make sure we can load the plugin
cmds.loadPlugin("MultiverseForMaya", quiet=True)
import multiverse

nodes = current_usd
with maintained_selection():
multiverse.AddUsdCompoundAssetPath(current_usd[0], self.fname)

namespace = current_usd[0].split("|")[1].split(":")[0]

container = containerise(
name=name,
namespace=namespace,
nodes=nodes,
context=context,
loader=self.__class__.__name__)

cmds.addAttr(container, longName="mvUsdCompoundShape",
niceName="mvUsdCompoundShape", dataType="string")
cmds.setAttr(container + ".mvUsdCompoundShape",
current_usd[0], type="string")

return container

def update(self, container, representation):
# type: (dict, dict) -> None
"""Update container with specified representation."""

cmds.loadPlugin("MultiverseForMaya", quiet=True)
import multiverse

node = container['objectName']
assert cmds.objExists(node), "Missing container"

members = cmds.sets(node, query=True) or []
shapes = cmds.ls(members, type="mvUsdCompoundShape")
assert shapes, "Cannot find mvUsdCompoundShape in container"

mvShape = container['mvUsdCompoundShape']
assert mvShape, "Missing mv source"

project_name = representation["context"]["project"]["name"]
prev_representation_id = cmds.getAttr("{}.representation".format(node))
prev_representation = get_representation_by_id(project_name,
prev_representation_id)
prev_path = os.path.normpath(prev_representation["data"]["path"])

path = get_representation_path(representation)

for shape in shapes:
asset_paths = multiverse.GetUsdCompoundAssetPaths(shape)
asset_paths = [os.path.normpath(p) for p in asset_paths]

assert asset_paths.count(prev_path) == 1, \
"Couldn't find matching path (or too many)"
prev_path_idx = asset_paths.index(prev_path)
asset_paths[prev_path_idx] = path
multiverse.SetUsdCompoundAssetPaths(shape, asset_paths)

cmds.setAttr("{}.representation".format(node),
str(representation["_id"]),
type="string")
mel.eval('refreshEditorTemplates;')

def switch(self, container, representation):
self.update(container, representation)

def remove(self, container):
# type: (dict) -> None
"""Remove loaded container."""
# Delete container and its contents
if cmds.objExists(container['objectName']):
members = cmds.sets(container['objectName'], query=True) or []
cmds.delete([container['objectName']] + members)

# Remove the namespace, if empty
namespace = container['namespace']
if cmds.namespace(exists=namespace):
members = cmds.namespaceInfo(namespace, listNamespace=True)
if not members:
cmds.namespace(removeNamespace=namespace)
else:
self.log.warning("Namespace not deleted because it "
"still has members: %s", namespace)
3 changes: 2 additions & 1 deletion openpype/hosts/maya/plugins/load/load_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class ReferenceLoader(openpype.hosts.maya.api.plugin.ReferenceLoader):
"rig",
"camerarig",
"xgen",
"staticMesh"]
"staticMesh",
"mvLook"]
representations = ["ma", "abc", "fbx", "mb"]

label = "Reference"
Expand Down
8 changes: 7 additions & 1 deletion openpype/hosts/maya/plugins/publish/collect_look.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ def collect(self, instance):
for res in self.collect_resources(n):
instance.data["resources"].append(res)

self.log.info("Collected resources: {}".format(instance.data["resources"]))
self.log.info("Collected resources: {}".format(
instance.data["resources"]))

# Log warning when no relevant sets were retrieved for the look.
if (
Expand Down Expand Up @@ -548,6 +549,11 @@ def collect_attributes_changed(self, instance):
if not cmds.attributeQuery(attr, node=node, exists=True):
continue
attribute = "{}.{}".format(node, attr)
# We don't support mixed-type attributes yet.
if cmds.attributeQuery(attr, node=node, multi=True):
self.log.warning("Attribute '{}' is mixed-type and is "
"not supported yet.".format(attribute))
continue
if cmds.getAttr(attribute, type=True) == "message":
continue
node_attributes[attr] = cmds.getAttr(attribute)
Expand Down
Loading