HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
animation.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_ANIMATION_H
8 #define USDSKEL_GENERATED_ANIMATION_H
9 
10 /// \file usdSkel/animation.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/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 // SKELANIMATION //
34 // -------------------------------------------------------------------------- //
35 
36 /// \class UsdSkelAnimation
37 ///
38 /// Describes a skel animation, where joint animation is stored in a
39 /// vectorized form.
40 ///
41 /// See the extended \ref UsdSkel_SkelAnimation "Skel Animation"
42 /// documentation for more information.
43 ///
44 ///
45 class UsdSkelAnimation : public UsdTyped
46 {
47 public:
48  /// Compile time constant representing what kind of schema this class is.
49  ///
50  /// \sa UsdSchemaKind
52 
53  /// Construct a UsdSkelAnimation on UsdPrim \p prim .
54  /// Equivalent to UsdSkelAnimation::Get(prim.GetStage(), prim.GetPath())
55  /// for a \em valid \p prim, but will not immediately throw an error for
56  /// an invalid \p prim
57  explicit UsdSkelAnimation(const UsdPrim& prim=UsdPrim())
58  : UsdTyped(prim)
59  {
60  }
61 
62  /// Construct a UsdSkelAnimation on the prim held by \p schemaObj .
63  /// Should be preferred over UsdSkelAnimation(schemaObj.GetPrim()),
64  /// as it preserves SchemaBase state.
65  explicit UsdSkelAnimation(const UsdSchemaBase& schemaObj)
66  : UsdTyped(schemaObj)
67  {
68  }
69 
70  /// Destructor.
72  virtual ~UsdSkelAnimation();
73 
74  /// Return a vector of names of all pre-declared attributes for this schema
75  /// class and all its ancestor classes. Does not include attributes that
76  /// may be authored by custom/extended methods of the schemas involved.
78  static const TfTokenVector &
79  GetSchemaAttributeNames(bool includeInherited=true);
80 
81  /// Return a UsdSkelAnimation holding the prim adhering to this
82  /// schema at \p path on \p stage. If no prim exists at \p path on
83  /// \p stage, or if the prim at that path does not adhere to this schema,
84  /// return an invalid schema object. This is shorthand for the following:
85  ///
86  /// \code
87  /// UsdSkelAnimation(stage->GetPrimAtPath(path));
88  /// \endcode
89  ///
91  static UsdSkelAnimation
92  Get(const UsdStagePtr &stage, const SdfPath &path);
93 
94  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
95  /// is defined (according to UsdPrim::IsDefined()) on this stage.
96  ///
97  /// If a prim adhering to this schema at \p path is already defined on this
98  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
99  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
100  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
101  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
102  /// current EditTarget for any nonexistent, or existing but not \a Defined
103  /// ancestors.
104  ///
105  /// The given \a path must be an absolute prim path that does not contain
106  /// any variant selections.
107  ///
108  /// If it is impossible to author any of the necessary PrimSpecs, (for
109  /// example, in case \a path cannot map to the current UsdEditTarget's
110  /// namespace) issue an error and return an invalid \a UsdPrim.
111  ///
112  /// Note that this method may return a defined prim whose typeName does not
113  /// specify this schema class, in case a stronger typeName opinion overrides
114  /// the opinion at the current EditTarget.
115  ///
117  static UsdSkelAnimation
118  Define(const UsdStagePtr &stage, const SdfPath &path);
119 
120 protected:
121  /// Returns the kind of schema this class belongs to.
122  ///
123  /// \sa UsdSchemaKind
125  UsdSchemaKind _GetSchemaKind() const override;
126 
127 private:
128  // needs to invoke _GetStaticTfType.
129  friend class UsdSchemaRegistry;
131  static const TfType &_GetStaticTfType();
132 
133  static bool _IsTypedSchema();
134 
135  // override SchemaBase virtuals.
137  const TfType &_GetTfType() const override;
138 
139 public:
140  // --------------------------------------------------------------------- //
141  // JOINTS
142  // --------------------------------------------------------------------- //
143  /// Array of tokens identifying which joints this animation's
144  /// data applies to. The tokens for joints correspond to the tokens of
145  /// Skeleton primitives. The order of the joints as listed here may
146  /// vary from the order of joints on the Skeleton itself.
147  ///
148  /// | ||
149  /// | -- | -- |
150  /// | Declaration | `uniform token[] joints` |
151  /// | C++ Type | VtArray<TfToken> |
152  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->TokenArray |
153  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
155  UsdAttribute GetJointsAttr() const;
156 
157  /// See GetJointsAttr(), and also
158  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
159  /// If specified, author \p defaultValue as the attribute's default,
160  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
161  /// the default for \p writeSparsely is \c false.
163  UsdAttribute CreateJointsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
164 
165 public:
166  // --------------------------------------------------------------------- //
167  // TRANSLATIONS
168  // --------------------------------------------------------------------- //
169  /// Joint-local translations of all affected joints. Array length
170  /// should match the size of the *joints* attribute.
171  ///
172  /// | ||
173  /// | -- | -- |
174  /// | Declaration | `float3[] translations` |
175  /// | C++ Type | VtArray<GfVec3f> |
176  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
179 
180  /// See GetTranslationsAttr(), and also
181  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
182  /// If specified, author \p defaultValue as the attribute's default,
183  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
184  /// the default for \p writeSparsely is \c false.
186  UsdAttribute CreateTranslationsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
187 
188 public:
189  // --------------------------------------------------------------------- //
190  // ROTATIONS
191  // --------------------------------------------------------------------- //
192  /// Joint-local unit quaternion rotations of all affected joints,
193  /// in 32-bit precision. Array length should match the size of the
194  /// *joints* attribute.
195  ///
196  /// | ||
197  /// | -- | -- |
198  /// | Declaration | `quatf[] rotations` |
199  /// | C++ Type | VtArray<GfQuatf> |
200  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->QuatfArray |
203 
204  /// See GetRotationsAttr(), and also
205  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
206  /// If specified, author \p defaultValue as the attribute's default,
207  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
208  /// the default for \p writeSparsely is \c false.
210  UsdAttribute CreateRotationsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
211 
212 public:
213  // --------------------------------------------------------------------- //
214  // SCALES
215  // --------------------------------------------------------------------- //
216  /// Joint-local scales of all affected joints, in
217  /// 16 bit precision. Array length should match the size of the *joints*
218  /// attribute.
219  ///
220  /// | ||
221  /// | -- | -- |
222  /// | Declaration | `half3[] scales` |
223  /// | C++ Type | VtArray<GfVec3h> |
224  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Half3Array |
226  UsdAttribute GetScalesAttr() const;
227 
228  /// See GetScalesAttr(), and also
229  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
230  /// If specified, author \p defaultValue as the attribute's default,
231  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
232  /// the default for \p writeSparsely is \c false.
234  UsdAttribute CreateScalesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
235 
236 public:
237  // --------------------------------------------------------------------- //
238  // BLENDSHAPES
239  // --------------------------------------------------------------------- //
240  /// Array of tokens identifying which blend shapes this
241  /// animation's data applies to. The tokens for blendShapes correspond to
242  /// the tokens set in the *skel:blendShapes* binding property of the
243  /// UsdSkelBindingAPI. Note that blendShapes does not accept time-sampled
244  /// values.
245  ///
246  /// | ||
247  /// | -- | -- |
248  /// | Declaration | `uniform token[] blendShapes` |
249  /// | C++ Type | VtArray<TfToken> |
250  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->TokenArray |
251  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
254 
255  /// See GetBlendShapesAttr(), and also
256  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
257  /// If specified, author \p defaultValue as the attribute's default,
258  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
259  /// the default for \p writeSparsely is \c false.
261  UsdAttribute CreateBlendShapesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
262 
263 public:
264  // --------------------------------------------------------------------- //
265  // BLENDSHAPEWEIGHTS
266  // --------------------------------------------------------------------- //
267  /// Array of weight values for each blend shape. Each weight value
268  /// is associated with the corresponding blend shape identified within the
269  /// *blendShapes* token array, and therefore must have the same length as
270  /// *blendShapes.
271  ///
272  /// | ||
273  /// | -- | -- |
274  /// | Declaration | `float[] blendShapeWeights` |
275  /// | C++ Type | VtArray<float> |
276  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
279 
280  /// See GetBlendShapeWeightsAttr(), and also
281  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
282  /// If specified, author \p defaultValue as the attribute's default,
283  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
284  /// the default for \p writeSparsely is \c false.
286  UsdAttribute CreateBlendShapeWeightsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
287 
288 public:
289  // ===================================================================== //
290  // Feel free to add custom code below this line, it will be preserved by
291  // the code generator.
292  //
293  // Just remember to:
294  // - Close the class declaration with };
295  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
296  // - Close the include guard with #endif
297  // ===================================================================== //
298  // --(BEGIN CUSTOM CODE)--
299 
300  /// Convenience method for querying resolved transforms at \p time.
301  /// Note that it is more efficient to query transforms through
302  /// UsdSkelAnimQuery or UsdSkelSkeletonQuery.
304  bool GetTransforms(VtMatrix4dArray* xforms,
306 
307  /// Convenience method for setting an array of transforms.
308  /// The given transforms must be _orthogonal_.
310  bool SetTransforms(const VtMatrix4dArray& xforms,
312 };
313 
315 
316 #endif
static USDSKEL_API UsdSkelAnimation Get(const UsdStagePtr &stage, const SdfPath &path)
static constexpr UsdTimeCode Default()
Definition: timeCode.h:113
USDSKEL_API UsdAttribute GetBlendShapeWeightsAttr() const
GT_API const UT_StringHolder time
USDSKEL_API UsdAttribute CreateRotationsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDSKEL_API UsdAttribute GetJointsAttr() const
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
USDSKEL_API UsdAttribute GetRotationsAttr() const
USDSKEL_API UsdAttribute CreateScalesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
static USDSKEL_API const TfTokenVector & GetSchemaAttributeNames(bool includeInherited=true)
USDSKEL_API bool SetTransforms(const VtMatrix4dArray &xforms, UsdTimeCode time=UsdTimeCode::Default()) const
USDSKEL_API UsdSchemaKind _GetSchemaKind() const override
static const UsdSchemaKind schemaKind
Definition: animation.h:51
Represents a concrete typed schema.
USDSKEL_API UsdAttribute GetScalesAttr() const
USDSKEL_API UsdAttribute CreateJointsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
USDSKEL_API UsdAttribute CreateTranslationsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSkelAnimation(const UsdPrim &prim=UsdPrim())
Definition: animation.h:57
UsdSkelAnimation(const UsdSchemaBase &schemaObj)
Definition: animation.h:65
Definition: prim.h:116
Definition: typed.h:44
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
USDSKEL_API bool GetTransforms(VtMatrix4dArray *xforms, UsdTimeCode time=UsdTimeCode::Default()) const
#define USDSKEL_API
Definition: api.h:23
Definition: path.h:273
USDSKEL_API UsdAttribute CreateBlendShapesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSchemaKind
Definition: common.h:112
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
USDSKEL_API UsdAttribute GetBlendShapesAttr() const
USDSKEL_API UsdAttribute GetTranslationsAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDSKEL_API UsdAttribute CreateBlendShapeWeightsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: type.h:47
static USDSKEL_API UsdSkelAnimation Define(const UsdStagePtr &stage, const SdfPath &path)
Definition: value.h:146
virtual USDSKEL_API ~UsdSkelAnimation()
Destructor.