Merged in feature/PYPE-527-yeti-support (pull request #319)

Yeti support

Approved-by: Milan Kolar <milan@orbi.tools>
This commit is contained in:
Ondřej Samohel 2019-10-25 12:37:33 +00:00 committed by Milan Kolar
commit 161f9f43aa
9 changed files with 94 additions and 44 deletions

View file

@ -39,8 +39,10 @@ class YetiCacheLoader(api.Loader):
cmds.loadPlugin("pgYetiMaya", quiet=True)
# Get JSON
fname, ext = os.path.splitext(self.fname)
settings_fname = "{}.fursettings".format(fname)
fbase = re.search(r'^(.+)\.(\d+|#+)\.fur', self.fname)
if not fbase:
raise RuntimeError('Cannot determine fursettings file path')
settings_fname = "{}.fursettings".format(fbase.group(1))
with open(settings_fname, "r") as fp:
fursettings = json.load(fp)
@ -102,7 +104,6 @@ class YetiCacheLoader(api.Loader):
namespace = container["namespace"]
container_node = container["objectName"]
path = api.get_representation_path(representation)
# Get all node data
fname, ext = os.path.splitext(path)
settings_fname = "{}.fursettings".format(fname)
@ -151,7 +152,8 @@ class YetiCacheLoader(api.Loader):
# Update cache file name
file_name = data["name"].replace(":", "_")
cache_file_path = "{}.%04d.fur".format(file_name)
data["attrs"]["cacheFileName"] = os.path.join(path, cache_file_path)
data["attrs"]["cacheFileName"] = os.path.join(
path, cache_file_path)
if cb_id not in scene_lookup:
@ -284,10 +286,15 @@ class YetiCacheLoader(api.Loader):
attributes = node_settings["attrs"]
# Check if cache file name is stored
# get number of # in path and convert it to C prinf format
# like %04d expected by Yeti
fbase = re.search(r'^(.+)\.(\d+|#+)\.fur', self.fname)
if not fbase:
raise RuntimeError('Cannot determine file path')
padding = len(fbase.group(2))
if "cacheFileName" not in attributes:
file_name = original_node.replace(":", "_")
cache_name = "{}.%04d.fur".format(file_name)
cache = os.path.join(self.fname, cache_name)
cache = "{}.%0{}d.fur".format(fbase.group(1), padding)
self.validate_cache(cache)
attributes["cacheFileName"] = cache

View file

@ -45,8 +45,10 @@ class CollectYetiRig(pyblish.api.InstancePlugin):
instance.data["resources"] = yeti_resources
# Force frame range for export
instance.data["frameStart"] = 1
instance.data["frameEnd"] = 1
instance.data["frameStart"] = cmds.playbackOptions(
query=True, animationStartTime=True)
instance.data["frameEnd"] = cmds.playbackOptions(
query=True, animationStartTime=True)
def collect_input_connections(self, instance):
"""Collect the inputs for all nodes in the input_SET"""
@ -114,15 +116,17 @@ class CollectYetiRig(pyblish.api.InstancePlugin):
resources = []
image_search_paths = cmds.getAttr("{}.imageSearchPath".format(node))
texture_filenames = []
if image_search_paths:
# TODO: Somehow this uses OS environment path separator, `:` vs `;`
# Later on check whether this is pipeline OS cross-compatible.
image_search_paths = [p for p in
image_search_paths.split(os.path.pathsep) if p]
# TODO: Somehow this uses OS environment path separator, `:` vs `;`
# Later on check whether this is pipeline OS cross-compatible.
image_search_paths = [p for p in
image_search_paths.split(os.path.pathsep) if p]
# List all related textures
texture_filenames = cmds.pgYetiCommand(node, listTextures=True)
self.log.info("Found %i texture(s)" % len(texture_filenames))
# List all related textures
texture_filenames = cmds.pgYetiCommand(node, listTextures=True)
self.log.info("Found %i texture(s)" % len(texture_filenames))
# Get all reference nodes
reference_nodes = cmds.pgYetiGraph(node,

View file

@ -7,11 +7,9 @@ import pype.api
class ExtractYetiCache(pype.api.Extractor):
"""Produce an alembic of just point positions and normals.
Positions and normals are preserved, but nothing more,
for plain and predictable point caches.
"""Producing Yeti cache files using scene time range.
This will extract Yeti cache file sequence and fur settings.
"""
label = "Extract Yeti Cache"
@ -44,7 +42,8 @@ class ExtractYetiCache(pype.api.Extractor):
else:
kwargs.update({"samples": samples})
self.log.info("Writing out cache")
self.log.info(
"Writing out cache {} - {}".format(start_frame, end_frame))
# Start writing the files for snap shot
# <NAME> will be replace by the Yeti node name
path = os.path.join(dirname, "<NAME>.%04d.fur")
@ -63,10 +62,29 @@ class ExtractYetiCache(pype.api.Extractor):
with open(data_file, "w") as fp:
json.dump(settings, fp, ensure_ascii=False)
# Ensure files can be stored
if "files" not in instance.data:
instance.data["files"] = list()
# build representations
if "representations" not in instance.data:
instance.data["representations"] = []
instance.data["files"].extend([cache_files, "yeti.fursettings"])
self.log.info("cache files: {}".format(cache_files[0]))
instance.data["representations"].append(
{
'name': 'fur',
'ext': 'fur',
'files': cache_files[0] if len(cache_files) == 1 else cache_files,
'stagingDir': dirname,
'anatomy_template': 'publish'
}
)
instance.data["representations"].append(
{
'name': 'fursettings',
'ext': 'fursettings',
'files': os.path.basename(data_file),
'stagingDir': dirname,
'anatomy_template': 'publish'
}
)
self.log.info("Extracted {} to {}".format(instance, dirname))

View file

@ -155,10 +155,30 @@ class ExtractYetiRig(pype.api.Extractor):
shader=False)
# Ensure files can be stored
if "files" not in instance.data:
instance.data["files"] = list()
# build representations
if "representations" not in instance.data:
instance.data["representations"] = []
instance.data["files"].extend(["yeti_rig.ma", "yeti.rigsettings"])
self.log.info("rig file: {}".format("yeti_rig.ma"))
instance.data["representations"].append(
{
'name': "ma",
'ext': 'ma',
'files': "yeti_rig.ma",
'stagingDir': dirname,
'anatomy_template': 'publish'
}
)
self.log.info("settings file: {}".format("yeti.rigsettings"))
instance.data["representations"].append(
{
'name': 'rigsettings',
'ext': 'rigsettings',
'files': 'yeti.rigsettings',
'stagingDir': dirname,
'anatomy_template': 'publish'
}
)
self.log.info("Extracted {} to {}".format(instance, dirname))

View file

@ -21,7 +21,7 @@ class ValidateFrameRange(pyblish.api.InstancePlugin):
"pointcache",
"camera",
"renderlayer",
"oolorbleed.vrayproxy"]
"colorbleed.vrayproxy"]
def process(self, instance):

View file

@ -1,9 +1,6 @@
import pyblish.api
import pype.action
import maya.cmds as cmds
import pype.maya.action
@ -60,4 +57,3 @@ class ValidateYetiRigCacheState(pyblish.api.InstancePlugin):
for node in invalid:
cmds.setAttr("%s.fileMode" % node, 0)
cmds.setAttr("%s.cacheFileName" % node, "", type="string")