Loading...
Searching...
No Matches
skinningQuery.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_SKINNING_QUERY_H
25#define PXR_USD_USD_SKEL_SKINNING_QUERY_H
26
28
29#include "pxr/pxr.h"
30#include "pxr/usd/usdSkel/api.h"
31
32#include "pxr/usd/usd/attribute.h"
33#include "pxr/usd/usd/prim.h"
34#include "pxr/usd/usd/relationship.h"
35
36#include "pxr/usd/usdGeom/primvar.h"
37
39
40#include <optional>
41
42PXR_NAMESPACE_OPEN_SCOPE
43
44
46
47
52{
53public:
54 USDSKEL_API
56
61 USDSKEL_API
63 const VtTokenArray& skelJointOrder,
64 const VtTokenArray& blendShapeOrder,
65 const UsdAttribute& jointIndices,
66 const UsdAttribute& jointWeights,
67 const UsdAttribute& skinningMethod,
68 const UsdAttribute& geomBindTransform,
69 const UsdAttribute& joints,
70 const UsdAttribute& blendShapes,
71 const UsdRelationship& blendShapeTargets);
72
74 bool IsValid() const { return bool(_prim); }
75
77 explicit operator bool() const { return IsValid(); }
78
79 const UsdPrim& GetPrim() const { return _prim; }
80
82 USDSKEL_API
83 bool HasBlendShapes() const;
84
86 USDSKEL_API
87 bool HasJointInfluences() const;
88
95 return _numInfluencesPerComponent;
96 }
97
98 const TfToken& GetInterpolation() const { return _interpolation; }
99
102 USDSKEL_API
103 bool IsRigidlyDeformed() const;
104
105 const UsdAttribute& GetSkinningMethodAttr() const {
106 return _skinningMethodAttr;
107 }
108
109 const UsdAttribute& GetGeomBindTransformAttr() const {
110 return _geomBindTransformAttr;
111 }
112
113 const UsdGeomPrimvar& GetJointIndicesPrimvar() const {
114 return _jointIndicesPrimvar;
115 }
116
117 const UsdGeomPrimvar& GetJointWeightsPrimvar() const {
118 return _jointWeightsPrimvar;
119 }
120
121 const UsdAttribute& GetBlendShapesAttr() const {
122 return _blendShapes;
123 }
124
125 const UsdRelationship& GetBlendShapeTargetsRel() const {
126 return _blendShapeTargets;
127 }
128
135 const UsdSkelAnimMapperRefPtr& GetJointMapper() const {
136 return _jointMapper;
137 }
138
140 const UsdSkelAnimMapperRefPtr& GetMapper() const { return _jointMapper; }
141
142
149 const UsdSkelAnimMapperRefPtr& GetBlendShapeMapper() const {
150 return _blendShapeMapper;
151 }
152
154 USDSKEL_API
155 bool GetJointOrder(VtTokenArray* jointOrder) const;
156
158 USDSKEL_API
159 bool GetBlendShapeOrder(VtTokenArray* blendShapes) const;
160
166 USDSKEL_API
167 bool GetTimeSamples(std::vector<double>* times) const;
168
174 USDSKEL_API
176 std::vector<double>* times) const;
177
182 USDSKEL_API
183 bool ComputeJointInfluences(VtIntArray* indices,
184 VtFloatArray* weights,
185 UsdTimeCode time=UsdTimeCode::Default()) const;
186
192 USDSKEL_API
194 size_t numPoints,
195 VtIntArray* indices,
196 VtFloatArray* weights,
197 UsdTimeCode time=UsdTimeCode::Default()) const;
198
207 template <typename Matrix4>
208 USDSKEL_API
210 VtVec3fArray* points,
211 UsdTimeCode time=UsdTimeCode::Default()) const;
212
221 template <typename Matrix4>
222 USDSKEL_API
224 VtVec3fArray* points,
225 UsdTimeCode time=UsdTimeCode::Default()) const;
226
237 template <typename Matrix4>
238 USDSKEL_API
240 Matrix4* xform,
241 UsdTimeCode time=UsdTimeCode::Default()) const;
242
249 template <typename Matrix4>
250 USDSKEL_API
251 float ComputeExtentsPadding(const VtArray<Matrix4>& skelRestXforms,
252 const UsdGeomBoundable& boundable) const;
253
254 USDSKEL_API
255 TfToken GetSkinningMethod() const;
256
257 USDSKEL_API
259 GetGeomBindTransform(UsdTimeCode time=UsdTimeCode::Default()) const;
260
261 USDSKEL_API
262 std::string GetDescription() const;
263
264private:
265
266 void _InitializeJointInfluenceBindings(
267 const UsdAttribute& jointIndices,
268 const UsdAttribute& jointWeights);
269
270 void _InitializeBlendShapeBindings(
271 const UsdAttribute& blendShapes,
272 const UsdRelationship& blendShapeTargets);
273
274 UsdPrim _prim;
275 int _numInfluencesPerComponent = 1;
276 int _flags = 0;
277 TfToken _interpolation;
278
279 UsdGeomPrimvar _jointIndicesPrimvar;
280 UsdGeomPrimvar _jointWeightsPrimvar;
281 UsdAttribute _skinningMethodAttr;
282 UsdAttribute _geomBindTransformAttr;
283 UsdAttribute _blendShapes;
284 UsdRelationship _blendShapeTargets;
285 UsdSkelAnimMapperRefPtr _jointMapper;
286 UsdSkelAnimMapperRefPtr _blendShapeMapper;
287 std::optional<VtTokenArray> _jointOrder;
288 std::optional<VtTokenArray> _blendShapeOrder;
289};
290
291PXR_NAMESPACE_CLOSE_SCOPE
292
293#endif // PXR_USD_USD_SKEL_SKINNING_QUERY_H
A basic mathematical interval class.
Definition: interval.h:50
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
Boundable introduces the ability for a prim to persistently cache a rectilinear, local-space,...
Definition: boundable.h:83
Schema wrapper for UsdAttribute for authoring and introspecting attributes that are primvars.
Definition: primvar.h:262
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
Object used for querying resolved bindings for skinning.
Definition: skinningQuery.h:52
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:94
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:74
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:84
static constexpr UsdTimeCode Default()
Produce a UsdTimeCode representing the sentinel value for 'default'.
Definition: timeCode.h:112
Represents an arbitrary dimensional rectangular container class.
Definition: array.h:228