├── LICENSE ├── README.md ├── concepts ├── asset_composition_arcs.md ├── mesh_with_materials │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── assets │ │ │ └── USDLogoLrg.png │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── python │ │ ├── USDLogoLrg.png │ │ └── material.py │ └── usda │ │ ├── simple │ │ ├── USDLogoLrg.png │ │ └── material.usda │ │ └── with_override │ │ ├── USDLogoLrg.png │ │ ├── base.usda │ │ └── override.usda ├── orphaned_over │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── python │ │ ├── base.usda │ │ ├── orphaned_over.py │ │ └── over.usda │ └── usda │ │ ├── base.usda │ │ └── over.usda ├── reference_into_prim │ ├── README.md │ ├── python │ │ └── reference_into_prim.py │ └── usda │ │ ├── base.usda │ │ └── reference.usda ├── relationship_forwarding │ ├── README.md │ ├── cpp │ │ ├── destination_forwarding │ │ │ ├── CMakeLists.txt │ │ │ ├── build │ │ │ │ └── .gitignore │ │ │ └── main.cpp │ │ └── source_forwarding │ │ │ ├── CMakeLists.txt │ │ │ ├── build │ │ │ └── .gitignore │ │ │ └── main.cpp │ ├── python │ │ ├── destination_forwarding.py │ │ └── source_forwarding.py │ └── usda │ │ ├── destination_forwarding.usda │ │ └── source_forwarding.usda ├── specializes_a_practical_example │ ├── README.md │ ├── layout.usda │ ├── modelling.usda │ └── settings.usda ├── specializes_as_a_fallback_mechanism │ ├── README.md │ ├── base.usda │ └── payload.usda ├── uniquify_an_instance │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ └── python │ │ ├── example.usda │ │ └── uniquify.py ├── valid_model_hierarchies │ ├── README.md │ ├── check.py │ ├── invalid_1.usda │ ├── invalid_2.usda │ ├── invalid_2b.usda │ ├── invalid_2c.usda │ ├── invalid_2d.usda │ ├── valid_1.usda │ ├── valid_2.usda │ ├── valid_3.usda │ ├── valid_4.usda │ └── valid_5.usda ├── variant_set_in_stronger_layer │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── python │ │ └── variant_set.py │ └── usda │ │ ├── base.usda │ │ └── override.usda ├── variant_set_production_shot │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── python │ │ └── shot.py │ └── usda │ │ ├── asset.usda │ │ ├── sequence.usda │ │ └── shot_v001.usda └── variant_set_understanding │ ├── README.md │ ├── arcs.usda │ ├── metadata_swap.usda │ └── sources │ ├── animation.usda │ ├── model.usda │ ├── sphere.usda │ ├── surfacing.usda │ └── surfacing_blue.usda ├── features ├── add_comment │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── python │ │ └── comment.py │ └── usda │ │ └── base.usda ├── asset_info │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── python │ │ └── asset_info.py │ └── usda │ │ └── asset_info.usda ├── batch_namespace_edit │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ ├── input.usda │ │ └── main.cpp │ └── python │ │ ├── batch_namespace_edit.py │ │ └── input.usda ├── caching │ ├── README.md │ ├── cpp │ │ ├── cache_utils │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── build │ │ │ │ └── .gitignore │ │ │ └── main.cpp │ │ └── caching │ │ │ ├── CMakeLists.txt │ │ │ ├── build │ │ │ └── .gitignore │ │ │ └── main.cpp │ └── python │ │ ├── README.md │ │ ├── cache_utils.py │ │ └── caching.py ├── edit_targets │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ └── main.cpp │ └── python │ │ └── edit.py ├── enable_debugging │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ └── python │ │ └── debugging.py ├── notice_send │ ├── README.md │ ├── cpp │ │ ├── notice_send_custom │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── build │ │ │ │ └── .gitignore │ │ │ └── main.cpp │ │ └── notice_send_global │ │ │ ├── CMakeLists.txt │ │ │ ├── build │ │ │ └── .gitignore │ │ │ └── main.cpp │ └── python │ │ ├── notice_send_custom.py │ │ ├── notice_send_derived.py │ │ └── notice_send_global.py ├── notices │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ └── python │ │ └── notice.py ├── profiling_usd.md ├── purposes │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── python │ │ └── purpose.py │ └── usda │ │ └── purpose.usda ├── sdf_change_block │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ └── python │ │ └── sdf_change_block.py ├── set_kind │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── python │ │ └── kind.py │ └── usda │ │ └── base.usda ├── specializes │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── python │ │ └── specializes.py │ └── usda │ │ └── specializes.usda ├── specializes_glossary_example │ ├── README.md │ ├── base.usda │ └── override.usda ├── time_varying_attributes_sdf │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ └── main.cpp │ └── python │ │ └── keyframe.py ├── usd_resolve_info │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ ├── clip_1.usda │ │ ├── clip_2.usda │ │ ├── clip_manifest.usda │ │ ├── main.cpp │ │ ├── ref.usda │ │ └── usd_resolve_info.usda │ └── python │ │ ├── clip_1.usda │ │ ├── clip_2.usda │ │ ├── clip_manifest.usda │ │ ├── ref.usda │ │ ├── usd_resolve_info.py │ │ └── usd_resolve_info.usda ├── userProperties │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ └── python │ │ └── user.py ├── value_caching │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── build │ │ │ └── .gitignore │ │ ├── forwarder.h │ │ └── main.cpp │ └── python │ │ └── value_caching.py ├── value_clips │ ├── README.md │ ├── cpp │ │ ├── explicit │ │ │ ├── CMakeLists.txt │ │ │ ├── build │ │ │ │ └── .gitignore │ │ │ └── main.cpp │ │ └── template_and_explicit │ │ │ ├── CMakeLists.txt │ │ │ ├── build │ │ │ └── .gitignore │ │ │ └── main.cpp │ ├── python │ │ ├── explicit.py │ │ └── template_and_explicit.py │ └── usda │ │ ├── explicit │ │ ├── README.md │ │ ├── clip_1.usda │ │ ├── clip_2.usda │ │ ├── clip_manifest.usda │ │ ├── ref.usda │ │ └── root.usda │ │ └── template_and_explicit │ │ ├── README.md │ │ ├── non_template_clip.usda │ │ ├── root.usda │ │ ├── set.usda │ │ ├── template_clip.00.usda │ │ ├── template_clip.01.usda │ │ └── template_clip.02.usda └── world_bounding_box │ ├── README.md │ ├── cpp │ ├── CMakeLists.txt │ ├── build │ │ └── .gitignore │ └── main.cpp │ └── python │ └── bounding_box.py ├── plugins ├── custom_resolver │ ├── README.md │ ├── project │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── build │ │ │ └── .gitignore │ │ ├── cmake │ │ │ └── FindUSD.cmake │ │ └── src │ │ │ ├── CMakeLists.txt │ │ │ ├── plugInfo.json │ │ │ ├── resolver.cpp │ │ │ └── resolver.h │ └── run_test │ │ └── custom_resolver.py ├── custom_schemas_with_python_bindings │ ├── README.md │ ├── compiling_the_schema │ │ ├── CMakeLists.txt │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build │ │ │ └── .gitignore │ │ └── src │ │ │ ├── CMakeLists.txt │ │ │ ├── __init__.py │ │ │ ├── __packageinit__.py │ │ │ ├── api.h │ │ │ ├── cmake │ │ │ └── TestoutConfig.cmake │ │ │ ├── complex.cpp │ │ │ ├── complex.h │ │ │ ├── generatedSchema.usda │ │ │ ├── module.cpp │ │ │ ├── moduleDeps.cpp │ │ │ ├── paramsAPI.cpp │ │ │ ├── paramsAPI.h │ │ │ ├── plugInfo.json │ │ │ ├── schema.usda │ │ │ ├── simple.cpp │ │ │ ├── simple.h │ │ │ ├── tokens.cpp │ │ │ ├── tokens.h │ │ │ ├── wrapComplex.cpp │ │ │ ├── wrapParamsAPI.cpp │ │ │ ├── wrapSimple.cpp │ │ │ └── wrapTokens.cpp │ ├── testing_the_compiled_schema_cpp │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── build │ │ │ └── .gitignore │ │ ├── main.cpp │ │ └── test.usda │ └── testing_the_compiled_schema_python │ │ ├── README.md │ │ ├── Test.usda │ │ └── custom_schema_include.py ├── plugin_metadata │ ├── README.md │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── build │ │ │ └── .gitignore │ │ └── main.cpp │ ├── definition │ │ └── plugInfo.json │ ├── python │ │ ├── README.md │ │ └── plugin_metadata.py │ └── usda │ │ └── plugin_metadata.usda ├── registered_variant_selection_export_policies │ ├── README.md │ ├── application_a.py │ ├── application_b.py │ └── plugin │ │ └── plugInfo.json ├── usdview_auto_reloader │ ├── README.md │ ├── plugins │ │ └── auto_reloader │ │ │ ├── __init__.py │ │ │ └── plugInfo.json │ └── some_file.usda ├── usdview_copy_camera │ ├── README.md │ └── plugins │ │ └── copy_camera │ │ ├── __init__.py │ │ ├── button_extended.py │ │ ├── camera_manager.py │ │ ├── path_machine.py │ │ └── plugInfo.json ├── usdview_purpose_swap │ ├── README.md │ ├── assets │ │ └── mesh.usda │ └── plugins │ │ └── purpose_swap │ │ ├── __init__.py │ │ └── plugInfo.json ├── usdview_root_loader │ ├── README.md │ ├── assets │ │ ├── mesh.usda │ │ ├── payload1.usda │ │ └── payload2.usda │ └── plugins │ │ └── root_loader │ │ ├── __init__.py │ │ └── plugInfo.json └── variant_fallbacks │ ├── README.md │ ├── cpp │ ├── CMakeLists.txt │ ├── README.md │ ├── build │ │ └── .gitignore │ └── main.cpp │ ├── example_file │ └── variant_set_with_no_authored_selection.usda │ ├── plugin │ └── plugInfo.json │ └── python │ ├── README.md │ └── variant_fallbacks.py ├── references ├── extents_hint_and_bounding_boxes │ ├── README.md │ ├── a_payload.usda │ ├── all_in_one.usda │ ├── all_in_one_broken.usda │ ├── does_not_work.usda │ ├── multiple_purposes.usda │ ├── simple.usda │ └── something.usda ├── link_to_the_api_documentation │ ├── README.md │ └── example_python_project │ │ ├── README.md │ │ ├── documentation │ │ ├── Makefile │ │ ├── make.bat │ │ └── source │ │ │ ├── conf.py │ │ │ └── index.rst │ │ └── python │ │ └── example_file.py ├── usdview_style_documentation │ ├── README.md │ ├── clip_1.usda │ ├── clip_2.usda │ ├── clip_manifest.usda │ ├── ref.usda │ └── usdview_style_stage.usda ├── where_to_find_resources.md └── working_with_plugins.md ├── tools ├── export_usdskel_from_scratch │ ├── README.md │ ├── example │ │ └── joints.ma │ └── python │ │ └── convert_maya_to_usdskel │ │ ├── __init__.py │ │ ├── animator.py │ │ ├── common.py │ │ ├── converter.py │ │ ├── helper.py │ │ ├── mesher.py │ │ └── skinner.py └── usd_searcher │ ├── README.md │ ├── bin │ └── usd-search │ └── python │ └── usd_searcher.py └── tricks ├── attribute_source_check ├── README.md ├── cpp │ ├── CMakeLists.txt │ └── main.cpp └── python │ └── attribute_check.py ├── bound_material_finder ├── README.md ├── cpp │ ├── CMakeLists.txt │ ├── build │ │ └── .gitignore │ └── main.cpp ├── python │ ├── material_binding_api.py │ └── materials.py └── usda │ ├── materials.usda │ ├── office_set.usda │ └── pencil.usda ├── copy_variant_set_to_prim ├── README.md ├── cpp │ ├── CMakeLists.txt │ ├── build │ │ └── .gitignore │ └── main.cpp └── python │ └── copy_variant_set_to_prim.py ├── fast_export ├── README.md ├── cpp │ ├── CMakeLists.txt │ ├── build │ │ └── .gitignore │ ├── log │ └── main.cpp └── python │ └── fast_export.py ├── flatten_layer_stack ├── README.md ├── cpp │ ├── CMakeLists.txt │ ├── build │ │ └── .gitignore │ └── main.cpp └── python │ └── flatten_layer_stack.py ├── get_sdf_prim_path ├── README.md ├── cpp │ ├── CMakeLists.txt │ └── main.cpp └── python │ └── get_path.py ├── multi_payload ├── README.md ├── cpp │ ├── CMakeLists.txt │ ├── build │ │ └── .gitignore │ └── main.cpp ├── python │ └── payload.py └── usda │ ├── cube_payload.usda │ ├── payload.usda │ └── sphere_payload.usda ├── stl_iteration ├── README.md └── cpp │ ├── CMakeLists.txt │ ├── build │ └── .gitignore │ └── main.cpp ├── stl_iteration2 ├── README.md └── cpp │ ├── CMakeLists.txt │ ├── build │ └── .gitignore │ └── main.cpp ├── traverse_instanced_prims ├── README.md ├── cpp │ ├── CMakeLists.txt │ ├── build │ │ └── .gitignore │ └── main.cpp └── python │ └── traverse_instanced_prims.py ├── use_weaker_layers_to_modify_stronger_layers ├── README.md ├── _complex_deactivate.usda ├── _over_asset_radius_2.usda ├── _over_asset_radius_3.usda ├── _state_switch_reference.usda ├── complex.usda ├── nested_variant_example.usda ├── over.usda ├── simple.usda └── state_switch.usda └── variant_set_auto_selections ├── README.md └── variant_set_auto_selections.usda /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Colin Kennedy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /concepts/mesh_with_materials/cpp/assets/USDLogoLrg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColinKennedy/USD-Cookbook/cfc60a6fa7fb4662bb3529da107bcaf095d0aca4/concepts/mesh_with_materials/cpp/assets/USDLogoLrg.png -------------------------------------------------------------------------------- /concepts/mesh_with_materials/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /concepts/mesh_with_materials/python/USDLogoLrg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColinKennedy/USD-Cookbook/cfc60a6fa7fb4662bb3529da107bcaf095d0aca4/concepts/mesh_with_materials/python/USDLogoLrg.png -------------------------------------------------------------------------------- /concepts/mesh_with_materials/usda/simple/USDLogoLrg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColinKennedy/USD-Cookbook/cfc60a6fa7fb4662bb3529da107bcaf095d0aca4/concepts/mesh_with_materials/usda/simple/USDLogoLrg.png -------------------------------------------------------------------------------- /concepts/mesh_with_materials/usda/with_override/USDLogoLrg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColinKennedy/USD-Cookbook/cfc60a6fa7fb4662bb3529da107bcaf095d0aca4/concepts/mesh_with_materials/usda/with_override/USDLogoLrg.png -------------------------------------------------------------------------------- /concepts/mesh_with_materials/usda/with_override/base.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Xform "TexModel" ( 4 | kind = "component" 5 | ) 6 | { 7 | def Mesh "card" 8 | { 9 | float3[] extent = [(-430, -145, 0), (430, 145, 0)] 10 | int[] faceVertexCounts = [4] 11 | int[] faceVertexIndices = [0, 1, 2, 3] 12 | point3f[] points = [(-430, -145, 0), (430, -145, 0), (430, 145, 0), (-430, 145, 0)] 13 | texCoord2f[] primvars:st = [(0, 0), (1, 0), (1, 1), (0, 1)] ( 14 | interpolation = "varying" 15 | ) 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /concepts/mesh_with_materials/usda/with_override/override.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | subLayers = [ 4 | @./base.usda@ 5 | ] 6 | ) 7 | 8 | 9 | over "TexModel" { 10 | over "card" { 11 | rel material:binding = 12 | 13 | def Material "boardMat" 14 | { 15 | token inputs:frame:stPrimvarName = "st" 16 | token outputs:surface.connect = 17 | 18 | def Shader "PBRShader" 19 | { 20 | uniform token info:id = "UsdPreviewSurface" 21 | color3f inputs:diffuseColor.connect = 22 | float inputs:metallic = 0 23 | float inputs:roughness = 0.4 24 | token outputs:surface 25 | } 26 | 27 | def Shader "stReader" 28 | { 29 | uniform token info:id = "UsdPrimvarReader_float2" 30 | token inputs:varname.connect = 31 | float2 outputs:result 32 | } 33 | 34 | def Shader "diffuseTexture" 35 | { 36 | uniform token info:id = "UsdUVTexture" 37 | asset inputs:file = @./USDLogoLrg.png@ 38 | float2 inputs:st.connect = 39 | float3 outputs:rgb 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /concepts/orphaned_over/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | 3 | An orphaned Over is an Over that does not author an Opinion that affects 4 | the composed Stage's result. In short, it's an `over` specifier that 5 | points to nothing. Check out the [usda folder](usda) for a better idea 6 | of what that looks like, if needed. 7 | 8 | 9 | ### C++ 10 | ```cpp 11 | for (auto const &prim : stage->TraverseAll()) { 12 | if (!prim.IsDefined()) { 13 | std::cout << prim.GetPath() << std::endl; 14 | } 15 | } 16 | ``` 17 | 18 | 19 | ### Python 20 | ```python 21 | print(list(prim for prim in stage.TraverseAll() if not prim.IsDefined())) 22 | ``` 23 | 24 | 25 | # See Also 26 | https://graphics.pixar.com/usd/docs/USD-Glossary.html#USDGlossary-Over 27 | -------------------------------------------------------------------------------- /concepts/orphaned_over/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(orphaned_over_project) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USDGEOM} 43 | ${USD_USD} 44 | ${USD_VT} 45 | ) 46 | -------------------------------------------------------------------------------- /concepts/orphaned_over/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /concepts/orphaned_over/python/base.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = """Some Prim definition. It could be anything. See "over.usda" for details.""" 4 | ) 5 | 6 | 7 | def Sphere "SomeSphere" { 8 | double radius = 4.0 9 | } 10 | -------------------------------------------------------------------------------- /concepts/orphaned_over/python/orphaned_over.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # IMPORT STANDARD LIBRARIES 5 | import os 6 | 7 | # IMPORT THIRD-PARTY LIBRARIES 8 | from pxr import Usd 9 | 10 | CURRENT_DIR = os.path.dirname(os.path.realpath(__file__)) 11 | 12 | 13 | def main(): 14 | """Run the main execution of the current script.""" 15 | stage = Usd.Stage.Open(os.path.join(CURRENT_DIR, "over.usda")) 16 | 17 | # Method 1: Search everything and filter out only what you need This 18 | # method is the "best" because it crosses composition arcs and finds 19 | # nested overs even if they're layered between concrete Prims 20 | # 21 | print(list(prim for prim in stage.TraverseAll() if not prim.IsDefined())) 22 | 23 | # Method 2: Search all Layers in the stage, recursively (follows 24 | # payloads and other composition arcs but does not follow all Prims) 25 | # 26 | print(list(stage.Traverse(~Usd.PrimIsDefined))) 27 | 28 | # Method 3: Search the opened stage Layer 29 | print(list(Usd.PrimRange.Stage(stage, ~Usd.PrimIsDefined))) 30 | 31 | 32 | if __name__ == "__main__": 33 | main() 34 | -------------------------------------------------------------------------------- /concepts/orphaned_over/python/over.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = """The "base.usda" file is brought in but our over "misses" the 4 | PrimSpec that it's meant to modify""" 5 | subLayers = [ 6 | @./base.usda@ 7 | ] 8 | ) 9 | 10 | 11 | over "SomethingNameThatIsNotSomeSphere" { 12 | double radius = 4.0 13 | } 14 | 15 | over "AnotherOne" { 16 | double radius = 5.0 17 | 18 | over "AndAnotherOne" { 19 | double radius = 10.0 20 | } 21 | } 22 | 23 | over "SomeSphere" { 24 | double radius = 10.0 25 | } 26 | -------------------------------------------------------------------------------- /concepts/orphaned_over/usda/base.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = """Some Prim definition. It could be anything. See "over.usda" for details.""" 4 | ) 5 | 6 | 7 | def Sphere "SomeSphere" { 8 | double radius = 4.0 9 | } 10 | -------------------------------------------------------------------------------- /concepts/orphaned_over/usda/over.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = """The "base.usda" file is brought in but our over "misses" the 4 | PrimSpec that it's meant to modify""" 5 | subLayers = [ 6 | @./base.usda@ 7 | ] 8 | ) 9 | 10 | 11 | over "SomethingNameThatIsNotSomeSphere" { 12 | double radius = 4.0 13 | } 14 | 15 | over "AnotherOne" { 16 | double radius = 5.0 17 | 18 | over "AndAnotherOne" { 19 | double radius = 10.0 20 | } 21 | } 22 | 23 | over "SomeSphere" { 24 | double radius = 10.0 25 | } 26 | -------------------------------------------------------------------------------- /concepts/reference_into_prim/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | Sometimes you need to reference a Prim like into anotheer 3 | stage but, when you do that, you want to keep the name and type of "Bar" 4 | in the other stage. 5 | 6 | This short snippet shows you how to do it. There's nothing much to this 7 | trick. Just query the type / name of some Prim path or fall back to the 8 | stage's defaultPrim to get the same information. 9 | 10 | 11 | ### Python 12 | 13 | ```python 14 | def add_prim_from_target(stage, target, prim_path=""): 15 | if not prim_path: 16 | prim = target.GetDefaultPrim() or target.GetPrimAtPath( 17 | target.GetRootLayer().defaultPrim 18 | ) 19 | else: 20 | prim = target.GetPrimAtPath(prim_path) 21 | 22 | if not prim.IsValid(): 23 | raise RuntimeError( 24 | 'Prim path "{prim_path}" could not be found and there is not ' 25 | "default Prim to fall back on.".format(prim_path=prim_path) 26 | ) 27 | 28 | creators = { 29 | Sdf.SpecifierClass: stage.CreateClassPrim, 30 | Sdf.SpecifierDef: functools.partial( 31 | stage.DefinePrim, typeName=prim.GetTypeName() 32 | ), 33 | Sdf.SpecifierOver: stage.OverridePrim, 34 | } 35 | 36 | creator = creators[prim.GetSpecifier()] 37 | created_prim = creator(prim.GetPath()) 38 | 39 | created_prim.GetReferences().AddReference( 40 | assetPath=target.GetRootLayer().identifier, primPath=prim.GetPath() 41 | ) 42 | ``` 43 | -------------------------------------------------------------------------------- /concepts/reference_into_prim/usda/base.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "/Foo/Bar" 4 | ) 5 | 6 | def "Foo" 7 | { 8 | def Xform "Bar" ( 9 | "some comment" 10 | ) 11 | { 12 | custom float some_property = 1 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /concepts/reference_into_prim/usda/reference.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Foo" 4 | { 5 | def "Bar" ( 6 | references = @./base.usda@ 7 | ) 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /concepts/relationship_forwarding/cpp/destination_forwarding/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(relationship_forwarding) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | 22 | find_package(PythonLibs REQUIRED) 23 | 24 | # 4. Include/Link Everything 25 | add_executable(run_it 26 | main.cpp 27 | ) 28 | 29 | target_include_directories(run_it 30 | PUBLIC 31 | ${PYTHON_INCLUDE_PATH} 32 | ${USD_INCLUDE_DIRECTORY} 33 | ) 34 | 35 | target_link_libraries( 36 | run_it 37 | ${PYTHON_LIBRARY} 38 | ${USD_BOOST_PYTHON} 39 | ${USD_SDF} 40 | ${USD_TF} 41 | ${USD_USDGEOM} 42 | ${USD_USD} 43 | ) 44 | -------------------------------------------------------------------------------- /concepts/relationship_forwarding/cpp/destination_forwarding/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /concepts/relationship_forwarding/cpp/source_forwarding/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(relationship_forwarding) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | 22 | find_package(PythonLibs REQUIRED) 23 | 24 | # 4. Include/Link Everything 25 | add_executable(run_it 26 | main.cpp 27 | ) 28 | 29 | target_include_directories(run_it 30 | PUBLIC 31 | ${PYTHON_INCLUDE_PATH} 32 | ${USD_INCLUDE_DIRECTORY} 33 | ) 34 | 35 | target_link_libraries( 36 | run_it 37 | ${PYTHON_LIBRARY} 38 | ${USD_BOOST_PYTHON} 39 | ${USD_SDF} 40 | ${USD_TF} 41 | ${USD_USDGEOM} 42 | ${USD_USD} 43 | ) 44 | -------------------------------------------------------------------------------- /concepts/relationship_forwarding/cpp/source_forwarding/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /concepts/relationship_forwarding/python/destination_forwarding.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """A demonstration of how to get the leaf-target values of a USD relationship.""" 5 | 6 | # IMPORT THIRD-PARTY LIBRARIES 7 | from pxr import Usd 8 | 9 | 10 | def main(): 11 | """Run the main execution of the current script.""" 12 | stage = Usd.Stage.Open("../usda/destination_forwarding.usda") 13 | prim = stage.GetPrimAtPath("/Forwarder") 14 | 15 | relationship = stage.GetPrimAtPath("/SomePrim").GetRelationship("another") 16 | print('This is the raw target value "{}"'.format(relationship.GetTargets())) 17 | print('But this is the true location "{}"'.format(relationship.GetForwardedTargets())) 18 | 19 | variant_sets = prim.GetVariantSets() 20 | variant_set = variant_sets.GetVariantSet("forwarding_variant_set") 21 | 22 | for variant in variant_set.GetVariantNames(): 23 | variant_set.SetVariantSelection(variant) 24 | 25 | print("Setting to {}".format(variant)) 26 | print('This is the raw target value "{}"'.format(relationship.GetTargets())) 27 | print('But this is the true location "{}"'.format(relationship.GetForwardedTargets())) 28 | 29 | 30 | if __name__ == "__main__": 31 | main() 32 | -------------------------------------------------------------------------------- /concepts/relationship_forwarding/python/source_forwarding.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """A demonstration of how to get the leaf-target values of a USD relationship.""" 5 | 6 | # IMPORT THIRD-PARTY LIBRARIES 7 | from pxr import Usd 8 | 9 | 10 | def main(): 11 | """Run the main execution of the current script.""" 12 | stage = Usd.Stage.Open('../usda/source_forwarding.usda') 13 | prim = stage.GetPrimAtPath('/SomePrim') 14 | 15 | relationship = prim.GetRelationship("another") 16 | print('This is the raw target value "{}"'.format(relationship.GetTargets())) 17 | print('But this is the true location "{}"'.format(relationship.GetForwardedTargets())) 18 | 19 | variant_sets = prim.GetVariantSets() 20 | variant_set = variant_sets.GetVariantSet('forwarding_variant_set') 21 | 22 | for variant in variant_set.GetVariantNames(): 23 | variant_set.SetVariantSelection(variant) 24 | 25 | print('This is the raw target value "{}"'.format(relationship.GetTargets())) 26 | print('But this is the true location "{}"'.format(relationship.GetForwardedTargets())) 27 | 28 | 29 | if __name__ == "__main__": 30 | main() 31 | -------------------------------------------------------------------------------- /concepts/relationship_forwarding/usda/destination_forwarding.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | "This example shows how to make a single relationship point to different targets after resolve-time, using VariantSets, without overriding its targets. The is a class so that means it won't show up in regular traversals. But we can still change its variant sets programmatically (even if artists can't). To \"expose\" to the user so they can change variants, just change `class` to `def`." 4 | ) 5 | 6 | class "Forwarder" ( 7 | variants = { 8 | string forwarding_variant_set = "selection_1" 9 | } 10 | prepend variantSets = "forwarding_variant_set" 11 | ) 12 | { 13 | variantSet "forwarding_variant_set" = { 14 | "selection_1" { 15 | rel something = 16 | 17 | } 18 | "selection_2" { 19 | rel something = 20 | 21 | } 22 | "selection_3" { 23 | rel something = 24 | 25 | } 26 | } 27 | } 28 | 29 | def Xform "SomePrim" 30 | { 31 | rel another = 32 | } 33 | 34 | def Xform "SomeLocation" 35 | { 36 | } 37 | 38 | def Xform "AnotherLocation" 39 | { 40 | } 41 | 42 | def Xform "ThirdLocation" 43 | { 44 | } 45 | 46 | -------------------------------------------------------------------------------- /concepts/relationship_forwarding/usda/source_forwarding.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | "This example shows how to override a relationship point to different targets after resolve-time, using VariantSets." 4 | ) 5 | 6 | class "Forwarder1" 7 | { 8 | rel something = 9 | } 10 | 11 | class "Forwarder2" 12 | { 13 | rel something = 14 | } 15 | 16 | class "Forwarder3" 17 | { 18 | rel something = 19 | } 20 | 21 | def Xform "SomePrim" ( 22 | variants = { 23 | string forwarding_variant_set = "selection_1" 24 | } 25 | prepend variantSets = "forwarding_variant_set" 26 | ) 27 | { 28 | variantSet "forwarding_variant_set" = { 29 | "selection_1" { 30 | rel another = 31 | 32 | } 33 | "selection_2" { 34 | rel another = 35 | 36 | } 37 | "selection_3" { 38 | rel another = 39 | 40 | } 41 | } 42 | } 43 | 44 | def Xform "SomeLocation" 45 | { 46 | } 47 | 48 | def Xform "AnotherLocation" 49 | { 50 | } 51 | 52 | def Xform "ThirdLocation" 53 | { 54 | } 55 | 56 | -------------------------------------------------------------------------------- /concepts/specializes_a_practical_example/layout.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | subLayers = [ 4 | @./modelling.usda@ 5 | ] 6 | ) 7 | 8 | def "Models" 9 | { 10 | def "Foo1" ( 11 | instanceable = true 12 | references = @./modelling.usda@ 13 | ) 14 | { 15 | float3 xformOp:translate = (2, 0, 1) 16 | uniform token[] xformOpOrder = ["xformOp:translate"] 17 | } 18 | 19 | def "Foo2" ( 20 | instanceable = true 21 | references = @./modelling.usda@ 22 | ) 23 | { 24 | float3 xformOp:translate = (2, 2, 7) 25 | uniform token[] xformOpOrder = ["xformOp:translate"] 26 | } 27 | } 28 | 29 | def Camera "SceneCamera1" ( 30 | references = 31 | ) 32 | { 33 | } 34 | 35 | def Camera "SceneCamera2" ( 36 | references = 37 | ) 38 | { 39 | } 40 | 41 | -------------------------------------------------------------------------------- /concepts/specializes_a_practical_example/modelling.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | subLayers = [ 4 | @./settings.usda@ 5 | ] 6 | ) 7 | 8 | class Xform "Grouper" 9 | { 10 | def Sphere "MySphere" 11 | { 12 | double radius = 4 13 | } 14 | } 15 | 16 | over "_class_CameraSettings" 17 | { 18 | double focalLength = 200 ( 19 | 'When you open layout.usda, anything that references "_class_CameraSettings" will have a value of 200. But anything that referennces "_class_CameraSettingsSpecialized" will not!' 20 | ) 21 | } 22 | 23 | -------------------------------------------------------------------------------- /concepts/specializes_a_practical_example/settings.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | class Camera "_class_CameraSettings" { 4 | double focalLength = 100.0 5 | } 6 | 7 | class Camera "_class_CameraSettingsSpecialized" 8 | ( 9 | specializes = 10 | ){ 11 | double focalLength = 100.0 12 | } 13 | -------------------------------------------------------------------------------- /concepts/specializes_as_a_fallback_mechanism/base.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | "A Layer that demonstrates why `specializes` can be used as a fallback-Prim mechanism. The reason it works is because it's the weakest composition arc." 4 | ) 5 | 6 | class "SomeClassWithRadius" 7 | { 8 | double radius = 4 9 | } 10 | 11 | class "FallbackClassWithRadius" 12 | { 13 | double radius = 5 14 | } 15 | 16 | def Sphere "MySphere1" ( 17 | "This Prim will have a radius of 4 because `references` is preferred over `specializes`." 18 | references = 19 | specializes = 20 | ) 21 | { 22 | } 23 | 24 | def Sphere "MySphere2" ( 25 | "This Prim will have a radius of 10 because `payload` is preferred over `specializes`." 26 | payload = @./payload.usda@ 27 | specializes = 28 | ) 29 | { 30 | } 31 | 32 | def Sphere "MySphere3" ( 33 | "This Prim will have a radius of 4 because `references` is preferred over `payload`." 34 | payload = @./payload.usda@ 35 | references = 36 | ) 37 | { 38 | } 39 | 40 | def Sphere "MySphere4" ( 41 | "This Prim will have a radius of 5 because `specializes` authors a value for it." 42 | specializes = 43 | ) 44 | { 45 | } 46 | 47 | def Sphere "MySphere5" ( 48 | "This Prim will have a radius of 1 because that is the fallback value for `Sphere`." 49 | ) 50 | { 51 | } 52 | 53 | -------------------------------------------------------------------------------- /concepts/specializes_as_a_fallback_mechanism/payload.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | 4 | def Sphere "MySphere" { 5 | double radius = 10 6 | } 7 | -------------------------------------------------------------------------------- /concepts/uniquify_an_instance/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | 3 | USD has interesting rules about instancing. If you're authoring a USD 4 | file from-scratch and you define a Prim inside of an Instanced Prim, 5 | that's considered legal USD code (it won't produce an error or warning). 6 | But if you load it in usdview, the Prim will not exist. 7 | 8 | Load [example.usda](python/example.usda) and you'll see what I mean. 9 | 10 | The Prim "SomePrimThatWillNotExist" will not be in usdview but it is 11 | defined in the .usda file. 12 | 13 | But if you try to actually programmatically write the same code, it 14 | will raise an exception (because it is technically wrong). 15 | 16 | The best way to make sure that you don't raise an exception while 17 | authoring opinions on a Prim is to make sure that you aren't writing 18 | over an instance. The easiest way is to just check for it. 19 | 20 | ```python 21 | if prim.IsInstance(): 22 | prim.SetInstanceable(False) 23 | # ... your opinion here ... 24 | ``` 25 | 26 | Also notice that the cpp and python versions create slightly different results. 27 | -------------------------------------------------------------------------------- /concepts/uniquify_an_instance/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(uniquify_an_instance) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USDGEOM} 43 | ${USD_USD} 44 | ${USD_VT} 45 | ) 46 | -------------------------------------------------------------------------------- /concepts/uniquify_an_instance/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /concepts/uniquify_an_instance/python/example.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Xform "AnotherPrim" 4 | { 5 | def Xform "InnerPrim1" ( 6 | instanceable = true 7 | prepend references = 8 | ) 9 | { 10 | def "SomePrimThatWillNotExist" 11 | { 12 | } 13 | } 14 | 15 | def Xform "InnerPrim2" ( 16 | instanceable = true 17 | prepend references = 18 | ) 19 | { 20 | } 21 | } 22 | 23 | def Xform "MyPrim" 24 | { 25 | def Xform "SomePrim" 26 | { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /concepts/uniquify_an_instance/python/uniquify.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # IMPORT THIRD-PARTY LIBRARIES 5 | from pxr import Tf, Usd, UsdGeom 6 | 7 | 8 | def main(): 9 | """Run the main execution of the current script.""" 10 | stage = Usd.Stage.CreateInMemory() 11 | 12 | master = "/MyPrim" 13 | 14 | instances = ["/AnotherPrim/InnerPrim1", "/AnotherPrim/InnerPrim2"] 15 | paths = ["/AnotherPrim", "/MyPrim/SomePrim", master] 16 | 17 | for path in paths + instances: 18 | UsdGeom.Xform.Define(stage, path) 19 | 20 | for instance in instances: 21 | prim = stage.GetPrimAtPath(instance) 22 | prim.GetReferences().AddReference("", primPath="/MyPrim") 23 | prim.SetInstanceable(True) 24 | 25 | try: 26 | stage.DefinePrim("/AnotherPrim/InnerPrim1/SomePrimThatWillNotExist") 27 | except Tf.ErrorException: 28 | # XXX : Because "/AnotherPrim/InnerPrim1" is an instance, 29 | # DefinePrim will raise an exception 30 | # 31 | print("EXCEPTION FOUND") 32 | 33 | stage.DefinePrim("/AnotherPrim/InnerPrim1").SetInstanceable(False) 34 | # XXX : We broke the instance so now it will not raise an exception 35 | # If you want to, you can also do `if not prim.IsInstance(): stage.DefinePrim` 36 | # 37 | stage.DefinePrim("/AnotherPrim/InnerPrim1/SomePrimThatWillExist") 38 | 39 | print(stage.ExportToString()) 40 | 41 | 42 | if __name__ == "__main__": 43 | main() 44 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/invalid_1.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | doc = "This has no kind defined. So it isn't a Model" 5 | ) 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/invalid_2.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | doc = "This has a valid Model kind" 5 | kind = "assembly" 6 | ) 7 | { 8 | def Scope "some_group" ( 9 | doc = "This has a valid Model kind" 10 | kind = "group" 11 | ) 12 | { 13 | def Scope "child" ( 14 | doc = "But don't expect this to be a valid Model kind" 15 | ) 16 | { 17 | } 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/invalid_2b.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" 4 | { 5 | def Scope "inner" ( 6 | doc = "This whole chain of kinds are invalid because the top-level Prim has no kind" 7 | kind = "assembly" 8 | ) 9 | { 10 | def Scope "some_group" ( 11 | doc = "This whole chain of kinds are invalid because the top-level Prim has no kind" 12 | kind = "group" 13 | ) 14 | { 15 | def Scope "last_one" ( 16 | doc = "This whole chain of kinds are invalid because the top-level Prim has no kind" 17 | kind = "component" 18 | ) 19 | { 20 | } 21 | } 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/invalid_2c.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | doc = "This is a valid Model kind" 5 | kind = "assembly" 6 | ) 7 | { 8 | def Scope "inner" ( 9 | doc = "Because this has no kind, all child Prims are an invalid Model" 10 | ) 11 | { 12 | def Scope "some_group" ( 13 | doc = "This is not a Model kind" 14 | kind = "group" 15 | ) 16 | { 17 | def Scope "last_one" ( 18 | doc = "This is not a Model kind" 19 | kind = "component" 20 | ) 21 | { 22 | } 23 | } 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/invalid_2d.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | doc = "This is valid" 5 | kind = "assembly" 6 | ) 7 | { 8 | def Scope "some_group" ( 9 | doc = "This is valid" 10 | kind = "group" 11 | ) 12 | { 13 | def Scope "some_component" ( 14 | doc = "This is valid" 15 | kind = "component" 16 | ) 17 | { 18 | def Scope "inner_invalid_group" ( 19 | doc = "This one isn't valid" 20 | kind = "group" 21 | ) 22 | { 23 | } 24 | } 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/valid_1.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | kind = "component" 5 | ) 6 | { 7 | } 8 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/valid_2.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | kind = "assembly" 5 | ) 6 | { 7 | def Scope "some_group" ( 8 | kind = "group" 9 | ) 10 | { 11 | def Scope "last_one" ( 12 | kind = "component" 13 | ) 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/valid_3.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | kind = "assembly" 5 | ) 6 | { 7 | def Scope "some_group" ( 8 | kind = "group" 9 | ) 10 | { 11 | def Scope "another_assembly" ( 12 | kind = "assembly" 13 | ) 14 | { 15 | def Scope "last_one" ( 16 | kind = "component" 17 | ) 18 | { 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/valid_4.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | kind = "component" 5 | ) 6 | { 7 | def Scope "child" ( 8 | kind = "subcomponent" 9 | ) 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /concepts/valid_model_hierarchies/valid_5.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root1" ( 4 | kind = "assembly" 5 | ) 6 | { 7 | } 8 | 9 | 10 | def Scope "root2" ( 11 | kind = "assembly" 12 | ) 13 | { 14 | def Scope "child" 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /concepts/variant_set_in_stronger_layer/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(variant_set_in_stronger_layer) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_GF gf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 23 | 24 | find_package(PythonLibs REQUIRED) 25 | 26 | # 4. Include/Link Everything 27 | add_executable(run_it 28 | main.cpp 29 | ) 30 | 31 | target_include_directories(run_it 32 | PUBLIC 33 | ${PYTHON_INCLUDE_PATH} 34 | ${USD_INCLUDE_DIRECTORY} 35 | ) 36 | 37 | target_link_libraries( 38 | run_it 39 | ${PYTHON_LIBRARY} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_GF} 42 | ${USD_SDF} 43 | ${USD_TF} 44 | ${USD_USDGEOM} 45 | ${USD_USD} 46 | ${USD_VT} 47 | ) 48 | -------------------------------------------------------------------------------- /concepts/variant_set_in_stronger_layer/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /concepts/variant_set_in_stronger_layer/usda/base.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = """A layer that authors some variant set""" 4 | ) 5 | 6 | def Sphere "SomeSphere" 7 | ( 8 | variants = { 9 | string some_variant = "variant_name_2" 10 | } 11 | prepend variantSets = "some_variant" 12 | ) 13 | { 14 | variantSet "some_variant" = { 15 | "variant_name_1" { 16 | double radius = 1.0 17 | } 18 | "variant_name_2" { 19 | double radius = 2.0 20 | } 21 | "variant_name_3" { 22 | double radius = 3.0 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /concepts/variant_set_in_stronger_layer/usda/override.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | subLayers = [ 4 | @./base.usda@ 5 | ] 6 | ) 7 | 8 | over "SomeSphere" ( 9 | variants = { 10 | string some_variant_set = "foo" 11 | } 12 | prepend variantSets = ["another", "some_variant_set"] 13 | ) 14 | { 15 | variantSet "some_variant_set" = { 16 | "foo" { 17 | double radius = 100 18 | 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /concepts/variant_set_production_shot/README.md: -------------------------------------------------------------------------------- 1 | # See Also 2 | https://graphics.pixar.com/usd/docs/USD-Glossary.html#USDGlossary-VariantSet 3 | 4 | https://graphics.pixar.com/usd/docs/USD-Glossary.html#USDGlossary-Variant 5 | -------------------------------------------------------------------------------- /concepts/variant_set_production_shot/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(variant_set_production_shot) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_GF gf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 23 | 24 | find_package(PythonLibs REQUIRED) 25 | 26 | # 4. Include/Link Everything 27 | add_executable(run_it 28 | main.cpp 29 | ) 30 | 31 | target_include_directories(run_it 32 | PUBLIC 33 | ${PYTHON_INCLUDE_PATH} 34 | ${USD_INCLUDE_DIRECTORY} 35 | ) 36 | 37 | target_link_libraries( 38 | run_it 39 | ${PYTHON_LIBRARY} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_GF} 42 | ${USD_SDF} 43 | ${USD_TF} 44 | ${USD_USDGEOM} 45 | ${USD_USD} 46 | ${USD_VT} 47 | ) 48 | -------------------------------------------------------------------------------- /concepts/variant_set_production_shot/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /concepts/variant_set_production_shot/usda/asset.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = """This file contains the "character" that will be changed in other layers.""" 4 | ) 5 | 6 | def Sphere "SomeSphere" { 7 | double radius = 3.0 8 | } 9 | -------------------------------------------------------------------------------- /concepts/variant_set_production_shot/usda/sequence.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | "We override the character to make it bigger and add some viewing option." 4 | doc = """A common set of data for an entire sequence.""" 5 | subLayers = [ 6 | @./asset.usda@, 7 | ] 8 | ) 9 | 10 | over "SomeSphere" 11 | ( 12 | prepend variantSets = ["some_variant_set"] 13 | variants = { 14 | string some_variant_set = "variant_name_1" 15 | } 16 | ) 17 | { 18 | double radius = 20 19 | 20 | variantSet "some_variant_set" = { 21 | "variant_name_1" { 22 | color3f[] primvars:displayColor = [(1, 0, 0)] 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /concepts/variant_set_production_shot/usda/shot_v001.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = """This shot takes the common settings from sequence.usda and adds to them.""" 4 | subLayers = [ 5 | @./sequence.usda@ 6 | ] 7 | ) 8 | 9 | over "SomeSphere" 10 | ( 11 | variants = { 12 | string some_variant_set = "variant_name_2" 13 | } 14 | ) 15 | { 16 | variantSet "some_variant_set" = { 17 | "variant_name_2" { 18 | color3f[] primvars:displayColor = [(0, 1, 0)] 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /concepts/variant_set_understanding/arcs.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | endTimeCode = 10 4 | startTimeCode = 0 5 | ) 6 | 7 | def Xform "transform" ( 8 | add references = [ 9 | @sources/model.usda@, 10 | @sources/surfacing.usda@ 11 | ] 12 | prepend variantSets = "state" 13 | ) 14 | { 15 | variantSet "state" = { 16 | "blue" ( 17 | add references = @sources/surfacing_blue.usda@ 18 | ) { 19 | 20 | } 21 | "motion" ( 22 | add references = @sources/animation.usda@ 23 | ) { 24 | 25 | } 26 | "sphere" ( 27 | add references = @sources/sphere.usda@ 28 | ) { 29 | 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /concepts/variant_set_understanding/metadata_swap.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Xform "root" ( 4 | prepend variantSets = "something" 5 | ) 6 | { 7 | variantSet "something" = { 8 | "option_a" ( 9 | some_metadata = "foo" 10 | ) { 11 | 12 | } 13 | "option_b" { 14 | 15 | } 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /concepts/variant_set_understanding/sources/animation.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "root" 4 | ) 5 | 6 | class "root" 7 | { 8 | double3 xformOp:translate:move.timeSamples = { 9 | 0: (0, 0, 0), 10 | 10: (0, 0, 20), 11 | } 12 | uniform token[] xformOpOrder = ["xformOp:translate:move"] 13 | } 14 | 15 | -------------------------------------------------------------------------------- /concepts/variant_set_understanding/sources/model.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "root" 4 | ) 5 | 6 | class Scope "root" 7 | { 8 | def Cube "model" 9 | { 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /concepts/variant_set_understanding/sources/sphere.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "root" 4 | ) 5 | 6 | class "root" 7 | { 8 | def Sphere "model" 9 | { 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /concepts/variant_set_understanding/sources/surfacing.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "surfacing" 4 | ) 5 | 6 | class "surfacing" 7 | { 8 | color3f[] primvars:displayColor = [(1, 0, 0)] 9 | } 10 | 11 | -------------------------------------------------------------------------------- /concepts/variant_set_understanding/sources/surfacing_blue.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "surfacing" 4 | ) 5 | 6 | class "surfacing" 7 | { 8 | color3f[] primvars:displayColor = [(0, 0, 1)] 9 | } 10 | 11 | -------------------------------------------------------------------------------- /features/add_comment/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | ### C++ 3 | ```cpp 4 | prim.SetMetadata(pxr::SdfFieldKeys->Comment, "I am a comment"); 5 | ``` 6 | 7 | 8 | ### Python 9 | ```python 10 | prim.SetMetadata("comment", "I am a comment") 11 | ``` 12 | 13 | 14 | ### USD 15 | ```usda 16 | #usda 1.0 17 | 18 | def Sphere "MySphere" ( 19 | "I am a comment" 20 | ) { 21 | } 22 | ``` 23 | -------------------------------------------------------------------------------- /features/add_comment/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(add_comment) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USDGEOM} 43 | ${USD_USD} 44 | ${USD_VT} 45 | ) 46 | -------------------------------------------------------------------------------- /features/add_comment/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/add_comment/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT STANDARD LIBRARIES 2 | #include 3 | #include 4 | 5 | // IMPORT THIRD-PARTY LIBRARIES 6 | #include 7 | #include 8 | 9 | 10 | int main() { 11 | auto stage = pxr::UsdStage::CreateInMemory(); 12 | stage->GetRootLayer()->SetDocumentation("This is an example of adding a comment. You can add comments inside any pair of ()s"); 13 | 14 | auto sphere = pxr::UsdGeomSphere::Define(stage, pxr::SdfPath("/SomeSphere")); 15 | sphere.GetPrim().SetMetadata( 16 | pxr::SdfFieldKeys->Comment, 17 | "I am a comment" 18 | ); 19 | 20 | auto* result = new std::string(); 21 | stage->GetRootLayer()->ExportToString(result); 22 | std::cout << *result << std::endl; 23 | delete result; 24 | result = nullptr; 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /features/add_comment/python/comment.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Show how to write a comment in USD Python API.""" 5 | 6 | # IMPORT THIRD-PARTY LIBRARIES 7 | from pxr import Usd, UsdGeom 8 | 9 | 10 | def main(): 11 | """Run the main execution of the current script.""" 12 | stage = Usd.Stage.CreateInMemory() 13 | 14 | sphere = UsdGeom.Sphere.Define(stage, "/SomeSphere") 15 | sphere.GetPrim().SetMetadata("comment", "I am a comment") 16 | 17 | print(stage.GetRootLayer().ExportToString()) 18 | 19 | 20 | if __name__ == "__main__": 21 | main() 22 | -------------------------------------------------------------------------------- /features/add_comment/usda/base.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = "This is an example of adding a comment. You can add comments inside any pair of ()s" 4 | ) 5 | 6 | def Sphere "MySphere" ( 7 | "I am a comment" 8 | kind = "component" 9 | ) { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /features/asset_info/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(asset_info) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USDGEOM} 43 | ${USD_USD} 44 | ${USD_VT} 45 | ) 46 | -------------------------------------------------------------------------------- /features/asset_info/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/asset_info/usda/asset_info.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Sphere "SomeSphere" ( 4 | assetInfo = { 5 | asset identifier = @some/path/to/file.usda@ 6 | string name = "some_asset" 7 | asset[] payloadAssetDependencies = [@something.usd@, @another/thing.usd@] 8 | string version = "v1" 9 | } 10 | ) 11 | { 12 | } 13 | 14 | def Sphere "AnotherSphere" ( 15 | assetInfo = { 16 | string identifier = "some/path/to/file.usda" 17 | string name = "some_asset" 18 | asset[] payloadAssetDependencies = [@something.usd@, @another/thing.usd@] 19 | string version = "v1" 20 | } 21 | ) 22 | { 23 | } 24 | 25 | def Sphere "LastSphere" ( 26 | assetInfo = { 27 | string identifier = "some/path/to/file.usda" 28 | string name = "some_asset" 29 | asset[] payloadAssetDependencies = [@something.usd@, @another/thing.usd@] 30 | string version = "v1" 31 | } 32 | ) 33 | { 34 | } 35 | -------------------------------------------------------------------------------- /features/batch_namespace_edit/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(batch_namespace_edit) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | 20 | find_package(PythonLibs REQUIRED) 21 | 22 | # 4. Include/Link Everything 23 | add_executable(run_it 24 | main.cpp 25 | ) 26 | 27 | target_include_directories(run_it 28 | PUBLIC 29 | ${PYTHON_INCLUDE_PATH} 30 | ${USD_INCLUDE_DIRECTORY} 31 | ) 32 | 33 | target_link_libraries( 34 | run_it 35 | ${PYTHON_LIBRARY} 36 | ${USD_BOOST_PYTHON} 37 | ${USD_SDF} 38 | ${USD_TF} 39 | ) 40 | -------------------------------------------------------------------------------- /features/batch_namespace_edit/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/caching/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | ## Auto-Add Stages To Cache 3 | ### C++ 4 | ```cpp 5 | auto cache = pxr::UsdStageCache {}; 6 | 7 | { 8 | pxr::UsdStageCacheContext context(cache); 9 | auto stage = pxr::UsdStage::CreateInMemory(); 10 | } 11 | ``` 12 | 13 | 14 | ### Python 15 | ```python 16 | cache = Usd.StageCache() 17 | 18 | with Usd.StageCacheContext(cache): 19 | stage = Usd.Stage.CreateInMemory() 20 | ``` 21 | 22 | 23 | ## Explicitly-Add Stages To Cache 24 | ### C++ 25 | ```cpp 26 | auto stage = pxr::UsdStage::CreateInMemory(); 27 | auto cache = pxr::UsdStageCache {}; 28 | cache.Insert(stage); 29 | ``` 30 | 31 | 32 | ### Python 33 | ```python 34 | stage = Usd.Stage.CreateInMemory() 35 | cache = Usd.StageCache() 36 | cache.Insert(stage) 37 | ``` 38 | 39 | 40 | ## Get Stage From Singleton Cache 41 | ### Python 42 | ```python 43 | def get_stage_from_id(stage_id): 44 | """Refer to the singleton UsdUtils cache to find a stage by-ID.""" 45 | cache = UsdUtils.StageCache.Get() 46 | print('Found stage', cache.Find(stage_id)) 47 | ``` 48 | 49 | 50 | # See Also 51 | https://graphics.pixar.com/usd/docs/api/class_usd_stage_cache.html 52 | 53 | https://graphics.pixar.com/usd/docs/api/class_usd_stage_cache_context.html 54 | 55 | https://graphics.pixar.com/usd/docs/api/class_usd_utils_stage_cache.html 56 | -------------------------------------------------------------------------------- /features/caching/cpp/cache_utils/README.md: -------------------------------------------------------------------------------- 1 | TODO : This project is unfinished. Fix later 2 | -------------------------------------------------------------------------------- /features/caching/cpp/cache_utils/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/caching/cpp/cache_utils/main.cpp: -------------------------------------------------------------------------------- 1 | /* This module is a variant of `caching.py` that explores uses of `pxr.UsdUtils.StageCache`. 2 | 3 | Unlike `pxr.Usd.StageCache` which is not a singleton, 4 | `pxr.UsdUtils.StageCache` is. This lets us use USD's stage cache without 5 | passing a cache object around to every function. It's very useful for 6 | applications. 7 | 8 | */ 9 | 10 | // IMPORT THIRD-PARTY LIBRARIES 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | int main() { 17 | auto stage = pxr::UsdStage::CreateInMemory(); 18 | auto cache = pxr::UsdUtilsStageCache::Get(); 19 | 20 | { 21 | pxr::UsdStageCacheContext context(cache); 22 | std::cout << std::boolalpha; 23 | std::cout << "This should be false: " << cache.Contains(stage) << '\n'; 24 | } 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /features/caching/cpp/caching/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(usd_caching) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_ARCH arch HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TBB tbb HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 22 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 23 | 24 | find_package(PythonLibs REQUIRED) 25 | 26 | # 4. Include/Link Everything 27 | add_executable(run_it 28 | main.cpp 29 | ) 30 | 31 | target_include_directories(run_it 32 | PUBLIC 33 | ${PYTHON_INCLUDE_PATH} 34 | ${USD_INCLUDE_DIRECTORY} 35 | ) 36 | 37 | target_link_libraries( 38 | run_it 39 | ${PYTHON_LIBRARY} 40 | ${USD_ARCH} 41 | ${USD_BOOST_PYTHON} 42 | ${USD_SDF} 43 | ${USD_TBB} 44 | ${USD_TF} 45 | ${USD_USDGEOM} 46 | ${USD_USD} 47 | ) 48 | -------------------------------------------------------------------------------- /features/caching/cpp/caching/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/caching/python/README.md: -------------------------------------------------------------------------------- 1 | ## More Information 2 | Check out [USD/pxr/usd/lib/usd/testenv/testUsdStageCache.py](TODO add URL here) 3 | -------------------------------------------------------------------------------- /features/edit_targets/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(asset_info) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_package(PythonLibs REQUIRED) 17 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_GEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | # 4. Include/Link Everything 24 | add_executable(run_it 25 | main.cpp 26 | ) 27 | 28 | target_include_directories(run_it 29 | PUBLIC 30 | ${PYTHON_INCLUDE_PATH} 31 | ${USD_INCLUDE_DIRECTORY} 32 | ) 33 | 34 | target_link_libraries( 35 | run_it 36 | ${PYTHON_LIBRARY} 37 | ${USD_BOOST_PYTHON} 38 | ${USD_GEOM} 39 | ${USD_SDF} 40 | ${USD_TF} 41 | ${USD_USD} 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /features/enable_debugging/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Setting output using environment variables 3 | Set TF_DEBUG_OUTPUT_FILE to "stderr". 4 | 5 | ```bash 6 | export TF_DEBUG_OUTPUT_FILE="stderr" 7 | ``` 8 | 9 | Pixar's documentation states that stdout is used to output messages by 10 | default. It goes further and says that you can only output to "stdout" 11 | or "stderr". 12 | -------------------------------------------------------------------------------- /features/enable_debugging/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(enable_debugging) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | 22 | find_package(PythonLibs REQUIRED) 23 | 24 | # 4. Include/Link Everything 25 | add_executable(run_it 26 | main.cpp 27 | ) 28 | 29 | target_include_directories(run_it 30 | PUBLIC 31 | ${PYTHON_INCLUDE_PATH} 32 | ${USD_INCLUDE_DIRECTORY} 33 | ) 34 | 35 | target_link_libraries( 36 | run_it 37 | ${PYTHON_LIBRARY} 38 | ${USD_BOOST_PYTHON} 39 | ${USD_SDF} 40 | ${USD_TF} 41 | ${USD_USDGEOM} 42 | ${USD_USD} 43 | ) 44 | -------------------------------------------------------------------------------- /features/enable_debugging/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/notice_send/README.md: -------------------------------------------------------------------------------- 1 | # See Also 2 | https://groups.google.com/forum/#!topic/usd-interest/qg898UklVyo 3 | 4 | 5 | https://graphics.pixar.com/usd/docs/api/sdf_page_front.html 6 | 7 | https://graphics.pixar.com/usd/docs/api/sdf_2notice_8h.html#class_sdf_notice 8 | 9 | https://github.com/PixarAnimationStudios/USD/blob/master/pxr/base/lib/tf/testenv/notice.cpp 10 | -------------------------------------------------------------------------------- /features/notice_send/cpp/notice_send_custom/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(notice_send_custom) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_ARCH arch HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_ARCH} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_SDF} 42 | ${USD_TF} 43 | ${USD_USDGEOM} 44 | ${USD_USD} 45 | ) 46 | -------------------------------------------------------------------------------- /features/notice_send/cpp/notice_send_custom/README.md: -------------------------------------------------------------------------------- 1 | TODO 2 | This project doesn't compile. I don't have time to fix it but may come back to fix it, layer 3 | -------------------------------------------------------------------------------- /features/notice_send/cpp/notice_send_custom/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/notice_send/cpp/notice_send_global/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(notice_send_global) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_ARCH arch HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_ARCH} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_SDF} 42 | ${USD_TF} 43 | ${USD_USDGEOM} 44 | ${USD_USD} 45 | ) 46 | -------------------------------------------------------------------------------- /features/notice_send/cpp/notice_send_global/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/notice_send/cpp/notice_send_global/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT THIRD-PARTY LIBRARIES 2 | #include "pxr/base/tf/notice.h" 3 | 4 | 5 | class MainListener : public pxr::TfWeakBase { 6 | public: 7 | MainListener() { 8 | // Register for invokation in any thread 9 | pxr::TfWeakPtr me(this); 10 | pxr::TfNotice::Register(me, &MainListener::some_function); 11 | } 12 | 13 | void some_function(pxr::TfNotice const ¬ice) { 14 | // XXX : If you're working in a threaded 15 | // environment, you need to lock this method. See 16 | // "USD/pxr/base/lib/tf/testenv/notice.cpp" for details. 17 | // 18 | std::cout << "Handle notice\n"; 19 | } 20 | }; 21 | 22 | 23 | int main() { 24 | { 25 | MainListener listener; 26 | pxr::TfNotice().Send(); // This will print the contents in `handle_notice` 27 | } 28 | // XXX : Instead of putting `listener` in a scope, you can also run 29 | // `listener.Revoke()` 30 | 31 | pxr::TfNotice().Send(); // This won't print anything 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /features/notice_send/python/notice_send_global.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """A module that shows how to register to Tf.Notice for any kind of object.""" 5 | 6 | # IMPORT THIRD-PARTY LIBRARIES 7 | from pxr import Tf 8 | 9 | 10 | 11 | def main(): 12 | """Run the main execution of the current script.""" 13 | def handle_notice(notice, sender): 14 | print("Handling notice") 15 | 16 | listener = Tf.Notice.RegisterGlobally("TfNotice", handle_notice) 17 | Tf.Notice().SendGlobally() # This will print the contents in `handle_notice` 18 | del listener # You can also run `listener.Revoke()` 19 | Tf.Notice().SendGlobally() # This won't print anything 20 | 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /features/notices/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(notices) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_ARCH arch HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 23 | 24 | find_package(PythonLibs REQUIRED) 25 | 26 | # 4. Include/Link Everything 27 | add_executable(run_it 28 | main.cpp 29 | ) 30 | 31 | target_include_directories(run_it 32 | PUBLIC 33 | ${PYTHON_INCLUDE_PATH} 34 | ${USD_INCLUDE_DIRECTORY} 35 | ) 36 | 37 | target_link_libraries( 38 | run_it 39 | ${PYTHON_LIBRARY} 40 | ${USD_ARCH} 41 | ${USD_BOOST_PYTHON} 42 | ${USD_SDF} 43 | ${USD_TF} 44 | ${USD_USDGEOM} 45 | ${USD_USD} 46 | ${USD_VT} 47 | ) 48 | -------------------------------------------------------------------------------- /features/notices/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/profiling_usd.md: -------------------------------------------------------------------------------- 1 | This section will hopfully get expanded upon in the future. But 2 | basically, USD doesn't have a lot of facilities to do profiling right 3 | now. 4 | 5 | The best you've got is 6 | [UsdUtilsComputeUsdStageStats](https://graphics.pixar.com/usd/docs/api/introspection_8h.html#a06bc3306d91684cc70b2b6e3768ca3f7). 7 | 8 | Apparently there's also a memory footprint tagging system but I couldn't 9 | get it to work and apparently it's not working currently. 10 | [Source here](https://groups.google.com/forum/#!searchin/usd-interest/malloc|sort:date/usd-interest/MvOBc3QHFY0/SSnRDrAxDAAJ) 11 | 12 | There's a brief section on [enable debugging C++ project](../concepts/enable_debugging/cpp/main.cpp) 13 | but again, it's pretty bare-minimum. 14 | -------------------------------------------------------------------------------- /features/purposes/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | ### C++ 3 | ```cpp 4 | purpose = pxr::UsdGeomImageable(prim).CreatePurposeAttr(); 5 | purpose.Set(pxr::UsdGeomTokens->proxy); 6 | purpose.Set(pxr::UsdGeomTokens->default_); 7 | purpose.Set(pxr::UsdGeomTokens->render); 8 | purpose.Set(pxr::UsdGeomTokens->guide); 9 | ``` 10 | 11 | 12 | ### Python 13 | ```python 14 | purpose = UsdGeom.Imageable(prim).CreatePurposeAttr() 15 | purpose.Set(UsdGeom.Tokens.default_) 16 | purpose.Set(UsdGeom.Tokens.guide) 17 | purpose.Set(UsdGeom.Tokens.proxy) 18 | purpose.Set(UsdGeom.Tokens.render) 19 | ``` 20 | 21 | 22 | ### USD 23 | ```usda 24 | #usda 1.0 25 | 26 | def Xform "Xform" 27 | { 28 | def Cube "SomeGuide" 29 | { 30 | uniform token purpose = "guide" 31 | } 32 | 33 | def Sphere "SomeRender" 34 | { 35 | uniform token purpose = "render" 36 | } 37 | 38 | def Cone "SomeProxy" 39 | { 40 | uniform token purpose = "proxy" 41 | } 42 | 43 | def Cylinder "SomeDefault" 44 | { 45 | uniform token purpose = "default" 46 | } 47 | } 48 | ``` 49 | 50 | 51 | # See Also 52 | https://graphics.pixar.com/usd/docs/USD-Glossary.html#USDGlossary-Purpose 53 | -------------------------------------------------------------------------------- /features/purposes/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(purposes) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USD} 43 | ${USD_USDGEOM} 44 | ${USD_VT} 45 | ) 46 | -------------------------------------------------------------------------------- /features/purposes/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/purposes/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT STANDARD LIBRARIES 2 | #include 3 | 4 | // IMPORT THIRD-PARTY LIBRARIES 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | int main() { 15 | auto stage = pxr::UsdStage::CreateInMemory(); 16 | auto xform = pxr::UsdGeomXform::Define(stage, pxr::SdfPath("/Xform")); 17 | 18 | auto cube = pxr::UsdGeomCube::Define(stage, pxr::SdfPath("/Xform/SomeGuide")); 19 | auto purpose = cube.CreatePurposeAttr(); 20 | purpose.Set(pxr::UsdGeomTokens->guide); 21 | 22 | auto sphere = pxr::UsdGeomSphere::Define(stage, pxr::SdfPath("/Xform/SomeRender")); 23 | purpose = sphere.CreatePurposeAttr(); 24 | purpose.Set(pxr::UsdGeomTokens->render); 25 | 26 | auto cone = pxr::UsdGeomCone::Define(stage, pxr::SdfPath("/Xform/SomeProxy")); 27 | purpose = cone.CreatePurposeAttr(); 28 | purpose.Set(pxr::UsdGeomTokens->proxy); 29 | 30 | auto cylinder = pxr::UsdGeomCylinder::Define(stage, pxr::SdfPath("/Xform/SomeDefault")); 31 | purpose = cylinder.CreatePurposeAttr(); 32 | purpose.Set(pxr::UsdGeomTokens->default_); 33 | 34 | auto* result = new std::string(); 35 | stage->GetRootLayer()->ExportToString(result); 36 | std::cout << *result << std::endl; 37 | delete result; 38 | result = nullptr; 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /features/purposes/python/purpose.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Create a series of Prims with different "purpose" Properties defined.""" 5 | 6 | # IMPORT THIRD-PARTY LIBRARIES 7 | from pxr import Usd, UsdGeom 8 | 9 | 10 | def main(): 11 | """Run the main execution of the current script.""" 12 | stage = Usd.Stage.CreateInMemory() 13 | xform = UsdGeom.Xform.Define(stage, "/Xform") 14 | 15 | cube = UsdGeom.Cube.Define(stage, "/Xform/SomeGuide") 16 | purpose = cube.CreatePurposeAttr() 17 | purpose.Set(UsdGeom.Tokens.guide) 18 | 19 | sphere = UsdGeom.Sphere.Define(stage, "/Xform/SomeRender") 20 | purpose = sphere.CreatePurposeAttr() 21 | purpose.Set(UsdGeom.Tokens.render) 22 | 23 | cone = UsdGeom.Cone.Define(stage, "/Xform/SomeProxy") 24 | purpose = cone.CreatePurposeAttr() 25 | purpose.Set(UsdGeom.Tokens.proxy) 26 | 27 | cylinder = UsdGeom.Cylinder.Define(stage, "/Xform/SomeDefault") 28 | purpose = cylinder.CreatePurposeAttr() 29 | purpose.Set(UsdGeom.Tokens.default_) 30 | 31 | print(stage.GetRootLayer().ExportToString()) 32 | 33 | 34 | if __name__ == "__main__": 35 | main() 36 | -------------------------------------------------------------------------------- /features/purposes/usda/purpose.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Xform "Xform" 4 | { 5 | def Cube "SomeGuide" 6 | { 7 | uniform token purpose = "guide" 8 | } 9 | 10 | def Sphere "SomeRender" 11 | { 12 | uniform token purpose = "render" 13 | } 14 | 15 | def Cone "SomeProxy" 16 | { 17 | uniform token purpose = "proxy" 18 | } 19 | 20 | def Cylinder "SomeDefault" 21 | { 22 | uniform token purpose = "default" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /features/sdf_change_block/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | 3 | USD's Change Processing sends notifications whenever changes are made. 4 | However, you can make significantly speed up your Sdf calls if you 5 | batch the changes into a single operation, which you can do using 6 | `SdfChangeBlock`. 7 | 8 | Because `SdfChangeBlock` is easy to use poorly, check out the 9 | documentation listed in [See Also](#See-Also) before using it in your own 10 | tools. 11 | 12 | 13 | ### C++ 14 | 15 | ```cpp 16 | #include 17 | 18 | // ... 19 | 20 | { 21 | pxr::SdfChangeBlock batcher; 22 | // ... do some Sdf API code, here 23 | } 24 | ``` 25 | 26 | 27 | ### Python 28 | 29 | ```python 30 | from pxr import Sdf 31 | 32 | # ... 33 | 34 | with Sdf.ChangeBlock(): 35 | # ... do some Sdf API code, here 36 | ``` 37 | 38 | 39 | # See Also 40 | https://graphics.pixar.com/usd/docs/api/class_sdf_change_block.html 41 | 42 | https://groups.google.com/d/msg/usd-interest/Bh6_sxij-f8/rnGtLK3tAQAJ 43 | -------------------------------------------------------------------------------- /features/sdf_change_block/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(sdf_change_block) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_ARCH arch HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_ARCH} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_SDF} 42 | ${USD_TF} 43 | ${USD_USDGEOM} 44 | ${USD_USD} 45 | ) 46 | -------------------------------------------------------------------------------- /features/sdf_change_block/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/sdf_change_block/python/sdf_change_block.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Batch-creating PrimSpecs, using SdfChangeBlock.""" 5 | 6 | # IMPORT THIRD-PARTY LIBRARIES 7 | from pxr import Sdf, UsdGeom 8 | 9 | 10 | def main(): 11 | """Run the main execution of the current script.""" 12 | layer = Sdf.Layer.CreateAnonymous() 13 | 14 | paths = { 15 | Sdf.Path("/AndMore"), 16 | Sdf.Path("/AnotherOne"), 17 | Sdf.Path("/AnotherOne/AndAnother"), 18 | Sdf.Path("/More"), 19 | Sdf.Path("/OkayNoMore"), 20 | Sdf.Path("/SomeSphere"), 21 | Sdf.Path("/SomeSphere/InnerPrim"), 22 | Sdf.Path("/SomeSphere/InnerPrim/LastOne"), 23 | } 24 | 25 | prefixes = set(prefix for path in paths for prefix in path.GetPrefixes()) 26 | with Sdf.ChangeBlock(): 27 | for path in prefixes: 28 | prim_spec = Sdf.CreatePrimInLayer(layer, path) 29 | prim_spec.specifier = Sdf.SpecifierDef 30 | prim_spec.typeName = UsdGeom.Xform.__name__ 31 | 32 | print(layer.ExportToString()) 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /features/set_kind/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(set_kind) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_KIND kind HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 23 | 24 | find_package(PythonLibs REQUIRED) 25 | 26 | # 4. Include/Link Everything 27 | add_executable(run_it 28 | main.cpp 29 | ) 30 | 31 | target_include_directories(run_it 32 | PUBLIC 33 | ${PYTHON_INCLUDE_PATH} 34 | ${USD_INCLUDE_DIRECTORY} 35 | ) 36 | 37 | target_link_libraries( 38 | run_it 39 | ${PYTHON_LIBRARY} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_KIND} 42 | ${USD_SDF} 43 | ${USD_TF} 44 | ${USD_USDGEOM} 45 | ${USD_USD} 46 | ${USD_VT} 47 | ) 48 | -------------------------------------------------------------------------------- /features/set_kind/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/set_kind/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT STANDARD LIBRARIES 2 | #include 3 | #include 4 | 5 | // IMPORT THIRD-PARTY LIBRARIES 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | int main() { 14 | auto stage = pxr::UsdStage::CreateInMemory(); 15 | stage->GetRootLayer()->SetDocumentation("This is an example of setting a Model Prim kind"); 16 | 17 | auto sphere1 = pxr::UsdGeomSphere::Define(stage, pxr::SdfPath("/SomeSphere")); 18 | pxr::UsdModelAPI(sphere1).SetKind(pxr::KindTokens->component); 19 | auto sphere2 = pxr::UsdGeomSphere::Define(stage, pxr::SdfPath("/SomeSphere/SphereChild")); 20 | pxr::UsdModelAPI(sphere2).SetKind(pxr::KindTokens->subcomponent); 21 | auto sphere3 = pxr::UsdGeomSphere::Define(stage, pxr::SdfPath("/SomeSphere/Foo")); 22 | pxr::UsdModelAPI(sphere3).SetKind(pxr::TfToken("does_not_exist")); 23 | sphere3.GetPrim().SetMetadata( 24 | pxr::SdfFieldKeys->Comment, 25 | "XXX: This kind is made up. But it could be real if we added to the KindRegistry\nhttps://graphics.pixar.com/usd/docs/api/class_kind_registry.html" 26 | ); 27 | 28 | auto* result = new std::string(); 29 | stage->GetRootLayer()->ExportToString(result); 30 | std::cout << *result << std::endl; 31 | delete result; 32 | result = nullptr; 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /features/set_kind/python/kind.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # IMPORT THIRD-PARTY LIBRARIES 5 | from pxr import Gf, Kind, Usd, UsdGeom 6 | 7 | 8 | def main(): 9 | """Run the main execution of the current script.""" 10 | stage = Usd.Stage.CreateInMemory() 11 | stage.GetRootLayer().documentation = ( 12 | "This is an example of setting a Model Prim kind" 13 | ) 14 | 15 | sphere1 = UsdGeom.Sphere.Define(stage, "/SomeSphere") 16 | Usd.ModelAPI(sphere1).SetKind(Kind.Tokens.component) 17 | sphere2 = UsdGeom.Sphere.Define(stage, "/SomeSphere/SphereChild") 18 | Usd.ModelAPI(sphere2).SetKind(Kind.Tokens.subcomponent) 19 | sphere3 = UsdGeom.Sphere.Define(stage, "/SomeSphere/Foo") 20 | Usd.ModelAPI(sphere3).SetKind("does_not_exist") 21 | sphere3.GetPrim().SetMetadata( 22 | "comment", 23 | "XXX: This kind is made up. But it could be real if we added to the KindRegistry\n" 24 | "https://graphics.pixar.com/usd/docs/api/class_kind_registry.html", 25 | ) 26 | 27 | print(stage.GetRootLayer().ExportToString()) 28 | 29 | 30 | if __name__ == "__main__": 31 | main() 32 | -------------------------------------------------------------------------------- /features/set_kind/usda/base.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = "This is an example of setting a Model Prim kind" 4 | ) 5 | 6 | def Sphere "MySphere" ( 7 | kind = "component" 8 | ) { 9 | def Sphere "SphereChild" ( 10 | kind = "subcomponent" 11 | ) 12 | { 13 | } 14 | 15 | def Sphere "Foo" ( 16 | "XXX: This kind is made up. But it could be real if we added to the KindRegistry" 17 | "https://graphics.pixar.com/usd/docs/api/class_kind_registry.html" 18 | kind = "does_not_exist" 19 | ) 20 | { 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /features/specializes/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | ### C++ 3 | ```cpp 4 | auto sphere = pxr::UsdGeomSphere::Define(stage, pxr::SdfPath {"/thing/SomethingElse/NestedEvenMore"}); 5 | auto prim = stage->DefinePrim(pxr::SdfPath("/thing/SomethingElse/SpecializedChild")); 6 | prim.GetSpecializes().AddSpecialize(sphere.GetPath()); 7 | ``` 8 | 9 | 10 | ### Python 11 | ```python 12 | sphere = UsdGeom.Sphere.Define(stage, "/thing/SomethingElse/NestedEvenMore") 13 | prim = stage.DefinePrim("/thing/SomethingElse/SpecializedChild") 14 | prim.GetSpecializes().AddSpecialize(sphere.GetPath()) 15 | ``` 16 | 17 | 18 | ### USD 19 | ```usda 20 | #usda 1.0 21 | 22 | def "thing" 23 | { 24 | def "SomethingElse" 25 | { 26 | def Sphere "NestedEvenMore" 27 | { 28 | } 29 | 30 | def "SpecializedChild" ( 31 | prepend specializes = 32 | ) 33 | { 34 | } 35 | } 36 | } 37 | ``` 38 | 39 | 40 | # See Also 41 | https://graphics.pixar.com/usd/docs/USD-Glossary.html#USDGlossary-Specializes 42 | -------------------------------------------------------------------------------- /features/specializes/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(specializes) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USDGEOM} 43 | ${USD_USD} 44 | ${USD_VT} 45 | ) 46 | -------------------------------------------------------------------------------- /features/specializes/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/specializes/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT THIRD-PARTY LIBRARIES 2 | #include 3 | #include 4 | #include 5 | 6 | 7 | int main() { 8 | auto stage = pxr::UsdStage::CreateInMemory(); 9 | 10 | auto sphere = pxr::UsdGeomSphere::Define(stage, pxr::SdfPath {"/thing/SomethingElse/NestedEvenMore"}); 11 | sphere.GetRadiusAttr().Set(4.0); 12 | 13 | auto prim = stage->DefinePrim(pxr::SdfPath("/thing/SomethingElse/SpecializedChild")); 14 | prim.GetSpecializes().AddSpecialize(sphere.GetPath()); 15 | 16 | auto* result = new std::string(); 17 | stage->GetRootLayer()->ExportToString(result); 18 | std::cout << *result << std::endl; 19 | delete result; 20 | result = nullptr; 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /features/specializes/python/specializes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # IMPORT THIRD-PARTY LIBRARIES 5 | from pxr import Usd, UsdGeom 6 | 7 | 8 | def main(): 9 | """Run the main execution of the current script.""" 10 | stage = Usd.Stage.CreateInMemory() 11 | # from inspection import dirgrep; dirgrep(stage, 'prim', sort=True) 12 | sphere = UsdGeom.Sphere.Define(stage, "/thing/SomethingElse/NestedEvenMore") 13 | sphere.GetRadiusAttr().Set(4) 14 | 15 | prim = stage.DefinePrim("/thing/SomethingElse/SpecializedChild") 16 | prim.GetSpecializes().AddSpecialize(sphere.GetPath()) 17 | 18 | print(stage.GetRootLayer().ExportToString()) 19 | 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /features/specializes/usda/specializes.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "thing" 4 | { 5 | def "SomethingElse" 6 | { 7 | def Sphere "NestedEvenMore" 8 | { 9 | } 10 | 11 | def "SpecializedChild" ( 12 | prepend specializes = 13 | ) 14 | { 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /features/specializes_glossary_example/README.md: -------------------------------------------------------------------------------- 1 | ## Quick Summary 2 | 3 | This section summarizes an example of the `specializes` Composition Arc. 4 | The code is taken straight from the USD Glossary. I made this section 5 | mainly as a reminder to myself that `specializes` is only particularly 6 | interesting once it has been included in another Layer (what the USD 7 | Glossary calls "it's referencing context"). 8 | 9 | 10 | ## See Also 11 | https://graphics.pixar.com/usd/docs/USD-Glossary.html?fbclid=IwAR2sqJgyq7xxDK8NGc2J-clSw5rLH3hi1zpFvHxIxnZBLmHcivIXWqewlHU#USDGlossary-Specializes 12 | -------------------------------------------------------------------------------- /features/specializes_glossary_example/base.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Xform "Robot" 4 | { 5 | def Scope "Materials" 6 | { 7 | def Material "Metal" 8 | { 9 | # Interface inputs drive shader parameters of the encapsulated network. 10 | # We are not showing the connections, nor how we encode that the 11 | # child Shader "Surface" is the primary output for the material. 12 | float inputs:diffuseGain = 0 13 | float inputs:specularRoughness = 0 14 | 15 | def Shader "Surface" 16 | { 17 | asset info:id = @PxrSurface@ 18 | double foo = 2.0 19 | } 20 | } 21 | 22 | def Material "CorrodedMetal" ( 23 | specializes = [] 24 | ) 25 | { 26 | # specialize roughness... 27 | float inputs:specularRoughness = 0.2 28 | 29 | # Adding a pattern to drive Surface bump 30 | def Shader "Corrosion" 31 | { 32 | asset info:id = @PxrOSL@ 33 | vector3f outputs:disp 34 | } 35 | 36 | over "Surface" 37 | { 38 | # Override that would connect specularBump to Corrosion pattern's "outputs:disp" attribute 39 | double foo = 3.0 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /features/specializes_glossary_example/override.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Xform "World" 4 | { 5 | def Xform "Characters" 6 | { 7 | def "Rosie" ( 8 | references = @./base.usda@ 9 | ) 10 | { 11 | over "Materials" 12 | { 13 | over "Metal" 14 | { 15 | float inputs:diffuseGain = 0.3 16 | float inputs:specularRoughness = 0.1 ( 17 | "This value will be applied to the \"Metal\" Prim but won't be applied to the \"CorrodedMetal\" Prim." 18 | ) 19 | } 20 | } 21 | } 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /features/time_varying_attributes_sdf/README.md: -------------------------------------------------------------------------------- 1 | ## Quick Explanation 2 | In USD's Sdf API, you can set time sample values. But the function call 3 | isn't very obvious. Normally if you were setting time-codes / values 4 | on an Attribute, you'd expect to be able to do that from the Attribute 5 | itself. But in Sdf API, you set the time-code / value pair not from the 6 | SdfAttributeSpec / UsdAttribute but from its parent SdfLayer. 7 | 8 | ### C++ 9 | ```cpp 10 | layer->SetTimeSample( 11 | attribute->GetPath(), 12 | 10.5 /* time code */, 13 | 9, /* value */ 14 | ); 15 | ``` 16 | 17 | 18 | ### Python 19 | ```python 20 | layer = stage.GetEditTarget().GetLayer() # By default, this is `stage.GetRootLayer` 21 | time_code = 10.5 22 | value = 9 # An arbitrary value 23 | layer.SetTimeSample(attribute.GetPath(), time_code, value) 24 | ``` 25 | 26 | 27 | ## See Also 28 | [SetTimeSample](https://graphics.pixar.com/usd/docs/api/class_sdf_layer.html) 29 | -------------------------------------------------------------------------------- /features/time_varying_attributes_sdf/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(time_varying_attributes_sdf) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | 11 | # 3. Boilerplate 12 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 13 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 14 | 15 | find_library(USD_ARCH arch HINTS ${USD_LIBRARY_DIRECTORY}) 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_VT usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | 22 | find_package(PythonLibs REQUIRED) 23 | 24 | # 4. Include/Link Everything 25 | add_executable(run_it 26 | main.cpp 27 | ) 28 | 29 | target_include_directories(run_it 30 | PUBLIC 31 | ${PYTHON_INCLUDE_PATH} 32 | ${USD_INCLUDE_DIRECTORY} 33 | ) 34 | 35 | target_link_libraries( 36 | run_it 37 | ${PYTHON_LIBRARY} 38 | ${USD_ARCH} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USD} 43 | ${USD_VT} 44 | ) 45 | -------------------------------------------------------------------------------- /features/time_varying_attributes_sdf/python/keyframe.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from pxr import Sdf, Usd 5 | 6 | 7 | def as_sdf(): 8 | """Run the main execution of the current script.""" 9 | layer = Sdf.Layer.CreateAnonymous() 10 | prim_spec = Sdf.CreatePrimInLayer(layer, "/root") 11 | prim_spec.specifier = Sdf.SpecifierDef 12 | attribute_spec = Sdf.AttributeSpec(prim_spec, "some_name", Sdf.ValueTypeNames.Int) 13 | attribute_spec.custom = True 14 | attribute_spec.default = 8 15 | 16 | layer.SetTimeSample(attribute_spec.path, 10.5, 9) 17 | 18 | print(layer.ExportToString()) 19 | 20 | 21 | def as_usd(): 22 | stage = Usd.Stage.CreateInMemory() 23 | prim = stage.DefinePrim("/root") 24 | attribute = prim.CreateAttribute("some_name", Sdf.ValueTypeNames.Int) 25 | attribute.Set(8) 26 | 27 | layer = stage.GetEditTarget().GetLayer() # By default, this is `stage.GetRootLayer` 28 | layer.SetTimeSample(attribute.GetPath(), 10.5, 9) 29 | 30 | print(layer.ExportToString()) 31 | 32 | 33 | if __name__ == "__main__": 34 | as_sdf() 35 | as_usd() 36 | -------------------------------------------------------------------------------- /features/usd_resolve_info/README.md: -------------------------------------------------------------------------------- 1 | ## Quick Explanation 2 | 3 | UsdResolveInfo is meant to inspect where an opinion 4 | comes from. It's mainly used in usdview to display 5 | information about properties to the user, covered on the 6 | [usdview_style_documentation](../../references/usdview_style_documentation) 7 | page. 8 | 9 | 10 | ## C++ 11 | 12 | ```cpp 13 | stage->GetPrimAtPath(pxr::SdfPath{"/Foo"}).GetAttribute(pxr::TfToken{"bar"}).GetResolveInfo().GetSource() 14 | ``` 15 | 16 | 17 | ## Python 18 | 19 | ```python 20 | stage.GetPrimAtPath("/Foo").GetAttribute("bar").GetResolveInfo().GetSource() 21 | ``` 22 | 23 | 24 | ## Reference 25 | 26 | [UsdResolveInfo](https://graphics.pixar.com/usd/docs/api/class_usd_resolve_info.html) 27 | -------------------------------------------------------------------------------- /features/usd_resolve_info/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(usd_resolve_info) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_package(PythonLibs REQUIRED) 21 | 22 | # 4. Include/Link Everything 23 | add_executable(run_it 24 | main.cpp 25 | ) 26 | 27 | target_include_directories(run_it 28 | PUBLIC 29 | ${PYTHON_INCLUDE_PATH} 30 | ${USD_INCLUDE_DIRECTORY} 31 | ) 32 | 33 | target_link_libraries( 34 | run_it 35 | ${PYTHON_LIBRARY} 36 | ${USD_BOOST_PYTHON} 37 | ${USD_SDF} 38 | ${USD_TF} 39 | ${USD_USD} 40 | ) 41 | -------------------------------------------------------------------------------- /features/usd_resolve_info/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/usd_resolve_info/cpp/clip_1.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double value_clipped_property.timeSamples = { 6 | 0: 12, 7 | 1: 15, 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /features/usd_resolve_info/cpp/clip_2.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double value_clipped_property = 10.0 6 | } 7 | -------------------------------------------------------------------------------- /features/usd_resolve_info/cpp/clip_manifest.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double value_clipped_property 6 | } 7 | -------------------------------------------------------------------------------- /features/usd_resolve_info/cpp/ref.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Ref" ( 4 | kind = "model" 5 | ) 6 | { 7 | double value_clipped_property = 20.0 8 | } 9 | -------------------------------------------------------------------------------- /features/usd_resolve_info/cpp/usd_resolve_info.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Xform "SomePrim" 4 | { 5 | double default_property = 1 6 | double time_samples_property = 20 7 | double time_samples_property.timeSamples = { 8 | 1: 10, 9 | } 10 | double time_dependent_property.timeSamples = { 11 | 1: 10, 12 | 2: 20, 13 | } 14 | } 15 | 16 | def Sphere "SomeSphere" 17 | { 18 | } 19 | 20 | 21 | def "PrimWithValueClips" ( 22 | clips = { 23 | dictionary default = { 24 | double2[] active = [(0, 0), (2, 1)] 25 | asset[] assetPaths = [@./clip_1.usda@, @./clip_2.usda@] 26 | string primPath = "/Clip" 27 | double2[] times = [(0, 0), (1, 0)] 28 | asset manifestAssetPath = @./clip_manifest.usda@ 29 | } 30 | } 31 | references = @./ref.usda@ 32 | ) 33 | { 34 | } 35 | 36 | -------------------------------------------------------------------------------- /features/usd_resolve_info/python/clip_1.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double value_clipped_property.timeSamples = { 6 | 0: 12, 7 | 1: 15, 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /features/usd_resolve_info/python/clip_2.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double value_clipped_property = 10.0 6 | } 7 | -------------------------------------------------------------------------------- /features/usd_resolve_info/python/clip_manifest.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double value_clipped_property 6 | } 7 | -------------------------------------------------------------------------------- /features/usd_resolve_info/python/ref.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Ref" ( 4 | kind = "model" 5 | ) 6 | { 7 | double value_clipped_property = 20.0 8 | } 9 | -------------------------------------------------------------------------------- /features/usd_resolve_info/python/usd_resolve_info.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Xform "SomePrim" 4 | { 5 | double default_property = 1 6 | double time_samples_property = 20 7 | double time_samples_property.timeSamples = { 8 | 1: 10, 9 | } 10 | double time_dependent_property.timeSamples = { 11 | 1: 10, 12 | 2: 20, 13 | } 14 | } 15 | 16 | def Sphere "SomeSphere" 17 | { 18 | } 19 | 20 | 21 | def "PrimWithValueClips" ( 22 | clips = { 23 | dictionary default = { 24 | double2[] active = [(0, 0), (2, 1)] 25 | asset[] assetPaths = [@./clip_1.usda@, @./clip_2.usda@] 26 | string primPath = "/Clip" 27 | double2[] times = [(0, 0), (1, 0)] 28 | asset manifestAssetPath = @./clip_manifest.usda@ 29 | } 30 | } 31 | references = @./ref.usda@ 32 | ) 33 | { 34 | } 35 | 36 | -------------------------------------------------------------------------------- /features/userProperties/README.md: -------------------------------------------------------------------------------- 1 | # Quick Explanation 2 | ## Create a userProperty 3 | ### C++ 4 | 5 | ```cpp 6 | auto attribute = sphere.GetPrim().CreateAttribute( 7 | pxr::TfToken {"userProperties:some_attribute"}, 8 | pxr::SdfValueTypeNames->Bool, 9 | true 10 | ); 11 | attribute.Set(false); 12 | ``` 13 | 14 | 15 | ### Python 16 | 17 | ```python 18 | attribute = sphere.GetPrim().CreateAttribute( 19 | "userProperties:some_attribute", Sdf.ValueTypeNames.Bool, True 20 | ) 21 | attribute.Set(False) 22 | ``` 23 | 24 | 25 | ## Find all userProperties 26 | ### C++ 27 | 28 | ```cpp 29 | auto is_user_property = [&](std::string const &path) { 30 | static std::string const properties = "userProperties"; 31 | 32 | // If `path` starts with "userProperties" then it's a user property 33 | return strncmp(path.c_str(), properties.c_str(), strlen(properties.c_str())) == 0; 34 | }; 35 | 36 | for (auto const &property : sphere.GetPrim().GetAuthoredProperties(is_user_property)) { 37 | std::cout << property.GetName() << " "; 38 | } 39 | std::cout << '\n'; 40 | ``` 41 | 42 | 43 | ### Python 44 | 45 | ```python 46 | def is_user_property(node): 47 | return node.startswith("userProperties:") 48 | 49 | print('user properties', sphere.GetPrim().GetAuthoredProperties(is_user_property)) 50 | ``` 51 | 52 | # See Also 53 | https://graphics.pixar.com/usd/docs/Maya-USD-Plugins.html 54 | -------------------------------------------------------------------------------- /features/userProperties/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(userProperties) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USDGEOM} 43 | ${USD_USD} 44 | ${USD_VT} 45 | ) 46 | -------------------------------------------------------------------------------- /features/userProperties/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/userProperties/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT STANDARD LIBRARIES 2 | #include 3 | #include 4 | #include 5 | 6 | // IMPORT THIRD-PARTY LIBRARIES 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | int main() { 13 | auto is_user_property = [&](std::string const &path) { 14 | static std::string const properties = "userProperties"; 15 | 16 | // If `path` starts with "userProperties" then it's a user property 17 | return strncmp(path.c_str(), properties.c_str(), strlen(properties.c_str())) == 0; 18 | }; 19 | 20 | auto stage = pxr::UsdStage::CreateInMemory(); 21 | auto sphere = pxr::UsdGeomSphere::Define(stage, pxr::SdfPath {"/SomeSphere"}); 22 | auto attribute = sphere.GetPrim().CreateAttribute( 23 | pxr::TfToken {"userProperties:some_attribute"}, 24 | pxr::SdfValueTypeNames->Bool, 25 | true 26 | ); 27 | attribute.Set(false); 28 | 29 | auto some_attribute_that_will_not_be_printed = sphere.GetPrim().CreateAttribute( 30 | pxr::TfToken {"another"}, 31 | pxr::SdfValueTypeNames->Bool, 32 | true 33 | ); 34 | 35 | for (auto const &property : sphere.GetPrim().GetAuthoredProperties(is_user_property)) { 36 | std::cout << property.GetName() << " "; 37 | } 38 | std::cout << '\n'; 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /features/userProperties/python/user.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """An example of how to set a custom Property, using userProperties.""" 5 | 6 | # IMPORT FUTURE LIBRARIES 7 | from __future__ import print_function 8 | 9 | # IMPORT THIRD-PARTY LIBRARIES 10 | from pxr import Sdf, Usd, UsdGeom 11 | 12 | 13 | def main(): 14 | """Run the main execution of the current script.""" 15 | def is_user_property(node): 16 | return node.startswith("userProperties:") 17 | 18 | stage = Usd.Stage.CreateInMemory() 19 | sphere = UsdGeom.Sphere.Define(stage, "/SomeSphere") 20 | attribute = sphere.GetPrim().CreateAttribute( 21 | "userProperties:some_attribute", Sdf.ValueTypeNames.Bool, True 22 | ) 23 | attribute.Set(False) 24 | some_attribute_that_will_not_be_printed = sphere.GetPrim().CreateAttribute( 25 | "another", Sdf.ValueTypeNames.Bool, True 26 | ) 27 | 28 | print('user properties', sphere.GetPrim().GetAuthoredProperties(is_user_property)) 29 | 30 | 31 | if __name__ == "__main__": 32 | main() 33 | -------------------------------------------------------------------------------- /features/value_caching/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(value_caching) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | find_package(PythonLibs REQUIRED) 23 | 24 | # 4. Include/Link Everything 25 | add_executable(run_it 26 | main.cpp 27 | ) 28 | 29 | target_include_directories(run_it 30 | PUBLIC 31 | ${PYTHON_INCLUDE_PATH} 32 | ${USD_INCLUDE_DIRECTORY} 33 | ) 34 | 35 | target_link_libraries( 36 | run_it 37 | ${PYTHON_LIBRARY} 38 | ${USD_BOOST_PYTHON} 39 | ${USD_SDF} 40 | ${USD_TF} 41 | ${USD_USD} 42 | ${USD_USDGEOM} 43 | ${USD_VT} 44 | ) 45 | -------------------------------------------------------------------------------- /features/value_caching/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/value_caching/cpp/forwarder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // IMPORT STANDARD LIBRARIES 4 | #include 5 | 6 | // IMPORT THIRD-PARTY LIBRARIES 7 | #include 8 | #include 9 | 10 | 11 | namespace forwarder { 12 | void forward(pxr::UsdAttribute const &attribute) { 13 | double value; 14 | attribute.Get(&value); 15 | } 16 | 17 | void forward_time_samples(pxr::UsdAttribute const &attribute) { 18 | std::vector times; 19 | attribute.GetTimeSamples(×); 20 | } 21 | 22 | void forward_query(pxr::UsdAttributeQuery const &attribute) { 23 | double value; 24 | attribute.Get(&value); 25 | } 26 | 27 | void forward_unioned_time_samples(std::vector queries) { 28 | std::vector times; 29 | pxr::UsdAttributeQuery::GetUnionedTimeSamples(queries, ×); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /features/value_clips/README.md: -------------------------------------------------------------------------------- 1 | # See Also 2 | https://graphics.pixar.com/usd/docs/USD-Glossary.html#USDGlossary-ValueClips 3 | -------------------------------------------------------------------------------- /features/value_clips/cpp/explicit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(explict_value_clips) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USDGEOM} 43 | ${USD_USD} 44 | ${USD_VT} 45 | ) 46 | -------------------------------------------------------------------------------- /features/value_clips/cpp/explicit/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/value_clips/cpp/explicit/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT THIRD-PARTY LIBRARIES 2 | #include 3 | #include 4 | 5 | 6 | int main() { 7 | auto stage = pxr::UsdStage::CreateInMemory(); 8 | stage->SetStartTimeCode(0); 9 | stage->SetEndTimeCode(12); 10 | 11 | auto prim = stage->DefinePrim(pxr::SdfPath("/Prim")); 12 | auto model = pxr::UsdClipsAPI(prim); 13 | model.SetClipActive({{0, 0}, {2, 1}}); 14 | model.SetClipAssetPaths( 15 | {pxr::SdfAssetPath{"./clip_1.usda"}, pxr::SdfAssetPath{"./clip_2.usda"}} 16 | ); 17 | model.SetClipPrimPath("/Clip"); 18 | model.SetClipTimes({{0, 0}, {1, 1}, {2, 0}, {3, 1}}); 19 | model.SetClipManifestAssetPath(pxr::SdfAssetPath{"./clip_manifest.usda"}); 20 | 21 | prim.GetReferences().AddReference( 22 | "./ref.usda", 23 | pxr::SdfPath{"/Ref"} 24 | ); 25 | 26 | auto* result = new std::string(); 27 | stage->GetRootLayer()->ExportToString(result); 28 | std::cout << *result << std::endl; 29 | delete result; 30 | result = nullptr; 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /features/value_clips/cpp/template_and_explicit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(template_and_explict_value_clips) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | find_package(PythonLibs REQUIRED) 23 | 24 | # 4. Include/Link Everything 25 | add_executable(run_it 26 | main.cpp 27 | ) 28 | 29 | target_include_directories(run_it 30 | PUBLIC 31 | ${PYTHON_INCLUDE_PATH} 32 | ${USD_INCLUDE_DIRECTORY} 33 | ) 34 | 35 | target_link_libraries( 36 | run_it 37 | ${PYTHON_LIBRARY} 38 | ${USD_BOOST_PYTHON} 39 | ${USD_SDF} 40 | ${USD_TF} 41 | ${USD_USDGEOM} 42 | ${USD_USD} 43 | ${USD_VT} 44 | ) 45 | -------------------------------------------------------------------------------- /features/value_clips/cpp/template_and_explicit/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/value_clips/python/explicit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Use the Value Clip API's explicit syntax to author Value Clips.""" 5 | 6 | # IMPORT THIRD-PARTY LIBRARIES 7 | from pxr import Sdf, Usd 8 | 9 | 10 | def main(): 11 | """Run the main execution of this module.""" 12 | stage = Usd.Stage.CreateInMemory() 13 | stage.SetStartTimeCode(0) 14 | stage.SetEndTimeCode(12) 15 | 16 | prim = stage.DefinePrim("/Prim") 17 | model = Usd.ClipsAPI(prim) 18 | model.SetClipActive([(0, 0), (2, 1)]) 19 | model.SetClipAssetPaths( 20 | [Sdf.AssetPath("./clip_1.usda"), Sdf.AssetPath("./clip_2.usda")] 21 | ) 22 | model.SetClipPrimPath("/Clip") 23 | model.SetClipTimes([(0, 0), (1, 1), (2, 0), (3, 1)]) 24 | model.SetClipManifestAssetPath("./clip_manifest.usda") 25 | 26 | prim.GetReferences().AddReference(assetPath="./ref.usda", primPath="/Ref") 27 | print(stage.GetRootLayer().ExportToString()) 28 | 29 | 30 | if __name__ == "__main__": 31 | main() 32 | -------------------------------------------------------------------------------- /features/value_clips/python/template_and_explicit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Use the Value Clip API's template syntax to author Value Clips.""" 5 | 6 | # IMPORT THIRD-PARTY LIBRARIES 7 | from pxr import Sdf, Usd 8 | 9 | 10 | def main(): 11 | """Run the main execution of this module.""" 12 | stage = Usd.Stage.CreateInMemory() 13 | stage.SetStartTimeCode(0) 14 | stage.SetEndTimeCode(2) 15 | 16 | prim = stage.DefinePrim("/Set") 17 | non_template_set_name = "non_template_clips" 18 | model = Usd.ClipsAPI(prim) 19 | model.SetClipActive([(0.0, 0)], non_template_set_name) 20 | model.SetClipAssetPaths( 21 | [Sdf.AssetPath("./non_template_clip.usda")], non_template_set_name 22 | ) 23 | model.SetClipPrimPath("/NonTemplate", non_template_set_name) 24 | 25 | template_set_name = "template_clips" 26 | model.SetClipTemplateAssetPath("./template_clip.##.usda", template_set_name) 27 | model.SetClipTemplateEndTime(2, template_set_name) 28 | model.SetClipTemplateStartTime(0, template_set_name) 29 | model.SetClipTemplateStride(1, template_set_name) 30 | model.SetClipPrimPath("/Template", template_set_name) 31 | 32 | prim.GetReferences().AddReference(assetPath="./set.usda", primPath="/Set") 33 | 34 | print(stage.GetRootLayer().ExportToString()) 35 | 36 | 37 | if __name__ == "__main__": 38 | main() 39 | -------------------------------------------------------------------------------- /features/value_clips/usda/explicit/clip_1.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double inManifestAndInClip.timeSamples = { 6 | 0: 0.0, 7 | 1: -1.0, 8 | } 9 | 10 | double notInManifestAndInClip.timeSamples = { 11 | 0: 0.0, 12 | 1: -1.0, 13 | } 14 | 15 | uniform double uniformInManifestAndInClip = 0.0 16 | } -------------------------------------------------------------------------------- /features/value_clips/usda/explicit/clip_2.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double notInManifestAndInClip.timeSamples = { 6 | 0: 0.0, 7 | 1: -10.0, 8 | } 9 | 10 | uniform double uniformInManifestAndInClip = 0.0 11 | } -------------------------------------------------------------------------------- /features/value_clips/usda/explicit/clip_manifest.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double inManifestAndInClip 6 | double inManifestNotInClip 7 | 8 | uniform double uniformInManifestAndInClip 9 | } -------------------------------------------------------------------------------- /features/value_clips/usda/explicit/ref.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Ref" ( 4 | kind = "model" 5 | ) 6 | { 7 | double inManifestAndInClip = 1.0 8 | double inManifestNotInClip = 2.0 9 | double notInManifestAndInClip = 3.0 10 | double notInManifestNotInClip = 4.0 11 | 12 | uniform double uniformInManifestAndInClip = 5.0 13 | } -------------------------------------------------------------------------------- /features/value_clips/usda/explicit/root.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | startTimeCode = 0 4 | endTimeCode = 12 5 | ) 6 | 7 | 8 | def "Prim" ( 9 | clips = { 10 | dictionary default = { 11 | double2[] active = [(0, 0), (2, 1)] 12 | asset[] assetPaths = [@./clip_1.usda@, @./clip_2.usda@] 13 | string primPath = "/Clip" 14 | double2[] times = [(0, 0), (1, 1), (2, 0), (3, 1)] 15 | asset manifestAssetPath = @./clip_manifest.usda@ 16 | } 17 | } 18 | references = @./ref.usda@ 19 | ) 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /features/value_clips/usda/template_and_explicit/README.md: -------------------------------------------------------------------------------- 1 | This section is copied from [USD's testUsdValueClips folder](https://github.com/PixarAnimationStudios/USD/tree/master/pxr/usd/lib/usd/testenv/testUsdValueClips/clipsets) 2 | 3 | If you've read the [explicit folder's README.md](../explicit/README.md) 4 | then this example is an extension of that. 5 | 6 | As mentioned before, there are two styles of Value Clip generation. 7 | Explicit and templates. This folder shows off both at once, in `root.usda`. 8 | 9 | `Set.non_template_clips` is explicit and `Set.template_clips` shows 10 | Value Clip template syntax. The main difference of template syntax is how templates are found. 11 | 12 | Instead of defining which Value Clip files are acive and for which 13 | time-ranges and each clip's filename, there's a strict naming convention 14 | defined by `templateAssetPath` and files are found starting at 15 | `templateStartTime` time (in this case `./template_clip.00.usda`). 16 | `templateStride` is added to `templateStartTime` over and over again to 17 | find new clip files until `templateEndTime` is reached. Easy, right? 18 | -------------------------------------------------------------------------------- /features/value_clips/usda/template_and_explicit/non_template_clip.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "NonTemplate" 4 | { 5 | def "Child_1" 6 | { 7 | float attr.timeSamples = { 8 | 0: -5, 9 | 1: -10, 10 | 2: -15, 11 | } 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /features/value_clips/usda/template_and_explicit/root.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | startTimeCode = 0 4 | endTimeCode = 2 5 | ) 6 | 7 | 8 | def "Set" ( 9 | clips = { 10 | dictionary non_template_clips = { 11 | double2[] active = [(0.0, 0)] 12 | asset[] assetPaths = [@./non_template_clip.usda@] 13 | string primPath = "/NonTemplate" 14 | } 15 | dictionary template_clips = { 16 | string templateAssetPath = "./template_clip.##.usda" 17 | double templateEndTime = 2 18 | double templateStartTime = 0 19 | double templateStride = 1 20 | string primPath = "/Template" 21 | } 22 | } 23 | 24 | references = @./set.usda@ 25 | ) 26 | { 27 | } 28 | -------------------------------------------------------------------------------- /features/value_clips/usda/template_and_explicit/set.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Set" 4 | { 5 | def "Child_1" 6 | { 7 | float attr = 1.0 8 | float attr.timeSamples = { 9 | 0: 0.0, 10 | 1: 10.0, 11 | 2: 20.0, 12 | } 13 | } 14 | 15 | def "Child_2" 16 | { 17 | float attr = 1.0 18 | float attr.timeSamples = { 19 | 0: 0.0, 20 | 1: 10.0, 21 | 2: 20.0, 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /features/value_clips/usda/template_and_explicit/template_clip.00.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Template" 4 | { 5 | def "Child_2" 6 | { 7 | float attr.timeSamples = { 8 | 0: -50, 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /features/value_clips/usda/template_and_explicit/template_clip.01.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Template" 4 | { 5 | def "Child_2" 6 | { 7 | float attr.timeSamples = { 8 | 1: -100, 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /features/value_clips/usda/template_and_explicit/template_clip.02.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Template" 4 | { 5 | def "Child_2" 6 | { 7 | float attr.timeSamples = { 8 | 2: -200, 9 | } 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /features/world_bounding_box/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | ### C++ 3 | ```cpp 4 | auto bounds = pxr::UsdGeomImageable(sphere).ComputeWorldBound( 5 | pxr::UsdTimeCode(1), 6 | pxr::TfToken("default") 7 | ); 8 | std::cout << bounds << std::endl; 9 | 10 | auto cache = pxr::UsdGeomBBoxCache( 11 | pxr::UsdTimeCode().Default(), 12 | pxr::UsdGeomImageable::GetOrderedPurposeTokens() 13 | ); 14 | 15 | std::cout << cache.ComputeWorldBound(sphere.GetPrim()) << std::endl; 16 | ``` 17 | 18 | 19 | ### Python 20 | ```python 21 | # Method #1: Compute at a certain time 22 | print(UsdGeom.Imageable(sphere).ComputeWorldBound( 23 | Usd.TimeCode(1), 24 | purpose1='default', 25 | )) 26 | 27 | # Method #2: Compute using a cache 28 | cache = UsdGeom.BBoxCache(Usd.TimeCode.Default(), ['default', 'render']) 29 | print(cache.ComputeWorldBound(sphere.GetPrim())) 30 | ``` 31 | -------------------------------------------------------------------------------- /features/world_bounding_box/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /features/world_bounding_box/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT THIRD-PARTY LIBRARIES 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | int main() { 10 | auto stage = pxr::UsdStage::CreateInMemory(); 11 | auto sphere = pxr::UsdGeomSphere::Define(stage, pxr::SdfPath("/SomeSphere")); 12 | sphere.AddTranslateOp().Set(pxr::GfVec3d(20, 30, 40)); 13 | 14 | auto bounds = pxr::UsdGeomImageable(sphere).ComputeWorldBound( 15 | pxr::UsdTimeCode(1), 16 | pxr::TfToken("default") 17 | ); 18 | std::cout << bounds << std::endl; 19 | 20 | auto cache = pxr::UsdGeomBBoxCache( 21 | pxr::UsdTimeCode().Default(), 22 | pxr::UsdGeomImageable::GetOrderedPurposeTokens() 23 | ); 24 | 25 | std::cout << cache.ComputeWorldBound(sphere.GetPrim()) << std::endl; 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /features/world_bounding_box/python/bounding_box.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # IMPORT THIRD-PARTY LIBRARIES 5 | from pxr import Gf, Usd, UsdGeom 6 | 7 | 8 | def main(): 9 | """Run the main execution of the current script.""" 10 | stage = Usd.Stage.CreateInMemory() 11 | sphere = UsdGeom.Sphere.Define(stage, "/SomeSphere") 12 | sphere.AddTranslateOp().Set(Gf.Vec3d(20, 30, 40)) 13 | 14 | # Method #1: Compute at a certain time 15 | print( 16 | UsdGeom.Imageable(sphere).ComputeWorldBound(Usd.TimeCode(1), purpose1="default") 17 | ) 18 | 19 | # Method #2: Compute using a cache 20 | cache = UsdGeom.BBoxCache(Usd.TimeCode.Default(), ["default", "render"]) 21 | print(cache.ComputeWorldBound(sphere.GetPrim())) 22 | 23 | 24 | if __name__ == "__main__": 25 | main() 26 | -------------------------------------------------------------------------------- /plugins/custom_resolver/README.md: -------------------------------------------------------------------------------- 1 | This project shows how to create a custom C++ / Python asset resolver, 2 | in USD. 3 | 4 | It's the most basic project you can write and does almost nothing. But 5 | it's a good template to build from. 6 | 7 | 8 | ## To build and run 9 | 1. Follow the build instructions located in the [C++ project folder](./project). 10 | 2. Run this code: 11 | 12 | (This code assumes that USD is already sourced and importable) 13 | 14 | ```python 15 | PXR_PLUGINPATH_NAME=$PWD/project/build/install/resources python run_test/custom_resolver.py 16 | ``` 17 | 18 | If the resolver was built correctly, you should see this output: 19 | 20 | ``` 21 | This should still print an empty string 22 | This should print /bar /bar 23 | ``` 24 | 25 | 26 | ## See Also 27 | https://graphics.pixar.com/usd/docs/api/class_plug_registry.html#plug_plugInfo 28 | 29 | https://github.com/LumaPictures/usd-uri-resolver/tree/master/URIResolver 30 | 31 | https://groups.google.com/d/msg/usd-interest/BEHMJAnR3Wo/nhsbEXnoAQAJ 32 | 33 | https://groups.google.com/d/msg/usd-interest/rTebJeQQXVA/o09edgGaAgAJ 34 | 35 | https://groups.google.com/d/msg/usd-interest/9JrXGGbzBnQ/__u_eV9JBgAJ 36 | 37 | https://groups.google.com/d/msg/usd-interest/9JrXGGbzBnQ/_f3oaqBdAwAJ 38 | 39 | https://groups.google.com/d/msg/usd-interest/eiSim09c7Bg/DPPzUeatAgAJ 40 | -------------------------------------------------------------------------------- /plugins/custom_resolver/project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | project(custom_resolver) 3 | cmake_minimum_required(VERSION 3.1) 4 | 5 | set(CMAKE_CXX_STANDARD 11) 6 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 7 | 8 | # 2.Configuration 9 | list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake") 10 | set(CMAKE_INSTALL_PREFIX "./install" CACHE PATH "..." FORCE) 11 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 12 | 13 | # 3. Boilerplate 14 | find_package(USD REQUIRED) 15 | 16 | add_subdirectory(src) 17 | -------------------------------------------------------------------------------- /plugins/custom_resolver/project/README.md: -------------------------------------------------------------------------------- 1 | ## Summary 2 | This project is a C++ USD resolver plugin. It does nothing but resolve 3 | "/foo" to "/bar". 4 | 5 | 6 | ## To Build 7 | ```bash 8 | cd build 9 | USD_INSTALL_ROOT=/usr/local/USD-19.07 cmake .. # or wherever you've installed USD 10 | make install 11 | ``` 12 | -------------------------------------------------------------------------------- /plugins/custom_resolver/project/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /plugins/custom_resolver/project/cmake/FindUSD.cmake: -------------------------------------------------------------------------------- 1 | # Simple module to find USD. 2 | 3 | if (EXISTS "$ENV{USD_INSTALL_ROOT}") 4 | set(USD_INSTALL_ROOT $ENV{USD_INSTALL_ROOT}) 5 | endif () 6 | 7 | find_path(USD_INCLUDE_DIR pxr/pxr.h 8 | PATHS ${USD_INSTALL_ROOT}/include 9 | DOC "USD Include directory") 10 | 11 | find_path(USD_LIBRARY_DIR libusd.so 12 | PATHS ${USD_INSTALL_ROOT}/lib 13 | DOC "USD Libraries directory") 14 | 15 | find_file(USD_GENSCHEMA 16 | names usdGenSchema 17 | PATHS ${USD_INSTALL_ROOT}/bin 18 | DOC "USD Gen schema application") 19 | 20 | if(USD_INCLUDE_DIR AND EXISTS "${USD_INCLUDE_DIR}/pxr/pxr.h") 21 | foreach(_usd_comp MAJOR MINOR PATCH) 22 | file(STRINGS 23 | "${USD_INCLUDE_DIR}/pxr/pxr.h" 24 | _usd_tmp 25 | REGEX "#define PXR_${_usd_comp}_VERSION .*$") 26 | string(REGEX MATCHALL "[0-9]+" USD_${_usd_comp}_VERSION ${_usd_tmp}) 27 | endforeach() 28 | set(USD_VERSION ${USD_MAJOR_VERSION}.${USD_MINOR_VERSION}.${USD_PATCH_VERSION}) 29 | endif() 30 | 31 | include(FindPackageHandleStandardArgs) 32 | 33 | find_package_handle_standard_args( 34 | USD 35 | REQUIRED_VARS 36 | USD_INCLUDE_DIR 37 | USD_LIBRARY_DIR 38 | USD_GENSCHEMA 39 | VERSION_VAR 40 | USD_VERSION) 41 | -------------------------------------------------------------------------------- /plugins/custom_resolver/project/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 4. Include/Link everything 2 | set(PLUGIN_NAME URIResolver) 3 | 4 | link_directories(${USD_LIBRARY_DIR}) 5 | 6 | 7 | set( 8 | SRC 9 | resolver.cpp 10 | ) 11 | 12 | add_library(${PLUGIN_NAME} 13 | SHARED 14 | ${SRC} 15 | ) 16 | 17 | find_package(PythonLibs REQUIRED) 18 | 19 | target_link_libraries(${PLUGIN_NAME} 20 | PUBLIC 21 | 22 | libboost_python.so 23 | libar.so 24 | ) 25 | 26 | target_include_directories( 27 | ${PLUGIN_NAME} 28 | SYSTEM 29 | PRIVATE 30 | ${USD_INCLUDE_DIR} 31 | 32 | PUBLIC 33 | ${PYTHON_INCLUDE_PATH} 34 | ) 35 | 36 | install( 37 | TARGETS 38 | ${PLUGIN_NAME} 39 | DESTINATION 40 | . 41 | ) 42 | 43 | install( 44 | FILES 45 | plugInfo.json 46 | DESTINATION 47 | ./resources 48 | ) 49 | -------------------------------------------------------------------------------- /plugins/custom_resolver/project/src/plugInfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "Plugins": [ 3 | { 4 | "Info": { 5 | "Types": { 6 | "URIResolver" : { 7 | "bases": ["ArResolver"] 8 | } 9 | } 10 | }, 11 | "LibraryPath": "../libURIResolver.so", 12 | "Name": "URIResolver", 13 | "Type": "library" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /plugins/custom_resolver/project/src/resolver.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT THIRD-PARTY LIBRARIES 2 | #include 3 | #include 4 | 5 | // IMPORT LOCAL LIBRARIES 6 | #include "resolver.h" 7 | 8 | PXR_NAMESPACE_OPEN_SCOPE 9 | 10 | AR_DEFINE_RESOLVER(URIResolver, ArResolver) 11 | 12 | 13 | URIResolver::URIResolver() : ArDefaultResolver() {} 14 | 15 | URIResolver::~URIResolver() = default; 16 | 17 | bool URIResolver::IsRelativePath(const std::string& path) { 18 | return false; 19 | } 20 | 21 | std::string URIResolver::Resolve(const std::string& path) { 22 | if (path == "/foo") { 23 | return "/bar"; 24 | } 25 | 26 | return ""; 27 | } 28 | 29 | PXR_NAMESPACE_CLOSE_SCOPE 30 | -------------------------------------------------------------------------------- /plugins/custom_resolver/project/src/resolver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // IMPORT THIRD-PARTY LIBRARIES 4 | #include 5 | 6 | PXR_NAMESPACE_OPEN_SCOPE 7 | 8 | class URIResolver : public ArDefaultResolver { 9 | public: 10 | URIResolver(); 11 | ~URIResolver(); 12 | 13 | bool IsRelativePath(const std::string& path) override; 14 | 15 | std::string Resolve(const std::string& path) override; 16 | 17 | // std::string ResolveWithAssetInfo( 18 | // const std::string& path, ArAssetInfo* assetInfo) override; 19 | // 20 | // void UpdateAssetInfo( 21 | // const std::string& identifier, const std::string& filePath, 22 | // const std::string& fileVersion, ArAssetInfo* assetInfo) override; 23 | // 24 | // // Quick workaround for a bug in USD 0.8.4. 25 | // std::string AnchorRelativePath( 26 | // const std::string& anchorPath, const std::string& path) override; 27 | // 28 | // VtValue GetModificationTimestamp( 29 | // const std::string& path, const std::string& resolvedPath) override; 30 | // 31 | // bool FetchToLocalResolvedPath( 32 | // const std::string& path, const std::string& resolvedPath) override; 33 | }; 34 | 35 | PXR_NAMESPACE_CLOSE_SCOPE 36 | -------------------------------------------------------------------------------- /plugins/custom_resolver/run_test/custom_resolver.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """This module tests if the custom resolver works.""" 5 | 6 | # IMPORT FUTURE LIBRARIES 7 | from __future__ import print_function 8 | 9 | # IMPORT THIRD-PARTY LIBRARIES 10 | from pxr import Ar 11 | 12 | 13 | def main(): 14 | """Run the main execution of the current script.""" 15 | print("This should still print an empty string", Ar.GetResolver().Resolve("this_wont_resolve")) 16 | print("This should print /bar", Ar.GetResolver().Resolve("/foo")) 17 | 18 | 19 | if __name__ == "__main__": 20 | main() 21 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/compiling_the_schema/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 3 | project(test-out VERSION 0.1.0 LANGUAGES CXX) 4 | 5 | # 2.Configuration 6 | set(CMAKE_INSTALL_PREFIX "./install" CACHE PATH "..." FORCE) 7 | 8 | # 3. Boilerplate 9 | set(USDPLUGIN_NAME testout) 10 | find_package(PythonLibs 2.7 REQUIRED) # Needed for `PYTHON_INCLUDE_PATH` 11 | add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) 12 | 13 | add_subdirectory(src) 14 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/compiling_the_schema/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/compiling_the_schema/src/__init__.py: -------------------------------------------------------------------------------- 1 | from . import _testout 2 | from pxr import Tf 3 | Tf.PrepareModule(_testout, locals()) 4 | del Tf 5 | 6 | try: 7 | import __DOC 8 | __DOC.Execute(locals()) 9 | del __DOC 10 | except Exception: 11 | try: 12 | import __tmpDoc 13 | __tmpDoc.Execute(locals()) 14 | del __tmpDoc 15 | except: 16 | pass 17 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/compiling_the_schema/src/__packageinit__.py: -------------------------------------------------------------------------------- 1 | """The main testout custom schema. 2 | 3 | This dynamic library was created based on USD's custom schema classes tutorial. 4 | 5 | Reference: 6 | https://graphics.pixar.com/usd/docs/Generating-New-Schema-Classes.html 7 | 8 | """ 9 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/compiling_the_schema/src/cmake/TestoutConfig.cmake: -------------------------------------------------------------------------------- 1 | get_filename_component(CUSTOM_SCHEMAS_DIRECTORY "${CMAKE_CURRENT_LIST_FILE}" PATH) 2 | 3 | find_package(PythonLibs REQUIRED) 4 | 5 | if(NOT TARGET testout::testout) 6 | include("${CUSTOM_SCHEMAS_DIRECTORY}/TestoutTargets.cmake") 7 | endif() 8 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/compiling_the_schema/src/generatedSchema.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | "WARNING: THIS FILE IS GENERATED. DO NOT EDIT." 4 | customLayerData = { 5 | string[] appliedAPISchemas = ["ParamsAPI"] 6 | string[] multipleApplyAPISchemas = [] 7 | } 8 | ) 9 | 10 | class "SimplePrim" ( 11 | doc = """An example of an untyped schema prim. Note that it does not 12 | specify a typeName""" 13 | ) 14 | { 15 | int intAttr = 0 ( 16 | doc = "An integer attribute with fallback value of 0." 17 | ) 18 | rel target ( 19 | doc = """A relationship called target that could point to another prim 20 | or a property""" 21 | ) 22 | } 23 | 24 | class ComplexPrim "ComplexPrim" ( 25 | doc = "An example of a untyped IsA schema prim" 26 | ) 27 | { 28 | string complexString = "somethingComplex" 29 | int intAttr = 0 ( 30 | doc = "An integer attribute with fallback value of 0." 31 | ) 32 | rel target ( 33 | doc = """A relationship called target that could point to another prim 34 | or a property""" 35 | ) 36 | } 37 | 38 | class "ParamsAPI" 39 | { 40 | double params:mass ( 41 | doc = "Double value denoting mass" 42 | ) 43 | double params:velocity ( 44 | doc = "Double value denoting velocity" 45 | ) 46 | double params:volume ( 47 | doc = "Double value denoting volume" 48 | ) 49 | } 50 | 51 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/compiling_the_schema/src/module.cpp: -------------------------------------------------------------------------------- 1 | #include "Python.h" 2 | #include "pxr/pxr.h" 3 | #include "pxr/base/tf/pyModule.h" 4 | 5 | PXR_NAMESPACE_USING_DIRECTIVE 6 | 7 | TF_WRAP_MODULE 8 | { 9 | TF_WRAP(UsdSchemaExamplesSimple); 10 | TF_WRAP(UsdSchemaExamplesComplex); 11 | TF_WRAP(UsdSchemaExamplesParamsAPI); 12 | TF_WRAP(UsdSchemaExamplesTokens); 13 | } 14 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/compiling_the_schema/src/moduleDeps.cpp: -------------------------------------------------------------------------------- 1 | #include "pxr/pxr.h" 2 | #include "pxr/base/tf/registryManager.h" 3 | #include "pxr/base/tf/scriptModuleLoader.h" 4 | #include "pxr/base/tf/token.h" 5 | 6 | #include 7 | 8 | PXR_NAMESPACE_OPEN_SCOPE 9 | 10 | TF_REGISTRY_FUNCTION(TfScriptModuleLoader) { 11 | // List of direct dependencies for this library. 12 | const std::vector reqs = { 13 | TfToken("sdf"), 14 | TfToken("tf"), 15 | TfToken("usd"), 16 | TfToken("vt") 17 | }; 18 | TfScriptModuleLoader::GetInstance(). 19 | RegisterLibrary(TfToken("testout"), TfToken("testout.Testout"), reqs); 20 | } 21 | 22 | PXR_NAMESPACE_CLOSE_SCOPE 23 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/testing_the_compiled_schema_cpp/README.md: -------------------------------------------------------------------------------- 1 | You must build the custom schema classes used in this project before you 2 | can follow the build steps below. If you haven't already done this, head 3 | over to [compiling_the_schema](../compiling_the_schema) to get started. 4 | 5 | 6 | ## How To Build 7 | Use the same build + compile steps as any other project in this repository. 8 | 9 | In other words, this: 10 | ```bash 11 | cd ./build 12 | USD_INSTALL_ROOT=/wherever/you/installed/USD cmake3 .. 13 | # USD_INSTALL_ROOT=/usr/local/USD-19.07 cmake3 .. 14 | make 15 | ./run_it 16 | ``` 17 | 18 | ### Important Build Note 19 | If you have any problems building and compiling this project, Make sure that 20 | the GCC version that you're using to run `make` with matches the GCC version 21 | that was used build the custom schemas. 22 | 23 | `gcc --version` <-- Check the version 24 | 25 | `which gcc` <-- Check the path on-disk, if needed 26 | 27 | 28 | ## Extra Information 29 | The overall project is explained in the folder above this one. Read 30 | through it if you want more of an explanation of what's going on. 31 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/testing_the_compiled_schema_cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/testing_the_compiled_schema_cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT STANDARD LIBRARIES 2 | #include 3 | #include 4 | 5 | // IMPORT THIRD-PARTY LIBRARIES 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | int main() { 12 | auto stage = pxr::UsdStage::Open("../test.usda"); 13 | 14 | auto prim = stage->GetPrimAtPath(pxr::SdfPath("/Simple")); 15 | auto simple = pxr::UsdSchemaExamplesSimple(prim); 16 | auto attribute = simple.GetIntAttrAttr(); 17 | int value = 0; 18 | attribute.Get(&value); 19 | std::cout << "Got a value: " << value << std::endl; 20 | attribute.Set(2); 21 | attribute.Get(&value); 22 | std::cout << "Got a value: " << value << std::endl; 23 | 24 | auto cp = stage->GetPrimAtPath(pxr::SdfPath("/Complex")); 25 | auto complex = pxr::UsdSchemaExamplesComplex(cp); 26 | std::string value1 {""}; 27 | complex.GetComplexStringAttr().Get(&value1); 28 | std::cout << value1 << std::endl; 29 | 30 | auto* result = new std::string(); 31 | stage->ExportToString(result); 32 | std::cout << *result << std::endl; 33 | delete result; 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/testing_the_compiled_schema_cpp/test.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = "Test stuff" 4 | ) 5 | 6 | def SimplePrim "Simple" 7 | { 8 | int intAttr = 5 9 | } 10 | 11 | def ComplexPrim "Complex" 12 | { 13 | string complexString = "a really complex string" 14 | int intAttr = 10 15 | add rel target = 16 | } 17 | 18 | def Xform "Object" ( 19 | prepend apiSchema = ["ParamsAPI"] 20 | ) 21 | { 22 | custom double params:mass = 1 23 | custom double params:velocity = 10 24 | custom double params:volume = 4 25 | } 26 | 27 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/testing_the_compiled_schema_python/Test.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def ComplexPrim "Complex" 4 | { 5 | string complexString = "a really complex string" 6 | int intAttr = 10 7 | add rel target = 8 | } 9 | 10 | def Xform "Object" ( 11 | prepend apiSchemas = ["ParamsAPI"] 12 | ) 13 | { 14 | custom double params:mass = 1 15 | custom double params:velocity = 10 16 | custom double params:volume = 4 17 | } 18 | 19 | -------------------------------------------------------------------------------- /plugins/custom_schemas_with_python_bindings/testing_the_compiled_schema_python/custom_schema_include.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """This module is a copy of Pixar's "Generating Custom Schema Classes" tutorial. 5 | 6 | Here, the custom schema classes are imported using the Python namespace 7 | that was created (instead of importing from `pxr`). 8 | 9 | Reference: 10 | https://graphics.pixar.com/usd/docs/Generating-New-Schema-Classes.html 11 | 12 | """ 13 | 14 | # IMPORT THIRD-PARTY LIBRARIES 15 | from pxr import Usd 16 | 17 | # IMPORT FIRST-PARTY LIBRARIES 18 | from testout import Testout 19 | 20 | 21 | def main(): 22 | """Run the main execution of the current script.""" 23 | stage = Usd.Stage.Open("Test.usda") 24 | cp = stage.GetPrimAtPath("/Complex") 25 | simple = Testout.Simple(cp) 26 | target = simple.GetTargetRel() 27 | intAttr = simple.GetIntAttrAttr() 28 | complex = Testout.Complex(cp) 29 | print 'complexString: %s' % complex.GetComplexStringAttr().Get() 30 | obj = stage.GetPrimAtPath("/Object") 31 | paramsAPI = Testout.ParamsAPI.Apply(obj); 32 | # assert obj.HasAPI(Testout.ParamsAPI) 33 | print 'mass: %s' % paramsAPI.GetMassAttr().Get() 34 | print 'velocity: %s' % paramsAPI.GetVelocityAttr().Get() 35 | print 'volume: %s' % paramsAPI.GetVolumeAttr().Get() 36 | 37 | 38 | if __name__ == "__main__": 39 | main() 40 | -------------------------------------------------------------------------------- /plugins/plugin_metadata/README.md: -------------------------------------------------------------------------------- 1 | ## Quick Explanation 2 | The USD documentation does a good job of explaining this concept. 3 | Essentially, plugin metadata is a way to add custom metadata information onto 4 | prims, attributes, layers, etc. that you wouldn't normally be able to 5 | add to. It's also easy to set up. The steps can be boiled down to: 6 | 7 | 1. Create a `plugInfo.json` file that describes the metadata that you want to add 8 | 2. Include the `plugInfo.json` parent directory into the `PXR_PLUGINPATH_NAME` environment variable so that it is discoverable by USD 9 | 3. Work as you normally do. Get/Set the metadata. 10 | 11 | This folder shows how to query the metadata, get information about it 12 | it in USD's schema registry, and how to author the plugin metadata 13 | `plugInfo.json` file. 14 | 15 | 16 | ## How To Check If Plugin Metadata Loaded 17 | ### C++ 18 | This gets you fallback information for metadata that is meant to be 19 | authored onto a SdfPrimSpec. 20 | ```cpp 21 | auto fallback = pxr::SdfSchema::GetInstance().GetFallback(pxr::TfToken {"my_custom_double"}); 22 | assert(fallback == 12.0 && "Plugin Metadata was not sourced correctly"); 23 | ``` 24 | 25 | This gets you fallback information for metadata that is meant to be 26 | authored onto a SdfLayer. 27 | ```python 28 | assert layer.pseudoRoot.GetFallbackForInfo("another_metadata") == Vt.DoubleArray( 29 | [5, 13] 30 | ), message 31 | ``` 32 | 33 | 34 | ## See Also 35 | https://graphics.pixar.com/usd/docs/api/sdf_page_front.html#sdf_plugin_metadata 36 | -------------------------------------------------------------------------------- /plugins/plugin_metadata/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(plugin_metadata) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_ARCH arch HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_ARCH} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_SDF} 42 | ${USD_TF} 43 | ${USD_USD} 44 | ${USD_VT} 45 | ) 46 | -------------------------------------------------------------------------------- /plugins/plugin_metadata/cpp/README.md: -------------------------------------------------------------------------------- 1 | # How To Build 2 | Build this project as normal: 3 | 4 | ```bash 5 | cd build 6 | USD_INSTALL_ROOT=/wherever/you/installed/USD/to cmake .. 7 | make 8 | ``` 9 | 10 | # How To Run 11 | This C++ project requires a `plugInfo.json` to be visible to USD so we 12 | can't simply call `./run_it` like usual. In a pipeline, your environment 13 | would already be set up to already include any environment variables you 14 | need but for our simple project, this is all you have to do to run it: 15 | 16 | 17 | ```bash 18 | cd .. 19 | PXR_PLUGINPATH_NAME=`dirname $PWD`/definition ./build/run_it 20 | ``` 21 | 22 | If the `plugInfo.json` parent directory is not found in `PXR_PLUGINPATH_NAME`, you will get this error message: 23 | 24 | ``` 25 | run_it: $PWD/main.cpp:17: int main(): Assertion `fallback == 12.0 && "Plugin Metadata was not sourced correctly"' failed. 26 | ``` 27 | -------------------------------------------------------------------------------- /plugins/plugin_metadata/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /plugins/plugin_metadata/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT STANDARD LIBRARIES 2 | #include 3 | #include 4 | 5 | // IMPORT THIRD-PARTY LIBRARIES 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | int main() { 12 | auto layer = pxr::SdfLayer::CreateAnonymous(); 13 | 14 | auto primspec = pxr::SdfCreatePrimInLayer(layer, pxr::SdfPath {"/SomePrim"}); 15 | auto fallback = pxr::SdfSchema::GetInstance().GetFallback(pxr::TfToken {"my_custom_double"}); 16 | 17 | assert(fallback == 12.0 && "Plugin Metadata was not sourced correctly"); 18 | assert(layer->GetPseudoRoot()->GetFallbackForInfo(pxr::TfToken {"another_metadata"}) == pxr::VtDoubleArray({5.0, 13.0}) && "Plugin Metadata was not sourced correctly"); 19 | 20 | std::cout << "The Plugin Metadata file is included correctly\n"; 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /plugins/plugin_metadata/definition/plugInfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "Plugins": [ 3 | { 4 | "Name": "Plugin double extension", 5 | "Type": "resource", 6 | "Info": { 7 | "SdfMetadata": { 8 | "another_metadata": { 9 | "type": "double[]", 10 | "appliesTo": "layers", 11 | "default": [5.0, 13.0] 12 | }, 13 | "my_custom_double": { 14 | "type": "double", 15 | "appliesTo": "prims", 16 | "default": 12.0 17 | } 18 | } 19 | } 20 | } 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /plugins/plugin_metadata/python/README.md: -------------------------------------------------------------------------------- 1 | # How To Run 2 | This C++ project requires a `plugInfo.json` to be visible to USD so we 3 | can't simply call `./run_it` like usual. In a pipeline, your environment 4 | would already be set up to already include any environment variables you 5 | need but for our simple project, this is all you have to do to run it: 6 | 7 | 8 | ```bash 9 | PXR_PLUGINPATH_NAME=`dirname $PWD`/definition python plugin_metadata.py 10 | ``` 11 | 12 | If the `plugInfo.json` parent directory is not found in `PXR_PLUGINPATH_NAME`, you will get this error message: 13 | 14 | ``` 15 | Traceback (most recent call last): 16 | File "plugin_metadata.py", line 26, in 17 | main() 18 | File "plugin_metadata.py", line 18, in main 19 | ), message 20 | AssertionError: Plugin Metadata was not sourced correctly 21 | ``` 22 | -------------------------------------------------------------------------------- /plugins/plugin_metadata/python/plugin_metadata.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """A simple module that checks if the Plugin Metadata file was sourced correctly.""" 5 | # IMPORT THIRD-PARTY LIBRARIES 6 | from pxr import Sdf, Vt 7 | 8 | 9 | def main(): 10 | """Run the main execution of the current script.""" 11 | layer = Sdf.Layer.CreateAnonymous() 12 | 13 | message = "Plugin Metadata was not sourced correctly" 14 | primspec = Sdf.CreatePrimInLayer(layer, "/SomePrim") 15 | 16 | assert ( 17 | "my_custom_double" in primspec.GetMetaDataInfoKeys() 18 | ), message 19 | 20 | assert layer.pseudoRoot.GetFallbackForInfo("another_metadata") == Vt.DoubleArray( 21 | [5, 13] 22 | ), message 23 | 24 | 25 | if __name__ == "__main__": 26 | main() 27 | -------------------------------------------------------------------------------- /plugins/plugin_metadata/usda/plugin_metadata.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "SomePrim1" 4 | ( 5 | my_custom_double = 10.0 6 | ){ 7 | 8 | } 9 | 10 | def "SomePrim2" 11 | ( 12 | my_custom_double = 10.0 13 | ){ 14 | 15 | } 16 | -------------------------------------------------------------------------------- /plugins/registered_variant_selection_export_policies/application_a.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Show how to print variant selection export policies.""" 5 | 6 | # IMPORT FUTURE LIBRARIES 7 | from __future__ import print_function 8 | 9 | # IMPORT THIRD-PARTY LIBRARIES 10 | from pxr import Usd, UsdUtils 11 | 12 | 13 | def main(): 14 | """Run the main execution of the current script.""" 15 | print('Printing the export policies') 16 | 17 | for variant in UsdUtils.GetRegisteredVariantSets(): 18 | print(variant.name, variant.selectionExportPolicy) 19 | 20 | print('Done') 21 | 22 | stage = Usd.Stage.CreateInMemory() 23 | 24 | prim = stage.DefinePrim("/Foo") 25 | 26 | variant_set = prim.GetVariantSets().AddVariantSet("some_variant_set") 27 | 28 | variant_set.AddVariant("foo") 29 | variant_set.SetVariantSelection("foo") 30 | 31 | print('Notice that, unless we actually check the variant selections ourselves, they still get written to-disk.') 32 | print(stage.GetRootLayer().ExportToString()) 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /plugins/registered_variant_selection_export_policies/application_b.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Show how to print variant selection export policies.""" 5 | 6 | # IMPORT FUTURE LIBRARIES 7 | from __future__ import print_function 8 | 9 | # IMPORT THIRD-PARTY LIBRARIES 10 | from pxr import Usd, UsdUtils 11 | 12 | 13 | def main(): 14 | """Run the main execution of the current script.""" 15 | print('Printing the export policies') 16 | 17 | for variant in UsdUtils.GetRegisteredVariantSets(): 18 | print(variant.name, variant.selectionExportPolicy) 19 | 20 | print('Done') 21 | 22 | stage = Usd.Stage.CreateInMemory() 23 | 24 | prim = stage.DefinePrim("/Foo") 25 | 26 | variant_set = prim.GetVariantSets().AddVariantSet("some_variant_set") 27 | 28 | variant_set.AddVariant("foo") 29 | variant_set.SetVariantSelection("foo") 30 | 31 | print('Notice that, unless we actually check the variant selections ourselves, they still get written to-disk.') 32 | print(stage.GetRootLayer().ExportToString()) 33 | 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /plugins/registered_variant_selection_export_policies/plugin/plugInfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "Plugins": [ 3 | { 4 | "Name": "Variant Selection Export Policies", 5 | "Type": "resource", 6 | "Info": { 7 | "UsdUtilsPipeline": { 8 | "RegisteredVariantSets": { 9 | "some_variant_set": { 10 | "selectionExportPolicy": "never" 11 | }, 12 | "standin": { 13 | "selectionExportPolicy": "never" 14 | } 15 | } 16 | } 17 | } 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /plugins/usdview_auto_reloader/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | 3 | This section is a combination of two different ideas. 4 | - A brilliant [live-coding in usdview post by Brett Levin](https://groups.google.com/d/msg/usd-interest/w3-KivsOuTE/psDcH9p-AgAJ) 5 | - Pixar's [usdview plugins tutorial](https://graphics.pixar.com/usd/docs/Creating-a-Usdview-Plugin.html) 6 | 7 | This section is a usdview plugin that can automatically reload the Stage 8 | whenever there are new changes. 9 | 10 | 11 | # How To Run 12 | 1. Use the following commands in the terminal: 13 | 14 | Linux 15 | ```bash 16 | echo -e '#usda 1.0\n\ndef Sphere "MyPrim" {\ndouble radius = 4\n}' > some_file.usda 17 | PYTHONPATH=$PWD/plugins:$PYTHONPATH PXR_PLUGINPATH_NAME=$PWD/plugins/auto_reloader:$PXR_PLUGINPATH_NAME usdview some_file.usda 18 | ``` 19 | 20 | 2. In the opened usdview, Click "Reloader" > "Toggle Auto-Reload USD 21 | Stage" 22 | 3. Open some_file.usda and do anything you'd like. Define new prims, 23 | rename things, change the radius size - anything you want. Without 24 | leaving the text editor, usdview should update with the new changes. 25 | 4. To disable the auto-reload feature, click "Reloader" > "Toggle 26 | Auto-Reload USD Stage" again. 27 | 28 | 29 | # See Also 30 | https://groups.google.com/d/msg/usd-interest/w3-KivsOuTE/psDcH9p-AgAJ 31 | 32 | https://graphics.pixar.com/usd/docs/Creating-a-Usdview-Plugin.html 33 | -------------------------------------------------------------------------------- /plugins/usdview_auto_reloader/plugins/auto_reloader/plugInfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "Plugins": [ 3 | { 4 | "Type": "python", 5 | "Name": "auto_reloader", 6 | "Info": { 7 | "Types": { 8 | "auto_reloader.AutoReloaderContainer": { 9 | "bases": ["pxr.Usdviewq.plugin.PluginContainer"], 10 | "displayName": "Reload usdview automatically" 11 | } 12 | } 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /plugins/usdview_auto_reloader/some_file.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Sphere "MyPrim" { 4 | double radius = 4 5 | } 6 | -------------------------------------------------------------------------------- /plugins/usdview_copy_camera/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | Have you ever been in usdview and wanted to save your current camera 3 | view for later? This quick little plugin does this for you. 4 | 5 | 6 | # Demonstration 7 | ![usdview_copy_camera_demonstration](https://user-images.githubusercontent.com/10103049/95707321-0a7d6e80-0c0e-11eb-9930-acf10ae7dde1.gif) 8 | 9 | 10 | # How To Run 11 | 1. Run this in the terminal 12 | 13 | Linux 14 | ```sh 15 | echo -e '#usda 1.0\n\ndef Sphere "MyPrim" {\ndouble radius = 4\n}' > some_file.usda 16 | PYTHONPATH=$PWD/plugins:$PYTHONPATH PXR_PLUGINPATH_NAME=$PWD/plugins/copy_camera:$PXR_PLUGINPATH_NAME usdview some_file.usda 17 | ``` 18 | 19 | 2. In the opened usdview, press the "Copy The Current Camera" menu button 20 | 3. In the pop-up window, type in the path to where you want this new camera to go. 21 | 4. Click "Copy" and you should now have a camera Prim exactly where you current camera is. 22 | -------------------------------------------------------------------------------- /plugins/usdview_copy_camera/plugins/copy_camera/plugInfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "Plugins": [ 3 | { 4 | "Type": "python", 5 | "Name": "copy_camera", 6 | "Info": { 7 | "Types": { 8 | "copy_camera.CopyCameraContainer": { 9 | "bases": ["pxr.Usdviewq.plugin.PluginContainer"], 10 | "displayName": "Copy The User's Current Camera" 11 | } 12 | } 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /plugins/usdview_purpose_swap/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | "Purpose Swap" changes between the proxy and render purpose in a single, 3 | convenient button. 4 | 5 | When dealing with massive USD stages, switching between purposes can 6 | actually take some time. Even usdview's GUI can be slow so this button 7 | minimizes the menus you must click through to just a single button 8 | press. 9 | 10 | ![usdview_purpose_swap_demonstration](https://user-images.githubusercontent.com/10103049/77233673-3c41c180-6b66-11ea-85e3-6de9d50e0158.gif) 11 | 12 | 13 | # How To Run 14 | 1. Run this command in the terminal: 15 | 16 | ```bash 17 | PYTHONPATH=$PWD/plugins:$PYTHONPATH PXR_PLUGINPATH_NAME=$PWD/plugins/purpose_swap:$PXR_PLUGINPATH_NAME usdview $PWD/assets/mesh.usda 18 | ``` 19 | 20 | # Customization 21 | The "Purpose Swap" plugin prefers to use the "proxy" USD purpose 22 | whenever it can. But if you prefer to use another purpose, such as 23 | "guide" or "render", "Purpose Swap" comes with some environment 24 | variables to configure this. 25 | 26 | e.g. 27 | 28 | This means "prefer the render purpose over the proxy purpose and swap between them." 29 | 30 | ```bash 31 | export USDVIEW_PURPOSE_SWAP_PRIMARY_PURPOSE=render 32 | export USDVIEW_PURPOSE_SWAP_SECONDARY_PURPOSE=proxy 33 | ``` 34 | 35 | This means "prefer the guide purpose over the render purpose and swap between them." 36 | 37 | ```bash 38 | export USDVIEW_PURPOSE_SWAP_PRIMARY_PURPOSE=guide 39 | export USDVIEW_PURPOSE_SWAP_SECONDARY_PURPOSE=render 40 | ``` 41 | -------------------------------------------------------------------------------- /plugins/usdview_purpose_swap/assets/mesh.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" 4 | { 5 | def Cube "cube_render" 6 | { 7 | uniform token purpose = "render" 8 | } 9 | 10 | def Sphere "sphere_proxy" 11 | { 12 | uniform token purpose = "proxy" 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /plugins/usdview_purpose_swap/plugins/purpose_swap/plugInfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "Plugins": [ 3 | { 4 | "Type": "python", 5 | "Name": "purpose_swap", 6 | "Info": { 7 | "Types": { 8 | "purpose_swap.PurposeSwapContainer": { 9 | "bases": ["pxr.Usdviewq.plugin.PluginContainer"], 10 | "displayName": "Swap USD Purposes" 11 | } 12 | } 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /plugins/usdview_root_loader/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | "Root Loader" lets you load or unload payloads at the selected Prims or 3 | any of the Prim's children. 4 | 5 | 6 | # How To Run 7 | 1. Run this command in the terminal: 8 | 9 | ```bash 10 | PYTHONPATH=$PWD/plugins:$PYTHONPATH PXR_PLUGINPATH_NAME=$PWD/plugins/root_loader:$PXR_PLUGINPATH_NAME usdview $PWD/assets/mesh.usda 11 | ``` 12 | 13 | 2. In the opened usdview, select a prim like `` 14 | 3. Go to the "Root Loader" menu and press "Root Unload" 15 | 4. Go to the "Root Loader" menu and press "Root Load" to get the selected Prim back 16 | 5. You should be able to select parent Prims and load/unload those, too 17 | 18 | 19 | # Justification 20 | usdview already comes with "Load" / "Unload" buttons, but they are too 21 | strict. If you have multiple Prims selected, every single Prim in the 22 | selection has to have a payload underneath it. Otherwise, the "Load" / 23 | "Unload" buttons get greyed out. Now imagine you have a set with 300 24 | payloads, they're each nested within other Prims, and you now have to 25 | expand the QTreeWidget in usdview, find exactly the Prims you're looking 26 | for, manually select each one, and then select "Unload". 27 | 28 | "Root Loader" lets you just select a single ancester Prim and every Prim 29 | underneath it will be unloaded. All without forking usdview or changing 30 | the way usdview works. 31 | 32 | 33 | -------------------------------------------------------------------------------- /plugins/usdview_root_loader/assets/mesh.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "Meshes" 4 | { 5 | def "Thing" ( 6 | payload = @./payload1.usda@ 7 | ) 8 | { 9 | } 10 | 11 | def "Another" ( 12 | payload = @./payload2.usda@ 13 | ) 14 | { 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /plugins/usdview_root_loader/assets/payload1.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Sphere "Mesh" 4 | { 5 | def Sphere "Another" 6 | { 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /plugins/usdview_root_loader/assets/payload2.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Sphere "Mesh" 4 | { 5 | def Sphere "Another" 6 | { 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /plugins/usdview_root_loader/plugins/root_loader/plugInfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "Plugins": [ 3 | { 4 | "Type": "python", 5 | "Name": "root_loader", 6 | "Info": { 7 | "Types": { 8 | "root_loader.RootLoaderContainer": { 9 | "bases": ["pxr.Usdviewq.plugin.PluginContainer"], 10 | "displayName": "Loader / Unloader" 11 | } 12 | } 13 | } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /plugins/variant_fallbacks/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(variant_fallbacks) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | 21 | find_package(PythonLibs REQUIRED) 22 | 23 | # 4. Include/Link Everything 24 | add_executable(run_it 25 | main.cpp 26 | ) 27 | 28 | target_include_directories(run_it 29 | PUBLIC 30 | ${PYTHON_INCLUDE_PATH} 31 | ${USD_INCLUDE_DIRECTORY} 32 | ) 33 | 34 | target_link_libraries( 35 | run_it 36 | ${PYTHON_LIBRARY} 37 | ${USD_BOOST_PYTHON} 38 | ${USD_SDF} 39 | ${USD_TF} 40 | ${USD_USD} 41 | ) 42 | -------------------------------------------------------------------------------- /plugins/variant_fallbacks/cpp/README.md: -------------------------------------------------------------------------------- 1 | ## How To Build 2 | 3 | Build this project as you normally would. For example: 4 | 5 | ```bash 6 | cd build 7 | USD_INSTALL_ROOT=/wherever/you/installed/USD/to cmake .. 8 | make 9 | ``` 10 | 11 | 12 | ## How To Run 13 | 14 | Because this folder requires a `plugInfo.json` file to be discoverable 15 | by USD, we can't just run the Python file as-is like normal. 16 | Instead, we need to add the directory of `plugInfo.json` to the 17 | `PXR_PLUGINPATH_NAME` environment variable: 18 | 19 | ```bash 20 | cd .. 21 | PXR_PLUGINPATH_NAME=`dirname $PWD`/plugin ./build/run_it 22 | ``` 23 | -------------------------------------------------------------------------------- /plugins/variant_fallbacks/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /plugins/variant_fallbacks/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT STANDARD LIBRARIES 2 | #include 3 | 4 | // IMPORT THIRD-PARTY LIBRARIES 5 | #include 6 | #include 7 | 8 | 9 | // Run the main execution of the current script. 10 | // 11 | // Important: 12 | // As mentioned in the `variant_fallbacks/README.md` file, variant 13 | // fallbacks are determined per-stage exactly when the stage is first 14 | // created. 15 | // 16 | // Most projects in this repository use stages that only exist in 17 | // memory but, in this case, it's easier to provide Prims up-front by 18 | // reading and existing USD file instead of creating one, from scratch. 19 | // 20 | int main() { 21 | auto stage = pxr::UsdStage::Open("../example_file/variant_set_with_no_authored_selection.usda"); 22 | 23 | auto prim = stage->DefinePrim(pxr::SdfPath {"/SomePrim"}); 24 | auto variant_set = prim.GetVariantSets().GetVariantSet("some_variant_set_name"); 25 | 26 | std::cout 27 | << "The currently-selected variant (which should be \"foo\"): \"" 28 | << variant_set.GetVariantSelection() 29 | << "\"\n"; 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /plugins/variant_fallbacks/example_file/variant_set_with_no_authored_selection.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "SomePrim" ( 4 | prepend variantSets = "some_variant_set_name" 5 | ) 6 | { 7 | variantSet "some_variant_set_name" = { 8 | "bar" { 9 | 10 | } 11 | "foo" { 12 | 13 | } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /plugins/variant_fallbacks/plugin/plugInfo.json: -------------------------------------------------------------------------------- 1 | { 2 | "Plugins": [ 3 | { 4 | "Name": "Variant Set Fallbacks", 5 | "Type": "resource", 6 | "Info": { 7 | "UsdVariantFallbacks": { 8 | "some_variant_set_name": ["possible_fallback_1", "possible_fallback_2", "possible_fallback_3", "foo", "bar"] 9 | } 10 | } 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /plugins/variant_fallbacks/python/README.md: -------------------------------------------------------------------------------- 1 | ## How To Run 2 | 3 | Because this folder requires a `plugInfo.json` file to be discoverable 4 | by USD, we can't just run the Python file as-is like normal. 5 | Instead, we need to add the directory of `plugInfo.json` to the 6 | `PXR_PLUGINPATH_NAME` environment variable: 7 | 8 | ```bash 9 | PXR_PLUGINPATH_NAME=`dirname $PWD`/plugin python variant_fallbacks.py 10 | ``` 11 | -------------------------------------------------------------------------------- /references/extents_hint_and_bounding_boxes/a_payload.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "cube" 4 | ) 5 | 6 | def Cube "cube" 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /references/extents_hint_and_bounding_boxes/all_in_one.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Cube "bounding_box_here" ( 4 | kind = "component" 5 | payload = @something.usda@ 6 | ) 7 | { 8 | float3[] extentsHint = [(-1, -1, -1), (1, 2.5, 1)] 9 | } 10 | -------------------------------------------------------------------------------- /references/extents_hint_and_bounding_boxes/all_in_one_broken.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" 4 | { 5 | def Cube "bounding_box_here" ( 6 | kind = "component" 7 | payload = @something.usda@ 8 | ) 9 | { 10 | float3[] extentsHint = [(-1, -1, -1), (1, 2.5, 1)] 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /references/extents_hint_and_bounding_boxes/does_not_work.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Cube "bounding_box_here" ( 4 | kind = "group" 5 | payload = @something.usda@ 6 | ) 7 | { 8 | def Scope "inner" ( 9 | doc = "The extentsHint is authored on a child, but that's not good!" 10 | kind = "component" 11 | ) 12 | { 13 | float3[] extentsHint = [(-1, -1, -1), (1, 2.5, 1)] 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /references/extents_hint_and_bounding_boxes/multiple_purposes.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | payload = @something.usda@ 5 | kind = "component" 6 | ) 7 | { 8 | float3[] extentsHint = [ 9 | (3.4028235e38, 3.4028235e38, 3.4028235e38), (-3.4028235e38, -3.4028235e38, -3.4028235e38), # default 10 | (-2.5, -3, -2.5), (-1.5, -1, -1.5), # render 11 | (-5.5, -5.5, -5.5), (-4.5, -4.5, -4.5), # proxy 12 | (4, 5.5, 4), (8, 6.5, 8) # guide 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /references/extents_hint_and_bounding_boxes/simple.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "bounding_box_here" ( 4 | kind = "component" 5 | payload = @a_payload.usda@ 6 | ) 7 | { 8 | float3[] extentsHint = [(-1, -1, -1), (1, 2.5, 1)] 9 | } 10 | -------------------------------------------------------------------------------- /references/extents_hint_and_bounding_boxes/something.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "literally_doesnt_matter" 4 | ) 5 | 6 | def Scope "literally_doesnt_matter" 7 | { 8 | } 9 | -------------------------------------------------------------------------------- /references/link_to_the_api_documentation/example_python_project/documentation/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /references/link_to_the_api_documentation/example_python_project/documentation/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /references/link_to_the_api_documentation/example_python_project/documentation/source/index.rst: -------------------------------------------------------------------------------- 1 | .. example_python_project documentation master file, created by 2 | sphinx-quickstart on Sat Apr 4 12:28:42 2020. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to example_python_project's documentation! 7 | ================================================== 8 | 9 | This documentation will only render correctly if the "python" folder is 10 | in your PYTHONPATH. So if you don't see any Python docstrings below this 11 | line, it's probably a problem with your environment. 12 | 13 | 14 | .. automodule:: example_file 15 | :members: 16 | 17 | 18 | Indices and tables 19 | ================== 20 | 21 | * :ref:`genindex` 22 | * :ref:`modindex` 23 | * :ref:`search` 24 | -------------------------------------------------------------------------------- /references/usdview_style_documentation/clip_1.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double inManifestAndInClip.timeSamples = { 6 | 0: 0.0, 7 | 1: -1.0, 8 | } 9 | 10 | double notInManifestAndInClip.timeSamples = { 11 | 0: 0.0, 12 | 1: -1.0, 13 | } 14 | 15 | uniform double uniformInManifestAndInClip = 0.0 16 | } -------------------------------------------------------------------------------- /references/usdview_style_documentation/clip_2.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double notInManifestAndInClip.timeSamples = { 6 | 0: 0.0, 7 | 1: -10.0, 8 | } 9 | 10 | uniform double uniformInManifestAndInClip = 0.0 11 | } -------------------------------------------------------------------------------- /references/usdview_style_documentation/clip_manifest.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Clip" 4 | { 5 | double inManifestAndInClip 6 | double inManifestNotInClip 7 | 8 | uniform double uniformInManifestAndInClip 9 | } -------------------------------------------------------------------------------- /references/usdview_style_documentation/ref.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def "Ref" ( 4 | kind = "model" 5 | ) 6 | { 7 | double inManifestAndInClip = 1.0 8 | double inManifestNotInClip = 2.0 9 | double notInManifestAndInClip = 3.0 10 | double notInManifestNotInClip = 4.0 11 | 12 | uniform double uniformInManifestAndInClip = 5.0 13 | } -------------------------------------------------------------------------------- /references/where_to_find_resources.md: -------------------------------------------------------------------------------- 1 | Do you want to learn USD but you don't know where to look? 2 | 3 | Here are some common questions / things you'd want to learn and how to 4 | find information about it. 5 | 6 | 7 | ## References 8 | [A thorough reference of different USD tools, libraries, and repositories](https://github.com/vfxpro99/usd-resources) 9 | [A community of USD-users](https://groups.google.com/forum/#!forum/usd-interest) 10 | 11 | 12 | ## Questions 13 | ### Where can I look to learn about the attributes/relationships/properties that a USD type supports? 14 | If you look at [the USD source 15 | code](https://github.com/PixarAnimationStudios/USD), there is a file 16 | called "schema.usda" that generates most (all?) USD type classes. 17 | 18 | Say you want to find the schema for "Sphere" and look up all of its 19 | properties. Clone that repository, cd into it, and run this: 20 | 21 | ```bash 22 | find . -name "*.usda" | grep -e schema.usda | xargs grep "class Sphere" 23 | ``` 24 | 25 | This will give you the line where that class is defined and you can open 26 | it up in your editor and read all about it. 27 | 28 | If you don't find what you need immediately, vary the search terms a bit 29 | and it should be easily findable. 30 | 31 | 32 | ### How do I learn about USDSkel? 33 | [Shows UsdSkel in-use](https://github.com/meshula/usdskelutil) 34 | -------------------------------------------------------------------------------- /tools/export_usdskel_from_scratch/python/convert_maya_to_usdskel/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColinKennedy/USD-Cookbook/cfc60a6fa7fb4662bb3529da107bcaf095d0aca4/tools/export_usdskel_from_scratch/python/convert_maya_to_usdskel/__init__.py -------------------------------------------------------------------------------- /tools/usd_searcher/README.md: -------------------------------------------------------------------------------- 1 | Sometimes, you just have to search a USD file for some text. Most of 2 | the time, if you're looking for something specific, you can open 3 | up usdview and dig around until you find what you need. But if, for 4 | example, you need to find every relationship containing the phrase "foo" 5 | or "bar", you're in for some trouble. 6 | 7 | USD files can refer anywhere on-disk. In studio pipelines, it's very 8 | common for Asset paths to be URIs referring to completely different 9 | folder locations or even refer to files in a database. 10 | 11 | To search USD files, you must also traverse its dependencies (wherever 12 | those dependencies may be) and search the dependency's contents. 13 | usd-search a command-line utility / Python module that searches through 14 | USD files, recursively. 15 | 16 | 17 | ## Features 18 | - Search through USD Layers, even crate files 19 | - Optionally searches through Asset paths 20 | - Supports regex matching 21 | 22 | 23 | ## How To Use 24 | ```bash 25 | PYTHONPATH=$USD_INSTALL_ROOT/lib/python:$PWD/python:$PYTHONPATH ./bin/usd-search foo /some/usd/file.usda 26 | ``` 27 | 28 | 29 | ## Requirements 30 | - USD must be importable in Python 31 | - (Optional) Your environment should be set up however it needs to be in 32 | order to resolve paths correctly 33 | -------------------------------------------------------------------------------- /tricks/attribute_source_check/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(attribute_source_check) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | 22 | find_package(PythonLibs REQUIRED) 23 | 24 | # 4. Include/Link Everything 25 | add_executable(run_it 26 | main.cpp 27 | ) 28 | 29 | target_include_directories(run_it 30 | PUBLIC 31 | ${PYTHON_INCLUDE_PATH} 32 | ${USD_INCLUDE_DIRECTORY} 33 | ) 34 | 35 | target_link_libraries( 36 | run_it 37 | ${PYTHON_LIBRARY} 38 | ${USD_BOOST_PYTHON} 39 | ${USD_SDF} 40 | ${USD_TF} 41 | ${USD_USD} 42 | ${USD_USDGEOM} 43 | ) 44 | -------------------------------------------------------------------------------- /tricks/bound_material_finder/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(bound_material_finder) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDSHADE usdShade HINTS ${USD_LIBRARY_DIRECTORY}) 21 | 22 | find_package(PythonLibs REQUIRED) 23 | 24 | # 4. Include/Link Everything 25 | add_executable(run_it 26 | main.cpp 27 | ) 28 | 29 | target_include_directories(run_it 30 | PUBLIC 31 | ${PYTHON_INCLUDE_PATH} 32 | ${USD_INCLUDE_DIRECTORY} 33 | ) 34 | 35 | target_link_libraries( 36 | run_it 37 | ${PYTHON_LIBRARY} 38 | ${USD_BOOST_PYTHON} 39 | ${USD_SDF} 40 | ${USD_TF} 41 | ${USD_USD} 42 | ${USD_USDSHADE} 43 | ) 44 | -------------------------------------------------------------------------------- /tricks/bound_material_finder/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tricks/bound_material_finder/python/materials.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """This module demonstrates the deprecated way to query material bindings. 5 | 6 | In short, don't use this. Check out `material_binding_api.py` for an 7 | updated way to search for bound materials. 8 | 9 | """ 10 | 11 | # IMPORT THIRD-PARTY LIBRARIES 12 | from pxr import Usd, UsdShade 13 | 14 | 15 | def main(): 16 | """Run the main execution of the current script.""" 17 | stage = Usd.Stage.Open("../usda/materials.usda") 18 | 19 | # XXX : It looks as though the `GetBindingRel` and 20 | # `GetBoundMaterial` work but only for the `material:binding` 21 | # Relationship. 22 | # 23 | prim = stage.GetPrimAtPath("/Bob/Geom/Belt") 24 | print('Found Prim "{}".'.format(UsdShade.Material.GetBoundMaterial(prim).GetPrim())) 25 | print('Found Relationship "{}".'.format(UsdShade.Material.GetBindingRel(prim))) 26 | 27 | # XXX : If you attempt to use them on a Prim with a material 28 | # Property with different syntax, like `material:binding:full`, 29 | # it'll just return back invalid Prim / Relationship information. 30 | # 31 | prim = stage.GetPrimAtPath("/Bob/Geom/Body") 32 | print('Found Prim "{}".'.format(UsdShade.Material.GetBoundMaterial(prim).GetPrim())) 33 | print('Found Relationship "{}".'.format(UsdShade.Material.GetBindingRel(prim))) 34 | 35 | 36 | if __name__ == "__main__": 37 | main() 38 | -------------------------------------------------------------------------------- /tricks/bound_material_finder/usda/materials.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Material "PreviewMaterial" 4 | { 5 | token outputs:glslfx:surface.connect = 6 | 7 | def Shader "pbsSurface" 8 | { 9 | } 10 | } 11 | 12 | def Material "Skin" 13 | { 14 | token outputs:ri:surface.connect = 15 | 16 | def Shader "pxrSurface1" 17 | { 18 | } 19 | } 20 | 21 | def Material "Leather" 22 | { 23 | token outputs:surface.connect = 24 | 25 | def Shader "uberSurface" 26 | { 27 | } 28 | } 29 | 30 | def Xform "Bob" 31 | { 32 | rel material:binding:preview = 33 | 34 | def Xform "Geom" 35 | { 36 | def Mesh "Body" 37 | { 38 | rel material:binding:full = 39 | } 40 | 41 | def Mesh "Belt" 42 | { 43 | rel material:binding = 44 | } 45 | } 46 | } 47 | 48 | def Xform "BrokenBindingPrim" 49 | { 50 | rel material:binding = 51 | } 52 | 53 | -------------------------------------------------------------------------------- /tricks/bound_material_finder/usda/pencil.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "Pencil" 4 | ) 5 | 6 | def Xform "Pencil" 7 | { 8 | def Scope "Geom" ( 9 | "I didn't bother actually positioning these child Prims because it's just a demo." 10 | ) 11 | { 12 | def Sphere "EraserHead" 13 | { 14 | } 15 | 16 | def Cylinder "Shaft" 17 | { 18 | } 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /tricks/copy_variant_set_to_prim/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(copy_variant_set_to_prim) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_ARCH arch HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_ARCH} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_SDF} 42 | ${USD_TF} 43 | ${USD_USDGEOM} 44 | ${USD_USD} 45 | ) 46 | -------------------------------------------------------------------------------- /tricks/copy_variant_set_to_prim/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tricks/fast_export/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | The USD documentation states that defining Prims and reparenting prims 3 | are some of the sloweest operations that USD does. 4 | 5 | That said, USD's Sdf API is fast at authoring PrimSpecs so when I ran 6 | across a suggestion the in USD forums to split an export into two passes 7 | (one for the PrimSpecs and one for the Properties/Attributes), I had to 8 | test it out. 9 | 10 | On my machine, the SDF version is over 100x faster than authoring the 11 | same Prims in a USD stage! 12 | 13 | 14 | ### C++ 15 | 16 | ```cpp 17 | auto prim_spec = pxr::SdfCreatePrimInLayer(layer, path); 18 | prim_spec->SetSpecifier(pxr::SdfSpecifierDef); 19 | ``` 20 | 21 | 22 | ### Python 23 | 24 | ```python 25 | prim_spec = Sdf.CreatePrimInLayer(layer, path) 26 | prim_spec.specifier = Sdf.SpecifierDef 27 | ``` 28 | 29 | 30 | # See Also 31 | https://groups.google.com/d/msg/usd-interest/Bh6_sxij-f8/3UYUui3cAQAJ 32 | 33 | https://groups.google.com/d/msg/usd-interest/Bh6_sxij-f8/rnGtLK3tAQAJ 34 | -------------------------------------------------------------------------------- /tricks/fast_export/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(fast_export) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_ARCH arch HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_ARCH} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_SDF} 42 | ${USD_TF} 43 | ${USD_USD} 44 | ${USD_USDGEOM} 45 | ) 46 | -------------------------------------------------------------------------------- /tricks/fast_export/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tricks/fast_export/cpp/log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ColinKennedy/USD-Cookbook/cfc60a6fa7fb4662bb3529da107bcaf095d0aca4/tricks/fast_export/cpp/log -------------------------------------------------------------------------------- /tricks/flatten_layer_stack/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(flatten_layer_stack) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_KIND kind HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | find_library(USD_USDUTILS usdUtils HINTS ${USD_LIBRARY_DIRECTORY}) 23 | 24 | find_package(PythonLibs REQUIRED) 25 | 26 | # 4. Include/Link Everything 27 | add_executable(run_it 28 | main.cpp 29 | ) 30 | 31 | target_include_directories(run_it 32 | PUBLIC 33 | ${PYTHON_INCLUDE_PATH} 34 | ${USD_INCLUDE_DIRECTORY} 35 | ) 36 | 37 | target_link_libraries( 38 | run_it 39 | ${PYTHON_LIBRARY} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_KIND} 42 | ${USD_SDF} 43 | ${USD_TF} 44 | ${USD_USD} 45 | ${USD_USDGEOM} 46 | ${USD_USDUTILS} 47 | ) 48 | -------------------------------------------------------------------------------- /tricks/flatten_layer_stack/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tricks/get_sdf_prim_path/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | Sometimes, you just need to select a Prim. If you have no variant 3 | sets, you can normally just do `stage.GetPrimAtPath("/foo/bar")` and 4 | you're done. But what if "bar" is defined behind a variant set and that 5 | variant set isn't selected in the current stage? Then GetPrimAtPath 6 | returns an invalid Prim. 7 | 8 | The basic steps goes like this 9 | - Have a description of the entire path (including variants + their selections) 10 | - Iterate overy every variant set and forcibly set the selections, one by one 11 | - Then you can get your path 12 | 13 | 14 | # See Also 15 | [Variants Tutorial](https://graphics.pixar.com/usd/docs/Authoring-Variants.html) 16 | 17 | [pxr::SdfPath::StripAllVariantSelections](https://graphics.pixar.com/usd/docs/api/class_sdf_path.html#af66d081e4ec164f04c3fb1805cfcfa4f) 18 | 19 | [pxr::UsdObject::IsValid](https://graphics.pixar.com/usd/docs/api/class_usd_object.html#afa8720abaf6972d6dac22a8cd1a67225) 20 | -------------------------------------------------------------------------------- /tricks/get_sdf_prim_path/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(get_sdf_prim_path) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_package(PythonLibs REQUIRED) 22 | 23 | # 4. Include/Link Everything 24 | add_executable(run_it 25 | main.cpp 26 | ) 27 | 28 | target_include_directories(run_it 29 | PUBLIC 30 | ${PYTHON_INCLUDE_PATH} 31 | ${USD_INCLUDE_DIRECTORY} 32 | ) 33 | 34 | target_link_libraries( 35 | run_it 36 | ${PYTHON_LIBRARY} 37 | ${USD_BOOST_PYTHON} 38 | ${USD_SDF} 39 | ${USD_TF} 40 | ${USD_USDGEOM} 41 | ${USD_USD} 42 | ) 43 | -------------------------------------------------------------------------------- /tricks/multi_payload/README.md: -------------------------------------------------------------------------------- 1 | The USD documentation suggests in a few places (sorry, can't find links 2 | right now) that Prims are meant to have one Payload. This however 3 | doesn't seem to be a requirement. 4 | 5 | In the USD glossary, Payloads are described as "a special kind of a 6 | Reference" that is weaker than References. As it turns out, you can 7 | use References and container Prims to collect multiple Payloads into a 8 | single Prim. 9 | 10 | 11 | ### USD 12 | ```usda 13 | #usda 1.0 14 | 15 | def Xform "SomeTransform" ( 16 | prepend references = [ 17 | , 18 | 19 | ] 20 | ) 21 | { 22 | } 23 | 24 | 25 | def Xform "SomeXformCube" ( 26 | prepend payload = @./cube_payload.usda@ 27 | ) 28 | { 29 | } 30 | 31 | 32 | def Xform "SomeXformSphere" ( 33 | prepend payload = @./sphere_payload.usda@ 34 | ) 35 | { 36 | } 37 | ``` 38 | 39 | The Python and C++ projects in this concept show how to replicate this, in-code. 40 | 41 | 42 | # See Also 43 | https://graphics.pixar.com/usd/docs/USD-Glossary.html#USDGlossary-Payload 44 | -------------------------------------------------------------------------------- /tricks/multi_payload/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(multi_payload) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 21 | 22 | find_package(PythonLibs REQUIRED) 23 | 24 | # 4. Include/Link Everything 25 | add_executable(run_it 26 | main.cpp 27 | ) 28 | 29 | target_include_directories(run_it 30 | PUBLIC 31 | ${PYTHON_INCLUDE_PATH} 32 | ${USD_INCLUDE_DIRECTORY} 33 | ) 34 | 35 | target_link_libraries( 36 | run_it 37 | ${PYTHON_LIBRARY} 38 | ${USD_BOOST_PYTHON} 39 | ${USD_SDF} 40 | ${USD_TF} 41 | ${USD_USDGEOM} 42 | ${USD_USD} 43 | ) 44 | -------------------------------------------------------------------------------- /tricks/multi_payload/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tricks/multi_payload/usda/cube_payload.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Cube "PayloadCubeThing" 4 | { 5 | def Cube "PayloadCube" 6 | { 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tricks/multi_payload/usda/payload.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Xform "SomeTransform" ( 4 | prepend references = [ 5 | , 6 | 7 | ] 8 | ) 9 | { 10 | } 11 | 12 | 13 | def Xform "SomeXformCube" ( 14 | prepend payload = @./cube_payload.usda@ 15 | ) 16 | { 17 | } 18 | 19 | 20 | def Xform "SomeXformSphere" ( 21 | prepend payload = @./sphere_payload.usda@ 22 | ) 23 | { 24 | } 25 | 26 | -------------------------------------------------------------------------------- /tricks/multi_payload/usda/sphere_payload.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Sphere "PayloadSphereThing" 4 | { 5 | def Sphere "PayloadSphere" 6 | { 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tricks/stl_iteration/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | ### C++ 3 | Example: Modifying objects 4 | ```cpp 5 | std::for_each(std::begin(range), std::end(range), [](pxr::UsdPrim const &prim){ 6 | pxr::UsdModelAPI(prim).SetKind(pxr::KindTokens->component); 7 | }); 8 | ``` 9 | 10 | Example: Printing / Reporting 11 | ```cpp 12 | auto range = pxr::UsdPrimRange::Stage(stage); 13 | 14 | // Get every prim using accumulate 15 | auto text = std::accumulate( 16 | std::begin(range), 17 | std::end(range), 18 | std::string {"Prims:"}, 19 | [](std::string text, pxr::UsdPrim const &prim) { 20 | return std::move(text) + "\n" + pxr::TfStringify(prim.GetPath()); 21 | } 22 | ); 23 | ``` 24 | -------------------------------------------------------------------------------- /tricks/stl_iteration/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(stl_iteration) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_KIND kind HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_SDF} 41 | ${USD_TF} 42 | ${USD_USDGEOM} 43 | ${USD_USD} 44 | ${USD_KIND} 45 | ) 46 | -------------------------------------------------------------------------------- /tricks/stl_iteration/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tricks/stl_iteration2/README.md: -------------------------------------------------------------------------------- 1 | # Quick Reference 2 | ### C++ 3 | Example: Using boost to do custom traverals 4 | ```cpp 5 | auto range = pxr::UsdPrimRange::Stage(stage); 6 | 7 | for (auto const &prim : range | boost::adaptors::filtered([](pxr::UsdPrim const &prim) { 8 | return prim.GetPath().GetName() == "AnotherSphere"; 9 | })) { 10 | pxr::UsdModelAPI(prim).SetKind(pxr::KindTokens->component); 11 | } 12 | ``` 13 | 14 | # See Also 15 | https://groups.google.com/forum/#!topic/usd-interest/J_tLjVaaePM 16 | -------------------------------------------------------------------------------- /tricks/stl_iteration2/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(stl_iteration2) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_KIND kind HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | 23 | find_package(PythonLibs REQUIRED) 24 | 25 | # 4. Include/Link Everything 26 | add_executable(run_it 27 | main.cpp 28 | ) 29 | 30 | target_include_directories(run_it 31 | PUBLIC 32 | ${PYTHON_INCLUDE_PATH} 33 | ${USD_INCLUDE_DIRECTORY} 34 | ) 35 | 36 | target_link_libraries( 37 | run_it 38 | ${PYTHON_LIBRARY} 39 | ${USD_BOOST_PYTHON} 40 | ${USD_KIND} 41 | ${USD_SDF} 42 | ${USD_TF} 43 | ${USD_USDGEOM} 44 | ${USD_USD} 45 | ) 46 | -------------------------------------------------------------------------------- /tricks/stl_iteration2/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tricks/stl_iteration2/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // IMPORT STANDARD LIBRARIES 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | // IMPORT THIRD-PARTY LIBRARIES 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | class is_positive_number { 16 | public: 17 | bool operator()(pxr::UsdPrim const &prim) { return true; } 18 | }; 19 | 20 | 21 | int main() { 22 | using FilterIter = boost::filter_iterator; 23 | 24 | auto stage = pxr::UsdStage::CreateInMemory(); 25 | stage->DefinePrim(pxr::SdfPath {"/SomeSphere"}); 26 | stage->DefinePrim(pxr::SdfPath {"/AnotherSphere"}); 27 | stage->DefinePrim(pxr::SdfPath {"/AnotherSphere/Here"}); 28 | auto range = pxr::UsdPrimRange::Stage(stage); 29 | 30 | for (auto const &prim : range | boost::adaptors::filtered([](pxr::UsdPrim const &prim) { 31 | return prim.GetPath().GetName() == "AnotherSphere"; 32 | })) { 33 | pxr::UsdModelAPI(prim).SetKind(pxr::KindTokens->component); 34 | } 35 | 36 | auto* result = new std::string(); 37 | stage->GetRootLayer()->ExportToString(result); 38 | std::cout << *result << std::endl; 39 | delete result; 40 | result = nullptr; 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /tricks/traverse_instanced_prims/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 1. Requirements 2 | cmake_minimum_required(VERSION 2.8.11) 3 | project(traverse_instanced_prims) 4 | 5 | set(CMAKE_CXX_STANDARD 14) 6 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 7 | 8 | # 2.Configuration 9 | add_compile_options(-Wno-deprecated) # This is just to avoid some spammy warnings 10 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # This line is optional. It's just for certain IDEs to use 11 | 12 | # 3. Boilerplate 13 | set(USD_LIBRARY_DIRECTORY $ENV{USD_INSTALL_ROOT}/lib) 14 | set(USD_INCLUDE_DIRECTORY $ENV{USD_INSTALL_ROOT}/include) 15 | 16 | find_library(USD_BOOST_PYTHON boost_python HINTS ${USD_LIBRARY_DIRECTORY}) 17 | find_library(USD_GF gf HINTS ${USD_LIBRARY_DIRECTORY}) 18 | find_library(USD_SDF sdf HINTS ${USD_LIBRARY_DIRECTORY}) 19 | find_library(USD_TF tf HINTS ${USD_LIBRARY_DIRECTORY}) 20 | find_library(USD_USD usd HINTS ${USD_LIBRARY_DIRECTORY}) 21 | find_library(USD_USDGEOM usdGeom HINTS ${USD_LIBRARY_DIRECTORY}) 22 | find_library(USD_VT vt HINTS ${USD_LIBRARY_DIRECTORY}) 23 | 24 | find_package(PythonLibs REQUIRED) 25 | 26 | # 4. Include/Link Everything 27 | add_executable(run_it 28 | main.cpp 29 | ) 30 | 31 | target_include_directories(run_it 32 | PUBLIC 33 | ${PYTHON_INCLUDE_PATH} 34 | ${USD_INCLUDE_DIRECTORY} 35 | ) 36 | 37 | target_link_libraries( 38 | run_it 39 | ${PYTHON_LIBRARY} 40 | ${USD_BOOST_PYTHON} 41 | ${USD_GF} 42 | ${USD_SDF} 43 | ${USD_TF} 44 | ${USD_USDGEOM} 45 | ${USD_USD} 46 | ${USD_VT} 47 | ) 48 | -------------------------------------------------------------------------------- /tricks/traverse_instanced_prims/cpp/build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tricks/use_weaker_layers_to_modify_stronger_layers/_complex_deactivate.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "root" 4 | ) 5 | 6 | def Scope "root" 7 | { 8 | over "common_container2" ( 9 | active = false 10 | ) 11 | { 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /tricks/use_weaker_layers_to_modify_stronger_layers/_over_asset_radius_2.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "root" 4 | ) 5 | 6 | over "root" ( 7 | variants = { 8 | string size = "small" 9 | } 10 | add variantSets = "size" 11 | ) 12 | { 13 | variantSet "size" = { 14 | "another_option" { 15 | over "my_sphere" 16 | { 17 | double radius = 0.5 18 | } 19 | 20 | } 21 | "small" { 22 | over "my_sphere" 23 | { 24 | double radius = 2 25 | } 26 | 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /tricks/use_weaker_layers_to_modify_stronger_layers/_over_asset_radius_3.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "root" 4 | ) 5 | 6 | over "root" ( 7 | variants = { 8 | string size = "big" 9 | } 10 | add variantSets = "size" 11 | ) 12 | { 13 | variantSet "size" = { 14 | "another_option" { 15 | over "my_sphere" 16 | { 17 | double radius = 1 18 | } 19 | 20 | } 21 | "big" { 22 | over "my_sphere" 23 | { 24 | double radius = 3 25 | } 26 | 27 | } 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /tricks/use_weaker_layers_to_modify_stronger_layers/_state_switch_reference.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | defaultPrim = "root" 4 | ) 5 | 6 | def "root" ( 7 | add variantSets = "some_other_variant" 8 | ) 9 | { 10 | variantSet "some_other_variant" = { 11 | "do_nothing" { 12 | 13 | } 14 | "force_selection_1_in_the_geo_variant_set" ( 15 | variants = { 16 | string geo = "selection_1" 17 | } 18 | ) { 19 | 20 | } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /tricks/use_weaker_layers_to_modify_stronger_layers/complex.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | variantSets = "geo" 5 | ) 6 | { 7 | def Scope "common_container" 8 | { 9 | double radius = 2 10 | } 11 | 12 | def Scope "common_container2" 13 | { 14 | double radius = 3 15 | } 16 | 17 | def Sphere "my_sphere" ( 18 | references = 19 | ) 20 | { 21 | } 22 | variantSet "geo" = { 23 | "selection_1" { 24 | 25 | } 26 | "selection_2" ( 27 | add references = @./_complex_deactivate.usda@ 28 | ) { 29 | 30 | } 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /tricks/use_weaker_layers_to_modify_stronger_layers/nested_variant_example.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "root" ( 4 | variants = { 5 | string geo = "selection_1" 6 | } 7 | prepend variantSets = "geo" 8 | ) 9 | { 10 | variantSet "geo" = { 11 | "selection_1" ( 12 | references = 13 | ) { 14 | 15 | } 16 | "selection_2" { 17 | 18 | } 19 | } 20 | } 21 | 22 | class "_inner_variant" ( 23 | prepend variantSets = "look" 24 | ) 25 | { 26 | variantSet "look" = { 27 | "look_1" ( 28 | variants = { 29 | string geo = "selection_2" 30 | } 31 | ) { 32 | 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /tricks/use_weaker_layers_to_modify_stronger_layers/over.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Scope "some_container" ( 4 | variants = { 5 | string geo = "selection_1" 6 | } 7 | add variantSets = "geo" 8 | ) 9 | { 10 | def Sphere "my_sphere" 11 | { 12 | } 13 | variantSet "geo" = { 14 | "selection_1" ( 15 | doc = "We add a reference which adds a variant set which overs the " 16 | add references = @./_over_asset_radius_2.usda@ 17 | ) { 18 | 19 | } 20 | "selection_2" ( 21 | doc = "We add a reference which adds a variant set which overs the " 22 | add references = @./_over_asset_radius_3.usda@ 23 | ) { 24 | 25 | } 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /tricks/use_weaker_layers_to_modify_stronger_layers/simple.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | 3 | def Sphere "prim_1" ( 4 | references = 5 | variantSets = "geo" 6 | ) 7 | { 8 | variantSet "geo" = { 9 | "big" { 10 | double radius = 3 11 | 12 | } 13 | "small" { 14 | double radius = 2 15 | 16 | } 17 | } 18 | } 19 | 20 | class "controller_prim" ( 21 | doc = "This Prim can be a class or def or over. Though class or def is preferred." 22 | variantSets = "another" 23 | ) 24 | { 25 | variantSet "another" = { 26 | "selection_1" ( 27 | doc = "Switch to this variant to force " 28 | variants = { 29 | string geo = "small" 30 | } 31 | ) { 32 | 33 | } 34 | "selection_2" ( 35 | doc = "Switch to this variant to force " 36 | variants = { 37 | string geo = "big" 38 | } 39 | ) { 40 | 41 | } 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /tricks/use_weaker_layers_to_modify_stronger_layers/state_switch.usda: -------------------------------------------------------------------------------- 1 | #usda 1.0 2 | ( 3 | doc = "A variant set in a weaker layer sets variants in this layer which modify a class object." 4 | ) 5 | 6 | class "_container" ( 7 | doc = "Changes to this class object will cause all who inherit it to auto-update." 8 | references = @./_state_switch_reference.usda@ 9 | add variantSets = "geo" 10 | ) 11 | { 12 | variantSet "geo" = { 13 | "selection_1" { 14 | custom int my_attribute = 8 15 | 16 | } 17 | "selection_2" { 18 | custom int my_attribute = 16 19 | 20 | } 21 | } 22 | } 23 | 24 | def Scope "item_1" ( 25 | inherits = 26 | ) 27 | { 28 | } 29 | 30 | def Scope "item_2" ( 31 | inherits = 32 | ) 33 | { 34 | } 35 | 36 | def Scope "selection_1" ( 37 | "This Prim has a selection so changes to don't affect it." 38 | doc = "Though honestly if you want this behavior, consider `specializes` instead." 39 | inherits = 40 | ) 41 | { 42 | } 43 | 44 | -------------------------------------------------------------------------------- /tricks/variant_set_auto_selections/README.md: -------------------------------------------------------------------------------- 1 | It's possible to force a parent VariantSet to change the selection of a child 2 | VariantSet. 3 | 4 | The way you do this is to make use of 3 features: 5 | 1. non-concrete Prims (in this case, class) 6 | 2. References 7 | 3. Variants 8 | 9 | The basic Prim structure goes like this 10 | 11 | - Parent 12 | - Child that contains VariantSet(s) that we want to modify 13 | - Some VariantSet which has opinions for the child and its VariantSets 14 | 15 | The parent has a VariantSet that will author 1 Prim, which has variant 16 | selection information stored in its metadata, inside the (). In this 17 | example, this would be "/Parent/HiddenContainer". 18 | 19 | Then in the child, in this case "/Parent/ChildSphere", you add a Reference to 20 | "/Parent/HiddenContainer". Because of the way Reference pulls in the Target Prim's information, 21 | "/Parent/ChildSphere" now contains the Variant selection that is written in "/Parent/HiddenContainer"! 22 | 23 | If you open variant_set_auto_selections.usda in usdview, the effect should be obvious. Whenever you change "parent_variant_set", the "/Parent/HiddenContainer" class will change its Variant selection. "/Parent/ChildSphere" picks up this Variant selection and then uses it, as its own. 24 | --------------------------------------------------------------------------------