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