mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
use time options for multiverse usd extractor
This commit is contained in:
parent
2adbe78122
commit
d6a0d2cd2e
1 changed files with 134 additions and 3 deletions
|
|
@ -13,6 +13,110 @@ class ExtractMultiverseUsd(openpype.api.Extractor):
|
|||
hosts = ["maya"]
|
||||
families = ["usd"]
|
||||
|
||||
@property
|
||||
def options(self):
|
||||
"""Overridable options for Multiverse USD Export
|
||||
|
||||
Given in the following format
|
||||
- {NAME: EXPECTED TYPE}
|
||||
|
||||
If the overridden option's type does not match,
|
||||
the option is not included and a warning is logged.
|
||||
|
||||
"""
|
||||
|
||||
return {
|
||||
"stripNamespaces": bool,
|
||||
"mergeTransformAndShape": bool,
|
||||
"writeAncestors": bool,
|
||||
"flattenParentXforms": bool,
|
||||
"writeSparseOverrides": bool,
|
||||
"useMetaPrimPath": bool,
|
||||
"customRootPath": str,
|
||||
"customAttributes": str,
|
||||
"nodeTypesToIgnore": str,
|
||||
"writeMeshes": bool,
|
||||
"writeCurves": bool,
|
||||
"writeParticles": bool,
|
||||
"writeCameras": bool,
|
||||
"writeLights": bool,
|
||||
"writeJoints": bool,
|
||||
"writeCollections": bool,
|
||||
"writePositions": bool,
|
||||
"writeNormals": bool,
|
||||
"writeUVs": bool,
|
||||
"writeColorSets": bool,
|
||||
"writeTangents": bool,
|
||||
"writeRefPositions": bool,
|
||||
"writeBlendShapes": bool,
|
||||
"writeDisplayColor": bool,
|
||||
"writeSkinWeights": bool,
|
||||
"writeMaterialAssignment": bool,
|
||||
"writeHardwareShader": bool,
|
||||
"writeShadingNetworks": bool,
|
||||
"writeTransformMatrix": bool,
|
||||
"writeUsdAttributes": bool,
|
||||
"timeVaryingTopology": bool,
|
||||
"customMaterialNamespace": str,
|
||||
"writeTimeRange": bool,
|
||||
"timeRangeStart": int,
|
||||
"timeRangeEnd": int,
|
||||
"timeRangeIncrement": int,
|
||||
"timeRangeNumTimeSamples": int,
|
||||
"timeRangeSamplesSpan": float,
|
||||
"timeRangeFramesPerSecond": float
|
||||
}
|
||||
|
||||
@property
|
||||
def default_options(self):
|
||||
"""The default options for Multiverse USD extraction."""
|
||||
start_frame = int(cmds.playbackOptions(query=True,
|
||||
animationStartTime=True))
|
||||
end_frame = int(cmds.playbackOptions(query=True,
|
||||
animationEndTime=True))
|
||||
|
||||
return {
|
||||
"stripNamespaces": False,
|
||||
"mergeTransformAndShape": False,
|
||||
"writeAncestors": True,
|
||||
"flattenParentXforms": False,
|
||||
"writeSparseOverrides": False,
|
||||
"useMetaPrimPath": False,
|
||||
"customRootPath": '',
|
||||
"customAttributes": '',
|
||||
"nodeTypesToIgnore": '',
|
||||
"writeMeshes": True,
|
||||
"writeCurves": True,
|
||||
"writeParticles": True,
|
||||
"writeCameras": False,
|
||||
"writeLights": False,
|
||||
"writeJoints": False,
|
||||
"writeCollections": False,
|
||||
"writePositions": True,
|
||||
"writeNormals": True,
|
||||
"writeUVs": True,
|
||||
"writeColorSets": False,
|
||||
"writeTangents": False,
|
||||
"writeRefPositions": False,
|
||||
"writeBlendShapes": False,
|
||||
"writeDisplayColor": False,
|
||||
"writeSkinWeights": False,
|
||||
"writeMaterialAssignment": False,
|
||||
"writeHardwareShader": False,
|
||||
"writeShadingNetworks": False,
|
||||
"writeTransformMatrix": True,
|
||||
"writeUsdAttributes": False,
|
||||
"timeVaryingTopology": False,
|
||||
"customMaterialNamespace": '',
|
||||
"writeTimeRange": False,
|
||||
"timeRangeStart": 1,
|
||||
"timeRangeEnd": 1,
|
||||
"timeRangeIncrement": 1,
|
||||
"timeRangeNumTimeSamples": 0,
|
||||
"timeRangeSamplesSpan": 0.0,
|
||||
"timeRangeFramesPerSecond": 24.0
|
||||
}
|
||||
|
||||
def process(self, instance):
|
||||
# Load plugin firstly
|
||||
cmds.loadPlugin("MultiverseForMaya", quiet=True)
|
||||
|
|
@ -23,6 +127,10 @@ class ExtractMultiverseUsd(openpype.api.Extractor):
|
|||
file_path = os.path.join(staging_dir, file_name)
|
||||
file_path = file_path.replace('\\', '/')
|
||||
|
||||
# Parse export options
|
||||
options = self.default_options
|
||||
self.log.info("Export options: {0}".format(options))
|
||||
|
||||
# Perform extraction
|
||||
self.log.info("Performing extraction ...")
|
||||
|
||||
|
|
@ -34,11 +142,33 @@ class ExtractMultiverseUsd(openpype.api.Extractor):
|
|||
type=("mesh"),
|
||||
noIntermediate=True,
|
||||
long=True)
|
||||
self.log.info('Collected object {}'.format(members))
|
||||
|
||||
# TODO: Deal with asset, composition, overide with options.
|
||||
import multiverse
|
||||
options = multiverse.AssetWriteOptions()
|
||||
multiverse.WriteAsset(file_path, members, options)
|
||||
|
||||
time_opts = None
|
||||
if options["writeTimeRange"]:
|
||||
time_opts = multiverse.TimeOptions()
|
||||
|
||||
time_opts.writeTimeRange = True
|
||||
|
||||
time_range_start = options["timeRangeStart"]
|
||||
time_range_end = options["timeRangeEnd"]
|
||||
time_opts.frameRange = (time_range_start, time_range_end)
|
||||
|
||||
time_opts.frameIncrement = options["timeRangeIncrement"]
|
||||
time_opts.numTimeSamples = options["timeRangeNumTimeSamples"]
|
||||
time_opts.timeSamplesSpan = options["timeRangeSamplesSpan"]
|
||||
time_opts.framePerSecond = options["timeRangeFramesPerSecond"]
|
||||
|
||||
asset_write_opts = multiverse.AssetWriteOptions(time_opts)
|
||||
for (k, v) in options.iteritems():
|
||||
if k == "writeTimeRange" or k.startswith("timeRange"):
|
||||
continue
|
||||
setattr(asset_write_opts, k, v)
|
||||
|
||||
multiverse.WriteAsset(file_path, members, asset_write_opts)
|
||||
|
||||
if "representations" not in instance.data:
|
||||
instance.data["representations"] = []
|
||||
|
|
@ -51,4 +181,5 @@ class ExtractMultiverseUsd(openpype.api.Extractor):
|
|||
}
|
||||
instance.data["representations"].append(representation)
|
||||
|
||||
self.log.info("Extracted {} to {}".format(instance, file_path))
|
||||
self.log.info("Extracted instance {} to {}".format(
|
||||
instance.name, file_path))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue