add usd-21-11-win64_py39

This commit is contained in:
Sébastien Albert committed 2021-12-07 17:43:55 +01:00
1 parent 41d23e71ba
commit ba5e1f7e67
15684 files changed
+3069957

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
#
# Copyright 2019 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
from pxr import Tf
Tf.PreparePythonModule()
del Tf
from . import cameraArgs
from . import colorArgs
from . import complexityArgs
from . import framesArgs
from . import rendererArgs
Binary file not shown.
Binary file not shown.
+57
View File
@@ -0,0 +1,57 @@
#
# Copyright 2019 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
def AddCmdlineArgs(argsParser, defaultValue=None, altHelpText=''):
"""
Adds camera-related command line arguments to argsParser.
The resulting 'camera' argument will be an Sdf.Path. If no value is given
and defaultValue is not overridden, 'camera' will be a single-element path
containing the primary camera name.
"""
from pxr import Sdf
from pxr import UsdUtils
if defaultValue is None:
defaultValue = UsdUtils.GetPrimaryCameraName()
helpText = altHelpText
if not helpText:
helpText = (
'Which camera to use - may be given as either just the '
'camera\'s prim name (i.e. just the last element in the prim '
'path), or as a full prim path. Note that if only the prim name '
'is used and more than one camera exists with that name, which '
'one is used will effectively be random (default=%(default)s)')
# This avoids an Sdf warning if an empty string is given, which someone
# might do for example with usdview to open the app using the 'Free' camera
# instead of the primary camera.
def _ToSdfPath(inputArg):
if not inputArg:
return Sdf.Path.emptyPath
return Sdf.Path(inputArg)
argsParser.add_argument('--camera', '-cam', action='store',
type=_ToSdfPath, default=defaultValue, help=helpText)
Binary file not shown.
+38
View File
@@ -0,0 +1,38 @@
#
# Copyright 2019 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
def AddCmdlineArgs(argsParser, defaultValue='sRGB', altHelpText=''):
"""
Adds color-related command line arguments to argsParser.
The resulting 'colorCorrectionMode' argument will be a Python string.
"""
helpText = altHelpText
if not helpText:
helpText = (
'the color correction mode to use (default=%(default)s)')
argsParser.add_argument('--colorCorrectionMode', '-color', action='store',
type=str, default=defaultValue,
choices=['disabled', 'sRGB', 'openColorIO'], help=helpText)
Binary file not shown.
@@ -0,0 +1,132 @@
#
# Copyright 2019 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
class RefinementComplexities(object):
"""
An enum-like container of standard complexity settings.
"""
class _RefinementComplexity(object):
"""
Class which represents a level of mesh refinement complexity. Each
level has a string identifier, a display name, and a float complexity
value.
"""
def __init__(self, compId, name, value):
self._id = compId
self._name = name
self._value = value
def __repr__(self):
return self.id
@property
def id(self):
return self._id
@property
def name(self):
return self._name
@property
def value(self):
return self._value
LOW = _RefinementComplexity("low", "Low", 1.0)
MEDIUM = _RefinementComplexity("medium", "Medium", 1.1)
HIGH = _RefinementComplexity("high", "High", 1.2)
VERY_HIGH = _RefinementComplexity("veryhigh", "Very High", 1.3)
_ordered = (LOW, MEDIUM, HIGH, VERY_HIGH)
@classmethod
def ordered(cls):
"""
Get a tuple of all complexity levels in order.
"""
return cls._ordered
@classmethod
def fromId(cls, compId):
"""
Get a complexity from its identifier.
"""
matches = [comp for comp in cls._ordered if comp.id == compId]
if len(matches) == 0:
raise ValueError("No complexity with id '{}'".format(compId))
return matches[0]
@classmethod
def fromName(cls, name):
"""
Get a complexity from its display name.
"""
matches = [comp for comp in cls._ordered if comp.name == name]
if len(matches) == 0:
raise ValueError("No complexity with name '{}'".format(name))
return matches[0]
@classmethod
def next(cls, comp):
"""
Get the next highest level of complexity. If already at the highest
level, return it.
"""
if comp not in cls._ordered:
raise ValueError("Invalid complexity: {}".format(comp))
nextIndex = min(
len(cls._ordered) - 1,
cls._ordered.index(comp) + 1)
return cls._ordered[nextIndex]
@classmethod
def prev(cls, comp):
"""
Get the next lowest level of complexity. If already at the lowest
level, return it.
"""
if comp not in cls._ordered:
raise ValueError("Invalid complexity: {}".format(comp))
prevIndex = max(0, cls._ordered.index(comp) - 1)
return cls._ordered[prevIndex]
def AddCmdlineArgs(argsParser, defaultValue=RefinementComplexities.LOW,
altHelpText=''):
"""
Adds complexity-related command line arguments to argsParser.
The resulting 'complexity' argument will be one of the standard
RefinementComplexities.
"""
helpText = altHelpText
if not helpText:
helpText = ('level of refinement to use (default=%(default)s)')
argsParser.add_argument('--complexity', '-c', action='store',
type=RefinementComplexities.fromId,
default=defaultValue,
choices=[c for c in RefinementComplexities.ordered()],
help=helpText)
Binary file not shown.
+269
View File
@@ -0,0 +1,269 @@
#
# Copyright 2019 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
def _GetFloatStringPrecision(floatString):
"""
Gets the floating point precision specified by floatString.
floatString can either contain an actual float in string form, or it can be
a frame placeholder. We simply split the string on the dot (.) and return
the length of the part after the dot, if any.
If there is no dot in the string, a precision of zero is assumed.
"""
floatPrecision = 0
if not floatString:
return floatPrecision
floatStringParts = floatString.split('.')
if len(floatStringParts) > 1:
floatPrecision = len(floatStringParts[1])
return floatPrecision
class FrameSpecIterator(object):
"""
A simple iterator object that handles splitting multiple comma-separated
FrameSpecs into their equivalent UsdUtils.TimeCodeRanges, and then yields
all of the time codes in all of those ranges sequentially when iterated.
This object also stores the minimum floating point precision required to
disambiguate any neighboring time codes in the FrameSpecs given. This can
be used to validate that the frame placeholder in a frame format string has
enough precision to uniquely identify every frame without collisions.
"""
from pxr import UsdUtils
FRAMESPEC_SEPARATOR = ','
def __init__(self, frameSpec):
from pxr import UsdUtils
# Assume all frames are integral until we find a frame spec with a
# non-integral stride.
self._minFloatPrecision = 0
self._timeCodeRanges = []
subFrameSpecs = frameSpec.split(self.FRAMESPEC_SEPARATOR)
for subFrameSpec in subFrameSpecs:
timeCodeRange = UsdUtils.TimeCodeRange.CreateFromFrameSpec(
subFrameSpec)
self._timeCodeRanges.append(timeCodeRange)
specParts = subFrameSpec.split(
UsdUtils.TimeCodeRange.Tokens.StrideSeparator)
if len(specParts) == 2:
stride = specParts[1]
stridePrecision = _GetFloatStringPrecision(stride)
self._minFloatPrecision = max(self._minFloatPrecision,
stridePrecision)
def __iter__(self):
for timeCodeRange in self._timeCodeRanges:
for timeCode in timeCodeRange:
yield timeCode
@property
def minFloatPrecision(self):
return self._minFloatPrecision
def AddCmdlineArgs(argsParser, altDefaultTimeHelpText='', altFramesHelpText=''):
"""
Adds frame-related command line arguments to argsParser.
The resulting 'frames' argument will be an iterable of UsdTimeCodes.
If no command-line arguments are given, 'frames' will be a list containing
only Usd.TimeCode.EarliestTime(). If '--defaultTime' is given, 'frames'
will be a list containing only Usd.TimeCode.Default(). Otherwise,
'--frames' must be given a FrameSpec (or a comma-separated list of
multiple FrameSpecs), and 'frames' will be a FrameSpecIterator which when
iterated will yield the time codes specified by the FrameSpec(s).
"""
timeGroup = argsParser.add_mutually_exclusive_group()
helpText = altDefaultTimeHelpText
if not helpText:
helpText = (
'explicitly operate at the Default time code (the default '
'behavior is to operate at the Earliest time code)')
timeGroup.add_argument('--defaultTime', '-d', action='store_true',
dest='defaultTime', help=helpText)
helpText = altFramesHelpText
if not helpText:
helpText = (
'specify FrameSpec(s) of the time codes to operate on - A '
'FrameSpec consists of up to three floating point values for the '
'start time code, end time code, and stride of a time code range. '
'A single time code can be specified, or a start and end time '
'code can be specified separated by a colon (:). When a start '
'and end time code are specified, the stride may optionally be '
'specified as well, separating it from the start and end time '
'codes with (x). Multiple FrameSpecs can be combined as a '
'comma-separated list. The following are examples of valid '
'FrameSpecs: 123 - 101:105 - 105:101 - 101:109x2 - 101:110x2 - '
'101:104x0.5')
timeGroup.add_argument('--frames', '-f', action='store', type=str,
dest='frames', metavar='FRAMESPEC[,FRAMESPEC...]',
help=helpText)
def GetFramePlaceholder(frameFormat):
"""
Gets the frame placeholder in a frame format string.
This function expects the input frameFormat string to contain exactly one
frame placeholder. The placeholder must be composed of exactly one or two
groups of one or more hashes ('#'), and if there are two, they must be
separated by a dot ('.').
If no such placeholder exists in the frame format string, None is returned.
"""
if not frameFormat:
return None
import re
PLACEHOLDER_PATTERN = r'^[^#]*(?P<placeholder>#+(\.#+)?)[^#]*$'
matches = re.search(PLACEHOLDER_PATTERN, frameFormat)
if not matches:
return None
placeholder = matches.group(1)
return placeholder
def ConvertFramePlaceholderToFloatSpec(frameFormat):
"""
Converts the frame placeholder in a frame format string to a Python
{}-style float specifier for use with string.format().
This function expects the input frameFormat string to contain exactly one
frame placeholder. The placeholder must be composed of exactly one or two
groups of one or more hashes ('#'), and if there are two, they must be
separated by a dot ('.').
The hashes after the dot indicate the floating point precision to use in
the frame numbers inserted into the frame format string. If there is only
a single group of hashes, the precision is zero and the inserted frame
numbers will be integer values.
The overall width of the frame placeholder specifies the minimum width to
use when inserting frame numbers into the frame format string. Formatted
frame numbers smaller than the minimum width will be zero-padded on the
left until they reach the minimum width.
If the input frame format string does not contain exactly one frame
placeholder, this function will return None, indicating that this frame
format string cannot be used when operating with a frame range.
"""
placeholder = GetFramePlaceholder(frameFormat)
if not placeholder:
return None
# Frame numbers are zero-padded up to the field width.
specFill = 0
# The full width of the placeholder determines the minimum field width.
specWidth = len(placeholder)
# The hashes after the dot, if any, determine the precision. If there are
# none, integer frame numbers are used.
specPrecision = 0
parts = placeholder.split('.')
if len(parts) > 1:
specPrecision = len(parts[1])
floatSpec = ('{frame:' +
'{fill}{width}.{precision}f'.format(fill=specFill,
width=specWidth, precision=specPrecision) +
'}')
return frameFormat.replace(placeholder, floatSpec)
def ValidateCmdlineArgs(argsParser, args, frameFormatArgName=None):
"""
Validates the frame-related arguments in args parsed by argsParser.
This populates 'frames' with the appropriate iterable based on the
command-line arguments given, so it should be called after parse_args() is
called on argsParser.
When working with frame ranges, particularly when writing out images for
each frame, it is common to also have command-line arguments such as an
output image path for specifying where those images should be written. The
value given to this argument should include a frame placeholder so that it
can have the appropriate time code inserted. If the application has such an
argument, its name can be specified using frameFormatArgName. That arg will
be checked to ensure that it has a frame placeholder and it will be given
a value with that placeholder replaced with a Python format specifier so
that the value is ready to use with the str.format(frame=<timeCode>)
method. If a frame range is not provided as an argument, then it is an
error to include a frame placeholder in the frame format string.
"""
from pxr import Usd
framePlaceholder = None
frameFormat = None
if frameFormatArgName is not None:
frameFormat = getattr(args, frameFormatArgName)
framePlaceholder = GetFramePlaceholder(frameFormat)
frameFormat = ConvertFramePlaceholderToFloatSpec(frameFormat)
if args.frames:
args.frames = FrameSpecIterator(args.frames)
if frameFormatArgName is not None:
if not frameFormat:
argsParser.error('%s must contain exactly one frame number '
'placeholder of the form "###"" or "###.###". Note that '
'the number of hash marks is variable in each group.' %
frameFormatArgName)
placeholderPrecision = _GetFloatStringPrecision(framePlaceholder)
if placeholderPrecision < args.frames.minFloatPrecision:
argsParser.error('The given FrameSpecs require a minimum '
'floating point precision of %d, but the frame '
'placeholder in %s only specified a precision of %d (%s). '
'The precision of the frame placeholder must be equal to '
'or greater than %d.' % (args.frames.minFloatPrecision,
frameFormatArgName, placeholderPrecision,
framePlaceholder,args.frames.minFloatPrecision))
setattr(args, frameFormatArgName, frameFormat)
else:
if frameFormat:
argsParser.error('%s cannot contain a frame number placeholder '
'when not operating on a frame range.' % frameFormatArgName)
if args.defaultTime:
args.frames = [Usd.TimeCode.Default()]
else:
args.frames = [Usd.TimeCode.EarliestTime()]
return args
Binary file not shown.
@@ -0,0 +1,72 @@
#
# Copyright 2019 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
HYDRA_DISABLED_OPTION_STRING = "HydraDisabled"
def GetAllPluginArguments():
"""
Returns argument strings for all the renderer plugins available.
"""
from pxr import UsdImagingGL
return [ UsdImagingGL.Engine.GetRendererDisplayName(pluginId) for
pluginId in UsdImagingGL.Engine.GetRendererPlugins() ]
def GetPluginIdFromArgument(argumentString):
"""
Returns plugin id, if found, for the passed in argument string.
Valid argument strings are returned by GetAllPluginArguments().
"""
from pxr import UsdImagingGL
for p in UsdImagingGL.Engine.GetRendererPlugins():
if argumentString == UsdImagingGL.Engine.GetRendererDisplayName(p):
return p
return None
def AddCmdlineArgs(argsParser, altHelpText='', allowHydraDisabled=False):
"""
Adds Hydra renderer-related command line arguments to argsParser.
The resulting 'rendererPlugin' argument will be a _RendererPlugin instance
representing one of the available Hydra renderer plugins.
"""
from pxr import UsdImagingGL
helpText = altHelpText
if not helpText:
helpText = (
'Hydra renderer plugin to use when generating images')
renderers = GetAllPluginArguments()
if allowHydraDisabled:
renderers.append(HYDRA_DISABLED_OPTION_STRING)
argsParser.add_argument('--renderer', '-r', action='store',
dest='rendererPlugin',
choices=renderers,
help=helpText)
Binary file not shown.