HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
particleFieldOrientationAttributeAPI.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 USDVOL_GENERATED_PARTICLEFIELDORIENTATIONATTRIBUTEAPI_H
8 #define USDVOL_GENERATED_PARTICLEFIELDORIENTATIONATTRIBUTEAPI_H
9 
10 /// \file usdVol/particleFieldOrientationAttributeAPI.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdVol/api.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "pxr/usd/usdVol/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 // PARTICLEFIELDORIENTATIONATTRIBUTEAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdVolParticleFieldOrientationAttributeAPI
37 ///
38 /// A ParticleField related applied schema that provides an
39 /// orientations attribute to define the orientation of the particles.
40 ///
41 /// Attributes are provided in both `float` and `half` types for some
42 /// easy data footprint affordance, data consumers should prefer
43 /// `float` version if available.
44 ///
45 /// The length of this attribute is expected to match the length of
46 /// the provided position data. If it is too long it will be truncated
47 /// to the number of particles define by the position data. If it is
48 /// too short it will be ignored.
49 ///
50 /// If the attribute is ignored or not populated, then a default value
51 /// of no rotation should be applied to the kernel instantiated at each
52 /// particle.
53 ///
55 {
56 public:
57  /// Compile time constant representing what kind of schema this class is.
58  ///
59  /// \sa UsdSchemaKind
61 
62  /// Construct a UsdVolParticleFieldOrientationAttributeAPI on UsdPrim \p prim .
63  /// Equivalent to UsdVolParticleFieldOrientationAttributeAPI::Get(prim.GetStage(), prim.GetPath())
64  /// for a \em valid \p prim, but will not immediately throw an error for
65  /// an invalid \p prim
67  : UsdAPISchemaBase(prim)
68  {
69  }
70 
71  /// Construct a UsdVolParticleFieldOrientationAttributeAPI on the prim held by \p schemaObj .
72  /// Should be preferred over UsdVolParticleFieldOrientationAttributeAPI(schemaObj.GetPrim()),
73  /// as it preserves SchemaBase state.
75  : UsdAPISchemaBase(schemaObj)
76  {
77  }
78 
79  /// Destructor.
82 
83  /// Return a vector of names of all pre-declared attributes for this schema
84  /// class and all its ancestor classes. Does not include attributes that
85  /// may be authored by custom/extended methods of the schemas involved.
87  static const TfTokenVector &
88  GetSchemaAttributeNames(bool includeInherited=true);
89 
90  /// Return a UsdVolParticleFieldOrientationAttributeAPI holding the prim adhering to this
91  /// schema at \p path on \p stage. If no prim exists at \p path on
92  /// \p stage, or if the prim at that path does not adhere to this schema,
93  /// return an invalid schema object. This is shorthand for the following:
94  ///
95  /// \code
96  /// UsdVolParticleFieldOrientationAttributeAPI(stage->GetPrimAtPath(path));
97  /// \endcode
98  ///
101  Get(const UsdStagePtr &stage, const SdfPath &path);
102 
103 
104  /// Returns true if this <b>single-apply</b> API schema can be applied to
105  /// the given \p prim. If this schema can not be a applied to the prim,
106  /// this returns false and, if provided, populates \p whyNot with the
107  /// reason it can not be applied.
108  ///
109  /// Note that if CanApply returns false, that does not necessarily imply
110  /// that calling Apply will fail. Callers are expected to call CanApply
111  /// before calling Apply if they want to ensure that it is valid to
112  /// apply a schema.
113  ///
114  /// \sa UsdPrim::GetAppliedSchemas()
115  /// \sa UsdPrim::HasAPI()
116  /// \sa UsdPrim::CanApplyAPI()
117  /// \sa UsdPrim::ApplyAPI()
118  /// \sa UsdPrim::RemoveAPI()
119  ///
120  USDVOL_API
121  static bool
122  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
123 
124  /// Applies this <b>single-apply</b> API schema to the given \p prim.
125  /// This information is stored by adding "ParticleFieldOrientationAttributeAPI" to the
126  /// token-valued, listOp metadata \em apiSchemas on the prim.
127  ///
128  /// \return A valid UsdVolParticleFieldOrientationAttributeAPI object is returned upon success.
129  /// An invalid (or empty) UsdVolParticleFieldOrientationAttributeAPI object is returned upon
130  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
131  /// resulting in failure.
132  ///
133  /// \sa UsdPrim::GetAppliedSchemas()
134  /// \sa UsdPrim::HasAPI()
135  /// \sa UsdPrim::CanApplyAPI()
136  /// \sa UsdPrim::ApplyAPI()
137  /// \sa UsdPrim::RemoveAPI()
138  ///
139  USDVOL_API
141  Apply(const UsdPrim &prim);
142 
143 protected:
144  /// Returns the kind of schema this class belongs to.
145  ///
146  /// \sa UsdSchemaKind
147  USDVOL_API
148  UsdSchemaKind _GetSchemaKind() const override;
149 
150 private:
151  // needs to invoke _GetStaticTfType.
152  friend class UsdSchemaRegistry;
153  USDVOL_API
154  static const TfType &_GetStaticTfType();
155 
156  static bool _IsTypedSchema();
157 
158  // override SchemaBase virtuals.
159  USDVOL_API
160  const TfType &_GetTfType() const override;
161 
162 public:
163  // --------------------------------------------------------------------- //
164  // ORIENTATIONS
165  // --------------------------------------------------------------------- //
166  /// Quaternion orientation for each particle.
167  ///
168  /// | ||
169  /// | -- | -- |
170  /// | Declaration | `quatf[] orientations` |
171  /// | C++ Type | VtArray<GfQuatf> |
172  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->QuatfArray |
173  USDVOL_API
175 
176  /// See GetOrientationsAttr(), and also
177  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
178  /// If specified, author \p defaultValue as the attribute's default,
179  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
180  /// the default for \p writeSparsely is \c false.
181  USDVOL_API
182  UsdAttribute CreateOrientationsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
183 
184 public:
185  // --------------------------------------------------------------------- //
186  // ORIENTATIONSH
187  // --------------------------------------------------------------------- //
188  /// Quaternion orientation for each particle. If the float
189  /// precision version is defined it should be preferred.
190  ///
191  /// | ||
192  /// | -- | -- |
193  /// | Declaration | `quath[] orientationsh` |
194  /// | C++ Type | VtArray<GfQuath> |
195  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->QuathArray |
196  USDVOL_API
198 
199  /// See GetOrientationshAttr(), and also
200  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
201  /// If specified, author \p defaultValue as the attribute's default,
202  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
203  /// the default for \p writeSparsely is \c false.
204  USDVOL_API
205  UsdAttribute CreateOrientationshAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
206 
207 public:
208  // ===================================================================== //
209  // Feel free to add custom code below this line, it will be preserved by
210  // the code generator.
211  //
212  // Just remember to:
213  // - Close the class declaration with };
214  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
215  // - Close the include guard with #endif
216  // ===================================================================== //
217  // --(BEGIN CUSTOM CODE)--
218 };
219 
221 
222 #endif
Single Apply API schema.
UsdVolParticleFieldOrientationAttributeAPI(const UsdPrim &prim=UsdPrim())
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDVOL_API UsdSchemaKind _GetSchemaKind() const override
USDVOL_API UsdAttribute CreateOrientationshAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDVOL_API UsdAttribute CreateOrientationsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDVOL_API UsdAttribute GetOrientationsAttr() const
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
static USDVOL_API UsdVolParticleFieldOrientationAttributeAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Definition: path.h:280
USDVOL_API UsdAttribute GetOrientationshAttr() const
UsdSchemaKind
Definition: common.h:112
UsdVolParticleFieldOrientationAttributeAPI(const UsdSchemaBase &schemaObj)
static USDVOL_API UsdVolParticleFieldOrientationAttributeAPI Apply(const UsdPrim &prim)
static USDVOL_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
virtual USDVOL_API ~UsdVolParticleFieldOrientationAttributeAPI()
Destructor.
Definition: type.h:47
#define USDVOL_API
Definition: api.h:23
static USDVOL_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Definition: value.h:89