HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
particleFieldPositionAttributeAPI.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_PARTICLEFIELDPOSITIONATTRIBUTEAPI_H
8 #define USDVOL_GENERATED_PARTICLEFIELDPOSITIONATTRIBUTEAPI_H
9 
10 /// \file usdVol/particleFieldPositionAttributeAPI.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 
20 
21 
22 #include "pxr/base/vt/value.h"
23 
24 #include "pxr/base/gf/vec3d.h"
25 #include "pxr/base/gf/vec3f.h"
26 #include "pxr/base/gf/matrix4d.h"
27 
28 #include "pxr/base/tf/token.h"
29 #include "pxr/base/tf/type.h"
30 
32 
33 class SdfAssetPath;
34 
35 // -------------------------------------------------------------------------- //
36 // PARTICLEFIELDPOSITIONATTRIBUTEAPI //
37 // -------------------------------------------------------------------------- //
38 
39 /// \class UsdVolParticleFieldPositionAttributeAPI
40 ///
41 /// A ParticleField related applied schema that provides a position
42 /// attribute to define the locations of the particles.
43 ///
44 /// Attributes are provided in both `float` and `half` types for some
45 /// easy data footprint affordance, data consumers should prefer
46 /// `float` version if available.
47 ///
48 /// The size of the positions attribute that is being used defines the
49 /// number of particles in the field. If no positions attribute is
50 /// provided then the ParticleField has no particles.
51 ///
53 {
54 public:
55  /// Compile time constant representing what kind of schema this class is.
56  ///
57  /// \sa UsdSchemaKind
59 
60  /// Construct a UsdVolParticleFieldPositionAttributeAPI on UsdPrim \p prim .
61  /// Equivalent to UsdVolParticleFieldPositionAttributeAPI::Get(prim.GetStage(), prim.GetPath())
62  /// for a \em valid \p prim, but will not immediately throw an error for
63  /// an invalid \p prim
65  : UsdAPISchemaBase(prim)
66  {
67  }
68 
69  /// Construct a UsdVolParticleFieldPositionAttributeAPI on the prim held by \p schemaObj .
70  /// Should be preferred over UsdVolParticleFieldPositionAttributeAPI(schemaObj.GetPrim()),
71  /// as it preserves SchemaBase state.
73  : UsdAPISchemaBase(schemaObj)
74  {
75  }
76 
77  /// Destructor.
80 
81  /// Return a vector of names of all pre-declared attributes for this schema
82  /// class and all its ancestor classes. Does not include attributes that
83  /// may be authored by custom/extended methods of the schemas involved.
85  static const TfTokenVector &
86  GetSchemaAttributeNames(bool includeInherited=true);
87 
88  /// Return a UsdVolParticleFieldPositionAttributeAPI holding the prim adhering to this
89  /// schema at \p path on \p stage. If no prim exists at \p path on
90  /// \p stage, or if the prim at that path does not adhere to this schema,
91  /// return an invalid schema object. This is shorthand for the following:
92  ///
93  /// \code
94  /// UsdVolParticleFieldPositionAttributeAPI(stage->GetPrimAtPath(path));
95  /// \endcode
96  ///
99  Get(const UsdStagePtr &stage, const SdfPath &path);
100 
101 
102  /// Returns true if this <b>single-apply</b> API schema can be applied to
103  /// the given \p prim. If this schema can not be a applied to the prim,
104  /// this returns false and, if provided, populates \p whyNot with the
105  /// reason it can not be applied.
106  ///
107  /// Note that if CanApply returns false, that does not necessarily imply
108  /// that calling Apply will fail. Callers are expected to call CanApply
109  /// before calling Apply if they want to ensure that it is valid to
110  /// apply a schema.
111  ///
112  /// \sa UsdPrim::GetAppliedSchemas()
113  /// \sa UsdPrim::HasAPI()
114  /// \sa UsdPrim::CanApplyAPI()
115  /// \sa UsdPrim::ApplyAPI()
116  /// \sa UsdPrim::RemoveAPI()
117  ///
118  USDVOL_API
119  static bool
120  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
121 
122  /// Applies this <b>single-apply</b> API schema to the given \p prim.
123  /// This information is stored by adding "ParticleFieldPositionAttributeAPI" to the
124  /// token-valued, listOp metadata \em apiSchemas on the prim.
125  ///
126  /// \return A valid UsdVolParticleFieldPositionAttributeAPI object is returned upon success.
127  /// An invalid (or empty) UsdVolParticleFieldPositionAttributeAPI object is returned upon
128  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
129  /// resulting in failure.
130  ///
131  /// \sa UsdPrim::GetAppliedSchemas()
132  /// \sa UsdPrim::HasAPI()
133  /// \sa UsdPrim::CanApplyAPI()
134  /// \sa UsdPrim::ApplyAPI()
135  /// \sa UsdPrim::RemoveAPI()
136  ///
137  USDVOL_API
139  Apply(const UsdPrim &prim);
140 
141 protected:
142  /// Returns the kind of schema this class belongs to.
143  ///
144  /// \sa UsdSchemaKind
145  USDVOL_API
146  UsdSchemaKind _GetSchemaKind() const override;
147 
148 private:
149  // needs to invoke _GetStaticTfType.
150  friend class UsdSchemaRegistry;
151  USDVOL_API
152  static const TfType &_GetStaticTfType();
153 
154  static bool _IsTypedSchema();
155 
156  // override SchemaBase virtuals.
157  USDVOL_API
158  const TfType &_GetTfType() const override;
159 
160 public:
161  // --------------------------------------------------------------------- //
162  // POSITIONS
163  // --------------------------------------------------------------------- //
164  /// Defines the position for each particle in local space.
165  ///
166  /// | ||
167  /// | -- | -- |
168  /// | Declaration | `point3f[] positions` |
169  /// | C++ Type | VtArray<GfVec3f> |
170  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Point3fArray |
171  USDVOL_API
173 
174  /// See GetPositionsAttr(), and also
175  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
176  /// If specified, author \p defaultValue as the attribute's default,
177  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
178  /// the default for \p writeSparsely is \c false.
179  USDVOL_API
180  UsdAttribute CreatePositionsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
181 
182 public:
183  // --------------------------------------------------------------------- //
184  // POSITIONSH
185  // --------------------------------------------------------------------- //
186  /// Defines the position for each particle in local space. If the
187  /// float precision attribute is defined it should be preferred.
188  ///
189  /// | ||
190  /// | -- | -- |
191  /// | Declaration | `point3h[] positionsh` |
192  /// | C++ Type | VtArray<GfVec3h> |
193  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Point3hArray |
194  USDVOL_API
196 
197  /// See GetPositionshAttr(), and also
198  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
199  /// If specified, author \p defaultValue as the attribute's default,
200  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
201  /// the default for \p writeSparsely is \c false.
202  USDVOL_API
203  UsdAttribute CreatePositionshAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
204 
205 public:
206  /// \name ParticleFieldPositionBaseAPI
207  ///
208  /// Convenience accessors for the built-in UsdVolParticleFieldPositionBaseAPI
209  ///
210  /// @{
211 
212  /// Constructs and returns a UsdVolParticleFieldPositionBaseAPI object.
213  /// Use this object to access UsdVolParticleFieldPositionBaseAPI custom methods.
214  USDVOL_API
216 
217  /// @}
218 public:
219  // ===================================================================== //
220  // Feel free to add custom code below this line, it will be preserved by
221  // the code generator.
222  //
223  // Just remember to:
224  // - Close the class declaration with };
225  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
226  // - Close the include guard with #endif
227  // ===================================================================== //
228  // --(BEGIN CUSTOM CODE)--
229 };
230 
232 
233 #endif
USDVOL_API UsdAttribute CreatePositionsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdVolParticleFieldPositionAttributeAPI(const UsdPrim &prim=UsdPrim())
Single Apply API schema.
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDVOL_API UsdVolParticleFieldPositionBaseAPI ParticleFieldPositionBaseAPI() const
static USDVOL_API UsdVolParticleFieldPositionAttributeAPI Apply(const UsdPrim &prim)
static USDVOL_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
USDVOL_API UsdAttribute CreatePositionshAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
virtual USDVOL_API ~UsdVolParticleFieldPositionAttributeAPI()
Destructor.
static USDVOL_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
USDVOL_API UsdAttribute GetPositionsAttr() const
Definition: path.h:280
USDVOL_API UsdSchemaKind _GetSchemaKind() const override
UsdSchemaKind
Definition: common.h:112
UsdVolParticleFieldPositionAttributeAPI(const UsdSchemaBase &schemaObj)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
#define USDVOL_API
Definition: api.h:23
USDVOL_API UsdAttribute GetPositionshAttr() const
static USDVOL_API UsdVolParticleFieldPositionAttributeAPI Get(const UsdStagePtr &stage, const SdfPath &path)
Definition: value.h:89