add usd-21-05-win64_py37

This commit is contained in:
Sébastien Albert committed 2021-12-07 17:16:25 +01:00
1 parent 41d23e71ba
commit 66bc054336
15675 files changed
+3061008

No files matched your search

@@ -0,0 +1,8 @@
#usda 1.0
def Xform "hello"
{
def Sphere "world"
{
}
}
@@ -0,0 +1,62 @@
#!/pxrpythonsubst
#
# 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 __future__ import print_function
# section 1
from pxr import Usd, UsdGeom, Vt
stage = Usd.Stage.Open('HelloWorld.usda')
xform = stage.GetPrimAtPath('/hello')
sphere = stage.GetPrimAtPath('/hello/world')
# section 2
expected = ['proxyPrim', 'purpose', 'visibility', 'xformOpOrder']
assert xform.GetPropertyNames() == expected
expected = ['doubleSided', 'extent', 'orientation',
'primvars:displayColor', 'primvars:displayOpacity',
'proxyPrim', 'purpose', 'radius', 'visibility', 'xformOpOrder']
assert sphere.GetPropertyNames() == expected
# section 3
extentAttr = sphere.GetAttribute('extent')
expected = Vt.Vec3fArray([(-1, -1, -1), (1, 1, 1)])
assert extentAttr.Get() == expected
# section 4
radiusAttr = sphere.GetAttribute('radius')
radiusAttr.Set(2)
extentAttr.Set(extentAttr.Get() * 2)
print(stage.GetRootLayer().ExportToString())
# section 5
from pxr import UsdGeom
sphereSchema = UsdGeom.Sphere(sphere)
color = sphereSchema.GetDisplayColorAttr()
color.Set([(0,0,1)])
print(stage.GetRootLayer().ExportToString())
stage.GetRootLayer().Save()
@@ -0,0 +1,17 @@
#usda 1.0
(
defaultPrim = "hello"
)
def Xform "hello"
{
custom double3 xformOp:translate = (4, 5, 6)
uniform token[] xformOpOrder = ["xformOp:translate"]
def Sphere "world"
{
float3[] extent = [(-2, -2, -2), (2, 2, 2)]
color3f[] primvars:displayColor = [(0, 0, 1)]
double radius = 2
}
}
@@ -0,0 +1,67 @@
#!/pxrpythonsubst
#
# 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 __future__ import print_function
# Assumes that $USD_INSTALL_ROOT/lib/python is in sys.path
from pxr import Usd, UsdGeom
stage = Usd.Stage.Open('HelloWorld.usda')
# Clear local opinion, which alwauys wins over variants.
colorAttr = UsdGeom.Gprim.Get(stage, '/hello/world').GetDisplayColorAttr()
colorAttr.Clear()
print(stage.GetRootLayer().ExportToString())
# Create variant set.
rootPrim = stage.GetPrimAtPath('/hello')
vset = rootPrim.GetVariantSets().AddVariantSet('shadingVariant')
print(stage.GetRootLayer().ExportToString())
# Create variant options.
vset.AddVariant('red')
vset.AddVariant('blue')
vset.AddVariant('green')
print(stage.GetRootLayer().ExportToString())
# Author red color behind red variant.
vset.SetVariantSelection('red')
with vset.GetVariantEditContext():
colorAttr.Set([(1,0,0)])
print(stage.GetRootLayer().ExportToString())
vset.SetVariantSelection('blue')
with vset.GetVariantEditContext():
colorAttr.Set([(0,0,1)])
vset.SetVariantSelection('green')
with vset.GetVariantEditContext():
colorAttr.Set([(0,1,0)])
print(stage.GetRootLayer().ExportToString())
stage.GetRootLayer().Export('HelloWorldWithVariants.usda')
# Print composed results-- note that variants get flattened away.
print(stage.ExportToString(False))
@@ -0,0 +1,5 @@
#usda 1.0
def Sphere "sphere"
{
}
@@ -0,0 +1,5 @@
#usda 1.0
def Sphere "sphere"
{
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,317 @@
#usda 1.0
(
defaultPrim = "Ball"
)
over "Ball" (
variants = {
string shadingVariant = "Cue"
}
add variantSets = "shadingVariant"
)
{
over "mesh"
{
}
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
}
}
}
variantSet "shadingVariant" = {
"Ball_1" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball1.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(1, 0.850422, 0.0241323)]
}
}
"Ball_10" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball10.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.0170208, 0.0444973, 0.363132)]
}
}
"Ball_11" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball11.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.947959, 0.0329563, 0.0134364)]
}
}
"Ball_12" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball12.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.0473661, 0.0167832, 0.133209)]
}
}
"Ball_13" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball13.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.956527, 0.215727, 0.0241323)]
}
}
"Ball_14" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball14.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.0013732, 0.0494753, 0.0429018)]
}
}
"Ball_15" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball15.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.333438, 0.0019764, 0.00550657)]
}
}
"Ball_2" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball2.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.0170208, 0.0444973, 0.363132)]
}
}
"Ball_3" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball3.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.947959, 0.0329563, 0.0134364)]
}
}
"Ball_4" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball4.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.0473661, 0.0167832, 0.133209)]
}
}
"Ball_5" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball5.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.956527, 0.215727, 0.0241323)]
}
}
"Ball_6" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball6.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.0013732, 0.0494753, 0.0429018)]
}
}
"Ball_7" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball7.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.333438, 0.0019764, 0.00550657)]
}
}
"Ball_8" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball8.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.00977218, 0.00908114, 0.00778151)]
}
}
"Ball_9" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ball9.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(1, 0.850422, 0.0241323)]
}
}
"Cue" {
over "Looks"
{
over "BallMaterial"
{
over "BallTexture"
{
string filename = "./tex/ballCue.tex"
}
}
}
over "mesh"
{
color3f[] primvars:displayColor = [(0.991221, 0.982484, 0.743576)]
}
}
}
}
@@ -0,0 +1,21 @@
#usda 1.0
(
defaultPrim = "Ball"
upAxis = "Y"
)
def Xform "Ball" (
assetInfo = {
asset identifier = @Ball/Ball.usd@
string name = "Ball"
}
kind = "component"
prepend references = [
@./Ball.shadingVariants.usda@,
@./Ball.maya.usd@
]
)
{
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,7 @@
#!/bin/bash -e
txmake=/opt/pixar/RenderManProServer-20.3/bin/txmake
$txmake ballCue.jpg ballCue.tex
$txmake ball1.jpg ball1.tex
$txmake ball9.jpg ball9.tex
$txmake ball8.jpg ball8.tex
$txmake ball4.jpg ball4.tex
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,17 @@
#usda 1.0
(
defaultPrim = "Table"
upAxis = "Y"
)
def Xform "Table" (
assetInfo = {
asset identifier = @Table/Table.usd@
string name = "Table"
}
kind = "component"
prepend references = @./Table.maya.usd@
)
{
}
@@ -0,0 +1,31 @@
#usda 1.0
(
defaultPrim = "main_cam"
endTimeCode = 0
startTimeCode = 0
)
def Camera "main_cam" (
kind = "component"
)
{
float circleOfConfusionSize = 0.0125
float4[] clippingPlanes = []
float2 clippingRange = (10, 500000)
matrix4d constraintTargets:HeadXf = ( (1, 0, 0, 0), (0, 0.999999999997669, 0, 0), (0, 0, 0.999999999997669, 0), (0, 15, 15, 1) ) (
constraintTargetIdentifier = "HeadXf"
customData = {
bool hasPropertyDefinition = 0
}
)
float3[] extentsHint = [(3.40282e+38, 3.40282e+38, 3.40282e+38), (-3.40282e+38, -3.40282e+38, -3.40282e+38)]
float focalLength = 25.047468
float focusDistance = 200
float fStop = 5.6
float horizontalAperture = 24
float lensSqueezeRatio = 1
token projection = "perspective"
uniform bool stereoscopic = 0
float verticalAperture = 13.5
}
Binary file not shown.
@@ -0,0 +1,19 @@
#usda 1.0
def Xform "World"
{
def Xform "sets"
{
}
def Xform "anim"
{
}
def "main_cam" (
prepend references = @./main_cam.usd@
)
{
}
}
Binary file not shown.
@@ -0,0 +1,121 @@
#!/pxrpythonsubst
#
# 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.
#
'''
Creates an asset file that consists of a top level layer and sublayers for
shading and geometry.
'''
from __future__ import print_function
import os
from pxr import Kind, Sdf, Usd, UsdGeom
def main():
import optparse
descr = __doc__.strip()
usage = 'usage: %prog [options] asset'
parser = optparse.OptionParser(description=descr, usage=usage)
parser.add_option('-k', '--kind', default=Kind.Tokens.component,
help="sets asset's model kind")
parser.add_option('-o', '--outputDir',
help='directory to create assets. if none specified, will use modelName.')
parser.add_option('-s', '--shadingVariantLayer',
help='add <asset>.shadingVariants.usda to model references.', default=False,
action='store_true')
parser.add_option('-f', '--force', default=False, action='store_true',
help='if False, this will error if [outputDir] exists')
options, args = parser.parse_args()
if len(args) != 1:
parser.error("No asset specified")
asset = args[0]
force = options.force
outputDir = options.outputDir
if not outputDir:
outputDir = asset
if os.path.exists(outputDir):
if not force:
parser.error('outputDir "%s" exists. Use -f to override' % outputDir)
else:
os.makedirs(outputDir)
_CreateAsset(asset, outputDir, options.kind, options.shadingVariantLayer)
def _CreateAsset(assetName, assetDir, assetKind, addShadingVariantLayer):
assetFilePath = os.path.join(assetDir, '%s.usd' % assetName)
print("Creating asset at %s" % assetFilePath)
# Make the layer ascii - good for readability, plus the file is small
rootLayer = Sdf.Layer.CreateNew(assetFilePath, args = {'format':'usda'})
assetStage = Usd.Stage.Open(rootLayer)
# Define a prim for the asset and make it the default for the stage.
assetPrim = UsdGeom.Xform.Define(assetStage, '/%s' % assetName).GetPrim()
assetStage.SetDefaultPrim(assetPrim)
# Lets viewing applications know how to orient a free camera properly
UsdGeom.SetStageUpAxis(assetStage, UsdGeom.Tokens.y)
# Usually we will "loft up" the kind authored into the exported geometry
# layer rather than re-stamping here; we'll leave that for a later
# tutorial, and just be explicit here.
model = Usd.ModelAPI(assetPrim)
if assetKind:
model.SetKind(assetKind)
model.SetAssetName(assetName)
model.SetAssetIdentifier('%s/%s.usd' % (assetName, assetName))
refs = []
if addShadingVariantLayer:
# if we're going to add it, then shading is stronger than geom and needs
# to be added first
refs.append('./%s.shadingVariants.usda' % assetName)
refs.append('./%s.maya.usd' % assetName)
_CreateAndReferenceLayers(assetPrim, assetDir, refs)
assetStage.GetRootLayer().Save()
def _CreateAndReferenceLayers(assetPrim, assetDir, refs):
from pxr import Usd
for refLayerPath in refs:
referencedStage = Usd.Stage.CreateNew(os.path.join(assetDir, refLayerPath))
referencedAssetPrim = referencedStage.DefinePrim(assetPrim.GetPath())
referencedStage.SetDefaultPrim(referencedAssetPrim)
referencedStage.GetRootLayer().Save()
assetPrim.GetReferences().AddReference(refLayerPath)
# If you want to print things out, you can do:
#print(rootLayer.ExportToString())
if __name__ == '__main__':
main()
@@ -0,0 +1,103 @@
#!/pxrpythonsubst
#
# 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.
#
'''
Creates a shot with separate layers for departments.
'''
from __future__ import print_function
import os
def main():
import optparse
descr = __doc__.strip()
usage = 'usage: %prog [options] shot'
parser = optparse.OptionParser(description=descr, usage=usage)
parser.add_option('-b', '--baseLayer',
help='this will be added verbatim in the subLayerPaths.')
parser.add_option('-o', '--outputDir',
help='directory to create shot. if none specified, will use shotName.')
parser.add_option('-f', '--force', default=False, action='store_true',
help='if False, this will error if [outputDir] exists')
options, args = parser.parse_args()
if len(args) != 1:
parser.error("No shot specified")
shot = args[0]
force = options.force
outputDir = options.outputDir
if not outputDir:
outputDir = shot
if os.path.exists(outputDir):
if not force:
parser.error('outputDir "%s" exists. Use -f to override' % outputDir)
else:
os.makedirs(outputDir)
_CreateShot(shot, outputDir, options.baseLayer)
def _CreateShot(shotName, shotDir, baseLayer):
shotFilePath = os.path.join(shotDir, '%s.usd' % shotName)
from pxr import Usd, UsdGeom
shotStage = Usd.Stage.CreateNew(shotFilePath)
print("Creating shot at %s" % shotFilePath)
_CreateAndAddSubLayers(shotStage, shotName, shotDir, [
'./%s_sim.usd' % shotName,
'./%s_anim.usd' % shotName,
'./%s_layout.usd' % shotName,
'./%s_sets.usd' % shotName,
])
if baseLayer:
shotStage.GetRootLayer().subLayerPaths.append(baseLayer)
# Lets viewing applications know how to orient a free camera properly
UsdGeom.SetStageUpAxis(shotStage, UsdGeom.Tokens.y)
shotStage.GetRootLayer().Save()
def _CreateAndAddSubLayers(stage, shotName, shotDir, subLayers):
# We use the Sdf API here to quickly create layers. Also, we're using it
# as a way to author the subLayerPaths as there is no way to do that
# directly in the Usd API.
from pxr import Sdf
rootLayer = stage.GetRootLayer()
for subLayerPath in subLayers:
Sdf.Layer.CreateNew(os.path.join(shotDir, subLayerPath))
rootLayer.subLayerPaths.append(subLayerPath)
# If you want to print things out, you can do:
#print(rootLayer.ExportToString())
if __name__ == '__main__':
main()
@@ -0,0 +1,64 @@
#!/pxrpythonsubst
#
# 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 __future__ import print_function
import os
ASSET_BASE = os.path.join('../../', 'models')
def main():
sequenceFilePath = 'shots/s00/s00.usd'
setsLayoutLayerFilePath = 'shots/s00/s00_sets.usd'
from pxr import Kind, Usd, UsdGeom, Sdf
stage = Usd.Stage.Open(sequenceFilePath)
# we use Sdf, a lower level library, to obtain the 'sets' layer.
workingLayer = Sdf.Layer.FindOrOpen(setsLayoutLayerFilePath)
assert stage.HasLocalLayer(workingLayer)
# this makes the workingLayer the target for authoring operations by the
# stage.
stage.SetEditTarget(workingLayer)
# Make sure the model-parents we need are well-specified
Usd.ModelAPI(UsdGeom.Xform.Define(stage, '/World')).SetKind(Kind.Tokens.group)
Usd.ModelAPI(UsdGeom.Xform.Define(stage, '/World/sets')).SetKind(Kind.Tokens.group)
# in previous examples, we've been using GetReferences().AddReference(...). The
# following uses .SetItems() instead which lets us explicitly set (replace)
# the references at once instead of adding.
stage.DefinePrim('/World/sets/Room_set').GetReferences().SetReferences([
Sdf.Reference(os.path.join(ASSET_BASE, 'Room_set/Room_set.usd'))])
stage.GetEditTarget().GetLayer().Save()
print('===')
print('usdview %s' % sequenceFilePath)
print('usdcat %s' % setsLayoutLayerFilePath)
if __name__ == '__main__':
main()
@@ -0,0 +1,133 @@
#!/pxrpythonsubst
#
# 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 script adds shading to the models at:
models/
Ball/
This script will change the texture path to point to different textures (though
we only ship textures for '1', '9', '8', '4'). We also set the displayColor in
the shadingVariants.
'''
import os
ASSET_BASE = os.path.join(os.getcwd(), 'models')
def main():
from pxr import Usd
stage = Usd.Stage.CreateNew(os.path.join(
ASSET_BASE,
'Ball/Ball.shadingVariants.usda'))
stage.GetRootLayer().defaultPrim = 'Ball'
_AddShadingToBall(stage)
stage.GetRootLayer().Save()
def _AddShadingToBall(stage):
from pxr import Sdf, UsdShade
model = stage.OverridePrim('/Ball')
texDir = os.path.join(ASSET_BASE, 'Ball/tex')
mesh = stage.OverridePrim('/Ball/mesh')
ballTexture = UsdShade.Shader(stage.OverridePrim(
model.GetPath().AppendPath('Looks/BallMaterial/BallTexture')))
# now we'll show adding some shading variants to the ball as well.
shadingVariantsInfo = [
('Cue', '', _Color(0.996, 0.992, 0.874)), # white
('Ball_1', '', _Color(1.000, 0.929, 0.184)), # yellow
('Ball_2', '', _Color(0.157, 0.243, 0.631)), # blue
('Ball_3', '', _Color(0.976, 0.212, 0.141)), # red
('Ball_4', '', _Color(0.250, 0.156, 0.400)), # purple
('Ball_5', '', _Color(0.980, 0.498, 0.184)), # orange
('Ball_6', '', _Color(0.050, 0.255, 0.239)), # green
('Ball_7', '', _Color(0.607, 0.059, 0.094)), # darkred
('Ball_8', '', _Color(0.122, 0.118, 0.110)), # black
('Ball_9', 'striped', _Color(1.000, 0.929, 0.184)), # yellow
('Ball_10', 'striped', _Color(0.157, 0.243, 0.631)), # blue
('Ball_11', 'striped', _Color(0.976, 0.212, 0.141)), # red
('Ball_12', 'striped', _Color(0.250, 0.156, 0.400)), # purple
('Ball_13', 'striped', _Color(0.980, 0.498, 0.184)), # orange
('Ball_14', 'striped', _Color(0.050, 0.255, 0.239)), # green
('Ball_15', 'striped', _Color(0.607, 0.059, 0.094)), # darkred
]
# create the shadingVariant variantSet
shadingVariant = model.GetVariantSets().AddVariantSet('shadingVariant')
for variantName, decoration, color in shadingVariantsInfo:
# creates a variant inside 'shadingVariant'
shadingVariant.AddVariant(variantName)
# switch to that variant
shadingVariant.SetVariantSelection(variantName)
# this 'with' construct here tells Usd that authoring operations should
# write to the shadingVariant.
with shadingVariant.GetVariantEditContext():
whichBall = variantName.split('_')[-1]
texPath = os.path.join(texDir, 'ball%s.tex' % whichBall)
# in the current variant, modify the color
_SetParameters(ballTexture, [
('filename', Sdf.ValueTypeNames.String, texPath),
])
# set the display color for hydra
_SetDisplayColor(mesh, color)
# currently not doing anything with decoration, but we could maybe
# use this to make the solid vs. stripes.
# now make the variant selection 'Cue' instead of the last variant that we
# created above.
shadingVariant.SetVariantSelection('Cue')
def _SetParameters(shadingNode, params):
'''
shadingNode is a UsdShadeShader
params are (paramName, paramType, value) tuples
'''
for paramName, paramType, value in params:
shadingNode.CreateInput(paramName, paramType).Set(value)
def _Color(r, g, b):
# for this tutorial, the colors i got are not in linear space.
from pxr import Gf
return Gf.ConvertDisplayToLinear(Gf.Vec3f(r, g, b))
def _SetDisplayColor(mesh, color):
from pxr import UsdGeom
# DisplayColor is actually an array. Here, we just author one color which
# applies to the whole mesh.
UsdGeom.Gprim(mesh).CreateDisplayColorAttr([color])
if __name__ == '__main__':
main()
@@ -0,0 +1,84 @@
#!/pxrpythonsubst
#
# 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 __future__ import print_function
def main():
shotFilePath = 'shots/s00_01/s00_01.usd'
animLayerFilePath = 'shots/s00_01/s00_01_anim.usd'
from pxr import Usd, Sdf
stage = Usd.Stage.Open(shotFilePath)
# set the timeCode range for the shot that other applications can use.
stage.SetStartTimeCode(1)
stage.SetEndTimeCode(10)
stage.GetRootLayer().Save()
# we use Sdf, a lower level library, to obtain the 'anim' layer.
workingLayer = Sdf.Layer.FindOrOpen(animLayerFilePath)
assert stage.HasLocalLayer(workingLayer)
# this makes the workingLayer the target for authoring operations by the
# stage.
stage.SetEditTarget(workingLayer)
_AnimateBilliards(stage)
stage.GetEditTarget().GetLayer().Save()
print('===')
print('usdview %s' % shotFilePath)
print('usdcat %s' % animLayerFilePath)
def _AnimateBilliards(stage):
_MoveBall(stage.GetPrimAtPath('/World/anim/CueBall'), (1, 0), 40)
#_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_2'), (0, 0), 0.0)
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_10'), (0, -1), 20)
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_1'), (1, -1), 5)
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_4'), (1, -0.5), 3.6)
def _MoveBall(ball, direction, speed):
from pxr import Usd, UsdGeom, Gf
v = Gf.Vec2d(*direction).GetNormalized() * speed
xformAPI = UsdGeom.XformCommonAPI(ball)
# Here we make use of GfVec3d rather than plain tuples so we can
# add vectors, and demonstrate the API (all Usd API's) will accept either.
# GetXformVectors() returns a tuple of
# (translation, rotation, scale, pivot, rotationOrder), from which we
# extract the first element, the translation
start = xformAPI.GetXformVectors(Usd.TimeCode.Default())[0]
end = start + Gf.Vec3d(v[0], 0, v[1])
# set keyframe for frame 1 and frame 10.
xformAPI.SetTranslate(start, 1)
xformAPI.SetTranslate(end, 10)
xformAPI.SetRotate(speed * Gf.Vec3f(3.7, 13.9, 91.34))
if __name__ == '__main__':
main()
@@ -0,0 +1,135 @@
#!/pxrpythonsubst
#
# 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 script assumes you have models at
models/
Ball/
Table/
It will create a new "set" (aggregate) model, Room_set at
models/Room_set
'''
import os
ASSET_BASE = os.path.join(os.getcwd(), 'models')
TABLE_HEIGHT = 74.5
BALL_RADIUS = 5.715 * 0.5
def main():
from pxr import Kind, Usd, UsdGeom
setFilePath = os.path.join(ASSET_BASE, 'Room_set/Room_set.usd')
# Create the model stage, the model prim, and also make the modelPrim the
# default prim so that the layer can be referenced without specifying a
# root path.
stage = Usd.Stage.CreateNew(setFilePath)
setModelPrim = UsdGeom.Xform.Define(stage, '/Room_set').GetPrim()
stage.SetDefaultPrim(setModelPrim)
# Lets viewing applications know how to orient a free camera properly
UsdGeom.SetStageUpAxis(stage, UsdGeom.Tokens.y)
# Models can have a "kind" which can be used to categorize models into
# different types. This is useful for other applications to reason about
# the model hierarchy.
Usd.ModelAPI(setModelPrim).SetKind(Kind.Tokens.assembly)
# add child models to our set.
_AddModel(stage, '/Room_set/Furniture/Table', 'Table/Table.usd')
ballNumber = 0
import math
for row in range(5):
tableX = 10 + row * 2 * BALL_RADIUS * math.cos(math.pi/6)
tableRowZ = -row * BALL_RADIUS
numBallsInRow = row + 1
for i in range(numBallsInRow):
ballNumber += 1
b = _AddModel(
stage,
'/Room_set/Props/Ball_%d' % ballNumber,
'Ball/Ball.usd')
# tableX and tableZ will arrange the balls into a triangle.
tableZ = tableRowZ + i * 2 * BALL_RADIUS
ballXlate = (tableX, TABLE_HEIGHT + BALL_RADIUS, tableZ)
# Apply the UsdGeom.Xformable schema to the model, and then set the
# transformation.
# We are only going to translate the balls, but we still use
# the helper XformCommonAPI schema to instantiate a translate op.
# XformCommonAPI helps ensure transform ops are interchangeable
# between applications, when you can make do with SRT + pivot
UsdGeom.XformCommonAPI(b).SetTranslate(ballXlate)
# we conveniently named the shadingVariant the same as the name of
# the ball.
shadingVariantName = b.GetName()
# get the variantSet "shadingVariant" and then set it accordingly.
vs = b.GetVariantSets().GetVariantSet('shadingVariant')
vs.SetVariantSelection(shadingVariantName)
stage.GetRootLayer().Save()
def _AddModel(stage, path, refPath):
'''
Adds a reference to refPath at the given path in the stage. This will make
sure the model hierarchy is maintained by ensuring that all ancestors of
the path have "kind" set to "group".
returns the referenced model.
'''
from pxr import Kind, Sdf, Usd, UsdGeom
# convert path to an Sdf.Path which has several methods that are useful
# when working with paths. We use GetPrefixes() here which returns a list
# of all the prim prefixes for a given path.
path = Sdf.Path(path)
for prefixPath in path.GetPrefixes()[1:-1]:
parentPrim = stage.GetPrimAtPath(prefixPath)
if not parentPrim:
parentPrim = UsdGeom.Xform.Define(stage, prefixPath).GetPrim()
Usd.ModelAPI(parentPrim).SetKind(Kind.Tokens.group)
# typeless def here because we'll be getting the type from the prim that
# we're referencing.
m = stage.DefinePrim(path)
m.GetReferences().AddReference(os.path.join(ASSET_BASE, refPath))
return m
if __name__ == '__main__':
main()
@@ -0,0 +1,117 @@
#!/pxrpythonsubst
#
# 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 __future__ import print_function
import os
ASSET_BASE = os.path.join(os.getcwd(), 'models')
TABLE_HEIGHT = 74.5
BALL_RADIUS = 5.715 * 0.5
def main():
shotFilePath = 'shots/s00_01/s00_01.usd'
layoutLayerFilePath = 'shots/s00_01/s00_01_layout.usd'
from pxr import Usd, Sdf
stage = Usd.Stage.Open(shotFilePath)
# set the timeCode range for the shot that other applications can use.
stage.SetStartTimeCode(1)
stage.SetEndTimeCode(10)
# we use Sdf, a lower level library, to obtain the 'layout' layer.
workingLayer = Sdf.Layer.FindOrOpen(layoutLayerFilePath)
assert stage.HasLocalLayer(workingLayer)
# this makes the workingLayer the target for authoring operations by the
# stage.
stage.SetEditTarget(workingLayer)
_SetupBilliards(stage)
_MoveCamera(stage)
stage.GetEditTarget().GetLayer().Save()
print('===')
print('usdview %s' % shotFilePath)
print('usdcat %s' % layoutLayerFilePath)
def _SetupBilliards(stage):
from pxr import Kind, Sdf, Usd, UsdGeom
# Make sure the model-parents we need are well-specified
Usd.ModelAPI(UsdGeom.Xform.Define(stage, '/World')).SetKind(Kind.Tokens.group)
Usd.ModelAPI(UsdGeom.Xform.Define(stage, '/World/anim')).SetKind(Kind.Tokens.group)
# in previous examples, we've been using GetReferences().AddReference(...). The
# following uses .SetItems() instead which lets us explicitly set (replace)
# the references at once instead of adding.
cueBall = stage.DefinePrim('/World/anim/CueBall')
cueBall.GetReferences().SetReferences([
Sdf.Reference(os.path.join(ASSET_BASE, 'Ball/Ball.usd'))])
# deactivate everything that isn't 8, 9, 1, 4. We accumulate the prims we
# want to deactivate so that we don't delete while iterating.
roomProps = stage.GetPrimAtPath('/World/sets/Room_set/Props')
keepers = set(['Ball_%d' % i for i in [1, 9, 8, 4] ])
toDeactivate = []
for child in roomProps.GetChildren():
if child.GetName() not in keepers:
toDeactivate.append(child)
for prim in toDeactivate:
prim.SetActive(False)
# the offset values are relative to the radius of the ball
def _MoveBall(ballPrim, offset):
translation = (offset[0] * BALL_RADIUS,
TABLE_HEIGHT + BALL_RADIUS,
offset[1] * BALL_RADIUS)
# Apply the UsdGeom.Xformable schema to the model, and then set the
# transformation. Note we can use ordinary python tuples
from pxr import UsdGeom
UsdGeom.XformCommonAPI(ballPrim).SetTranslate(translation)
# all these values are just eye-balled and are relative to Ball_1.
_MoveBall(cueBall, (1.831, 4.331))
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_2'), (0.000, 0.000))
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_10'), (2.221, 1.119))
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_1'), (3.776, 0.089))
_MoveBall(stage.GetPrimAtPath('/World/sets/Room_set/Props/Ball_4'), (5.453, -0.543))
def _MoveCamera(stage):
from pxr import UsdGeom, Gf
cam = UsdGeom.Camera.Get(stage, '/World/main_cam')
# the camera derives from UsdGeom.Xformable so we can
# use the XformCommonAPI on it, too, and see how rotations are handled
xformAPI = UsdGeom.XformCommonAPI(cam)
xformAPI.SetTranslate( (8, 120, 8) )
# -86 degree rotation around X axis. Can specify rotation order as
# optional parameter
xformAPI.SetRotate( (-86, 0, 0 ) )
if __name__ == '__main__':
main()
@@ -0,0 +1,31 @@
#!/pxrpythonsubst
#
# 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 Usd, UsdGeom
stage = Usd.Stage.CreateNew('HelloWorld.usda')
xformPrim = UsdGeom.Xform.Define(stage, '/hello')
spherePrim = UsdGeom.Sphere.Define(stage, '/hello/world')
stage.GetRootLayer().Save()
@@ -0,0 +1,31 @@
#!/pxrpythonsubst
#
# 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 Usd
stage = Usd.Stage.CreateNew('HelloWorldRedux.usda')
xform = stage.DefinePrim('/hello', 'Xform')
sphere = stage.DefinePrim('/hello/world', 'Sphere')
stage.GetRootLayer().Save()
@@ -0,0 +1,11 @@
#usda 1.0
def Xform "hello"
{
def Sphere "world"
{
float3[] extent = [(-2, -2, -2), (2, 2, 2)]
color3f[] primvars:displayColor = [(0, 0, 1)]
double radius = 2
}
}
@@ -0,0 +1,70 @@
#!/pxrpythonsubst
#
# 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.
#
# Assumes that $USD_INSTALL_ROOT/lib/python is in sys.path
from __future__ import print_function
from pxr import Usd, UsdGeom
stage = Usd.Stage.Open('HelloWorld.usda')
# XXX: save the usd file to the local directory where the test
# is being administered so RefExample will have access to it
stage.Export('HelloWorld.usda')
hello = stage.GetPrimAtPath('/hello')
stage.SetDefaultPrim(hello)
UsdGeom.XformCommonAPI(hello).SetTranslate((4, 5, 6))
print(stage.GetRootLayer().ExportToString())
stage.GetRootLayer().Save()
# Create an over on which to create our reference.
refStage = Usd.Stage.CreateNew('RefExample.usda')
refSphere = refStage.OverridePrim('/refSphere')
print(refStage.GetRootLayer().ExportToString())
# Reference in the layer.
refSphere.GetReferences().AddReference('./HelloWorld.usda')
print(refStage.GetRootLayer().ExportToString())
refStage.GetRootLayer().Save()
# Clear out any authored transformation over the reference.
refXform = UsdGeom.Xformable(refSphere)
refXform.SetXformOpOrder([])
print(refStage.GetRootLayer().ExportToString())
# Reference in the layer again, on another over.
refSphere2 = refStage.OverridePrim('/refSphere2')
refSphere2.GetReferences().AddReference('./HelloWorld.usda')
print(refStage.GetRootLayer().ExportToString())
refStage.GetRootLayer().Save()
# Author displayColor on a namespace descendant of the referenced prim.
overSphere = UsdGeom.Sphere.Get(refStage, '/refSphere2/world' )
overSphere.GetDisplayColorAttr().Set( [(1, 0, 0)] )
print(refStage.GetRootLayer().ExportToString())
refStage.GetRootLayer().Save()
# Print the final composed results.
print(refStage.ExportToString())
@@ -0,0 +1,17 @@
#usda 1.0
(
defaultPrim = "hello"
)
def Xform "hello"
{
custom double3 xformOp:translate = (4, 5, 6)
uniform token[] xformOpOrder = ["xformOp:translate"]
def Sphere "world"
{
float3[] extent = [(-2, -2, -2), (2, 2, 2)]
color3f[] primvars:displayColor = [(0, 0, 1)]
double radius = 2
}
}
@@ -0,0 +1,19 @@
#usda 1.0
over "refSphere" (
prepend references = @HelloWorld.usda@
)
{
uniform token[] xformOpOrder = []
}
over "refSphere2" (
prepend references = @HelloWorld.usda@
)
{
over "world"
{
color3f[] primvars:displayColor = [(1, 0, 0)]
}
}
@@ -0,0 +1,63 @@
#!/pxrpythonsubst
#
# 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 Usd, UsdGeom
# section 1
stage = Usd.Stage.Open("RefExample.usda")
assert([x for x in stage.Traverse()] == [stage.GetPrimAtPath("/refSphere"),
stage.GetPrimAtPath("/refSphere/world"), stage.GetPrimAtPath("/refSphere2"),
stage.GetPrimAtPath("/refSphere2/world")])
# section 2
assert([x for x in stage.Traverse() if UsdGeom.Sphere(x)] ==
[stage.GetPrimAtPath("/refSphere/world"),
stage.GetPrimAtPath("/refSphere2/world")])
# section 3
treeIter = iter(Usd.PrimRange.PreAndPostVisit(stage.GetPseudoRoot()))
treeIterExpectedResults = [(stage.GetPrimAtPath("/"), False),
(stage.GetPrimAtPath("/refSphere"), False),
(stage.GetPrimAtPath("/refSphere/world"), False),
(stage.GetPrimAtPath("/refSphere/world"), True),
(stage.GetPrimAtPath("/refSphere"), True),
(stage.GetPrimAtPath("/refSphere2"), False),
(stage.GetPrimAtPath("/refSphere2/world"), False),
(stage.GetPrimAtPath("/refSphere2/world"), True),
(stage.GetPrimAtPath("/refSphere2"), True),
(stage.GetPrimAtPath("/"), True)]
treeIterActualResults = [(x, treeIter.IsPostVisit()) for x in treeIter]
assert treeIterExpectedResults == treeIterActualResults
# section 4
# Deactivate the prim as we would in usdview
ref2Prim = stage.GetPrimAtPath('/refSphere2')
stage.SetEditTarget(stage.GetSessionLayer())
Usd.Prim.SetActive(ref2Prim, False)
assert ([x for x in stage.Traverse()] == [stage.GetPrimAtPath("/refSphere"),
stage.GetPrimAtPath("/refSphere/world")])