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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_USD_UTILS_PIPELINE_H
25 #define PXR_USD_USD_UTILS_PIPELINE_H
26 
27 /// \file usdUtils/pipeline.h
28 ///
29 /// Collection of module-scoped utilities for establishing pipeline
30 /// conventions for things not currently suitable or possible to canonize in
31 /// USD's schema modules.
32 
33 #include "pxr/pxr.h"
34 #include "pxr/usd/usdUtils/api.h"
36 
37 #include "pxr/base/tf/envSetting.h"
38 #include "pxr/base/tf/token.h"
40 #include "pxr/usd/sdf/path.h"
41 #include "pxr/usd/usd/common.h"
42 
44 
46 
49 
50 /// Define the shading pipeline's convention for naming a companion
51 /// alpha/opacity attribute and primvarnames given the full name of a
52 /// color-valued attribute
55 
56 /// Returns the model name associated with a given root layer. In order,
57 /// it looks for defaultPrim metadata, a prim matching the filename,
58 /// and then the first concrete root prim.
60 TfToken UsdUtilsGetModelNameFromRootLayer(const SdfLayerHandle& rootLayer);
61 
62 /// Certain variant sets can be registered with the system.
63 ///
64 /// Returns the set of UsdUtilsRegisteredVariantSet objects that are registered
65 /// with the pipeline.
66 ///
67 /// Variant sets can be registered through direct enumeration inside a
68 /// `plugInfo.json`, or via a plugin for situations that require dynamic
69 /// configuration at runtime.
70 ///
71 /// This list will be empty until one or more `plugInfo.json` files
72 /// discoverable by your USD installation contain an entry in the
73 /// UsdUtilsPipeline group like the following:
74 /// \code{json}
75 /// "UsdUtilsPipeline": {
76 /// "RegisteredVariantSets": {
77 /// "modelingVariant": {
78 /// "selectionExportPolicy": "always"
79 /// },
80 /// "standin": {
81 /// "selectionExportPolicy": "never"
82 /// }
83 /// }
84 /// }
85 /// \endcode
86 ///
87 /// After the above variantSets are registered, this will then load any plugin
88 /// that has a `plugInfo.json` with:
89 ///
90 /// \code{json}
91 /// "UsdUtilsPipeline": {
92 /// "RegistersVariantSets": true
93 /// }
94 /// \endcode
95 ///
96 /// This plugin should then have code that registers code to run for
97 /// `UsdUtilsRegisteredVariantSet`:
98 /// \code{cpp}
99 /// TF_REGISTRY_FUNCTION(UsdUtilsRegisteredVariantSet) {
100 /// std::string variantSetName = ...;
101 /// UsdUtilsRegisteredVariantSet::SelectionExportPolicy exportPolicy = ...;
102 /// UsdUtilsRegisterVariantSet(variantSetName, exportPolicy);
103 /// }
104 /// \endcode
105 ///
106 /// \sa UsdUtilsRegisterVariantSet
108 const std::set<UsdUtilsRegisteredVariantSet>& UsdUtilsGetRegisteredVariantSets();
109 
110 /// Registers \p variantSetName with \p selectionExportPolicy.
111 ///
112 /// \sa UsdUtilsGetRegisteredVariantSets
115  const std::string& variantSetName,
117  selectionExportPolicy);
118 
119 /// If a valid UsdPrim already exists at \p path on the USD stage \p stage,
120 /// returns it. It not, it checks to see if the path belongs to a prim
121 /// underneath an instance and returns the corresponding prototype prim.
122 ///
123 /// This returns an invalid UsdPrim if no corresponding prototype prim can be
124 /// found and if no prim exists at the path.
125 ///
126 /// This method is similar to UsdStage::GetPrimAtPath(), in that it will never
127 /// author scene description, and therefore is safe to use as a "reader" in the
128 /// Usd multi-threading model.
130 UsdPrim UsdUtilsGetPrimAtPathWithForwarding(const UsdStagePtr &stage,
131  const SdfPath &path);
132 
133 /// Given a path, uninstances all the instanced prims in the namespace chain and
134 /// returns the resulting prim at the requested path. Returns a NULL prim if the
135 /// given path doesn't exist and does not correspond to a valid prim inside a
136 /// prototype.
138 UsdPrim UsdUtilsUninstancePrimAtPath(const UsdStagePtr &stage,
139  const SdfPath &path);
140 
141 /// Returns the name of the primary UV set used on meshes and nurbs.
142 /// By default the name is "st".
145 
146 /// Returns the name of the reference position used on meshes and nurbs.
147 /// By default the name is "pref".
150 
151 /// Get the name of the USD prim under which materials are expected to be
152 /// authored.
153 ///
154 /// The scope name can be configured in the metadata of a plugInfo.json file
155 /// like so:
156 /// \code{json}
157 /// "UsdUtilsPipeline": {
158 /// "MaterialsScopeName": "SomeScopeName"
159 /// }
160 /// \endcode
161 ///
162 /// If \p forceDefault is true, any value specified in a plugInfo.json will be
163 /// ignored and the built-in default will be returned. This is primarily used
164 /// for unit testing purposes as a way to ignore any site-based configuration.
166 TfToken UsdUtilsGetMaterialsScopeName(const bool forceDefault = false);
167 
168 /// Get the name of the USD prim representing the primary camera.
169 /// By default the name is "main_cam".
170 ///
171 /// The camera name can be configured in the metadata of a plugInfo.json file
172 /// like so:
173 /// \code{json}
174 /// "UsdUtilsPipeline": {
175 /// "PrimaryCameraName": "SomeCameraName"
176 /// }
177 /// \endcode
178 ///
179 /// If \p forceDefault is true, any value specified in a plugInfo.json will be
180 /// ignored and the built-in default will be returned. This is primarily used
181 /// for unit testing purposes as a way to ignore any site-based configuration.
183 TfToken UsdUtilsGetPrimaryCameraName(const bool forceDefault = false);
184 
186 
187 #endif
Definition: layer.h:97
USDUTILS_API const TfToken & UsdUtilsGetPrimaryUVSetName()
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
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:87
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfLayer)
USDUTILS_API TfToken UsdUtilsGetPrimaryCameraName(const bool forceDefault=false)
USDUTILS_API const TfToken & UsdUtilsGetPrefName()
Definition: prim.h:133
Definition: path.h:290
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
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:91
#define USDUTILS_API
Definition: api.h:40
USDUTILS_API TfToken UsdUtilsGetAlphaAttributeNameForColor(TfToken const &colorAttrName)