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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef USDSKEL_GENERATED_ANIMATION_H
25 #define USDSKEL_GENERATED_ANIMATION_H
26 
27 /// \file usdSkel/animation.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdSkel/api.h"
31 #include "pxr/usd/usd/typed.h"
32 #include "pxr/usd/usd/prim.h"
33 #include "pxr/usd/usd/stage.h"
34 #include "pxr/usd/usdSkel/tokens.h"
35 
36 #include "pxr/base/vt/value.h"
37 
38 #include "pxr/base/gf/vec3d.h"
39 #include "pxr/base/gf/vec3f.h"
40 #include "pxr/base/gf/matrix4d.h"
41 
42 #include "pxr/base/tf/token.h"
43 #include "pxr/base/tf/type.h"
44 
46 
47 class SdfAssetPath;
48 
49 // -------------------------------------------------------------------------- //
50 // SKELANIMATION //
51 // -------------------------------------------------------------------------- //
52 
53 /// \class UsdSkelAnimation
54 ///
55 /// Describes a skel animation, where joint animation is stored in a
56 /// vectorized form.
57 ///
58 /// See the extended \ref UsdSkel_SkelAnimation "Skel Animation"
59 /// documentation for more information.
60 ///
61 ///
62 class UsdSkelAnimation : public UsdTyped
63 {
64 public:
65  /// Compile time constant representing what kind of schema this class is.
66  ///
67  /// \sa UsdSchemaKind
69 
70  /// Construct a UsdSkelAnimation on UsdPrim \p prim .
71  /// Equivalent to UsdSkelAnimation::Get(prim.GetStage(), prim.GetPath())
72  /// for a \em valid \p prim, but will not immediately throw an error for
73  /// an invalid \p prim
74  explicit UsdSkelAnimation(const UsdPrim& prim=UsdPrim())
75  : UsdTyped(prim)
76  {
77  }
78 
79  /// Construct a UsdSkelAnimation on the prim held by \p schemaObj .
80  /// Should be preferred over UsdSkelAnimation(schemaObj.GetPrim()),
81  /// as it preserves SchemaBase state.
82  explicit UsdSkelAnimation(const UsdSchemaBase& schemaObj)
83  : UsdTyped(schemaObj)
84  {
85  }
86 
87  /// Destructor.
89  virtual ~UsdSkelAnimation();
90 
91  /// Return a vector of names of all pre-declared attributes for this schema
92  /// class and all its ancestor classes. Does not include attributes that
93  /// may be authored by custom/extended methods of the schemas involved.
95  static const TfTokenVector &
96  GetSchemaAttributeNames(bool includeInherited=true);
97 
98  /// Return a UsdSkelAnimation holding the prim adhering to this
99  /// schema at \p path on \p stage. If no prim exists at \p path on
100  /// \p stage, or if the prim at that path does not adhere to this schema,
101  /// return an invalid schema object. This is shorthand for the following:
102  ///
103  /// \code
104  /// UsdSkelAnimation(stage->GetPrimAtPath(path));
105  /// \endcode
106  ///
108  static UsdSkelAnimation
109  Get(const UsdStagePtr &stage, const SdfPath &path);
110 
111  /// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
112  /// is defined (according to UsdPrim::IsDefined()) on this stage.
113  ///
114  /// If a prim adhering to this schema at \p path is already defined on this
115  /// stage, return that prim. Otherwise author an \a SdfPrimSpec with
116  /// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
117  /// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
118  /// with \p specifier == \a SdfSpecifierDef and empty typeName at the
119  /// current EditTarget for any nonexistent, or existing but not \a Defined
120  /// ancestors.
121  ///
122  /// The given \a path must be an absolute prim path that does not contain
123  /// any variant selections.
124  ///
125  /// If it is impossible to author any of the necessary PrimSpecs, (for
126  /// example, in case \a path cannot map to the current UsdEditTarget's
127  /// namespace) issue an error and return an invalid \a UsdPrim.
128  ///
129  /// Note that this method may return a defined prim whose typeName does not
130  /// specify this schema class, in case a stronger typeName opinion overrides
131  /// the opinion at the current EditTarget.
132  ///
134  static UsdSkelAnimation
135  Define(const UsdStagePtr &stage, const SdfPath &path);
136 
137 protected:
138  /// Returns the kind of schema this class belongs to.
139  ///
140  /// \sa UsdSchemaKind
142  UsdSchemaKind _GetSchemaKind() const override;
143 
144 private:
145  // needs to invoke _GetStaticTfType.
146  friend class UsdSchemaRegistry;
148  static const TfType &_GetStaticTfType();
149 
150  static bool _IsTypedSchema();
151 
152  // override SchemaBase virtuals.
154  const TfType &_GetTfType() const override;
155 
156 public:
157  // --------------------------------------------------------------------- //
158  // JOINTS
159  // --------------------------------------------------------------------- //
160  /// Array of tokens identifying which joints this animation's
161  /// data applies to. The tokens for joints correspond to the tokens of
162  /// Skeleton primitives. The order of the joints as listed here may
163  /// vary from the order of joints on the Skeleton itself.
164  ///
165  /// | ||
166  /// | -- | -- |
167  /// | Declaration | `uniform token[] joints` |
168  /// | C++ Type | VtArray<TfToken> |
169  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->TokenArray |
170  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
172  UsdAttribute GetJointsAttr() const;
173 
174  /// See GetJointsAttr(), and also
175  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
176  /// If specified, author \p defaultValue as the attribute's default,
177  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
178  /// the default for \p writeSparsely is \c false.
180  UsdAttribute CreateJointsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
181 
182 public:
183  // --------------------------------------------------------------------- //
184  // TRANSLATIONS
185  // --------------------------------------------------------------------- //
186  /// Joint-local translations of all affected joints. Array length
187  /// should match the size of the *joints* attribute.
188  ///
189  /// | ||
190  /// | -- | -- |
191  /// | Declaration | `float3[] translations` |
192  /// | C++ Type | VtArray<GfVec3f> |
193  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Float3Array |
196 
197  /// See GetTranslationsAttr(), and also
198  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
199  /// If specified, author \p defaultValue as the attribute's default,
200  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
201  /// the default for \p writeSparsely is \c false.
203  UsdAttribute CreateTranslationsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
204 
205 public:
206  // --------------------------------------------------------------------- //
207  // ROTATIONS
208  // --------------------------------------------------------------------- //
209  /// Joint-local unit quaternion rotations of all affected joints,
210  /// in 32-bit precision. Array length should match the size of the
211  /// *joints* attribute.
212  ///
213  /// | ||
214  /// | -- | -- |
215  /// | Declaration | `quatf[] rotations` |
216  /// | C++ Type | VtArray<GfQuatf> |
217  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->QuatfArray |
220 
221  /// See GetRotationsAttr(), and also
222  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
223  /// If specified, author \p defaultValue as the attribute's default,
224  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
225  /// the default for \p writeSparsely is \c false.
227  UsdAttribute CreateRotationsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
228 
229 public:
230  // --------------------------------------------------------------------- //
231  // SCALES
232  // --------------------------------------------------------------------- //
233  /// Joint-local scales of all affected joints, in
234  /// 16 bit precision. Array length should match the size of the *joints*
235  /// attribute.
236  ///
237  /// | ||
238  /// | -- | -- |
239  /// | Declaration | `half3[] scales` |
240  /// | C++ Type | VtArray<GfVec3h> |
241  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->Half3Array |
243  UsdAttribute GetScalesAttr() const;
244 
245  /// See GetScalesAttr(), 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.
251  UsdAttribute CreateScalesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
252 
253 public:
254  // --------------------------------------------------------------------- //
255  // BLENDSHAPES
256  // --------------------------------------------------------------------- //
257  /// Array of tokens identifying which blend shapes this
258  /// animation's data applies to. The tokens for blendShapes correspond to
259  /// the tokens set in the *skel:blendShapes* binding property of the
260  /// UsdSkelBindingAPI.
261  ///
262  /// | ||
263  /// | -- | -- |
264  /// | Declaration | `uniform token[] blendShapes` |
265  /// | C++ Type | VtArray<TfToken> |
266  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->TokenArray |
267  /// | \ref SdfVariability "Variability" | SdfVariabilityUniform |
270 
271  /// See GetBlendShapesAttr(), and also
272  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
273  /// If specified, author \p defaultValue as the attribute's default,
274  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
275  /// the default for \p writeSparsely is \c false.
277  UsdAttribute CreateBlendShapesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
278 
279 public:
280  // --------------------------------------------------------------------- //
281  // BLENDSHAPEWEIGHTS
282  // --------------------------------------------------------------------- //
283  /// Array of weight values for each blend shape. Each weight value
284  /// is associated with the corresponding blend shape identified within the
285  /// *blendShapes* token array, and therefore must have the same length as
286  /// *blendShapes.
287  ///
288  /// | ||
289  /// | -- | -- |
290  /// | Declaration | `float[] blendShapeWeights` |
291  /// | C++ Type | VtArray<float> |
292  /// | \ref Usd_Datatypes "Usd Type" | SdfValueTypeNames->FloatArray |
295 
296  /// See GetBlendShapeWeightsAttr(), and also
297  /// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
298  /// If specified, author \p defaultValue as the attribute's default,
299  /// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
300  /// the default for \p writeSparsely is \c false.
302  UsdAttribute CreateBlendShapeWeightsAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
303 
304 public:
305  // ===================================================================== //
306  // Feel free to add custom code below this line, it will be preserved by
307  // the code generator.
308  //
309  // Just remember to:
310  // - Close the class declaration with };
311  // - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
312  // - Close the include guard with #endif
313  // ===================================================================== //
314  // --(BEGIN CUSTOM CODE)--
315 
316  /// Convenience method for querying resolved transforms at \p time.
317  /// Note that it is more efficient to query transforms through
318  /// UsdSkelAnimQuery or UsdSkelSkeletonQuery.
320  bool GetTransforms(VtMatrix4dArray* xforms,
322 
323  /// Convenience method for setting an array of transforms.
324  /// The given transforms must be _orthogonal_.
326  bool SetTransforms(const VtMatrix4dArray& xforms,
328 };
329 
331 
332 #endif
static USDSKEL_API UsdSkelAnimation Get(const UsdStagePtr &stage, const SdfPath &path)
static constexpr UsdTimeCode Default()
Definition: timeCode.h:112
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:68
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:74
UsdSkelAnimation(const UsdSchemaBase &schemaObj)
Definition: animation.h:82
Definition: prim.h:133
Definition: typed.h:61
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
USDSKEL_API bool GetTransforms(VtMatrix4dArray *xforms, UsdTimeCode time=UsdTimeCode::Default()) const
#define USDSKEL_API
Definition: api.h:40
Definition: path.h:290
USDSKEL_API UsdAttribute CreateBlendShapesAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
UsdSchemaKind
Definition: common.h:129
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
USDSKEL_API UsdAttribute GetBlendShapesAttr() const
USDSKEL_API UsdAttribute GetTranslationsAttr() const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
USDSKEL_API UsdAttribute CreateBlendShapeWeightsAttr(VtValue const &defaultValue=VtValue(), bool writeSparsely=false) const
Definition: type.h:64
static USDSKEL_API UsdSkelAnimation Define(const UsdStagePtr &stage, const SdfPath &path)
Definition: value.h:164
virtual USDSKEL_API ~UsdSkelAnimation()
Destructor.