HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
particleFieldSphericalHarmonicsAttributeAPI.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_PARTICLEFIELDSPHERICALHARMONICSATTRIBUTEAPI_H
8 #define USDVOL_GENERATED_PARTICLEFIELDSPHERICALHARMONICSATTRIBUTEAPI_H
9 
10 /// \file usdVol/particleFieldSphericalHarmonicsAttributeAPI.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 // PARTICLEFIELDSPHERICALHARMONICSATTRIBUTEAPI //
37 // -------------------------------------------------------------------------- //
38 
39 /// \class UsdVolParticleFieldSphericalHarmonicsAttributeAPI
40 ///
41 /// A ParticleField related applied schema that provides spherical
42 /// harmonics attributes to define the radiance of the particles.
43 ///
44 /// The spherical harmonics degree is constant across all the particles
45 /// in the ParticleField.
46 ///
47 /// Attributes are provided in both `float` and `half` types for some
48 /// easy data footprint affordance, data consumers should prefer
49 /// `float` version if available.
50 ///
51 /// The length of this attribute is expected to match the length of
52 /// the provided position data times the per-particle element size
53 /// derived from the SH degree (specifically element size =
54 /// (degree+1)*(degree+1)). If it is too long it will be truncated
55 /// to the number of particles define by the position data. If it is
56 /// too short it will be ignored.
57 ///
58 /// If it is ignored or not populated, the particle should use a SH
59 /// coefficient corresponding to a DC signal of (0.5, 0.5, 0.5),
60 /// with degree 0.
61 ///
62 ///
64 {
65 public:
66  /// Compile time constant representing what kind of schema this class is.
67  ///
68  /// \sa UsdSchemaKind
70 
71  /// Construct a UsdVolParticleFieldSphericalHarmonicsAttributeAPI on UsdPrim \p prim .
72  /// Equivalent to UsdVolParticleFieldSphericalHarmonicsAttributeAPI::Get(prim.GetStage(), prim.GetPath())
73  /// for a \em valid \p prim, but will not immediately throw an error for
74  /// an invalid \p prim
76  : UsdAPISchemaBase(prim)
77  {
78  }
79 
80  /// Construct a UsdVolParticleFieldSphericalHarmonicsAttributeAPI on the prim held by \p schemaObj .
81  /// Should be preferred over UsdVolParticleFieldSphericalHarmonicsAttributeAPI(schemaObj.GetPrim()),
82  /// as it preserves SchemaBase state.
84  : UsdAPISchemaBase(schemaObj)
85  {
86  }
87 
88  /// Destructor.
91 
92  /// Return a vector of names of all pre-declared attributes for this schema
93  /// class and all its ancestor classes. Does not include attributes that
94  /// may be authored by custom/extended methods of the schemas involved.
96  static const TfTokenVector &
97  GetSchemaAttributeNames(bool includeInherited=true);
98 
99  /// Return a UsdVolParticleFieldSphericalHarmonicsAttributeAPI holding the prim adhering to this
100  /// schema at \p path on \p stage. If no prim exists at \p path on
101  /// \p stage, or if the prim at that path does not adhere to this schema,
102  /// return an invalid schema object. This is shorthand for the following:
103  ///
104  /// \code
105  /// UsdVolParticleFieldSphericalHarmonicsAttributeAPI(stage->GetPrimAtPath(path));
106  /// \endcode
107  ///
108  USDVOL_API
110  Get(const UsdStagePtr &stage, const SdfPath &path);
111 
112 
113  /// Returns true if this <b>single-apply</b> API schema can be applied to
114  /// the given \p prim. If this schema can not be a applied to the prim,
115  /// this returns false and, if provided, populates \p whyNot with the
116  /// reason it can not be applied.
117  ///
118  /// Note that if CanApply returns false, that does not necessarily imply
119  /// that calling Apply will fail. Callers are expected to call CanApply
120  /// before calling Apply if they want to ensure that it is valid to
121  /// apply a schema.
122  ///
123  /// \sa UsdPrim::GetAppliedSchemas()
124  /// \sa UsdPrim::HasAPI()
125  /// \sa UsdPrim::CanApplyAPI()
126  /// \sa UsdPrim::ApplyAPI()
127  /// \sa UsdPrim::RemoveAPI()
128  ///
129  USDVOL_API
130  static bool
131  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
132 
133  /// Applies this <b>single-apply</b> API schema to the given \p prim.
134  /// This information is stored by adding "ParticleFieldSphericalHarmonicsAttributeAPI" to the
135  /// token-valued, listOp metadata \em apiSchemas on the prim.
136  ///
137  /// \return A valid UsdVolParticleFieldSphericalHarmonicsAttributeAPI object is returned upon success.
138  /// An invalid (or empty) UsdVolParticleFieldSphericalHarmonicsAttributeAPI object is returned upon
139  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
140  /// resulting in failure.
141  ///
142  /// \sa UsdPrim::GetAppliedSchemas()
143  /// \sa UsdPrim::HasAPI()
144  /// \sa UsdPrim::CanApplyAPI()
145  /// \sa UsdPrim::ApplyAPI()
146  /// \sa UsdPrim::RemoveAPI()
147  ///
148  USDVOL_API
150  Apply(const UsdPrim &prim);
151 
152 protected:
153  /// Returns the kind of schema this class belongs to.
154  ///
155  /// \sa UsdSchemaKind
156  USDVOL_API
157  UsdSchemaKind _GetSchemaKind() const override;
158 
159 private:
160  // needs to invoke _GetStaticTfType.
161  friend class UsdSchemaRegistry;
162  USDVOL_API
163  static const TfType &_GetStaticTfType();
164 
165  static bool _IsTypedSchema();
166 
167  // override SchemaBase virtuals.
168  USDVOL_API
169  const TfType &_GetTfType() const override;
170 
171 public:
172  // --------------------------------------------------------------------- //
173  // RADIANCESPHERICALHARMONICSDEGREE
174  // --------------------------------------------------------------------- //
175  /// The highest degree of the spherical harmonics. A degree of N
176  /// implies a coefficient element size (per particle) of (N+1)*(N+1) values.
177  /// The spherical harmonics degree is the same for all particles in the
178  /// ParticleField.
179  ///
180  /// | ||
181  /// | -- | -- |
182  /// | Declaration | `uniform int radiance:sphericalHarmonicsDegree = 3` |
183  /// | C++ Type | int |
184  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Int |
185  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
186  USDVOL_API
188 
189  /// See GetRadianceSphericalHarmonicsDegreeAttr(), and also
190  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
191  /// If specified, author \p defaultValue as the attribute's default,
192  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
193  /// the default for \p writeSparsely is \c false.
194  USDVOL_API
195  UsdAttribute CreateRadianceSphericalHarmonicsDegreeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
196 
197 public:
198  // --------------------------------------------------------------------- //
199  // RADIANCESPHERICALHARMONICSCOEFFICIENTS
200  // --------------------------------------------------------------------- //
201  /// Flattened array of SH coefficients.
202  /// The SH coefficients are grouped in the array by particle, meaning each
203  /// particle has N contiguous coefficients, Y(m,l) sorted first by order (m)
204  /// and then within the order by index (l). A renderer can compute an
205  /// element size per particle based on the SH degree, and use that to stripe
206  /// the array by particle.
207  ///
208  /// | ||
209  /// | -- | -- |
210  /// | Declaration | `float3[] radiance:sphericalHarmonicsCoefficients` |
211  /// | C++ Type | VtArray<GfVec3f> |
212  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
213  USDVOL_API
215 
216  /// See GetRadianceSphericalHarmonicsCoefficientsAttr(), and also
217  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
218  /// If specified, author \p defaultValue as the attribute's default,
219  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
220  /// the default for \p writeSparsely is \c false.
221  USDVOL_API
222  UsdAttribute CreateRadianceSphericalHarmonicsCoefficientsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
223 
224 public:
225  // --------------------------------------------------------------------- //
226  // RADIANCESPHERICALHARMONICSCOEFFICIENTSH
227  // --------------------------------------------------------------------- //
228  /// Flattened array of SH coefficients.
229  /// The SH coefficients are grouped in the array by particle, meaning each
230  /// particle has N contiguous coefficients, Y(m,l) sorted first by order (m)
231  /// and then within the order by index (l). A renderer can compute an
232  /// element size per particle based on the SH degree, and use that to stripe
233  /// the array by particle.
234  ///
235  /// If the float precision version is available it should be preferred.
236  ///
237  /// | ||
238  /// | -- | -- |
239  /// | Declaration | `half3[] radiance:sphericalHarmonicsCoefficientsh` |
240  /// | C++ Type | VtArray<GfVec3h> |
241  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Half3Array |
242  USDVOL_API
244 
245  /// See GetRadianceSphericalHarmonicsCoefficientshAttr(), 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.
250  USDVOL_API
251  UsdAttribute CreateRadianceSphericalHarmonicsCoefficientshAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
252 
253 public:
254  /// \name ParticleFieldRadianceBaseAPI
255  ///
256  /// Convenience accessors for the built-in UsdVolParticleFieldRadianceBaseAPI
257  ///
258  /// @{
259 
260  /// Constructs and returns a UsdVolParticleFieldRadianceBaseAPI object.
261  /// Use this object to access UsdVolParticleFieldRadianceBaseAPI custom methods.
262  USDVOL_API
264 
265  /// @}
266 public:
267  // ===================================================================== //
268  // Feel free to add custom code below this line, it will be preserved by
269  // the code generator.
270  //
271  // Just remember to:
272  // - Close the class declaration with };
273  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
274  // - Close the include guard with #endif
275  // ===================================================================== //
276  // --(BEGIN CUSTOM CODE)--
277 };
278 
280 
281 #endif
Single Apply API schema.
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
virtual USDVOL_API ~UsdVolParticleFieldSphericalHarmonicsAttributeAPI()
Destructor.
static USDVOL_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDVOL_API UsdAttribute GetRadianceSphericalHarmonicsCoefficientsAttr() const
static USDVOL_API UsdVolParticleFieldSphericalHarmonicsAttributeAPI Apply(const UsdPrim &prim)
static USDVOL_API UsdVolParticleFieldSphericalHarmonicsAttributeAPI Get(const UsdStagePtr &stage, const SdfPath &path)
static USDVOL_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
USDVOL_API UsdSchemaKind _GetSchemaKind() const override
USDVOL_API UsdAttribute CreateRadianceSphericalHarmonicsDegreeAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
Definition: path.h:280
USDVOL_API UsdAttribute CreateRadianceSphericalHarmonicsCoefficientshAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSchemaKind
Definition: common.h:112
USDVOL_API UsdAttribute GetRadianceSphericalHarmonicsDegreeAttr() const
USDVOL_API UsdAttribute CreateRadianceSphericalHarmonicsCoefficientsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
USDVOL_API UsdAttribute GetRadianceSphericalHarmonicsCoefficientshAttr() const
USDVOL_API UsdVolParticleFieldRadianceBaseAPI ParticleFieldRadianceBaseAPI() const
#define USDVOL_API
Definition: api.h:23
Definition: value.h:89