HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
particleFieldOpacityAttributeAPI.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_PARTICLEFIELDOPACITYATTRIBUTEAPI_H
8 #define USDVOL_GENERATED_PARTICLEFIELDOPACITYATTRIBUTEAPI_H
9 
10 /// \file usdVol/particleFieldOpacityAttributeAPI.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 // PARTICLEFIELDOPACITYATTRIBUTEAPI //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdVolParticleFieldOpacityAttributeAPI
37 ///
38 /// A ParticleField related applied schema that provides an
39 /// opacities attribute to define the opacity of the particles.
40 ///
41 /// The opacity here should be in the range [0, 1], and inline with the
42 /// traditional (linear) sense of computer graphics opacity, not the
43 /// transformed data sometimes seen in PLY files associated with
44 /// gaussian splats, where the values need to be processed with a
45 /// sigmoid activation function.
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. If it is too long it will be truncated
53 /// to the number of particles define by the position data. If it is
54 /// too short it will be ignored.
55 ///
56 /// If it is ignored or not populated, then the default value of fully
57 /// opaque (1.0) should be used.
58 ///
59 ///
61 {
62 public:
63  /// Compile time constant representing what kind of schema this class is.
64  ///
65  /// \sa UsdSchemaKind
67 
68  /// Construct a UsdVolParticleFieldOpacityAttributeAPI on UsdPrim \p prim .
69  /// Equivalent to UsdVolParticleFieldOpacityAttributeAPI::Get(prim.GetStage(), prim.GetPath())
70  /// for a \em valid \p prim, but will not immediately throw an error for
71  /// an invalid \p prim
73  : UsdAPISchemaBase(prim)
74  {
75  }
76 
77  /// Construct a UsdVolParticleFieldOpacityAttributeAPI on the prim held by \p schemaObj .
78  /// Should be preferred over UsdVolParticleFieldOpacityAttributeAPI(schemaObj.GetPrim()),
79  /// as it preserves SchemaBase state.
81  : UsdAPISchemaBase(schemaObj)
82  {
83  }
84 
85  /// Destructor.
88 
89  /// Return a vector of names of all pre-declared attributes for this schema
90  /// class and all its ancestor classes. Does not include attributes that
91  /// may be authored by custom/extended methods of the schemas involved.
93  static const TfTokenVector &
94  GetSchemaAttributeNames(bool includeInherited=true);
95 
96  /// Return a UsdVolParticleFieldOpacityAttributeAPI holding the prim adhering to this
97  /// schema at \p path on \p stage. If no prim exists at \p path on
98  /// \p stage, or if the prim at that path does not adhere to this schema,
99  /// return an invalid schema object. This is shorthand for the following:
100  ///
101  /// \code
102  /// UsdVolParticleFieldOpacityAttributeAPI(stage->GetPrimAtPath(path));
103  /// \endcode
104  ///
105  USDVOL_API
107  Get(const UsdStagePtr &stage, const SdfPath &path);
108 
109 
110  /// Returns true if this <b>single-apply</b> API schema can be applied to
111  /// the given \p prim. If this schema can not be a applied to the prim,
112  /// this returns false and, if provided, populates \p whyNot with the
113  /// reason it can not be applied.
114  ///
115  /// Note that if CanApply returns false, that does not necessarily imply
116  /// that calling Apply will fail. Callers are expected to call CanApply
117  /// before calling Apply if they want to ensure that it is valid to
118  /// apply a schema.
119  ///
120  /// \sa UsdPrim::GetAppliedSchemas()
121  /// \sa UsdPrim::HasAPI()
122  /// \sa UsdPrim::CanApplyAPI()
123  /// \sa UsdPrim::ApplyAPI()
124  /// \sa UsdPrim::RemoveAPI()
125  ///
126  USDVOL_API
127  static bool
128  CanApply(const UsdPrim &prim, std::string *whyNot=nullptr);
129 
130  /// Applies this <b>single-apply</b> API schema to the given \p prim.
131  /// This information is stored by adding "ParticleFieldOpacityAttributeAPI" to the
132  /// token-valued, listOp metadata \em apiSchemas on the prim.
133  ///
134  /// \return A valid UsdVolParticleFieldOpacityAttributeAPI object is returned upon success.
135  /// An invalid (or empty) UsdVolParticleFieldOpacityAttributeAPI object is returned upon
136  /// failure. See \ref UsdPrim::ApplyAPI() for conditions
137  /// resulting in failure.
138  ///
139  /// \sa UsdPrim::GetAppliedSchemas()
140  /// \sa UsdPrim::HasAPI()
141  /// \sa UsdPrim::CanApplyAPI()
142  /// \sa UsdPrim::ApplyAPI()
143  /// \sa UsdPrim::RemoveAPI()
144  ///
145  USDVOL_API
147  Apply(const UsdPrim &prim);
148 
149 protected:
150  /// Returns the kind of schema this class belongs to.
151  ///
152  /// \sa UsdSchemaKind
153  USDVOL_API
154  UsdSchemaKind _GetSchemaKind() const override;
155 
156 private:
157  // needs to invoke _GetStaticTfType.
158  friend class UsdSchemaRegistry;
159  USDVOL_API
160  static const TfType &_GetStaticTfType();
161 
162  static bool _IsTypedSchema();
163 
164  // override SchemaBase virtuals.
165  USDVOL_API
166  const TfType &_GetTfType() const override;
167 
168 public:
169  // --------------------------------------------------------------------- //
170  // OPACITIES
171  // --------------------------------------------------------------------- //
172  /// Opacity for each particle.
173  ///
174  /// | ||
175  /// | -- | -- |
176  /// | Declaration | `float[] opacities` |
177  /// | C++ Type | VtArray<float> |
178  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
179  USDVOL_API
181 
182  /// See GetOpacitiesAttr(), and also
183  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
184  /// If specified, author \p defaultValue as the attribute's default,
185  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
186  /// the default for \p writeSparsely is \c false.
187  USDVOL_API
188  UsdAttribute CreateOpacitiesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
189 
190 public:
191  // --------------------------------------------------------------------- //
192  // OPACITIESH
193  // --------------------------------------------------------------------- //
194  /// Opacity for each particle. If the float precision version is
195  /// available it should be preferred.
196  ///
197  /// | ||
198  /// | -- | -- |
199  /// | Declaration | `half[] opacitiesh` |
200  /// | C++ Type | VtArray<GfHalf> |
201  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->HalfArray |
202  USDVOL_API
204 
205  /// See GetOpacitieshAttr(), 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 CreateOpacitieshAttr(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
Single Apply API schema.
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDVOL_API UsdVolParticleFieldOpacityAttributeAPI Get(const UsdStagePtr &stage, const SdfPath &path)
virtual USDVOL_API ~UsdVolParticleFieldOpacityAttributeAPI()
Destructor.
USDVOL_API UsdAttribute CreateOpacitieshAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDVOL_API UsdAttribute GetOpacitiesAttr() const
static USDVOL_API UsdVolParticleFieldOpacityAttributeAPI Apply(const UsdPrim &prim)
Definition: prim.h:116
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
USDVOL_API UsdAttribute GetOpacitieshAttr() const
Definition: path.h:280
UsdVolParticleFieldOpacityAttributeAPI(const UsdPrim &prim=UsdPrim())
USDVOL_API UsdAttribute CreateOpacitiesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdVolParticleFieldOpacityAttributeAPI(const UsdSchemaBase &schemaObj)
UsdSchemaKind
Definition: common.h:112
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
static USDVOL_API bool CanApply(const UsdPrim &prim, std::string *whyNot=nullptr)
static USDVOL_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
Definition: type.h:47
#define USDVOL_API
Definition: api.h:23
USDVOL_API UsdSchemaKind _GetSchemaKind() const override
Definition: value.h:89