mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
use openpye built-in variables for multiverse usd extractor
This commit is contained in:
parent
ae9e34bc62
commit
370416a949
1 changed files with 28 additions and 32 deletions
|
|
@ -58,22 +58,13 @@ class ExtractMultiverseUsd(openpype.api.Extractor):
|
|||
"writeUsdAttributes": bool,
|
||||
"timeVaryingTopology": bool,
|
||||
"customMaterialNamespace": str,
|
||||
"writeTimeRange": bool,
|
||||
"timeRangeStart": int,
|
||||
"timeRangeEnd": int,
|
||||
"timeRangeIncrement": int,
|
||||
"timeRangeNumTimeSamples": int,
|
||||
"timeRangeSamplesSpan": float,
|
||||
"timeRangeFramesPerSecond": float
|
||||
"numTimeSamples": int,
|
||||
"timeSamplesSpan": 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,
|
||||
|
|
@ -108,13 +99,8 @@ class ExtractMultiverseUsd(openpype.api.Extractor):
|
|||
"writeUsdAttributes": False,
|
||||
"timeVaryingTopology": False,
|
||||
"customMaterialNamespace": '',
|
||||
"writeTimeRange": True,
|
||||
"timeRangeStart": start_frame,
|
||||
"timeRangeEnd": end_frame,
|
||||
"timeRangeIncrement": 1,
|
||||
"timeRangeNumTimeSamples": 0,
|
||||
"timeRangeSamplesSpan": 0.0,
|
||||
"timeRangeFramesPerSecond": 24.0
|
||||
"numTimeSamples": 1,
|
||||
"timeSamplesSpan": 0.0
|
||||
}
|
||||
|
||||
def process(self, instance):
|
||||
|
|
@ -130,6 +116,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor):
|
|||
# Parse export options
|
||||
options = self.default_options
|
||||
self.log.info("Export options: {0}".format(options))
|
||||
self.log.info("Export instance data: {0}".format(instance.data))
|
||||
|
||||
# Perform extraction
|
||||
self.log.info("Performing extraction ...")
|
||||
|
|
@ -144,30 +131,39 @@ class ExtractMultiverseUsd(openpype.api.Extractor):
|
|||
long=True)
|
||||
self.log.info('Collected object {}'.format(members))
|
||||
|
||||
# TODO: Deal with asset, composition, overide with options.
|
||||
import multiverse
|
||||
|
||||
time_opts = None
|
||||
if options["writeTimeRange"]:
|
||||
frame_start = instance.data['frameStart']
|
||||
frame_end = instance.data['frameEnd']
|
||||
step = instance.data['step']
|
||||
fps = instance.data['fps']
|
||||
if frame_end != frame_start:
|
||||
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"]
|
||||
time_opts.frameRange = (frame_start, frame_end)
|
||||
time_opts.frameIncrement = step
|
||||
time_opts.numTimeSamples = instance.data["numTimeSamples"]
|
||||
time_opts.timeSamplesSpan = instance.data["timeSamplesSpan"]
|
||||
time_opts.framePerSecond = fps
|
||||
|
||||
asset_write_opts = multiverse.AssetWriteOptions(time_opts)
|
||||
options_items = getattr(options, "iteritems", options.items)
|
||||
for (k, v) in options_items():
|
||||
if k == "writeTimeRange" or k.startswith("timeRange"):
|
||||
options_discard_keys = [
|
||||
'numTimeSamples',
|
||||
'timeSamplesSpan',
|
||||
'frameStart',
|
||||
'frameEnd',
|
||||
'handleStart',
|
||||
'handleEnd',
|
||||
'step',
|
||||
'fps'
|
||||
]
|
||||
for key, value in options_items():
|
||||
if key in options_discard_keys:
|
||||
continue
|
||||
setattr(asset_write_opts, k, v)
|
||||
setattr(asset_write_opts, key, instance.data[key])
|
||||
|
||||
multiverse.WriteAsset(file_path, members, asset_write_opts)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue