All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
skinningQuery.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_SKINNING_QUERY_H
8#define PXR_USD_USD_SKEL_SKINNING_QUERY_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usdSkel/api.h"
14
15#include "pxr/usd/usd/attribute.h"
16#include "pxr/usd/usd/prim.h"
17#include "pxr/usd/usd/relationship.h"
18
19#include "pxr/usd/usdGeom/primvar.h"
20
22
23#include <optional>
24
25PXR_NAMESPACE_OPEN_SCOPE
26
27
29
30
35{
36public:
37 USDSKEL_API
39
44 USDSKEL_API
46 const VtTokenArray& skelJointOrder,
47 const VtTokenArray& blendShapeOrder,
48 const UsdAttribute& jointIndices,
49 const UsdAttribute& jointWeights,
50 const UsdAttribute& skinningMethod,
51 const UsdAttribute& geomBindTransform,
52 const UsdAttribute& joints,
53 const UsdAttribute& blendShapes,
54 const UsdRelationship& blendShapeTargets);
55
57 bool IsValid() const { return bool(_prim); }
58
60 explicit operator bool() const { return IsValid(); }
61
62 const UsdPrim& GetPrim() const { return _prim; }
63
65 USDSKEL_API
66 bool HasBlendShapes() const;
67
69 USDSKEL_API
70 bool HasJointInfluences() const;
71
78 return _numInfluencesPerComponent;
79 }
80
81 const TfToken& GetInterpolation() const { return _interpolation; }
82
85 USDSKEL_API
86 bool IsRigidlyDeformed() const;
87
88 const UsdAttribute& GetSkinningMethodAttr() const {
89 return _skinningMethodAttr;
90 }
91
92 const UsdAttribute& GetGeomBindTransformAttr() const {
93 return _geomBindTransformAttr;
94 }
95
96 const UsdGeomPrimvar& GetJointIndicesPrimvar() const {
97 return _jointIndicesPrimvar;
98 }
99
100 const UsdGeomPrimvar& GetJointWeightsPrimvar() const {
101 return _jointWeightsPrimvar;
102 }
103
104 const UsdAttribute& GetBlendShapesAttr() const {
105 return _blendShapes;
106 }
107
108 const UsdRelationship& GetBlendShapeTargetsRel() const {
109 return _blendShapeTargets;
110 }
111
118 const UsdSkelAnimMapperRefPtr& GetJointMapper() const {
119 return _jointMapper;
120 }
121
123 const UsdSkelAnimMapperRefPtr& GetMapper() const { return _jointMapper; }
124
125
132 const UsdSkelAnimMapperRefPtr& GetBlendShapeMapper() const {
133 return _blendShapeMapper;
134 }
135
137 USDSKEL_API
138 bool GetJointOrder(VtTokenArray* jointOrder) const;
139
141 USDSKEL_API
142 bool GetBlendShapeOrder(VtTokenArray* blendShapes) const;
143
149 USDSKEL_API
150 bool GetTimeSamples(std::vector<double>* times) const;
151
157 USDSKEL_API
159 std::vector<double>* times) const;
160
165 USDSKEL_API
166 bool ComputeJointInfluences(VtIntArray* indices,
167 VtFloatArray* weights,
168 UsdTimeCode time=UsdTimeCode::Default()) const;
169
175 USDSKEL_API
177 size_t numPoints,
178 VtIntArray* indices,
179 VtFloatArray* weights,
180 UsdTimeCode time=UsdTimeCode::Default()) const;
181
190 template <typename Matrix4>
191 USDSKEL_API
193 VtVec3fArray* points,
194 UsdTimeCode time=UsdTimeCode::Default()) const;
195
204 template <typename Matrix4>
205 USDSKEL_API
207 VtVec3fArray* points,
208 UsdTimeCode time=UsdTimeCode::Default()) const;
209
220 template <typename Matrix4>
221 USDSKEL_API
223 Matrix4* xform,
224 UsdTimeCode time=UsdTimeCode::Default()) const;
225
232 template <typename Matrix4>
233 USDSKEL_API
234 float ComputeExtentsPadding(const VtArray<Matrix4>& skelRestXforms,
235 const UsdGeomBoundable& boundable) const;
236
237 USDSKEL_API
238 TfToken GetSkinningMethod() const;
239
240 USDSKEL_API
242 GetGeomBindTransform(UsdTimeCode time=UsdTimeCode::Default()) const;
243
244 USDSKEL_API
245 std::string GetDescription() const;
246
247private:
248
249 void _InitializeJointInfluenceBindings(
250 const UsdAttribute& jointIndices,
251 const UsdAttribute& jointWeights);
252
253 void _InitializeBlendShapeBindings(
254 const UsdAttribute& blendShapes,
255 const UsdRelationship& blendShapeTargets);
256
257 UsdPrim _prim;
258 int _numInfluencesPerComponent = 1;
259 int _flags = 0;
260 TfToken _interpolation;
261
262 UsdGeomPrimvar _jointIndicesPrimvar;
263 UsdGeomPrimvar _jointWeightsPrimvar;
264 UsdAttribute _skinningMethodAttr;
265 UsdAttribute _geomBindTransformAttr;
266 UsdAttribute _blendShapes;
267 UsdRelationship _blendShapeTargets;
268 UsdSkelAnimMapperRefPtr _jointMapper;
269 UsdSkelAnimMapperRefPtr _blendShapeMapper;
270 std::optional<VtTokenArray> _jointOrder;
271 std::optional<VtTokenArray> _blendShapeOrder;
272};
273
274PXR_NAMESPACE_CLOSE_SCOPE
275
276#endif // PXR_USD_USD_SKEL_SKINNING_QUERY_H
A basic mathematical interval class.
Definition: interval.h:33
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:71
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:160
Boundable introduces the ability for a prim to persistently cache a rectilinear, local-space,...
Definition: boundable.h:66
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars.
Definition: primvar.h:245
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:111
Object used for querying resolved bindings for skinning.
Definition: skinningQuery.h:35
USDSKEL_API bool HasBlendShapes() const
Returns true if there are blend shapes associated with this prim.
USDSKEL_API bool ComputeSkinnedNormals(const VtArray< Matrix4 > &xforms, VtVec3fArray *points, UsdTimeCode time=UsdTimeCode::Default()) const
Compute skinned normals using specified skinning method attr (fallback to linear blend skinning if no...
USDSKEL_API bool GetBlendShapeOrder(VtTokenArray *blendShapes) const
Get the blend shapes for this skinning site, if any.
USDSKEL_API bool IsRigidlyDeformed() const
Returns true if the held prim has the same joint influences across all points, or false otherwise.
const UsdSkelAnimMapperRefPtr & GetJointMapper() const
Return a mapper for remapping from the joint order of the skeleton to the local joint order of this p...
USDSKEL_API bool GetTimeSamplesInInterval(const GfInterval &interval, std::vector< double > *times) const
Populate times with the union of time samples within interval, for all properties that affect skinnin...
USDSKEL_API bool ComputeJointInfluences(VtIntArray *indices, VtFloatArray *weights, UsdTimeCode time=UsdTimeCode::Default()) const
Convenience method for computing joint influences.
USDSKEL_API float ComputeExtentsPadding(const VtArray< Matrix4 > &skelRestXforms, const UsdGeomBoundable &boundable) const
Helper for computing an approximate padding for use in extents computations.
int GetNumInfluencesPerComponent() const
Returns the number of influences encoded for each component.
Definition: skinningQuery.h:77
const UsdSkelAnimMapperRefPtr & GetBlendShapeMapper() const
Return the mapper for remapping blend shapes from the order of the bound SkelAnimation to the local b...
USDSKEL_API bool ComputeSkinnedPoints(const VtArray< Matrix4 > &xforms, VtVec3fArray *points, UsdTimeCode time=UsdTimeCode::Default()) const
Compute skinned points using specified skinning method attr (fallback to linear blend skinning if not...
bool IsValid() const
Returns true if this query is valid.
Definition: skinningQuery.h:57
const UsdSkelAnimMapperRefPtr & GetMapper() const
USDSKEL_API bool GetTimeSamples(std::vector< double > *times) const
Populate times with the union of time samples for all properties that affect skinning,...
USDSKEL_API bool ComputeSkinnedTransform(const VtArray< Matrix4 > &xforms, Matrix4 *xform, UsdTimeCode time=UsdTimeCode::Default()) const
Compute a skinning transform using specified skinning method attr (fallback to linear blend skinning ...
USDSKEL_API bool HasJointInfluences() const
Returns true if joint influence data is associated with this prim.
USDSKEL_API bool ComputeVaryingJointInfluences(size_t numPoints, VtIntArray *indices, VtFloatArray *weights, UsdTimeCode time=UsdTimeCode::Default()) const
Convenience method for computing joint influence, where constant influences are expanded to hold valu...
USDSKEL_API bool GetJointOrder(VtTokenArray *jointOrder) const
Get the custom joint order for this skinning site, if any.
USDSKEL_API UsdSkelSkinningQuery(const UsdPrim &prim, const VtTokenArray &skelJointOrder, const VtTokenArray &blendShapeOrder, const UsdAttribute &jointIndices, const UsdAttribute &jointWeights, const UsdAttribute &skinningMethod, const UsdAttribute &geomBindTransform, const UsdAttribute &joints, const UsdAttribute &blendShapes, const UsdRelationship &blendShapeTargets)
Construct a new skining query for the resolved properties set through the UsdSkelBindingAPI,...
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:67
static constexpr UsdTimeCode Default()
Produce a UsdTimeCode representing the sentinel value for 'default'.
Definition: timeCode.h:95
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:211