< Converting Between Layer Formats Authoring Variants >


Traversing a Stage

This tutorial focuses on traversing the composed prims on a UsdStage, using the operators from the Shift_USD catalog. The example will reuse the layer files generated in the previous tutorial Referencing Layers.

The base files for the example, HelloWorld.usda and RefExample.usda, can be found in the following path in the Shift installation folder: <path_to_the_shift_installation_folder>/shift/examples/USD/tutorials/tutorial_03_referencing_layers/result/.

Tutorial

  1. Open Shift application. A new window instance of Shift should appear like the following one:
Shift UI.
Figure 1: Shift UI.
NOTE

Before creating the USD workflow, ensure that the USD nodes appear in the Node List widget. The catalogs combobox should show sUSD and sUSDTypes if USD is correctly loaded in Shift. If this is not the case, please check again the Shift_USD installation page.

  1. Add a new UsdStageOpen node to the board and rename it as OpenStage. Using the Inspector widget, set as the value for the filepath input plug a filepath pointing to the RefExample.usda file. For the current example, the filepath will be: D:/USD_TUTORIALS/05/RefExample.usda. The board should look like the following:
Added 'OpenStage' node to the board.
Figure 2: Added 'OpenStage' node to the board.
  1. For traversing the stage, add a new UsdStageTraverse node to the board and rename it as TraverseStage. Connect the stage output plug from the OpenStage node to the stage input plug of the new node. Leave the primType input plug set to Any and the traverseAll input plug set to False. The board should look like the following:
Added 'TraverseStage' node to the board connected to 'OpenStage'.
Figure 3: Added 'TraverseStage' node to the board connected to 'OpenStage'.
  1. Execute the current workflow for checking the prims output plug from the TraverseStage node. The value of the plug should be: [Usd.Prim(</refSphere>), Usd.Prim(</refSphere/world>), Usd.Prim(</refSphere2>), Usd.Prim(</refSphere2/world>)], containing all the prims that build the stage. The board should look like the following:
'TraverseStage' node prims plug value.
Figure 4: 'TraverseStage' node prims plug value.
  1. For filtering the values of the prims output plug in the TraverseStage node, set the primType input plug to Sphere. Execute again the node to refresh the output plug result. Once the node is executed again the plug value should be: [Usd.Prim(</refSphere/world>), Usd.Prim(</refSphere2/world>)]. The board should look like the following:
'TraverseStage' node prims plug value filtering by 'Sphere' prim type.
Figure 5: 'TraverseStage' node prims plug value filtering by 'Sphere' prim type.
  1. To activate/deactivate a prim in a specific layer, for the current example, the session layer, add a new UsdStageSessionLayerGet node and rename it as SessionLayerGet. Connect the stage output plug from the OpenStage node to the stage input plug of the new node. The board should look like the following:
Added the 'SessionLayerGet' node to the board connected to the 'OpenStage' node.
Figure 6: Added the 'SessionLayerGet' node to the board connected to the 'OpenStage' node.
  1. Setting the edit target layer of the stage is important so that any modification done to the stage is registered in that layer instead of the root layer of the stage. Add a new UsdStageEditTargetSet node and rename it as SessionLayerTargetSet. Connect the stage and sessionLayer output plugs from the SessionLayerGet node to the stage and layer input plugs, respectively, of the new node. The board should look like the following:
Added the 'SessionLayerTargetSet' node to the board connected to the 'SessionLayerGet' node.
Figure 7: Added the 'SessionLayerTargetSet' node to the board connected to the 'SessionLayerGet' node.
  1. Add a new UsdPrimGet node and rename it as RefSphere2Get. Connect the stage output plug from the SessionLayerTargetSet node to the stage input plug of the new node and set /refSphere2 as the value for the primpath input plug. The board should look like the following:
Added the 'RefSphere2Get' node to the board connected to the 'SessionLayerTargetSet' node.
Figure 8: Added the 'RefSphere2Get' node to the board connected to the 'SessionLayerTargetSet' node.
  1. Add a new UsdPrimDisable node and rename it as RefSphere2Disable. Connect the prim output plug from the RefSphere2Get node to the prim input plug of the new node and set the value of the disabled input plug to True too. The board should look like the following:
Added the 'RefSphere2Disable' node to the board connected to the 'RefSphere2Get' node.
Figure 9: Added the 'RefSphere2Disable' node to the board connected to the 'RefSphere2Get' node.
  1. Now, select the nodes SessionLayerGet, SessionLayerTargetSet, RefSphere2Get and RefSphere2Disable and execute only the selected nodes. Once the execution has finished, the board should look like the following:
Executing workflow only on 'SessionLayerGet', 'SessionLayerTargetSet', 'RefSphere2Get' and 'RefSphere2Disable' nodes.
Figure 10: Executing workflow only on 'SessionLayerGet', 'SessionLayerTargetSet', 'RefSphere2Get' and 'RefSphere2Disable' nodes.
  1. Select the TraverseStage node and change the value of the primType input plug to Any. Execute the selected node only to recompute the prims output plug value. The value of the prims output plug should not contain the disabled prim and children anymore. The board should look like the following:
Re-executing the 'TraverseStage' node after deactivating a prim.
Figure 11: Re-executing the 'TraverseStage' node after deactivating a prim.
  1. Now, with the TraverseStage node selected, set the traverseAll input plug value to True. Execute the selected node only to recompute the prims output plug value. The value of the prims output plug should be: [Usd.Prim(</refSphere>), Usd.Prim(</refSphere/world>), Usd.Prim(</refSphere2>)]. The board should look like the following:
Re-executing the 'TraverseStage' node with traverseAll plug set to True.
Figure 12: Re-executing the 'TraverseStage' node with **traverseAll** plug set to True.

Workflow Resources

The workflow corresponding to this tutorial can be found in the following path in the Shift installation folder: <path_to_the_shift_installation_folder>/shift/examples/USD/tutorials/tutorial_05_traversing_stage/tutorial_05.sft


< Converting Between Layer Formats Authoring Variants >


Inbibo Logo

consultancy, automation and digital creatures

65 Compton Street, London, United Kingdom, EC1V 0BN

info@inbibo.co.uk

Information

Products

© 2024 Inbibo LTD. - All rights reserved - Design & Development: def:studio