HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
visibilityAPI.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 USDGEOM_GENERATED_VISIBILITYAPI_H
25 #define USDGEOM_GENERATED_VISIBILITYAPI_H
26 
27 /// \file usdGeom/visibilityAPI.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdGeom/api.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdGeom/tokens.h"
35 
36 #include "pxr/base/vt/value.h"
37 
38 #include "pxr/base/gf/vec3d.h"
39 #include "pxr/base/gf/vec3f.h"
40 #include "pxr/base/gf/matrix4d.h"
41 
42 #include "pxr/base/tf/token.h"
43 #include "pxr/base/tf/type.h"
44 
46 
47 class SdfAssetPath;
48 
49 // -------------------------------------------------------------------------- //
50 // VISIBILITYAPI //
51 // -------------------------------------------------------------------------- //
52 
53 /// \class UsdGeomVisibilityAPI
54 ///
55 ///
56 /// UsdGeomVisibilityAPI introduces properties that can be used to author
57 /// visibility opinions.
58 ///
59 /// \note
60 /// Currently, this schema only introduces the attributes that are used to
61 /// control purpose visibility. Later, this schema will define _all_
62 /// visibility-related properties and UsdGeomImageable will no longer define
63 /// those properties.
64 ///
65 /// The purpose visibility attributes added by this schema,
66 /// _guideVisibility_, _proxyVisibility_, and _renderVisibility_ can each be
67 /// used to control visibility for geometry of the corresponding purpose
68 /// values, with the overall _visibility_ attribute acting as an
69 /// override. I.e., if _visibility_ evaluates to "invisible", purpose
70 /// visibility is invisible; otherwise, purpose visibility is determined by
71 /// the corresponding purpose visibility attribute.
72 ///
73 /// Note that the behavior of _guideVisibility_ is subtly different from the
74 /// _proxyVisibility_ and _renderVisibility_ attributes, in that "guide"
75 /// purpose visibility always evaluates to either "invisible" or "visible",
76 /// whereas the other attributes may yield computed values of "inherited" if
77 /// there is no authored opinion on the attribute or inherited from an
78 /// ancestor. This is motivated by the fact that, in Pixar"s user workflows,
79 /// we have never found a need to have all guides visible in a scene by
80 /// default, whereas we do find that flexibility useful for "proxy" and
81 /// "render" geometry.
82 ///
83 /// This schema can only be applied to UsdGeomImageable prims. The
84 /// UseGeomImageable schema provides API for computing the purpose visibility
85 /// values that result from the attributes introduced by this schema.
86 ///
87 ///
88 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
89 /// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
90 /// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
91 /// as the value.
92 ///
94 {
95 public:
96  /// Compile time constant representing what kind of schema this class is.
97  ///
98  /// \sa UsdSchemaKind
100 
101  /// Construct a UsdGeomVisibilityAPI on UsdPrim \p prim .
102  /// Equivalent to UsdGeomVisibilityAPI::Get(prim.GetStage(), prim.GetPath())
103  /// for a \em valid \p prim, but will not immediately throw an error for
104  /// an invalid \p prim
105  explicit UsdGeomVisibilityAPI(const UsdPrim& prim=UsdPrim())
106  : UsdAPISchemaBase(prim)
107  {
108  }
109 
110  /// Construct a UsdGeomVisibilityAPI on the prim held by \p schemaObj .
111  /// Should be preferred over UsdGeomVisibilityAPI(schemaObj.GetPrim()),
112  /// as it preserves SchemaBase state.
113  explicit UsdGeomVisibilityAPI(const UsdSchemaBase& schemaObj)
114  : UsdAPISchemaBase(schemaObj)
115  {
116  }
117 
118  /// Destructor.
120  virtual ~UsdGeomVisibilityAPI();
121 
122  /// Return a vector of names of all pre-declared attributes for this schema
123  /// class and all its ancestor classes. Does not include attributes that
124  /// may be authored by custom/extended methods of the schemas involved.
126  static const TfTokenVector &
127  GetSchemaAttributeNames(bool includeInherited=true);
128 
129  /// Return a UsdGeomVisibilityAPI holding the prim adhering to this
130  /// schema at \p path on \p stage. If no prim exists at \p path on
131  /// \p stage, or if the prim at that path does not adhere to this schema,
132  /// return an invalid schema object. This is shorthand for the following:
133  ///
134  /// \code
135  /// UsdGeomVisibilityAPI(stage->GetPrimAtPath(path));
136  /// \endcode
137  ///
139  static UsdGeomVisibilityAPI
140  Get(const UsdStagePtr &stage, const SdfPath &path);
141 
142 
143  /// Returns true if this <b>single-apply</b> API schema can be applied to
144  /// the given \p prim. If this schema can not be a applied to the prim,
145  /// this returns false and, if provided, populates \p whyNot with the
146  /// reason it can not be applied.
147  ///
148  /// Note that if CanApply returns false, that does not necessarily imply
149  /// that calling Apply will fail. Callers are expected to call CanApply
150  /// before calling Apply if they want to ensure that it is valid to
151  /// apply a schema.
152  ///
153  /// \sa UsdPrim::GetAppliedSchemas()
154  /// \sa UsdPrim::HasAPI()
155  /// \sa UsdPrim::CanApplyAPI()
156  /// \sa UsdPrim::ApplyAPI()
157  /// \sa UsdPrim::RemoveAPI()
158  ///
160  static bool
161  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
162 
163  /// Applies this <b>single-apply</b> API schema to the given \p prim.
164  /// This information is stored by adding "VisibilityAPI" to the
165  /// token-valued, listOp metadata \em apiSchemas on the prim.
166  ///
167  /// \return A valid UsdGeomVisibilityAPI object is returned upon success.
168  /// An invalid (or empty) UsdGeomVisibilityAPI object is returned upon
169  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
170  /// resulting in failure.
171  ///
172  /// \sa UsdPrim::GetAppliedSchemas()
173  /// \sa UsdPrim::HasAPI()
174  /// \sa UsdPrim::CanApplyAPI()
175  /// \sa UsdPrim::ApplyAPI()
176  /// \sa UsdPrim::RemoveAPI()
177  ///
179  static UsdGeomVisibilityAPI
180  Apply(const UsdPrim &prim);
181 
182 protected:
183  /// Returns the kind of schema this class belongs to.
184  ///
185  /// \sa UsdSchemaKind
187  UsdSchemaKind _GetSchemaKind() const override;
188 
189 private:
190  // needs to invoke _GetStaticTfType.
191  friend class UsdSchemaRegistry;
193  static const TfType &_GetStaticTfType();
194 
195  static bool _IsTypedSchema();
196 
197  // override SchemaBase virtuals.
199  const TfType &_GetTfType() const override;
200 
201 public:
202  // --------------------------------------------------------------------- //
203  // GUIDEVISIBILITY
204  // --------------------------------------------------------------------- //
205  ///
206  /// This attribute controls visibility for geometry with purpose "guide".
207  ///
208  /// Unlike overall _visibility_, _guideVisibility_ is uniform, and
209  /// therefore cannot be animated.
210  ///
211  /// Also unlike overall _visibility_, _guideVisibility_ is tri-state, in
212  /// that a descendant with an opinion of "visible" overrides an ancestor
213  /// opinion of "invisible".
214  ///
215  /// The _guideVisibility_ attribute works in concert with the overall
216  /// _visibility_ attribute: The visibility of a prim with purpose "guide"
217  /// is determined by the inherited values it receives for the _visibility_
218  /// and _guideVisibility_ attributes. If _visibility_ evaluates to
219  /// "invisible", the prim is invisible. If _visibility_ evaluates to
220  /// "inherited" and _guideVisibility_ evaluates to "visible", then the
221  /// prim is visible. __Otherwise, it is invisible.__
222  ///
223  ///
224  /// | ||
225  /// | -- | -- |
226  /// | Declaration | `uniform token guideVisibility = "invisible"` |
227  /// | C++ Type | TfToken |
228  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
229  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
230  /// | \ref UsdGeomTokens "Allowed Values" | inherited, invisible, visible |
233 
234  /// See GetGuideVisibilityAttr(), and also
235  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
236  /// If specified, author \p defaultValue as the attribute's default,
237  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
238  /// the default for \p writeSparsely is \c false.
240  UsdAttribute CreateGuideVisibilityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
241 
242 public:
243  // --------------------------------------------------------------------- //
244  // PROXYVISIBILITY
245  // --------------------------------------------------------------------- //
246  ///
247  /// This attribute controls visibility for geometry with purpose "proxy".
248  ///
249  /// Unlike overall _visibility_, _proxyVisibility_ is uniform, and
250  /// therefore cannot be animated.
251  ///
252  /// Also unlike overall _visibility_, _proxyVisibility_ is tri-state, in
253  /// that a descendant with an opinion of "visible" overrides an ancestor
254  /// opinion of "invisible".
255  ///
256  /// The _proxyVisibility_ attribute works in concert with the overall
257  /// _visibility_ attribute: The visibility of a prim with purpose "proxy"
258  /// is determined by the inherited values it receives for the _visibility_
259  /// and _proxyVisibility_ attributes. If _visibility_ evaluates to
260  /// "invisible", the prim is invisible. If _visibility_ evaluates to
261  /// "inherited" then: If _proxyVisibility_ evaluates to "visible", then
262  /// the prim is visible; if _proxyVisibility_ evaluates to "invisible",
263  /// then the prim is invisible; if _proxyVisibility_ evaluates to
264  /// "inherited", then the prim may either be visible or invisible,
265  /// depending on a fallback value determined by the calling context.
266  ///
267  ///
268  /// | ||
269  /// | -- | -- |
270  /// | Declaration | `uniform token proxyVisibility = "inherited"` |
271  /// | C++ Type | TfToken |
272  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
273  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
274  /// | \ref UsdGeomTokens "Allowed Values" | inherited, invisible, visible |
277 
278  /// See GetProxyVisibilityAttr(), and also
279  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
280  /// If specified, author \p defaultValue as the attribute's default,
281  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
282  /// the default for \p writeSparsely is \c false.
284  UsdAttribute CreateProxyVisibilityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
285 
286 public:
287  // --------------------------------------------------------------------- //
288  // RENDERVISIBILITY
289  // --------------------------------------------------------------------- //
290  ///
291  /// This attribute controls visibility for geometry with purpose
292  /// "render".
293  ///
294  /// Unlike overall _visibility_, _renderVisibility_ is uniform, and
295  /// therefore cannot be animated.
296  ///
297  /// Also unlike overall _visibility_, _renderVisibility_ is tri-state, in
298  /// that a descendant with an opinion of "visible" overrides an ancestor
299  /// opinion of "invisible".
300  ///
301  /// The _renderVisibility_ attribute works in concert with the overall
302  /// _visibility_ attribute: The visibility of a prim with purpose "render"
303  /// is determined by the inherited values it receives for the _visibility_
304  /// and _renderVisibility_ attributes. If _visibility_ evaluates to
305  /// "invisible", the prim is invisible. If _visibility_ evaluates to
306  /// "inherited" then: If _renderVisibility_ evaluates to "visible", then
307  /// the prim is visible; if _renderVisibility_ evaluates to "invisible",
308  /// then the prim is invisible; if _renderVisibility_ evaluates to
309  /// "inherited", then the prim may either be visible or invisible,
310  /// depending on a fallback value determined by the calling context.
311  ///
312  ///
313  /// | ||
314  /// | -- | -- |
315  /// | Declaration | `uniform token renderVisibility = "inherited"` |
316  /// | C++ Type | TfToken |
317  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
318  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
319  /// | \ref UsdGeomTokens "Allowed Values" | inherited, invisible, visible |
322 
323  /// See GetRenderVisibilityAttr(), and also
324  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
325  /// If specified, author \p defaultValue as the attribute's default,
326  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
327  /// the default for \p writeSparsely is \c false.
329  UsdAttribute CreateRenderVisibilityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
330 
331 public:
332  // ===================================================================== //
333  // Feel free to add custom code below this line, it will be preserved by
334  // the code generator.
335  //
336  // Just remember to:
337  // - Close the class declaration with };
338  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
339  // - Close the include guard with #endif
340  // ===================================================================== //
341  // --(BEGIN CUSTOM CODE)--
342 
343  /// Return the attribute that is used for expressing visibility opinions
344  /// for the given \p purpose.
345  ///
346  /// The valid purpose tokens are "guide", "proxy", and "render" which
347  /// return the attributes *guideVisibility*, *proxyVisibility*, and
348  /// *renderVisibility* respectively.
349  ///
350  /// Note that while "default" is a valid purpose token for
351  /// UsdGeomImageable::GetPurposeVisibilityAttr, it is not a valid purpose
352  /// for this function, as UsdGeomVisibilityAPI itself does not have a
353  /// default visibility attribute. Calling this function with "default
354  /// will result in a coding error.
355  ///
357  UsdAttribute GetPurposeVisibilityAttr(const TfToken &purpose) const;
358 };
359 
361 
362 #endif
static const UsdSchemaKind schemaKind
Definition: visibilityAPI.h:99
static USDGEOM_API UsdGeomVisibilityAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Single Apply API schema.
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDGEOM_API UsdAttribute GetGuideVisibilityAttr() const
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
static USDGEOM_API UsdGeomVisibilityAPI Apply(const UsdPrim &prim)
USDGEOM_API UsdAttribute CreateProxyVisibilityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: token.h:87
static USDGEOM_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
USDGEOM_API UsdAttribute GetPurposeVisibilityAttr(const TfToken &purpose) const
virtual USDGEOM_API ~UsdGeomVisibilityAPI()
Destructor.
USDGEOM_API UsdAttribute CreateGuideVisibilityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:133
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
USDGEOM_API UsdAttribute GetProxyVisibilityAttr() const
Definition: path.h:290
UsdGeomVisibilityAPI(const UsdSchemaBase &schemaObj)
UsdSchemaKind
Definition: common.h:129
UsdGeomVisibilityAPI(const UsdPrim &prim=UsdPrim())
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: type.h:64
#define USDGEOM_API
Definition: api.h:40
USDGEOM_API UsdAttribute CreateRenderVisibilityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: value.h:164
USDGEOM_API UsdAttribute GetRenderVisibilityAttr() const