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 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 PXR_USD_USD_SKEL_ANIM_QUERY_H
25 #define PXR_USD_USD_SKEL_ANIM_QUERY_H
26 
27 /// \file usdSkel/animQuery.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdSkel/api.h"
31 
33 #include "pxr/base/vt/types.h"
34 
35 #include "pxr/usd/sdf/path.h"
36 #include "pxr/usd/usd/prim.h"
37 #include "pxr/usd/usd/timeCode.h"
38 
39 
41 
42 
43 class GfMatrix4d;
44 class UsdAttribute;
45 class UsdSkelCache;
46 
47 
48 TF_DECLARE_REF_PTRS(UsdSkel_AnimQueryImpl);
49 
50 
51 /// \class UsdSkelAnimQuery
52 ///
53 /// Class providing efficient queries of primitives that provide skel animation.
55 {
56 public:
59 
60  /// Return true if this query is valid.
61  bool IsValid() const { return (bool)_impl; }
62 
63  /// Boolean conversion operator. Equivalent to IsValid().
64  explicit operator bool() const { return IsValid(); }
65 
66  /// Equality comparison. Return true if \a lhs and \a rhs represent the
67  /// same UsdSkelAnimQuery, false otherwise.
68  friend bool operator==(const UsdSkelAnimQuery& lhs,
69  const UsdSkelAnimQuery& rhs) {
70  return lhs.GetPrim() == rhs.GetPrim();
71  }
72 
73  /// Inequality comparison. Return false if \a lhs and \a rhs represent the
74  /// same UsdSkelAnimQuery, true otherwise.
75  friend bool operator!=(const UsdSkelAnimQuery& lhs,
76  const UsdSkelAnimQuery& rhs) {
77  return !(lhs == rhs);
78  }
79 
80  // hash_value overload for std/hboost hash.
81  friend size_t hash_value(const UsdSkelAnimQuery& query) {
82  return hash_value(query.GetPrim());
83  }
84 
85  /// Return the primitive this anim query reads from.
87  UsdPrim GetPrim() const;
88 
89  /// Compute joint transforms in joint-local space.
90  /// Transforms are returned in the order specified by the joint ordering
91  /// of the animation primitive itself.
92  template <typename Matrix4>
95  VtArray<Matrix4>* xforms,
97 
98  /// Compute translation,rotation,scale components of the joint transforms
99  /// in joint-local space. This is provided to facilitate direct streaming
100  /// of animation data in a form that can efficiently be processed for
101  /// animation blending.
104  VtVec3fArray* translations,
105  VtQuatfArray* rotations,
106  VtVec3hArray* scales,
108 
111  VtFloatArray* weights,
113 
114  /// Get the time samples at which values contributing to joint transforms
115  /// are set. This only computes the time samples for sampling transforms in
116  /// joint-local space, and does not include time samples affecting the
117  /// root transformation.
118  ///
119  /// \sa UsdAttribute::GetTimeSamples
121  bool GetJointTransformTimeSamples(std::vector<double>* times) const;
122 
123  /// Get the time samples at which values contributing to joint transforms
124  /// are set, over \p interval. This only computes the time samples for
125  /// sampling transforms in joint-local space, and does not include time
126  /// samples affecting the root transformation.
127  ///
128  /// \sa UsdAttribute::GetTimeSamplesInInterval
131  std::vector<double>* times) const;
132 
133  /// Get the attributes contributing to JointTransform computations
135  bool GetJointTransformAttributes(std::vector<UsdAttribute>* attrs) const;
136 
137  /// Return true if it possible, but not certain, that joint transforms
138  /// computed through this animation query change over time, false otherwise.
139  ///
140  /// \sa UsdAttribute::ValueMightBeTimeVayring
143 
144  /// Get the time samples at which values contributing to blend shape weights
145  /// have been set.
146  ///
147  /// \sa UsdAttribute::GetTimeSamples
149  bool GetBlendShapeWeightTimeSamples(std::vector<double>* attrs) const;
150 
151  /// Get the time samples at which values contributing to blend shape weights
152  /// are set, over \p interval.
153  ///
154  /// \sa UsdAttribute::GetTimeSamplesInInterval
157  std::vector<double>* times) const;
158 
159  /// Get the attributes contributing to blendshape weight computations.
161  bool GetBlendShapeWeightAttributes(std::vector<UsdAttribute>* attrs) const;
162 
163  /// Return true if it possible, but not certain, that the blend shape
164  /// weights computed through this animation query change over time,
165  /// false otherwise.
166  ///
167  /// \sa UsdAttribute::ValueMightBeTimeVayring
170 
171  /// Returns an array of tokens describing the ordering of joints in the
172  /// animation.
173  ///
174  /// \sa UsdSkelSkeleton::GetJointOrder
176  VtTokenArray GetJointOrder() const;
177 
178  /// Returns an array of tokens describing the ordering of blend shape
179  /// channels in the animation.
181  VtTokenArray GetBlendShapeOrder() const;
182 
184  std::string GetDescription() const;
185 
186 private:
187  UsdSkelAnimQuery(const UsdSkel_AnimQueryImplRefPtr& impl)
188  : _impl(impl) {}
189 
190  UsdSkel_AnimQueryImplRefPtr _impl;
191 
192  friend class UsdSkel_CacheImpl;
193 };
194 
195 
197 
198 #endif // PXR_USD_USD_SKEL_ANIM_QUERY_H
GLenum query
Definition: glad.h:2772
static constexpr UsdTimeCode Default()
Definition: timeCode.h:112
friend size_t hash_value(const UsdSkelAnimQuery &query)
Definition: animQuery.h:81
USDSKEL_API bool GetJointTransformTimeSamplesInInterval(const GfInterval &interval, std::vector< double > *times) const
GT_API const UT_StringHolder time
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
USDSKEL_API bool GetJointTransformAttributes(std::vector< UsdAttribute > *attrs) const
Get the attributes contributing to JointTransform computations.
USDSKEL_API VtTokenArray GetJointOrder() const
friend class UsdSkel_CacheImpl
Definition: animQuery.h:192
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:58
bool IsValid() const
Return true if this query is valid.
Definition: animQuery.h:61
Definition: prim.h:135
USDSKEL_API bool BlendShapeWeightsMightBeTimeVarying() const
friend bool operator==(const UsdSkelAnimQuery &lhs, const UsdSkelAnimQuery &rhs)
Definition: animQuery.h:68
#define USDSKEL_API
Definition: api.h:40
Definition: types.h:173
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:75
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
TF_DECLARE_REF_PTRS(UsdSkel_AnimQueryImpl)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
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