add usd-21-11-win64_py39
This commit is contained in:
1 parent
41d23e71ba
commit
ba5e1f7e67
15684 files changed
+3069957
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
"""
|
||||
Camera utilities.
|
||||
|
||||
"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
"""
|
||||
garch
|
||||
|
||||
"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
"""
|
||||
Graphics Foundation
|
||||
This package defines classes for fundamental graphics types and operations.
|
||||
"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
"""
|
||||
glf
|
||||
|
||||
"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
"""Python bindings for libKind"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Copyright 2018 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.
|
||||
#
|
||||
|
||||
"""Python bindings for libNdr"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
"""
|
||||
This package defines facilities for dealing with plugins.
|
||||
"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
"""
|
||||
Pixar OSD implementation.
|
||||
"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,82 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
|
||||
def Find(layerFileName, scenePath=None):
|
||||
'''Find(layerFileName, scenePath) -> object
|
||||
|
||||
layerFileName: string
|
||||
scenePath: Path
|
||||
|
||||
If given a single string argument, returns the menv layer with
|
||||
the given filename. If given two arguments (a string and a Path), finds
|
||||
the menv layer with the given filename and returns the scene object
|
||||
within it at the given path.'''
|
||||
layer = Layer.Find(layerFileName)
|
||||
if (scenePath is None): return layer
|
||||
return layer.GetObjectAtPath(scenePath)
|
||||
|
||||
|
||||
# Test utilities
|
||||
def _PathElemsToPrefixes(absolute, elements):
|
||||
if absolute:
|
||||
string = "/"
|
||||
else:
|
||||
string = ""
|
||||
|
||||
lastElemWasDotDot = False
|
||||
didFirst = False
|
||||
|
||||
for elem in elements:
|
||||
if elem == Path.parentPathElement:
|
||||
# dotdot
|
||||
if didFirst:
|
||||
string = string + "/"
|
||||
else:
|
||||
didFirst = True
|
||||
string = string + elem
|
||||
lastElemWasDotDot = True
|
||||
elif elem[0] == ".":
|
||||
# property
|
||||
if lastElemWasDotDot:
|
||||
string = string + "/"
|
||||
string = string + elem
|
||||
lastElemWasDotDot = False
|
||||
elif elem[0] == "[":
|
||||
# rel attr or sub-attr indices, don't care which
|
||||
string = string + elem
|
||||
lastElemWasDotDot = False
|
||||
else:
|
||||
if didFirst:
|
||||
string = string + "/"
|
||||
else:
|
||||
didFirst = True
|
||||
string = string + elem
|
||||
lastElemWasDotDot = False
|
||||
if not string:
|
||||
return []
|
||||
path = Path(string)
|
||||
return path.GetPrefixes()
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# Copyright 2018 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.
|
||||
#
|
||||
|
||||
"""Python bindings for libSdr"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,611 @@
|
||||
#!/pxrpythonsubst
|
||||
#
|
||||
# Copyright 2018 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.
|
||||
|
||||
"""
|
||||
Common utilities that shader-based parser plugins can use in their tests.
|
||||
|
||||
This is mostly focused on dealing with OSL and Args files. This may need to be
|
||||
expanded/generalized to accommodate other types in the future.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from pxr import Ndr
|
||||
from pxr import Sdr
|
||||
from pxr.Sdf import ValueTypeNames as SdfTypes
|
||||
from pxr import Tf
|
||||
|
||||
|
||||
def IsNodeOSL(node):
|
||||
"""
|
||||
Determines if the given node has an OSL source type.
|
||||
"""
|
||||
|
||||
return node.GetSourceType() == "OSL"
|
||||
|
||||
# XXX Maybe rename this to GetSdfType (as opposed to the Sdr type)
|
||||
def GetType(property):
|
||||
"""
|
||||
Given a property (SdrShaderProperty), return the SdfValueTypeName type.
|
||||
"""
|
||||
sdfTypeIndicator = property.GetTypeAsSdfType()
|
||||
sdfValueTypeName = sdfTypeIndicator[0]
|
||||
tfType = sdfValueTypeName.type
|
||||
|
||||
return tfType
|
||||
|
||||
def TestBasicProperties(node):
|
||||
"""
|
||||
Test the correctness of the properties on the specified node (only the
|
||||
non-shading-specific aspects).
|
||||
"""
|
||||
|
||||
isOSL = IsNodeOSL(node)
|
||||
|
||||
# Data that varies between OSL/Args
|
||||
# --------------------------------------------------------------------------
|
||||
metadata = {
|
||||
"widget": "number",
|
||||
"label": "inputA label",
|
||||
"page": "inputs1",
|
||||
"help": "inputA help message",
|
||||
"uncategorized": "1"
|
||||
}
|
||||
|
||||
if not isOSL:
|
||||
metadata["name"] = "inputA"
|
||||
metadata["default"] = "0.0"
|
||||
metadata["type"] = "float"
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
properties = {
|
||||
"inputA": node.GetInput("inputA"),
|
||||
"inputB": node.GetInput("inputB"),
|
||||
"inputC": node.GetInput("inputC"),
|
||||
"inputD": node.GetInput("inputD"),
|
||||
"inputF2": node.GetInput("inputF2"),
|
||||
"inputStrArray": node.GetInput("inputStrArray"),
|
||||
"resultF": node.GetOutput("resultF"),
|
||||
"resultI": node.GetOutput("resultI"),
|
||||
}
|
||||
|
||||
assert properties["inputA"].GetName() == "inputA"
|
||||
assert properties["inputA"].GetType() == "float"
|
||||
assert properties["inputA"].GetDefaultValue() == 0.0
|
||||
assert not properties["inputA"].IsOutput()
|
||||
assert not properties["inputA"].IsArray()
|
||||
assert not properties["inputA"].IsDynamicArray()
|
||||
assert properties["inputA"].GetArraySize() == 0
|
||||
assert properties["inputA"].GetInfoString() == "inputA (type: 'float'); input"
|
||||
assert properties["inputA"].IsConnectable()
|
||||
assert properties["inputA"].CanConnectTo(properties["resultF"])
|
||||
assert not properties["inputA"].CanConnectTo(properties["resultI"])
|
||||
assert properties["inputA"].GetMetadata() == metadata
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Check some array variations
|
||||
# --------------------------------------------------------------------------
|
||||
assert properties["inputD"].IsDynamicArray()
|
||||
assert properties["inputD"].GetArraySize() == 1 if isOSL else -1
|
||||
assert properties["inputD"].IsArray()
|
||||
assert list(properties["inputD"].GetDefaultValue()) == [1]
|
||||
|
||||
assert not properties["inputF2"].IsDynamicArray()
|
||||
assert properties["inputF2"].GetArraySize() == 2
|
||||
assert properties["inputF2"].IsArray()
|
||||
assert not properties["inputF2"].IsConnectable()
|
||||
assert list(properties["inputF2"].GetDefaultValue()) == [1.0, 2.0]
|
||||
|
||||
assert properties["inputStrArray"].GetArraySize() == 4
|
||||
assert list(properties["inputStrArray"].GetDefaultValue()) == \
|
||||
["test", "string", "array", "values"]
|
||||
|
||||
|
||||
def TestShadingProperties(node):
|
||||
"""
|
||||
Test the correctness of the properties on the specified node (only the
|
||||
shading-specific aspects).
|
||||
"""
|
||||
|
||||
isOSL = IsNodeOSL(node)
|
||||
|
||||
properties = {
|
||||
"inputA": node.GetShaderInput("inputA"),
|
||||
"inputB": node.GetShaderInput("inputB"),
|
||||
"inputC": node.GetShaderInput("inputC"),
|
||||
"inputD": node.GetShaderInput("inputD"),
|
||||
"inputF2": node.GetShaderInput("inputF2"),
|
||||
"inputF3": node.GetShaderInput("inputF3"),
|
||||
"inputF4": node.GetShaderInput("inputF4"),
|
||||
"inputF5": node.GetShaderInput("inputF5"),
|
||||
"inputInterp": node.GetShaderInput("inputInterp"),
|
||||
"inputOptions": node.GetShaderInput("inputOptions"),
|
||||
"inputPoint": node.GetShaderInput("inputPoint"),
|
||||
"inputNormal": node.GetShaderInput("inputNormal"),
|
||||
"inputStruct": node.GetShaderInput("inputStruct"),
|
||||
"inputAssetIdentifier": node.GetShaderInput("inputAssetIdentifier"),
|
||||
"resultF": node.GetShaderOutput("resultF"),
|
||||
"resultF2": node.GetShaderOutput("resultF2"),
|
||||
"resultF3": node.GetShaderOutput("resultF3"),
|
||||
"resultI": node.GetShaderOutput("resultI"),
|
||||
"vstruct1": node.GetShaderOutput("vstruct1"),
|
||||
"vstruct1_bump": node.GetShaderOutput("vstruct1_bump"),
|
||||
"outputPoint": node.GetShaderOutput("outputPoint"),
|
||||
"outputNormal": node.GetShaderOutput("outputNormal"),
|
||||
"outputColor": node.GetShaderOutput("outputColor"),
|
||||
"outputVector": node.GetShaderOutput("outputVector"),
|
||||
}
|
||||
|
||||
assert properties["inputA"].GetLabel() == "inputA label"
|
||||
assert properties["inputA"].GetHelp() == "inputA help message"
|
||||
assert properties["inputA"].GetPage() == "inputs1"
|
||||
assert properties["inputA"].GetWidget() == "number"
|
||||
assert properties["inputA"].GetHints() == {
|
||||
"uncategorized": "1"
|
||||
}
|
||||
assert properties["inputA"].GetOptions() == []
|
||||
assert properties["inputA"].GetVStructMemberOf() == ""
|
||||
assert properties["inputA"].GetVStructMemberName() == ""
|
||||
assert not properties["inputA"].IsVStructMember()
|
||||
assert not properties["inputA"].IsVStruct()
|
||||
assert properties["inputA"].IsConnectable()
|
||||
assert properties["inputA"].GetValidConnectionTypes() == []
|
||||
assert properties["inputA"].CanConnectTo(properties["resultF"])
|
||||
assert not properties["inputA"].CanConnectTo(properties["resultI"])
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Check correct options parsing
|
||||
# --------------------------------------------------------------------------
|
||||
assert set(properties["inputOptions"].GetOptions()) == {
|
||||
("opt1", "opt1val"),
|
||||
("opt2", "opt2val")
|
||||
}
|
||||
|
||||
assert set(properties["inputInterp"].GetOptions()) == {
|
||||
("linear", ""),
|
||||
("catmull-rom", ""),
|
||||
("bspline", ""),
|
||||
("constant", ""),
|
||||
}
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Check cross-type connection allowances
|
||||
# --------------------------------------------------------------------------
|
||||
assert properties["inputPoint"].CanConnectTo(properties["outputNormal"])
|
||||
assert properties["inputNormal"].CanConnectTo(properties["outputPoint"])
|
||||
assert properties["inputNormal"].CanConnectTo(properties["outputColor"])
|
||||
assert properties["inputNormal"].CanConnectTo(properties["outputVector"])
|
||||
assert properties["inputNormal"].CanConnectTo(properties["resultF3"])
|
||||
assert properties["inputF2"].CanConnectTo(properties["resultF2"])
|
||||
assert properties["inputD"].CanConnectTo(properties["resultI"])
|
||||
assert not properties["inputNormal"].CanConnectTo(properties["resultF2"])
|
||||
assert not properties["inputF4"].CanConnectTo(properties["resultF2"])
|
||||
assert not properties["inputF2"].CanConnectTo(properties["resultF3"])
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Check clean and unclean mappings to Sdf types
|
||||
# --------------------------------------------------------------------------
|
||||
assert properties["inputB"].GetTypeAsSdfType() == (SdfTypes.Int, "")
|
||||
assert properties["inputF2"].GetTypeAsSdfType() == (SdfTypes.Float2, "")
|
||||
assert properties["inputF3"].GetTypeAsSdfType() == (SdfTypes.Float3, "")
|
||||
assert properties["inputF4"].GetTypeAsSdfType() == (SdfTypes.Float4, "")
|
||||
assert properties["inputF5"].GetTypeAsSdfType() == (SdfTypes.FloatArray, "")
|
||||
assert properties["inputStruct"].GetTypeAsSdfType() == \
|
||||
(SdfTypes.Token, Sdr.PropertyTypes.Struct)
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# Ensure asset identifiers are detected correctly
|
||||
# --------------------------------------------------------------------------
|
||||
assert properties["inputAssetIdentifier"].IsAssetIdentifier()
|
||||
assert not properties["inputOptions"].IsAssetIdentifier()
|
||||
assert properties["inputAssetIdentifier"].GetTypeAsSdfType() == \
|
||||
(SdfTypes.Asset, "")
|
||||
|
||||
# Nested pages and VStructs are only possible in args files
|
||||
if not isOSL:
|
||||
# ----------------------------------------------------------------------
|
||||
# Check nested page correctness
|
||||
# ----------------------------------------------------------------------
|
||||
assert properties["vstruct1"].GetPage() == "VStructs.Nested"
|
||||
assert properties["vstruct1_bump"].GetPage() == "VStructs.Nested.More"
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
# Check VStruct correctness
|
||||
# ----------------------------------------------------------------------
|
||||
assert properties["vstruct1"].IsVStruct()
|
||||
assert properties["vstruct1"].GetVStructMemberOf() == ""
|
||||
assert properties["vstruct1"].GetVStructMemberName() == ""
|
||||
assert not properties["vstruct1"].IsVStructMember()
|
||||
|
||||
assert not properties["vstruct1_bump"].IsVStruct()
|
||||
assert properties["vstruct1_bump"].GetVStructMemberOf() == "vstruct1"
|
||||
assert properties["vstruct1_bump"].GetVStructMemberName() == "bump"
|
||||
assert properties["vstruct1_bump"].IsVStructMember()
|
||||
|
||||
|
||||
def TestBasicNode(node, nodeSourceType, nodeDefinitionURI, nodeImplementationURI):
|
||||
"""
|
||||
Test basic, non-shader-specific correctness on the specified node.
|
||||
"""
|
||||
|
||||
# Implementation notes:
|
||||
# ---
|
||||
# The source type needs to be passed manually in order to ensure the utils
|
||||
# do not have a dependency on the plugin (where the source type resides).
|
||||
# The URIs are manually specified because the utils cannot know ahead of
|
||||
# time where the node originated.
|
||||
|
||||
isOSL = IsNodeOSL(node)
|
||||
nodeContext = "OSL" if isOSL else "pattern"
|
||||
|
||||
# Data that varies between OSL/Args
|
||||
# --------------------------------------------------------------------------
|
||||
nodeName = "TestNodeOSL" if isOSL else "TestNodeARGS"
|
||||
numOutputs = 8 if isOSL else 10
|
||||
outputNames = {
|
||||
"resultF", "resultF2", "resultF3", "resultI", "outputPoint",
|
||||
"outputNormal", "outputColor", "outputVector"
|
||||
}
|
||||
metadata = {
|
||||
"category": "testing",
|
||||
"departments": "testDept",
|
||||
"help": "This is the test node",
|
||||
"label": "TestNodeLabel",
|
||||
"primvars": "primvar1|primvar2|primvar3|$primvarNamingProperty|"
|
||||
"$invalidPrimvarNamingProperty",
|
||||
"uncategorizedMetadata": "uncategorized"
|
||||
}
|
||||
|
||||
if not isOSL:
|
||||
metadata.pop("category")
|
||||
metadata.pop("label")
|
||||
metadata.pop("uncategorizedMetadata")
|
||||
|
||||
outputNames.add("vstruct1")
|
||||
outputNames.add("vstruct1_bump")
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
nodeInputs = {propertyName: node.GetShaderInput(propertyName)
|
||||
for propertyName in node.GetInputNames()}
|
||||
|
||||
nodeOutputs = {propertyName: node.GetShaderOutput(propertyName)
|
||||
for propertyName in node.GetOutputNames()}
|
||||
|
||||
assert node.GetName() == nodeName
|
||||
assert node.GetContext() == nodeContext
|
||||
assert node.GetSourceType() == nodeSourceType
|
||||
assert node.GetFamily() == ""
|
||||
assert node.GetResolvedDefinitionURI() == nodeDefinitionURI
|
||||
assert node.GetResolvedImplementationURI() == nodeImplementationURI
|
||||
assert node.IsValid()
|
||||
assert len(nodeInputs) == 17
|
||||
assert len(nodeOutputs) == numOutputs
|
||||
assert nodeInputs["inputA"] is not None
|
||||
assert nodeInputs["inputB"] is not None
|
||||
assert nodeInputs["inputC"] is not None
|
||||
assert nodeInputs["inputD"] is not None
|
||||
assert nodeInputs["inputF2"] is not None
|
||||
assert nodeInputs["inputF3"] is not None
|
||||
assert nodeInputs["inputF4"] is not None
|
||||
assert nodeInputs["inputF5"] is not None
|
||||
assert nodeInputs["inputInterp"] is not None
|
||||
assert nodeInputs["inputOptions"] is not None
|
||||
assert nodeInputs["inputPoint"] is not None
|
||||
assert nodeInputs["inputNormal"] is not None
|
||||
assert nodeOutputs["resultF2"] is not None
|
||||
assert nodeOutputs["resultI"] is not None
|
||||
assert nodeOutputs["outputPoint"] is not None
|
||||
assert nodeOutputs["outputNormal"] is not None
|
||||
assert nodeOutputs["outputColor"] is not None
|
||||
assert nodeOutputs["outputVector"] is not None
|
||||
print(set(node.GetInputNames()))
|
||||
assert set(node.GetInputNames()) == {
|
||||
"inputA", "inputB", "inputC", "inputD", "inputF2", "inputF3", "inputF4",
|
||||
"inputF5", "inputInterp", "inputOptions", "inputPoint", "inputNormal",
|
||||
"inputStruct", "inputAssetIdentifier", "primvarNamingProperty",
|
||||
"invalidPrimvarNamingProperty", "inputStrArray"
|
||||
}
|
||||
assert set(node.GetOutputNames()) == outputNames
|
||||
|
||||
# There may be additional metadata passed in via the NdrNodeDiscoveryResult.
|
||||
# So, ensure that the bits we expect to see are there instead of doing
|
||||
# an equality check.
|
||||
nodeMetadata = node.GetMetadata()
|
||||
for i,j in metadata.items():
|
||||
assert i in nodeMetadata
|
||||
assert nodeMetadata[i] == metadata[i]
|
||||
|
||||
# Test basic property correctness
|
||||
TestBasicProperties(node)
|
||||
|
||||
|
||||
def TestShaderSpecificNode(node):
|
||||
"""
|
||||
Test shader-specific correctness on the specified node.
|
||||
"""
|
||||
|
||||
isOSL = IsNodeOSL(node)
|
||||
|
||||
# Data that varies between OSL/Args
|
||||
# --------------------------------------------------------------------------
|
||||
numOutputs = 8 if isOSL else 10
|
||||
label = "TestNodeLabel" if isOSL else ""
|
||||
category = "testing" if isOSL else ""
|
||||
vstructNames = [] if isOSL else ["vstruct1"]
|
||||
pages = {"", "inputs1", "inputs2", "results"} if isOSL else \
|
||||
{"", "inputs1", "inputs2", "results", "VStructs.Nested",
|
||||
"VStructs.Nested.More"}
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
shaderInputs = {propertyName: node.GetShaderInput(propertyName)
|
||||
for propertyName in node.GetInputNames()}
|
||||
|
||||
shaderOutputs = {propertyName: node.GetShaderOutput(propertyName)
|
||||
for propertyName in node.GetOutputNames()}
|
||||
|
||||
assert len(shaderInputs) == 17
|
||||
assert len(shaderOutputs) == numOutputs
|
||||
assert shaderInputs["inputA"] is not None
|
||||
assert shaderInputs["inputB"] is not None
|
||||
assert shaderInputs["inputC"] is not None
|
||||
assert shaderInputs["inputD"] is not None
|
||||
assert shaderInputs["inputF2"] is not None
|
||||
assert shaderInputs["inputF3"] is not None
|
||||
assert shaderInputs["inputF4"] is not None
|
||||
assert shaderInputs["inputF5"] is not None
|
||||
assert shaderInputs["inputInterp"] is not None
|
||||
assert shaderInputs["inputOptions"] is not None
|
||||
assert shaderInputs["inputPoint"] is not None
|
||||
assert shaderInputs["inputNormal"] is not None
|
||||
assert shaderOutputs["resultF"] is not None
|
||||
assert shaderOutputs["resultF2"] is not None
|
||||
assert shaderOutputs["resultF3"] is not None
|
||||
assert shaderOutputs["resultI"] is not None
|
||||
assert shaderOutputs["outputPoint"] is not None
|
||||
assert shaderOutputs["outputNormal"] is not None
|
||||
assert shaderOutputs["outputColor"] is not None
|
||||
assert shaderOutputs["outputVector"] is not None
|
||||
assert node.GetLabel() == label
|
||||
assert node.GetCategory() == category
|
||||
assert node.GetHelp() == "This is the test node"
|
||||
assert node.GetDepartments() == ["testDept"]
|
||||
assert set(node.GetPages()) == pages
|
||||
assert set(node.GetPrimvars()) == {"primvar1", "primvar2", "primvar3"}
|
||||
assert set(node.GetAdditionalPrimvarProperties()) == {"primvarNamingProperty"}
|
||||
assert set(node.GetPropertyNamesForPage("results")) == {
|
||||
"resultF", "resultF2", "resultF3", "resultI"
|
||||
}
|
||||
assert set(node.GetPropertyNamesForPage("")) == {
|
||||
"outputPoint", "outputNormal", "outputColor", "outputVector"
|
||||
}
|
||||
assert set(node.GetPropertyNamesForPage("inputs1")) == {"inputA"}
|
||||
assert set(node.GetPropertyNamesForPage("inputs2")) == {
|
||||
"inputB", "inputC", "inputD", "inputF2", "inputF3", "inputF4", "inputF5",
|
||||
"inputInterp", "inputOptions", "inputPoint", "inputNormal",
|
||||
"inputStruct", "inputAssetIdentifier", "primvarNamingProperty",
|
||||
"invalidPrimvarNamingProperty", "inputStrArray"
|
||||
}
|
||||
assert node.GetAllVstructNames() == vstructNames
|
||||
|
||||
# Test shading-specific property correctness
|
||||
TestShadingProperties(node)
|
||||
|
||||
|
||||
def TestShaderPropertiesNode(node):
|
||||
"""
|
||||
Tests property correctness on the specified shader node, which must be
|
||||
one of the following pre-defined nodes:
|
||||
* 'TestShaderPropertiesNodeOSL'
|
||||
* 'TestShaderPropertiesNodeARGS'
|
||||
* 'TestShaderPropertiesNodeUSD'
|
||||
These pre-defined nodes have a property of every type that Sdr supports.
|
||||
|
||||
Property correctness is defined as:
|
||||
* The shader property has the expected SdrPropertyType
|
||||
* The shader property has the expected SdfValueTypeName
|
||||
* If the shader property has a default value, the default value's type
|
||||
matches the shader property's type
|
||||
"""
|
||||
# This test should only be run on the following allowed node names
|
||||
# --------------------------------------------------------------------------
|
||||
allowedNodeNames = ["TestShaderPropertiesNodeOSL",
|
||||
"TestShaderPropertiesNodeARGS",
|
||||
"TestShaderPropertiesNodeUSD"]
|
||||
|
||||
# If this assertion on the name fails, then this test was called with the
|
||||
# wrong node.
|
||||
assert node.GetName() in allowedNodeNames
|
||||
|
||||
# If we have the correct node name, double check that the source type is
|
||||
# also correct
|
||||
if node.GetName() == "TestShaderPropertiesNodeOSL":
|
||||
assert node.GetSourceType() == "OSL"
|
||||
elif node.GetName() == "TestShaderPropertiesNodeARGS":
|
||||
assert node.GetSourceType() == "RmanCpp"
|
||||
elif node.GetName() == "TestShaderPropertiesNodeUSD":
|
||||
assert node.GetSourceType() == "glslfx"
|
||||
|
||||
nodeInputs = {propertyName: node.GetShaderInput(propertyName)
|
||||
for propertyName in node.GetInputNames()}
|
||||
|
||||
nodeOutputs = {propertyName: node.GetShaderOutput(propertyName)
|
||||
for propertyName in node.GetOutputNames()}
|
||||
|
||||
# For each property, we test that:
|
||||
# * The property has the expected SdrPropertyType
|
||||
# * The property has the expected TfType (from SdfValueTypeName)
|
||||
# * The property's type and default value's type match
|
||||
|
||||
property = nodeInputs["inputInt"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Int
|
||||
assert GetType(property) == Tf.Type.FindByName("int")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputString"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.String
|
||||
assert GetType(property) == Tf.Type.FindByName("string")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputFloat"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Float
|
||||
assert GetType(property) == Tf.Type.FindByName("float")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputColor"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Color
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputPoint"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Point
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputNormal"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Normal
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputVector"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Vector
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputMatrix"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Matrix
|
||||
assert GetType(property) == Tf.Type.FindByName("GfMatrix4d")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
if node.GetName() != "TestShaderPropertiesNodeUSD":
|
||||
# XXX Note that 'struct' and 'vstruct' types are currently unsupported
|
||||
# by the UsdShadeShaderDefParserPlugin, which parses shaders defined in
|
||||
# usd files. Please see UsdShadeShaderDefParserPlugin implementation for
|
||||
# details.
|
||||
property = nodeInputs["inputStruct"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Struct
|
||||
assert GetType(property) == Tf.Type.FindByName("TfToken")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputVstruct"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Vstruct
|
||||
assert GetType(property) == Tf.Type.FindByName("TfToken")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputIntArray"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Int
|
||||
assert GetType(property) == Tf.Type.FindByName("VtArray<int>")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputStringArray"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.String
|
||||
assert GetType(property) == Tf.Type.FindByName("VtArray<string>")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputFloatArray"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Float
|
||||
assert GetType(property) == Tf.Type.FindByName("VtArray<float>")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputColorArray"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Color
|
||||
assert GetType(property) == Tf.Type.FindByName("VtArray<GfVec3f>")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputPointArray"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Point
|
||||
assert GetType(property) == Tf.Type.FindByName("VtArray<GfVec3f>")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputNormalArray"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Normal
|
||||
assert GetType(property) == Tf.Type.FindByName("VtArray<GfVec3f>")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputVectorArray"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Vector
|
||||
assert GetType(property) == Tf.Type.FindByName("VtArray<GfVec3f>")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputMatrixArray"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Matrix
|
||||
assert GetType(property) == Tf.Type.FindByName("VtArray<GfMatrix4d>")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputFloat2"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Float
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec2f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputFloat3"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Float
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputFloat4"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Float
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec4f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputAsset"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.String
|
||||
assert GetType(property) == Tf.Type.FindByName("SdfAssetPath")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputAssetArray"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.String
|
||||
assert GetType(property) == Tf.Type.FindByName("VtArray<SdfAssetPath>")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputColorRoleNone"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Float
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputPointRoleNone"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Float
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputNormalRoleNone"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Float
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeInputs["inputVectorRoleNone"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Float
|
||||
assert GetType(property) == Tf.Type.FindByName("GfVec3f")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
property = nodeOutputs["outputSurface"]
|
||||
assert property.GetType() == Sdr.PropertyTypes.Terminal
|
||||
assert GetType(property) == Tf.Type.FindByName("TfToken")
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
# Specific test of implementationName feature, we can skip type-tests
|
||||
property = nodeInputs["normal"]
|
||||
assert property.GetImplementationName() == "aliasedNormalInput"
|
||||
assert Ndr._ValidateProperty(node, property)
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# This file makes this module importable from python, which avoids a warning
|
||||
# when initializing the SdrRegistry.
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,246 @@
|
||||
#
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
"""
|
||||
Tf -- Tools Foundation
|
||||
"""
|
||||
|
||||
# Type to help handle DLL import paths on Windows with python interpreters v3.8
|
||||
# and newer. These interpreters don't search for DLLs in the path anymore, you
|
||||
# have to provide a path explicitly. This re-enables path searching for USD
|
||||
# dependency libraries
|
||||
import platform, sys
|
||||
if sys.version_info >= (3, 8) and platform.system() == "Windows":
|
||||
import contextlib
|
||||
|
||||
@contextlib.contextmanager
|
||||
def WindowsImportWrapper():
|
||||
import os
|
||||
dirs = []
|
||||
import_paths = os.getenv('PXR_USD_WINDOWS_DLL_PATH')
|
||||
if import_paths is None:
|
||||
import_paths = os.getenv('PATH', '')
|
||||
for path in import_paths.split(os.pathsep):
|
||||
# Calling add_dll_directory raises an exception if paths don't
|
||||
# exist, or if you pass in dot
|
||||
if os.path.exists(path) and path != '.':
|
||||
dirs.append(os.add_dll_directory(path))
|
||||
# This block guarantees we clear the dll directories if an exception
|
||||
# is raised in the with block.
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
for dll_dir in dirs:
|
||||
dll_dir.close()
|
||||
del os
|
||||
del contextlib
|
||||
else:
|
||||
class WindowsImportWrapper(object):
|
||||
def __enter__(self):
|
||||
pass
|
||||
def __exit__(self, exc_type, ex_val, exc_tb):
|
||||
pass
|
||||
del platform, sys
|
||||
|
||||
|
||||
def PreparePythonModule(moduleName=None):
|
||||
"""Prepare an extension module at import time. This will import the
|
||||
Python module associated with the caller's module (e.g. '_tf' for 'pxr.Tf')
|
||||
or the module with the specified moduleName and copy its contents into
|
||||
the caller's local namespace.
|
||||
|
||||
Generally, this should only be called by the __init__.py script for a module
|
||||
upon loading a boost python module (generally '_libName.so')."""
|
||||
import importlib
|
||||
import inspect
|
||||
frame = inspect.currentframe().f_back
|
||||
try:
|
||||
f_locals = frame.f_locals
|
||||
|
||||
# If an explicit moduleName is not supplied, construct it from the
|
||||
# caller's module name, like "pxr.Tf", and our naming conventions,
|
||||
# which results in "_tf".
|
||||
if moduleName is None:
|
||||
moduleName = f_locals["__name__"].split(".")[-1]
|
||||
moduleName = "_" + moduleName[0].lower() + moduleName[1:]
|
||||
|
||||
with WindowsImportWrapper():
|
||||
module = importlib.import_module(
|
||||
"." + moduleName, f_locals["__name__"])
|
||||
|
||||
PrepareModule(module, f_locals)
|
||||
try:
|
||||
del f_locals[moduleName]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
module = importlib.import_module(".__DOC", f_locals["__name__"])
|
||||
module.Execute(f_locals)
|
||||
try:
|
||||
del f_locals["__DOC"]
|
||||
except KeyError:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
finally:
|
||||
del frame
|
||||
|
||||
def PrepareModule(module, result):
|
||||
"""PrepareModule(module, result) -- Prepare an extension module at import
|
||||
time. Generally, this should only be called by the __init__.py script for a
|
||||
module upon loading a boost python module (generally '_libName.so')."""
|
||||
# inject into result.
|
||||
ignore = frozenset(['__name__', '__package__', '__builtins__',
|
||||
'__doc__', '__file__', '__path__'])
|
||||
newModuleName = result.get('__name__')
|
||||
|
||||
for key, value in module.__dict__.items():
|
||||
if not key in ignore:
|
||||
result[key] = value
|
||||
|
||||
# Lie about the module from which value came.
|
||||
if newModuleName and hasattr(value, '__module__'):
|
||||
try:
|
||||
setattr(value, '__module__', newModuleName)
|
||||
except AttributeError as e:
|
||||
# The __module__ attribute of Boost.Python.function
|
||||
# objects is not writable, so we get this exception
|
||||
# a lot. Just ignore it. We're really only concerned
|
||||
# about the data objects like enum values and such.
|
||||
#
|
||||
pass
|
||||
|
||||
def GetCodeLocation(framesUp):
|
||||
"""Returns a tuple (moduleName, functionName, fileName, lineNo).
|
||||
|
||||
To trace the current location of python execution, use GetCodeLocation().
|
||||
By default, the information is returned at the current stack-frame; thus
|
||||
|
||||
info = GetCodeLocation()
|
||||
|
||||
will return information about the line that GetCodeLocation() was called
|
||||
from. One can write:
|
||||
|
||||
def genericDebugFacility():
|
||||
info = GetCodeLocation(1)
|
||||
# print out data
|
||||
|
||||
|
||||
def someCode():
|
||||
...
|
||||
if bad:
|
||||
genericDebugFacility()
|
||||
|
||||
and genericDebugFacility() will get information associated with its caller,
|
||||
i.e. the function someCode()."""
|
||||
import sys
|
||||
f_back = sys._getframe(framesUp).f_back
|
||||
return (f_back.f_globals['__name__'], f_back.f_code.co_name,
|
||||
f_back.f_code.co_filename, f_back.f_lineno)
|
||||
|
||||
PreparePythonModule()
|
||||
|
||||
# Need to provide an exception type that tf errors will show up as.
|
||||
class ErrorException(RuntimeError):
|
||||
def __init__(self, *args):
|
||||
RuntimeError.__init__(self, *args)
|
||||
self.__TfException = True
|
||||
|
||||
def __str__(self):
|
||||
return '\n\t' + '\n\t'.join([str(e) for e in self.args])
|
||||
__SetErrorExceptionClass(ErrorException)
|
||||
|
||||
def Warn(msg, template=""):
|
||||
"""Issue a warning via the TfDiagnostic system.
|
||||
|
||||
At this time, template is ignored.
|
||||
"""
|
||||
codeInfo = GetCodeLocation(framesUp=1)
|
||||
_Warn(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
|
||||
|
||||
def Status(msg, verbose=True):
|
||||
"""Issues a status update to the Tf diagnostic system.
|
||||
|
||||
If verbose is True (the default) then information about where in the code
|
||||
the status update was issued from is included.
|
||||
"""
|
||||
if verbose:
|
||||
codeInfo = GetCodeLocation(framesUp=1)
|
||||
_Status(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
|
||||
else:
|
||||
_Status(msg, "", "", "", 0)
|
||||
|
||||
def RaiseCodingError(msg):
|
||||
"""Raise a coding error to the Tf Diagnostic system."""
|
||||
codeInfo = GetCodeLocation(framesUp=1)
|
||||
_RaiseCodingError(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
|
||||
|
||||
def RaiseRuntimeError(msg):
|
||||
"""Raise a runtime error to the Tf Diagnostic system."""
|
||||
codeInfo = GetCodeLocation(framesUp=1)
|
||||
_RaiseRuntimeError(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
|
||||
|
||||
def Fatal(msg):
|
||||
"""Raise a fatal error to the Tf Diagnostic system."""
|
||||
codeInfo = GetCodeLocation(framesUp=1)
|
||||
_Fatal(msg, codeInfo[0], codeInfo[1], codeInfo[2], codeInfo[3])
|
||||
|
||||
|
||||
class NamedTemporaryFile(object):
|
||||
"""A named temporary file which keeps the internal file handle closed.
|
||||
A class which constructs a temporary file(that isn't open) on __enter__,
|
||||
provides its name as an attribute, and deletes it on __exit__.
|
||||
|
||||
Note: The constructor args for this object match those of
|
||||
python's tempfile.mkstemp() function, and will have the same effect on
|
||||
the underlying file created."""
|
||||
|
||||
def __init__(self, suffix='', prefix='', dir=None, text=False):
|
||||
# Note that we defer creation until the enter block to
|
||||
# prevent users from unintentionally creating a bunch of
|
||||
# temp files that don't get cleaned up.
|
||||
self._args = (suffix, prefix, dir, text)
|
||||
|
||||
def __enter__(self):
|
||||
from tempfile import mkstemp
|
||||
from os import close
|
||||
|
||||
fd, path = mkstemp(*self._args)
|
||||
close(fd)
|
||||
|
||||
# XXX: We currently only expose the name attribute
|
||||
# more can be added based on client needs in the future.
|
||||
self._name = path
|
||||
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
import os
|
||||
os.remove(self.name)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""The path for the temporary file created."""
|
||||
return self._name
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
#
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,59 @@
|
||||
#
|
||||
# Copyright 2021 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
|
||||
|
||||
def _NoArgs():
|
||||
return "_NoArgs result"
|
||||
|
||||
def _ReturnInt():
|
||||
return 42
|
||||
|
||||
def _RepeatStrings(stringList, numRepeats):
|
||||
return [s * numRepeats for s in stringList]
|
||||
|
||||
def _ConcatWithList(arg1, arg2, *args):
|
||||
return str.join(
|
||||
" ",
|
||||
[str(a) for a in
|
||||
[arg1, arg2]
|
||||
+ list(args)])
|
||||
|
||||
def _ConcatWithKwArgs(arg1, arg2, arg3 = "c", arg4 = "d", **kwargs):
|
||||
return str.join(
|
||||
" ",
|
||||
[str(a) for a in
|
||||
[arg1, arg2, arg3, arg4]
|
||||
+ ["%s=%s" % (k, kwargs[k]) for k in sorted(kwargs.keys())]])
|
||||
|
||||
def _GetTheeToANonery(arg):
|
||||
assert arg is None
|
||||
|
||||
_globalVar = 88
|
||||
|
||||
def _RaiseException():
|
||||
raise Exception("test exception")
|
||||
|
||||
def _RaiseTfError():
|
||||
Tf.RaiseRuntimeError("test error")
|
||||
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
|
||||
raise RuntimeError('This module should not get loaded!')
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Copyright 2016 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.ScriptModuleLoader()._LoadModulesForLibrary('DepLoadsAll')
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,30 @@
|
||||
#
|
||||
# Copyright 2016 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.ScriptModuleLoader()._LoadModulesForLibrary('LoadsAll')
|
||||
|
||||
# Request to load everything. This will be deferred by the TfScriptModuleLoader
|
||||
# until after the current dependency load is complete.
|
||||
Tf.ScriptModuleLoader()._LoadModulesForLibrary('')
|
||||
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
#
|
||||
# Copyright 2016 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.ScriptModuleLoader()._LoadModulesForLibrary('LoadsUnknown')
|
||||
|
||||
from . import testTfScriptModuleLoader_Unknown
|
||||
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright 2016 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.ScriptModuleLoader()._LoadModulesForLibrary('Other')
|
||||
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
pass
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
|
||||
# Register this library with a new, previously unknown dependency. Note, we're
|
||||
# just using 'sys' as the module to load here, which is a lie. It should really
|
||||
# be this module, but it doesn't matter, and it's not trivial to come up with a
|
||||
# robust, correct module name for this module.
|
||||
Tf.ScriptModuleLoader()._RegisterLibrary('Unknown', 'sys',
|
||||
['NewDynamicDependency'])
|
||||
|
||||
# Register the dependency. In this case we use 'sys' just because it saves us
|
||||
# from creating a real module called NewDynamicDependency.
|
||||
Tf.ScriptModuleLoader()._RegisterLibrary('NewDynamicDependency', 'sys', [])
|
||||
|
||||
# Load dependencies for this module, which includes the
|
||||
# NewDynamicDependency. This is a reentrant load that will be handled
|
||||
# immediately by TfScriptModuleLoader.
|
||||
Tf.ScriptModuleLoader()._LoadModulesForLibrary('Unknown')
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,89 @@
|
||||
#
|
||||
# Copyright 2018 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.
|
||||
#
|
||||
"""
|
||||
Trace -- Utilities for counting and recording events.
|
||||
"""
|
||||
|
||||
from pxr import Tf
|
||||
Tf.PreparePythonModule()
|
||||
del Tf
|
||||
|
||||
import contextlib
|
||||
|
||||
@contextlib.contextmanager
|
||||
def TraceScope(label):
|
||||
"""A context manager that calls BeginEvent on the global collector on enter
|
||||
and EndEvent on exit."""
|
||||
try:
|
||||
collector = Collector()
|
||||
eventId = collector.BeginEvent(label)
|
||||
yield
|
||||
finally:
|
||||
collector.EndEvent(label)
|
||||
|
||||
del contextlib
|
||||
|
||||
def TraceFunction(obj):
|
||||
"""A decorator that enables tracing the function that it decorates.
|
||||
If you decorate with 'TraceFunction' the function will be traced in the
|
||||
global collector."""
|
||||
|
||||
collector = Collector()
|
||||
|
||||
def decorate(func):
|
||||
import inspect
|
||||
|
||||
if inspect.ismethod(func):
|
||||
callableTypeLabel = 'method'
|
||||
classLabel = func.__self__.__class__.__name__+'.'
|
||||
else:
|
||||
callableTypeLabel = 'func'
|
||||
classLabel = ''
|
||||
|
||||
module = inspect.getmodule(func)
|
||||
if module is not None:
|
||||
moduleLabel = module.__name__+'.'
|
||||
else:
|
||||
moduleLabel = ''
|
||||
|
||||
label = 'Python {0}: {1}{2}{3}'.format(
|
||||
callableTypeLabel,
|
||||
moduleLabel,
|
||||
classLabel,
|
||||
func.__name__)
|
||||
def invoke(*args, **kwargs):
|
||||
with TraceScope(label):
|
||||
return func(*args, **kwargs)
|
||||
|
||||
invoke.__name__ = func.__name__
|
||||
# Make sure wrapper function gets attributes of wrapped function.
|
||||
import functools
|
||||
return functools.update_wrapper(invoke, func)
|
||||
|
||||
return decorate(obj)
|
||||
|
||||
def TraceMethod(obj):
|
||||
"""A convenience. Same as TraceFunction but changes the recorded
|
||||
label to use the term 'method' rather than 'function'."""
|
||||
return TraceFunction(obj)
|
||||
Binary file not shown.
@@ -0,0 +1,78 @@
|
||||
#
|
||||
# Copyright 2018 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.
|
||||
#
|
||||
|
||||
# Execute a script with tracing enabled.
|
||||
|
||||
# Usage: python -m pxr.Trace [-o OUTPUT] [-c "command" | FILE]
|
||||
|
||||
from __future__ import print_function
|
||||
import argparse, sys
|
||||
|
||||
parser = argparse.ArgumentParser(description='Trace script execution.')
|
||||
parser.add_argument('-o', dest='output', metavar='OUTPUT',
|
||||
type=str, default=None,
|
||||
help='trace output; defaults to stdout')
|
||||
parser.add_argument('-c', dest='cmd',
|
||||
type=str,
|
||||
help='trace <cmd> as a Python script')
|
||||
parser.add_argument('file', metavar="FILE",
|
||||
nargs='?',
|
||||
default=None,
|
||||
help='script to trace')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.cmd and not args.file:
|
||||
print("Must specify a command or script to trace", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if args.cmd and args.file:
|
||||
print("Only one of -c or FILE may be specified", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
from pxr import Trace
|
||||
|
||||
env = {}
|
||||
|
||||
# Create a Main function that is traced so we always capture a useful
|
||||
# top-level scope.
|
||||
if args.file:
|
||||
@Trace.TraceFunction
|
||||
def Main():
|
||||
exec(compile(open(args.file).read(), args.file, 'exec'), env)
|
||||
else:
|
||||
@Trace.TraceFunction
|
||||
def Main():
|
||||
exec(args.cmd, env)
|
||||
|
||||
try:
|
||||
Trace.Collector().enabled = True
|
||||
Main()
|
||||
finally:
|
||||
Trace.Collector().enabled = False
|
||||
|
||||
if args.output is not None:
|
||||
Trace.Reporter.globalReporter.Report(args.output)
|
||||
else:
|
||||
Trace.Reporter.globalReporter.Report()
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
Binary file not shown.
Binary file not shown.
@@ -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.
@@ -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.
@@ -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.
@@ -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.
@@ -0,0 +1,26 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# Copyright 2016 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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,27 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
#
|
||||
#====
|
||||
# Copyright (c) 2018, NVIDIA CORPORATION
|
||||
#======
|
||||
#
|
||||
|
||||
#
|
||||
# Copyright 2016 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
|
||||
Binary file not shown.
Binary file not shown.
Loaded 100 of 15684 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user