All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
skeletonQuery.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_SKELETONQUERY_H
25 #define USDSKEL_SKELETONQUERY_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdSkel/api.h"
31 
32 #include "pxr/base/tf/declarePtrs.h"
33 #include "pxr/base/vt/types.h"
34 
35 #include "pxr/usd/usd/prim.h"
36 
37 #include "pxr/usd/usdSkel/animMapper.h"
38 #include "pxr/usd/usdSkel/animQuery.h"
39 
40 
41 PXR_NAMESPACE_OPEN_SCOPE
42 
43 class UsdGeomXformCache;
44 class UsdSkelSkeleton;
45 class UsdSkelTopology;
46 
48 
49 
71 {
72 public:
74 
76  bool IsValid() const { return _definition; }
77 
79  explicit operator bool() const { return IsValid(); }
80 
83  friend bool operator==(const UsdSkelSkeletonQuery& lhs,
84  const UsdSkelSkeletonQuery& rhs) {
85  return lhs._definition == rhs._definition &&
86  lhs._animQuery == rhs._animQuery;
87  }
88 
91  friend bool operator!=(const UsdSkelSkeletonQuery& lhs,
92  const UsdSkelSkeletonQuery& rhs) {
93  return !(lhs == rhs);
94  }
95 
98  USDSKEL_API
99  bool HasBindPose() const;
100 
103  USDSKEL_API
104  bool HasRestPose() const;
105 
106  // hash_value overload for std/boost hash.
107  USDSKEL_API
108  friend size_t hash_value(const UsdSkelSkeletonQuery& query);
109 
112  USDSKEL_API
113  UsdPrim GetPrim() const;
114 
116  USDSKEL_API
117  const UsdSkelSkeleton& GetSkeleton() const;
118 
121  USDSKEL_API
122  const UsdSkelAnimQuery& GetAnimQuery() const;
123 
125  USDSKEL_API
126  const UsdSkelTopology& GetTopology() const;
127 
130  USDSKEL_API
131  const UsdSkelAnimMapper& GetMapper() const;
132 
137  USDSKEL_API
138  VtTokenArray GetJointOrder() const;
139 
148  template <typename Matrix4>
149  USDSKEL_API
151  UsdTimeCode time,
152  bool atRest=false) const;
153 
159  template <typename Matrix4>
160  USDSKEL_API
162  UsdTimeCode time,
163  bool atRest=false) const;
164 
171  template <typename Matrix4>
172  USDSKEL_API
174  UsdTimeCode time) const;
175 
183  template <typename Matrix4>
184  USDSKEL_API
186  UsdGeomXformCache* xfCache,
187  bool atRest=false) const;
188 
198  template <typename Matrix4>
199  USDSKEL_API
201  UsdTimeCode time) const;
202 
204  template <typename Matrix4>
205  USDSKEL_API
206  bool GetJointWorldBindTransforms(VtArray<Matrix4>* xforms) const;
207 
208  USDSKEL_API
209  std::string GetDescription() const;
210 
211 private:
212 
213  USDSKEL_API
214  UsdSkelSkeletonQuery(const UsdSkel_SkelDefinitionRefPtr& definition,
215  const UsdSkelAnimQuery& anim=UsdSkelAnimQuery());
216 
217  bool _HasMappableAnim() const;
218 
219  template <typename Matrix4>
220  bool _ComputeJointLocalTransforms(VtArray<Matrix4>* xforms,
221  UsdTimeCode time,
222  bool atRest=false) const;
223 
224  template <typename Matrix4>
225  bool _ComputeJointSkelTransforms(VtArray<Matrix4>* xforms,
226  UsdTimeCode time,
227  bool atRest=false) const;
228 
229  template <typename Matrix4>
230  bool _ComputeSkinningTransforms(VtArray<Matrix4>* xforms,
231  UsdTimeCode time) const;
232 
233 private:
234  UsdSkel_SkelDefinitionRefPtr _definition;
235  UsdSkelAnimQuery _animQuery;
236  UsdSkelAnimMapper _animToSkelMapper;
237 
238  friend class UsdSkel_CacheImpl;
239 };
240 
241 
242 PXR_NAMESPACE_CLOSE_SCOPE
243 
244 #endif // USDSKEL_SKELETONQUERY_H
USDSKEL_API bool HasRestPose() const
Returns true if the size of the array returned by skeleton::GetRestTransformsAttr() matches the numbe...
USDSKEL_API bool ComputeJointRestRelativeTransforms(VtArray< Matrix4 > *xforms, UsdTimeCode time) const
Compute joint transforms which, when concatenated against the rest pose, produce joint transforms in ...
USDSKEL_API bool ComputeSkinningTransforms(VtArray< Matrix4 > *xforms, UsdTimeCode time) const
Compute transforms representing the change in transformation of a joint from its rest pose...
Object holding information describing skeleton topology.
Definition: topology.h:45
Internal cache implementation.
Definition: cacheImpl.h:72
Structure storing the core definition of a Skeleton.
Class providing efficient queries of primitives that provide skel animation.
Definition: animQuery.h:54
USDSKEL_API bool ComputeJointSkelTransforms(VtArray< Matrix4 > *xforms, UsdTimeCode time, bool atRest=false) const
Compute joint transforms in skeleton space, at time.
USDSKEL_API UsdPrim GetPrim() const
Returns the underlying Skeleton primitive corresponding to the bound skeleton instance, if any.
friend bool operator==(const UsdSkelSkeletonQuery &lhs, const UsdSkelSkeletonQuery &rhs)
Equality comparison.
Definition: skeletonQuery.h:83
USDSKEL_API const UsdSkelSkeleton & GetSkeleton() const
Returns the bound skeleton instance, if any.
USDSKEL_API bool HasBindPose() const
Returns true if the size of the array returned by skeleton::GetBindTransformsAttr() matches the numbe...
USDSKEL_API const UsdSkelAnimMapper & GetMapper() const
Returns a mapper for remapping from the bound animation, if any, to the Skeleton. ...
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
USDSKEL_API bool ComputeJointWorldTransforms(VtArray< Matrix4 > *xforms, UsdGeomXformCache *xfCache, bool atRest=false) const
Compute joint transforms in world space, at whatever time is configured on xfCache.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
USDSKEL_API bool ComputeJointLocalTransforms(VtArray< Matrix4 > *xforms, UsdTimeCode time, bool atRest=false) const
Compute joint transforms in joint-local space, at time.
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:193
Describes a skeleton.
Definition: skeleton.h:63
USDSKEL_API const UsdSkelTopology & GetTopology() const
Returns the topology of the bound skeleton instance, if any.
USDSKEL_API VtTokenArray GetJointOrder() const
Returns an arrray of joint paths, given as tokens, describing the order and parent-child relationship...
bool IsValid() const
Return true if this query is valid.
Definition: skeletonQuery.h:76
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:75
Primary interface to reading bound skeleton data.
Definition: skeletonQuery.h:70
friend bool operator!=(const UsdSkelSkeletonQuery &lhs, const UsdSkelSkeletonQuery &rhs)
Inequality comparison.
Definition: skeletonQuery.h:91
USDSKEL_API bool GetJointWorldBindTransforms(VtArray< Matrix4 > *xforms) const
Returns the world space joint transforms at bind time.
USDSKEL_API const UsdSkelAnimQuery & GetAnimQuery() const
Returns the animation query that provides animation for the bound skeleton instance, if any.
A caching mechanism for transform matrices.
Definition: xformCache.h:58