HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
animQuery.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 PXR_USD_USD_SKEL_ANIM_QUERY_H
8 #define PXR_USD_USD_SKEL_ANIM_QUERY_H
9 
10 /// \file usdSkel/animQuery.h
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdSkel/api.h"
14 
16 #include "pxr/base/vt/types.h"
17 
18 #include "pxr/usd/sdf/path.h"
19 #include "pxr/usd/usd/prim.h"
20 #include "pxr/usd/usd/timeCode.h"
21 
22 
24 
25 
26 class GfMatrix4d;
27 class UsdAttribute;
28 class UsdSkelCache;
29 
30 
31 TF_DECLARE_REF_PTRS(UsdSkel_AnimQueryImpl);
32 
33 
34 /// \class UsdSkelAnimQuery
35 ///
36 /// Class providing efficient queries of primitives that provide skel animation.
38 {
39 public:
42 
43  /// Return true if this query is valid.
44  bool IsValid() const { return (bool)_impl; }
45 
46  /// Boolean conversion operator. Equivalent to IsValid().
47  explicit operator bool() const { return IsValid(); }
48 
49  /// Equality comparison. Return true if \a lhs and \a rhs represent the
50  /// same UsdSkelAnimQuery, false otherwise.
51  friend bool operator==(const UsdSkelAnimQuery& lhs,
52  const UsdSkelAnimQuery& rhs) {
53  return lhs.GetPrim() == rhs.GetPrim();
54  }
55 
56  /// Inequality comparison. Return false if \a lhs and \a rhs represent the
57  /// same UsdSkelAnimQuery, true otherwise.
58  friend bool operator!=(const UsdSkelAnimQuery& lhs,
59  const UsdSkelAnimQuery& rhs) {
60  return !(lhs == rhs);
61  }
62 
63  // hash_value overload for std/boost hash.
64  friend size_t hash_value(const UsdSkelAnimQuery& query) {
65  return hash_value(query.GetPrim());
66  }
67 
68  /// Return the primitive this anim query reads from.
70  UsdPrim GetPrim() const;
71 
72  /// Compute joint transforms in joint-local space.
73  /// Transforms are returned in the order specified by the joint ordering
74  /// of the animation primitive itself.
75  template <typename Matrix4>
78  VtArray<Matrix4>* xforms,
80 
81  /// Compute translation,rotation,scale components of the joint transforms
82  /// in joint-local space. This is provided to facilitate direct streaming
83  /// of animation data in a form that can efficiently be processed for
84  /// animation blending.
87  VtVec3fArray* translations,
88  VtQuatfArray* rotations,
89  VtVec3hArray* scales,
91 
94  VtFloatArray* weights,
96 
97  /// Get the time samples at which values contributing to joint transforms
98  /// are set. This only computes the time samples for sampling transforms in
99  /// joint-local space, and does not include time samples affecting the
100  /// root transformation.
101  ///
102  /// \sa UsdAttribute::GetTimeSamples
104  bool GetJointTransformTimeSamples(std::vector<double>* times) const;
105 
106  /// Get the time samples at which values contributing to joint transforms
107  /// are set, over \p interval. This only computes the time samples for
108  /// sampling transforms in joint-local space, and does not include time
109  /// samples affecting the root transformation.
110  ///
111  /// \sa UsdAttribute::GetTimeSamplesInInterval
114  std::vector<double>* times) const;
115 
116  /// Get the attributes contributing to JointTransform computations
118  bool GetJointTransformAttributes(std::vector<UsdAttribute>* attrs) const;
119 
120  /// Return true if it possible, but not certain, that joint transforms
121  /// computed through this animation query change over time, false otherwise.
122  ///
123  /// \sa UsdAttribute::ValueMightBeTimeVayring
126 
127  /// Get the time samples at which values contributing to blend shape weights
128  /// have been set.
129  ///
130  /// \sa UsdAttribute::GetTimeSamples
132  bool GetBlendShapeWeightTimeSamples(std::vector<double>* attrs) const;
133 
134  /// Get the time samples at which values contributing to blend shape weights
135  /// are set, over \p interval.
136  ///
137  /// \sa UsdAttribute::GetTimeSamplesInInterval
140  std::vector<double>* times) const;
141 
142  /// Get the attributes contributing to blendshape weight computations.
144  bool GetBlendShapeWeightAttributes(std::vector<UsdAttribute>* attrs) const;
145 
146  /// Return true if it possible, but not certain, that the blend shape
147  /// weights computed through this animation query change over time,
148  /// false otherwise.
149  ///
150  /// \sa UsdAttribute::ValueMightBeTimeVayring
153 
154  /// Returns an array of tokens describing the ordering of joints in the
155  /// animation.
156  ///
157  /// \sa UsdSkelSkeleton::GetJointOrder
159  VtTokenArray GetJointOrder() const;
160 
161  /// Returns an array of tokens describing the ordering of blend shape
162  /// channels in the animation.
164  VtTokenArray GetBlendShapeOrder() const;
165 
167  std::string GetDescription() const;
168 
169 private:
170  UsdSkelAnimQuery(const UsdSkel_AnimQueryImplRefPtr& impl)
171  : _impl(impl) {}
172 
173  UsdSkel_AnimQueryImplRefPtr _impl;
174 
175  friend class UsdSkel_CacheImpl;
176 };
177 
178 
180 
181 #endif // PXR_USD_USD_SKEL_ANIM_QUERY_H
GLenum query
Definition: glad.h:2772
static constexpr UsdTimeCode Default()
Definition: timeCode.h:113
friend size_t hash_value(const UsdSkelAnimQuery &query)
Definition: animQuery.h:64
USDSKEL_API bool GetJointTransformTimeSamplesInInterval(const GfInterval &interval, std::vector< double > *times) const
GT_API const UT_StringHolder time
USDSKEL_API bool GetJointTransformAttributes(std::vector< UsdAttribute > *attrs) const
Get the attributes contributing to JointTransform computations.
OutGridT const XformOp bool bool
USDSKEL_API VtTokenArray GetJointOrder() const
friend class UsdSkel_CacheImpl
Definition: animQuery.h:175
USDSKEL_API bool ComputeJointLocalTransformComponents(VtVec3fArray *translations, VtQuatfArray *rotations, VtVec3hArray *scales, UsdTimeCode time=UsdTimeCode::Default()) const
USDSKEL_API bool GetJointTransformTimeSamples(std::vector< double > *times) const
USDSKEL_API bool ComputeBlendShapeWeights(VtFloatArray *weights, UsdTimeCode time=UsdTimeCode::Default()) const
USDSKEL_API UsdSkelAnimQuery()
Definition: animQuery.h:41
bool IsValid() const
Return true if this query is valid.
Definition: animQuery.h:44
Definition: prim.h:116
USDSKEL_API bool BlendShapeWeightsMightBeTimeVarying() const
friend bool operator==(const UsdSkelAnimQuery &lhs, const UsdSkelAnimQuery &rhs)
Definition: animQuery.h:51
#define USDSKEL_API
Definition: api.h:23
Definition: types.h:153
USDSKEL_API bool GetBlendShapeWeightTimeSamples(std::vector< double > *attrs) const
USDSKEL_API bool JointTransformsMightBeTimeVarying() const
friend bool operator!=(const UsdSkelAnimQuery &lhs, const UsdSkelAnimQuery &rhs)
Definition: animQuery.h:58
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
TF_DECLARE_REF_PTRS(UsdSkel_AnimQueryImpl)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
USDSKEL_API std::string GetDescription() const
USDSKEL_API bool ComputeJointLocalTransforms(VtArray< Matrix4 > *xforms, UsdTimeCode time=UsdTimeCode::Default()) const
USDSKEL_API bool GetBlendShapeWeightTimeSamplesInInterval(const GfInterval &interval, std::vector< double > *times) const
USDSKEL_API bool GetBlendShapeWeightAttributes(std::vector< UsdAttribute > *attrs) const
Get the attributes contributing to blendshape weight computations.
USDSKEL_API UsdPrim GetPrim() const
Return the primitive this anim query reads from.
USDSKEL_API VtTokenArray GetBlendShapeOrder() const