Exercise: Organizing Prim Hierarchy#
In this exercise, we’re going to organize all mesh prims under a new Geometry
scope and all material prims under a Looks
scope. This will provide organization and define jurisdictions for products contributed by modelers versus those contributed by surfacers.
Let’s take a look back at our building. Open the
lrg_bldgF.usd
in usdview by running the following command in the Visual Studio Code terminal:
Windows:
.\scripts\usdview.bat .\asset_structure\exercise_03\lrg_bldgF.usd
Linux:
./scripts/usdview.sh ./asset_structure/exercise_03/lrg_bldgF.usd
Expand the root and World dropdowns.
Right now all of our prims are encapsulated in World. It is not immediately clear to downstream users how each prim relates to one another. Let’s separate the materials from the geometry to provide more clarity.
Open the following script in Visual Studio Code:
asset_structure/exercise_03/organize_prims.py
We see some familiar code reparenting our prims, but this time we are reparenting them based on if they are a mesh or a material. The snippet below shows how we are sorting the prims:
1for prim in default_prim_children:
2 if prim.IsA(UsdGeom.Mesh):
3 editor.ReparentPrim(prim, geom_scope)
4 editor.ApplyEdits()
5 elif prim.IsA(UsdShade.Material):
6 editor.ReparentPrim(prim, looks_scope)
7 editor.ApplyEdits()
Let’s run the script and see how it changes our layer. In the terminal, run the script using the following command:
Windows:
python .\asset_structure\exercise_03\organize_prims.py
Linux:
python ./asset_structure/exercise_03/organize_prims.py
Now, open the file in usdview by running the following command:
Windows:
.\scripts\usdview.bat .\asset_structure\exercise_03\lrg_bldgF.usd
Linux:
./scripts/usdview.sh ./asset_structure/exercise_03/lrg_bldgF.usd
Expand the root and World dropdowns if they’re not already expanded.
Now we can see that our meshes are grouped under our Geometry
scope and our materials are grouped under Looks
. This should make it easier for users to find what they’re looking for in the scene.