HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pipeline.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_USD_UTILS_PIPELINE_H
8 #define PXR_USD_USD_UTILS_PIPELINE_H
9 
10 /// \file usdUtils/pipeline.h
11 ///
12 /// Collection of module-scoped utilities for establishing pipeline
13 /// conventions for things not currently suitable or possible to canonize in
14 /// USD's schema modules.
15 
16 #include "pxr/pxr.h"
17 #include "pxr/usd/usdUtils/api.h"
19 
20 #include "pxr/base/tf/envSetting.h"
21 #include "pxr/base/tf/token.h"
23 #include "pxr/usd/sdf/path.h"
24 #include "pxr/usd/usd/common.h"
25 
27 
29 
32 
35 
36 /// Define the shading pipeline's convention for naming a companion
37 /// alpha/opacity attribute and primvarnames given the full name of a
38 /// color-valued attribute
41 
42 /// Returns the model name associated with a given root layer. In order,
43 /// it looks for defaultPrim metadata, a prim matching the filename,
44 /// and then the first concrete root prim.
46 TfToken UsdUtilsGetModelNameFromRootLayer(const SdfLayerHandle& rootLayer);
47 
48 /// Certain variant sets can be registered with the system.
49 ///
50 /// Returns the set of UsdUtilsRegisteredVariantSet objects that are registered
51 /// with the pipeline.
52 ///
53 /// Variant sets can be registered through direct enumeration inside a
54 /// `plugInfo.json`, or via a plugin for situations that require dynamic
55 /// configuration at runtime.
56 ///
57 /// This list will be empty until one or more `plugInfo.json` files
58 /// discoverable by your USD installation contain an entry in the
59 /// UsdUtilsPipeline group like the following:
60 /// \code{json}
61 /// "UsdUtilsPipeline": {
62 /// "RegisteredVariantSets": {
63 /// "modelingVariant": {
64 /// "selectionExportPolicy": "always"
65 /// },
66 /// "standin": {
67 /// "selectionExportPolicy": "never"
68 /// }
69 /// }
70 /// }
71 /// \endcode
72 ///
73 /// After the above variantSets are registered, this will then load any plugin
74 /// that has a `plugInfo.json` with:
75 ///
76 /// \code{json}
77 /// "UsdUtilsPipeline": {
78 /// "RegistersVariantSets": true
79 /// }
80 /// \endcode
81 ///
82 /// This plugin should then have code that registers code to run for
83 /// `UsdUtilsRegisteredVariantSet`:
84 /// \code{cpp}
85 /// TF_REGISTRY_FUNCTION(UsdUtilsRegisteredVariantSet) {
86 /// std::string variantSetName = ...;
87 /// UsdUtilsRegisteredVariantSet::SelectionExportPolicy exportPolicy = ...;
88 /// UsdUtilsRegisterVariantSet(variantSetName, exportPolicy);
89 /// }
90 /// \endcode
91 ///
92 /// \sa UsdUtilsRegisterVariantSet
94 const std::set<UsdUtilsRegisteredVariantSet>& UsdUtilsGetRegisteredVariantSets();
95 
96 /// Registers \p variantSetName with \p selectionExportPolicy.
97 ///
98 /// \sa UsdUtilsGetRegisteredVariantSets
101  const std::string& variantSetName,
103  selectionExportPolicy);
104 
105 /// If a valid UsdPrim already exists at \p path on the USD stage \p stage,
106 /// returns it. It not, it checks to see if the path belongs to a prim
107 /// underneath an instance and returns the corresponding prototype prim.
108 ///
109 /// This returns an invalid UsdPrim if no corresponding prototype prim can be
110 /// found and if no prim exists at the path.
111 ///
112 /// This method is similar to UsdStage::GetPrimAtPath(), in that it will never
113 /// author scene description, and therefore is safe to use as a "reader" in the
114 /// Usd multi-threading model.
116 UsdPrim UsdUtilsGetPrimAtPathWithForwarding(const UsdStagePtr &stage,
117  const SdfPath &path);
118 
119 /// Given a path, uninstances all the instanced prims in the namespace chain and
120 /// returns the resulting prim at the requested path. Returns a NULL prim if the
121 /// given path doesn't exist and does not correspond to a valid prim inside a
122 /// prototype.
124 UsdPrim UsdUtilsUninstancePrimAtPath(const UsdStagePtr &stage,
125  const SdfPath &path);
126 
127 /// Returns the name of the primary UV set used on meshes and nurbs.
128 /// By default the name is "st".
131 
132 /// Returns the name of the reference position used on meshes and nurbs.
133 /// By default the name is "pref".
136 
137 /// Get the name of the USD prim under which materials are expected to be
138 /// authored.
139 ///
140 /// The scope name can be configured in the metadata of a plugInfo.json file
141 /// like so:
142 /// \code{json}
143 /// "UsdUtilsPipeline": {
144 /// "MaterialsScopeName": "SomeScopeName"
145 /// }
146 /// \endcode
147 ///
148 /// If \p forceDefault is true, any value specified in a plugInfo.json will be
149 /// ignored and the built-in default will be returned. This is primarily used
150 /// for unit testing purposes as a way to ignore any site-based configuration.
152 TfToken UsdUtilsGetMaterialsScopeName(const bool forceDefault = false);
153 
154 /// Get the name of the USD prim representing the primary camera.
155 /// By default the name is "main_cam".
156 ///
157 /// The camera name can be configured in the metadata of a plugInfo.json file
158 /// like so:
159 /// \code{json}
160 /// "UsdUtilsPipeline": {
161 /// "PrimaryCameraName": "SomeCameraName"
162 /// }
163 /// \endcode
164 ///
165 /// If \p forceDefault is true, any value specified in a plugInfo.json will be
166 /// ignored and the built-in default will be returned. This is primarily used
167 /// for unit testing purposes as a way to ignore any site-based configuration.
169 TfToken UsdUtilsGetPrimaryCameraName(const bool forceDefault = false);
170 
172 
173 #endif
Definition: layer.h:81
USDUTILS_API const TfToken & UsdUtilsGetPrimaryUVSetName()
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDUTILS_API TfToken UsdUtilsGetModelNameFromRootLayer(const SdfLayerHandle &rootLayer)
USDUTILS_API void UsdUtilsRegisterVariantSet(const std::string &variantSetName, const UsdUtilsRegisteredVariantSet::SelectionExportPolicy &selectionExportPolicy)
USDUTILS_API UsdPrim UsdUtilsGetPrimAtPathWithForwarding(const UsdStagePtr &stage, const SdfPath &path)
USDUTILS_API TfEnvSetting< bool > USD_FORCE_DEFAULT_MATERIALS_SCOPE_NAME
Definition: token.h:70
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)
USDUTILS_API TfToken UsdUtilsGetPrimaryCameraName(const bool forceDefault=false)
USDUTILS_API const TfToken & UsdUtilsGetPrefName()
Definition: prim.h:116
Definition: path.h:280
USDUTILS_API TfEnvSetting< bool > USD_POPULATE_LEGACY_ALLOWED_TOKENS
USDUTILS_API TfToken UsdUtilsGetMaterialsScopeName(const bool forceDefault=false)
USDUTILS_API const std::set< UsdUtilsRegisteredVariantSet > & UsdUtilsGetRegisteredVariantSets()
USDUTILS_API UsdPrim UsdUtilsUninstancePrimAtPath(const UsdStagePtr &stage, const SdfPath &path)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
#define USDUTILS_API
Definition: api.h:23
USDUTILS_API TfToken UsdUtilsGetAlphaAttributeNameForColor(TfToken const &colorAttrName)