HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gprim.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_GPRIM_H
8 #define USDGEOM_GENERATED_GPRIM_H
9 
10 /// \file usdGeom/gprim.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 // GPRIM //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdGeomGprim
37 ///
38 /// Base class for all geometric primitives.
39 ///
40 /// Gprim encodes basic graphical properties such as \em doubleSided and
41 /// \em orientation, and provides primvars for "display color" and "display
42 /// opacity" that travel with geometry to be used as shader overrides.
43 ///
44 /// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
45 /// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
46 /// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
47 /// as the value.
48 ///
50 {
51 public:
52  /// Compile time constant representing what kind of schema this class is.
53  ///
54  /// \sa UsdSchemaKind
56 
57  /// Construct a UsdGeomGprim on UsdPrim \p prim .
58  /// Equivalent to UsdGeomGprim::Get(prim.GetStage(), prim.GetPath())
59  /// for a \em valid \p prim, but will not immediately throw an error for
60  /// an invalid \p prim
61  explicit UsdGeomGprim(const UsdPrim& prim=UsdPrim())
62  : UsdGeomBoundable(prim)
63  {
64  }
65 
66  /// Construct a UsdGeomGprim on the prim held by \p schemaObj .
67  /// Should be preferred over UsdGeomGprim(schemaObj.GetPrim()),
68  /// as it preserves SchemaBase state.
69  explicit UsdGeomGprim(const UsdSchemaBase& schemaObj)
70  : UsdGeomBoundable(schemaObj)
71  {
72  }
73 
74  /// Destructor.
76  virtual ~UsdGeomGprim();
77 
78  /// Return a vector of names of all pre-declared attributes for this schema
79  /// class and all its ancestor classes. Does not include attributes that
80  /// may be authored by custom/extended methods of the schemas involved.
82  static const TfTokenVector &
83  GetSchemaAttributeNames(bool includeInherited=true);
84 
85  /// Return a UsdGeomGprim holding the prim adhering to this
86  /// schema at \p path on \p stage. If no prim exists at \p path on
87  /// \p stage, or if the prim at that path does not adhere to this schema,
88  /// return an invalid schema object. This is shorthand for the following:
89  ///
90  /// \code
91  /// UsdGeomGprim(stage->GetPrimAtPath(path));
92  /// \endcode
93  ///
95  static UsdGeomGprim
96  Get(const UsdStagePtr &stage, const SdfPath &path);
97 
98 
99 protected:
100  /// Returns the kind of schema this class belongs to.
101  ///
102  /// \sa UsdSchemaKind
104  UsdSchemaKind _GetSchemaKind() const override;
105 
106 private:
107  // needs to invoke _GetStaticTfType.
108  friend class UsdSchemaRegistry;
110  static const TfType &_GetStaticTfType();
111 
112  static bool _IsTypedSchema();
113 
114  // override SchemaBase virtuals.
116  const TfType &_GetTfType() const override;
117 
118 public:
119  // --------------------------------------------------------------------- //
120  // DISPLAYCOLOR
121  // --------------------------------------------------------------------- //
122  /// It is useful to have an "official" colorSet that can be used
123  /// as a display or modeling color, even in the absence of any specified
124  /// shader for a gprim. DisplayColor serves this role; because it is a
125  /// UsdGeomPrimvar, it can also be used as a gprim override for any shader
126  /// that consumes a \em displayColor parameter.
127  ///
128  /// | ||
129  /// | -- | -- |
130  /// | Declaration | `color3f[] primvars:displayColor` |
131  /// | C++ Type | VtArray<GfVec3f> |
132  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Color3fArray |
135 
136  /// See GetDisplayColorAttr(), and also
137  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
138  /// If specified, author \p defaultValue as the attribute's default,
139  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
140  /// the default for \p writeSparsely is \c false.
142  UsdAttribute CreateDisplayColorAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
143 
144 public:
145  // --------------------------------------------------------------------- //
146  // DISPLAYOPACITY
147  // --------------------------------------------------------------------- //
148  /// Companion to \em displayColor that specifies opacity, broken
149  /// out as an independent attribute rather than an rgba color, both so that
150  /// each can be independently overridden, and because shaders rarely consume
151  /// rgba parameters.
152  ///
153  /// | ||
154  /// | -- | -- |
155  /// | Declaration | `float[] primvars:displayOpacity` |
156  /// | C++ Type | VtArray<float> |
157  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
160 
161  /// See GetDisplayOpacityAttr(), and also
162  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
163  /// If specified, author \p defaultValue as the attribute's default,
164  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
165  /// the default for \p writeSparsely is \c false.
167  UsdAttribute CreateDisplayOpacityAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
168 
169 public:
170  // --------------------------------------------------------------------- //
171  // DOUBLESIDED
172  // --------------------------------------------------------------------- //
173  /// Although some renderers treat all parametric or polygonal
174  /// surfaces as if they were effectively laminae with outward-facing
175  /// normals on both sides, some renderers derive significant optimizations
176  /// by considering these surfaces to have only a single outward side,
177  /// typically determined by control-point winding order and/or
178  /// \em orientation. By doing so they can perform "backface culling" to
179  /// avoid drawing the many polygons of most closed surfaces that face away
180  /// from the viewer.
181  ///
182  /// However, it is often advantageous to model thin objects such as paper
183  /// and cloth as single, open surfaces that must be viewable from both
184  /// sides, always. Setting a gprim's \em doubleSided attribute to
185  /// \c true instructs all renderers to disable optimizations such as
186  /// backface culling for the gprim, and attempt (not all renderers are able
187  /// to do so, but the USD reference GL renderer always will) to provide
188  /// forward-facing normals on each side of the surface for lighting
189  /// calculations.
190  ///
191  /// | ||
192  /// | -- | -- |
193  /// | Declaration | `uniform bool doubleSided = 0` |
194  /// | C++ Type | bool |
195  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Bool |
196  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
199 
200  /// See GetDoubleSidedAttr(), and also
201  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
202  /// If specified, author \p defaultValue as the attribute's default,
203  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
204  /// the default for \p writeSparsely is \c false.
206  UsdAttribute CreateDoubleSidedAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
207 
208 public:
209  // --------------------------------------------------------------------- //
210  // ORIENTATION
211  // --------------------------------------------------------------------- //
212  /// Orientation specifies whether the gprim's surface normal
213  /// should be computed using the right hand rule, or the left hand rule.
214  /// Please see \ref UsdGeom_WindingOrder for a deeper explanation and
215  /// generalization of orientation to composed scenes with transformation
216  /// hierarchies.
217  ///
218  /// | ||
219  /// | -- | -- |
220  /// | Declaration | `uniform token orientation = "rightHanded"` |
221  /// | C++ Type | TfToken |
222  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Token |
223  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
224  /// | \ref UsdGeomTokens "Allowed Values" | rightHanded, leftHanded |
227 
228  /// See GetOrientationAttr(), and also
229  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
230  /// If specified, author \p defaultValue as the attribute's default,
231  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
232  /// the default for \p writeSparsely is \c false.
234  UsdAttribute CreateOrientationAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
235 
236 public:
237  // ===================================================================== //
238  // Feel free to add custom code below this line, it will be preserved by
239  // the code generator.
240  //
241  // Just remember to:
242  // - Close the class declaration with };
243  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
244  // - Close the include guard with #endif
245  // ===================================================================== //
246  // --(BEGIN CUSTOM CODE)--
247 
248  /// Convenience function to get the displayColor Attribute as a Primvar.
249  ///
250  /// \sa GetDisplayColorAttr(), CreateDisplayColorPrimvar()
253 
254  /// Convenience function to create the displayColor primvar, optionally
255  /// specifying interpolation and elementSize
256  ///
257  /// \sa CreateDisplayColorAttr(), GetDisplayColorPrimvar()
260  const TfToken& interpolation = TfToken(),
261  int elementSize = -1) const;
262 
263  /// Convenience function to get the displayOpacity Attribute as a Primvar.
264  ///
265  /// \sa GetDisplayOpacityAttr(), CreateDisplayOpacityPrimvar()
268 
269  /// Convenience function to create the displayOpacity primvar, optionally
270  /// specifying interpolation and elementSize
271  ///
272  /// \sa CreateDisplayOpacityAttr(), GetDisplayOpacityPrimvar()
275  const TfToken& interpolation = TfToken(),
276  int elementSize = -1) const;
277 
278 };
279 
281 
282 #endif
USDGEOM_API UsdAttribute CreateDisplayOpacityAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDGEOM_API UsdAttribute GetDisplayColorAttr() const
UsdGeomGprim(const UsdSchemaBase &schemaObj)
Definition: gprim.h:69
USDGEOM_API UsdAttribute CreateDisplayColorAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
virtual USDGEOM_API ~UsdGeomGprim()
Destructor.
USDGEOM_API UsdGeomPrimvar CreateDisplayColorPrimvar(const TfToken &interpolation=TfToken(), int elementSize=-1) const
UsdGeomGprim(const UsdPrim &prim=UsdPrim())
Definition: gprim.h:61
USDGEOM_API UsdAttribute GetOrientationAttr() const
USDGEOM_API UsdAttribute GetDisplayOpacityAttr() const
USDGEOM_API UsdAttribute CreateOrientationAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: token.h:70
Represents a non-concrete typed schema.
static USDGEOM_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
static USDGEOM_API UsdGeomGprim Get(const UsdStagePtr &stage, const SdfPath &path)
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:273
USDGEOM_API UsdSchemaKind _GetSchemaKind() const override
USDGEOM_API UsdAttribute GetDoubleSidedAttr() const
UsdSchemaKind
Definition: common.h:112
USDGEOM_API UsdGeomPrimvar GetDisplayOpacityPrimvar() const
static const UsdSchemaKind schemaKind
Definition: gprim.h:55
USDGEOM_API UsdGeomPrimvar GetDisplayColorPrimvar() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDGEOM_API UsdAttribute CreateDoubleSidedAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
USDGEOM_API UsdGeomPrimvar CreateDisplayOpacityPrimvar(const TfToken &interpolation=TfToken(), int elementSize=-1) const
#define USDGEOM_API
Definition: api.h:23
Definition: value.h:146