HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
blendShape.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 USDSKEL_GENERATED_BLENDSHAPE_H
8 #define USDSKEL_GENERATED_BLENDSHAPE_H
9 
10 /// \file usdSkel/blendShape.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdSkel/api.h"
14 #include "pxr/usd/usd/typed.h"
15 #include "pxr/usd/usd/prim.h"
16 #include "pxr/usd/usd/stage.h"
17 #include "pxr/usd/usdSkel/tokens.h"
18 
19 #include "pxr/base/tf/span.h"
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 // BLENDSHAPE //
37 // -------------------------------------------------------------------------- //
38 
39 /// \class UsdSkelBlendShape
40 ///
41 /// Describes a target blend shape, possibly containing inbetween
42 /// shapes.
43 ///
44 /// See the extended \ref UsdSkel_BlendShape "Blend Shape Schema
45 /// documentation for information.
46 ///
47 ///
49 {
50 public:
51  /// Compile time constant representing what kind of schema this class is.
52  ///
53  /// \sa UsdSchemaKind
55 
56  /// Construct a UsdSkelBlendShape on UsdPrim \p prim .
57  /// Equivalent to UsdSkelBlendShape::Get(prim.GetStage(), prim.GetPath())
58  /// for a \em valid \p prim, but will not immediately throw an error for
59  /// an invalid \p prim
60  explicit UsdSkelBlendShape(const UsdPrim& prim=UsdPrim())
61  : UsdTyped(prim)
62  {
63  }
64 
65  /// Construct a UsdSkelBlendShape on the prim held by \p schemaObj .
66  /// Should be preferred over UsdSkelBlendShape(schemaObj.GetPrim()),
67  /// as it preserves SchemaBase state.
68  explicit UsdSkelBlendShape(const UsdSchemaBase& schemaObj)
69  : UsdTyped(schemaObj)
70  {
71  }
72 
73  /// Destructor.
75  virtual ~UsdSkelBlendShape();
76 
77  /// Return a vector of names of all pre-declared attributes for this schema
78  /// class and all its ancestor classes. Does not include attributes that
79  /// may be authored by custom/extended methods of the schemas involved.
81  static const TfTokenVector &
82  GetSchemaAttributeNames(bool includeInherited=true);
83 
84  /// Return a UsdSkelBlendShape holding the prim adhering to this
85  /// schema at \p path on \p stage. If no prim exists at \p path on
86  /// \p stage, or if the prim at that path does not adhere to this schema,
87  /// return an invalid schema object. This is shorthand for the following:
88  ///
89  /// \code
90  /// UsdSkelBlendShape(stage->GetPrimAtPath(path));
91  /// \endcode
92  ///
94  static UsdSkelBlendShape
95  Get(const UsdStagePtr &stage, const SdfPath &path);
96 
97  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
98  /// is defined (according to UsdPrim::IsDefined()) on this stage.
99  ///
100  /// If a prim adhering to this schema at \p path is already defined on this
101  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
102  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
103  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
104  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
105  /// current EditTarget for any nonexistent, or existing but not \a Defined
106  /// ancestors.
107  ///
108  /// The given \a path must be an absolute prim path that does not contain
109  /// any variant selections.
110  ///
111  /// If it is impossible to author any of the necessary PrimSpecs, (for
112  /// example, in case \a path cannot map to the current UsdEditTarget's
113  /// namespace) issue an error and return an invalid \a UsdPrim.
114  ///
115  /// Note that this method may return a defined prim whose typeName does not
116  /// specify this schema class, in case a stronger typeName opinion overrides
117  /// the opinion at the current EditTarget.
118  ///
120  static UsdSkelBlendShape
121  Define(const UsdStagePtr &stage, const SdfPath &path);
122 
123 protected:
124  /// Returns the kind of schema this class belongs to.
125  ///
126  /// \sa UsdSchemaKind
128  UsdSchemaKind _GetSchemaKind() const override;
129 
130 private:
131  // needs to invoke _GetStaticTfType.
132  friend class UsdSchemaRegistry;
134  static const TfType &_GetStaticTfType();
135 
136  static bool _IsTypedSchema();
137 
138  // override SchemaBase virtuals.
140  const TfType &_GetTfType() const override;
141 
142 public:
143  // --------------------------------------------------------------------- //
144  // OFFSETS
145  // --------------------------------------------------------------------- //
146  /// **Required property**. Position offsets which, when added to the
147  /// base pose, provides the target shape.
148  ///
149  /// | ||
150  /// | -- | -- |
151  /// | Declaration | `uniform vector3f[] offsets` |
152  /// | C++ Type | VtArray<GfVec3f> |
153  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Vector3fArray |
154  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
157 
158  /// See GetOffsetsAttr(), and also
159  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
160  /// If specified, author \p defaultValue as the attribute's default,
161  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
162  /// the default for \p writeSparsely is \c false.
164  UsdAttribute CreateOffsetsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
165 
166 public:
167  // --------------------------------------------------------------------- //
168  // NORMALOFFSETS
169  // --------------------------------------------------------------------- //
170  /// **Required property**. Normal offsets which, when added to the
171  /// base pose, provides the normals of the target shape.
172  ///
173  /// | ||
174  /// | -- | -- |
175  /// | Declaration | `uniform vector3f[] normalOffsets` |
176  /// | C++ Type | VtArray<GfVec3f> |
177  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Vector3fArray |
178  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
181 
182  /// See GetNormalOffsetsAttr(), 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.
188  UsdAttribute CreateNormalOffsetsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
189 
190 public:
191  // --------------------------------------------------------------------- //
192  // POINTINDICES
193  // --------------------------------------------------------------------- //
194  /// **Optional property**. Indices into the original mesh that
195  /// correspond to the values in *offsets* and of any inbetween shapes. If
196  /// authored, the number of elements must be equal to the number of elements
197  /// in the *offsets* array.
198  ///
199  /// | ||
200  /// | -- | -- |
201  /// | Declaration | `uniform int[] pointIndices` |
202  /// | C++ Type | VtArray<int> |
203  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->IntArray |
204  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
207 
208  /// See GetPointIndicesAttr(), and also
209  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
210  /// If specified, author \p defaultValue as the attribute's default,
211  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
212  /// the default for \p writeSparsely is \c false.
214  UsdAttribute CreatePointIndicesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
215 
216 public:
217  // ===================================================================== //
218  // Feel free to add custom code below this line, it will be preserved by
219  // the code generator.
220  //
221  // Just remember to:
222  // - Close the class declaration with };
223  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
224  // - Close the include guard with #endif
225  // ===================================================================== //
226  // --(BEGIN CUSTOM CODE)--
227 
228  /// Author scene description to create an attribute on this prim that
229  /// will be recognized as an Inbetween (i.e. will present as a valid
230  /// UsdSkelInbetweenShape).
231  ///
232  /// The name of the created attribute or may or may not be the specified
233  /// \p attrName, due to the possible need to apply property namespacing.
234  /// Creation may fail and return an invalid Inbetwen if \p attrName
235  /// contains a reserved keyword.
236  ///
237  /// \return an invalid UsdSkelInbetweenShape if we failed to create a valid
238  /// attribute, a valid UsdSkelInbetweenShape otherwise. It is not an error
239  /// to create over an existing, compatible attribute.
240  ///
241  /// \sa UsdSkelInbetweenShape::IsInbetween()
244 
245  /// Return the Inbetween corresponding to the attribute named \p name,
246  /// which will be valid if an Inbetween attribute definition already exists.
247  ///
248  /// Name lookup will account for Inbetween namespacing, which means that
249  /// this method will succeed in some cases where
250  /// `UsdSkelInbetweenShape(prim->GetAttribute(name))` will not, unless
251  /// \p name has the proper namespace prefix.
252  ///
253  /// \sa HasInbetween()
256 
257  /// Return true if there is a defined Inbetween named \p name on this prim.
258  ///
259  /// Name lookup will account for Inbetween namespacing.
260  ///
261  /// \sa GetInbetween()
263  bool HasInbetween(const TfToken& name) const;
264 
265  /// Return valid UsdSkelInbetweenShape objects for all defined Inbetweens on
266  /// this prim.
268  std::vector<UsdSkelInbetweenShape> GetInbetweens() const;
269 
270  /// Like GetInbetweens(), but exclude inbetwens that have no authored scene
271  //// description.
273  std::vector<UsdSkelInbetweenShape> GetAuthoredInbetweens() const;
274 
275  /// Validates a set of point indices for a given point count.
276  /// This ensures that all point indices are in the range [0, numPoints).
277  /// Returns true if the indices are valid, or false otherwise.
278  /// If invalid and \p reason is non-null, an error message describing
279  /// the first validation error will be set.
282  size_t numPoints,
283  std::string* reason=nullptr);
284 
285 private:
286  std::vector<UsdSkelInbetweenShape>
287  _MakeInbetweens(const std::vector<UsdProperty>& props) const;
288 };
289 
291 
292 #endif
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
USDSKEL_API UsdSkelInbetweenShape GetInbetween(const TfToken &name) const
USDSKEL_API UsdSkelInbetweenShape CreateInbetween(const TfToken &name) const
USDSKEL_API std::vector< UsdSkelInbetweenShape > GetAuthoredInbetweens() const
Like GetInbetweens(), but exclude inbetwens that have no authored scene / description.
USDSKEL_API UsdAttribute GetPointIndicesAttr() const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static USDSKEL_API UsdSkelBlendShape Define(const UsdStagePtr &stage, const SdfPath &path)
static USDSKEL_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDSKEL_API UsdAttribute GetOffsetsAttr() const
UsdSkelBlendShape(const UsdPrim &prim=UsdPrim())
Definition: blendShape.h:60
Definition: token.h:70
Represents a concrete typed schema.
Definition: span.h:70
USDSKEL_API UsdAttribute CreatePointIndicesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: prim.h:116
Definition: typed.h:44
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
GLuint const GLchar * name
Definition: glcorearb.h:786
USDSKEL_API std::vector< UsdSkelInbetweenShape > GetInbetweens() const
#define USDSKEL_API
Definition: api.h:23
Definition: path.h:273
USDSKEL_API UsdAttribute GetNormalOffsetsAttr() const
USDSKEL_API UsdSchemaKind _GetSchemaKind() const override
USDSKEL_API UsdAttribute CreateOffsetsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSchemaKind
Definition: common.h:112
USDSKEL_API UsdAttribute CreateNormalOffsetsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDSKEL_API UsdSkelBlendShape Get(const UsdStagePtr &stage, const SdfPath &path)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: type.h:47
USDSKEL_API bool HasInbetween(const TfToken &name) const
UsdSkelBlendShape(const UsdSchemaBase &schemaObj)
Definition: blendShape.h:68
static const UsdSchemaKind schemaKind
Definition: blendShape.h:54
Definition: value.h:146
static USDSKEL_API bool ValidatePointIndices(TfSpan< const int > indices, size_t numPoints, std::string *reason=nullptr)
virtual USDSKEL_API ~UsdSkelBlendShape()
Destructor.
GLenum GLuint GLsizei const GLenum * props
Definition: glcorearb.h:2525