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