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