Exercise: Your First Asset#

Let’s take a look at export.usd in usdview.

  1. In the Visual Studio Code terminal, run the following command:

Windows:

.\scripts\usdview.bat .\asset_structure\exercise_01\export.usd

Linux:

./scripts/usdview.sh ./asset_structure/exercise_01/export.usd

Take a second to look at the tree view in the top left corner.

Notice that the mesh and material prims don’t have a common ancestor prim that could be referenced to include them all together. Even though the “root” item in the tree view looks like an ancestor prim, it represents the stage’s pseudo-root and is not a defined prim. We can address this by creating an entry point prim and making all the current root prims its children.

  1. In Visual Studio Code, open the following file: asset_structure/exercise_01/make_entry_point.py

  2. In our script, we will define a World prim under which the rest of the prims will be reparented. Add the code below into the block:

1# Move all root prims under new entry point prim.
2editor = Usd.NamespaceEditor(stage)
3for prim in root_prims:
4    editor.ReparentPrim(prim, world_prim)
5    # NamespaceEditor takes care of updating all relationship targets (e.g. material bindings)
6    editor.ApplyEdits()
  1. Save the file and then run the script using the following command:

Windows:

python .\asset_structure\exercise_01\make_entry_point.py

Linux:

python ./asset_structure/exercise_01/make_entry_point.py
  1. The output will now be in lrg_bldgF.usd. Run the following command so we can view this in usdview:

Windows:

.\scripts\usdview.bat .\asset_structure\exercise_01\lrg_bldgF.usd

Linux:

./scripts/usdview.sh ./asset_structure/exercise_01/lrg_bldgF.usd
  1. If the “root” dropdown is not expanded when the file opens, expand it now. Notice how all of our prims are now under World.

  1. Now that we have a fully referenceable asset, we’ll create a new layer called scene.usda that contains three references of lrg_bldgF.usd. In Visual Studio Code, run the following command in the terminal:

Windows:

python .\asset_structure\exercise_01\reference_asset.py

Linux:

python ./asset_structure/exercise_01/reference_asset.py
  1. Next, take a look at our new file in usdview. Run the following command so we can open the file in usdview:

Windows:

.\scripts\usdview.bat .\asset_structure\exercise_01\scene.usda

Linux:

./scripts/usdview.sh ./asset_structure/exercise_01/scene.usda

Notice that when referencing the building, all associated materials and geometry are also included. If we hadn’t consolidated these into a single entry point, there would be no clear indication of what should be brought over.