HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utils.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_UTILS_H
25 #define PXR_USD_USD_SKEL_UTILS_H
26 
27 /// \file usdSkel/utils.h
28 ///
29 /// Collection of utility methods.
30 ///
31 
32 #include "pxr/pxr.h"
33 #include "pxr/usd/usdSkel/api.h"
34 
35 #include "pxr/base/gf/quatf.h"
36 #include "pxr/base/gf/matrix3d.h"
37 #include "pxr/base/gf/matrix3f.h"
38 #include "pxr/base/gf/matrix4d.h"
39 #include "pxr/base/gf/matrix4f.h"
40 #include "pxr/base/gf/vec3h.h"
41 #include "pxr/base/gf/vec3h.h"
42 #include "pxr/base/tf/span.h"
43 #include "pxr/base/vt/array.h"
44 #include "pxr/base/vt/types.h"
45 
46 #include "pxr/usd/sdf/path.h"
47 
48 #include <cstddef>
49 
50 // XXX: Included for backwards compatibility.
52 
53 
55 
56 
57 class GfMatrix3f;
58 class GfRange3f;
59 class GfRotation;
60 class UsdPrim;
61 class UsdPrimRange;
62 class UsdRelationship;
63 class UsdSkelRoot;
64 class UsdSkelTopology;
65 
66 
67 /// \defgroup UsdSkel_Utils Utilities
68 /// @{
69 
70 
71 /// Returns true if \p prim is a valid skel animation source.
73 bool
75 
76 
77 /// Returns true if \p prim is considered to be a skinnable primitive.
78 /// Whether or not the prim is actually skinned additionally depends on whether
79 /// or not the prim has a bound skeleton, and prop joint influences.
81 bool
82 UsdSkelIsSkinnablePrim(const UsdPrim& prim);
83 
84 
85 /// \defgroup UsdSkel_JointTransformUtils Joint Transform Utilities
86 /// Utilities for working with vectorized joint transforms.
87 /// @{
88 
89 
90 /// Compute joint transforms in joint-local space.
91 /// Transforms are computed from \p xforms, holding concatenated
92 /// joint transforms, and \p inverseXforms, providing the inverse
93 /// of each of those transforms. The resulting local space transforms
94 /// are written to \p jointLocalXforms, which must be the same size
95 /// as \p topology.
96 /// If the root joints include an additional, external transformation
97 /// -- eg., such as the skel local-to-world transformation -- then the
98 /// inverse of that transform should be passed as \p rootInverseXform.
99 /// If no \p rootInverseXform is provided, then \p xform and \p inverseXforms
100 /// should be based on joint transforms computed in skeleton space.
101 /// Each transform array must be sized to the number of joints from \p topology.
103 bool
106  TfSpan<const GfMatrix4d> inverseXforms,
107  TfSpan<GfMatrix4d> jointLocalXforms,
108  const GfMatrix4d* rootInverseXform=nullptr);
109 
110 /// \overload
112 bool
115  TfSpan<const GfMatrix4f> inverseXforms,
116  TfSpan<GfMatrix4f> jointLocalXforms,
117  const GfMatrix4f* rootInverseXform=nullptr);
118 
119 /// Compute joint transforms in joint-local space.
120 /// This is a convenience overload, which computes the required inverse
121 /// transforms internally.
123 bool
126  TfSpan<GfMatrix4d> jointLocalXforms,
127  const GfMatrix4d* rootInverseXform=nullptr);
128 
130 bool
133  TfSpan<GfMatrix4f> jointLocalXforms,
134  const GfMatrix4f* rootInverseXform=nullptr);
135 
136 
137 /// \overload
138 /// \deprecated Use form that takes TfSpan arguments.
140 bool
142  const VtMatrix4dArray& xforms,
143  const VtMatrix4dArray& inverseXforms,
144  VtMatrix4dArray* jointLocalXforms,
145  const GfMatrix4d* rootInverseXform=nullptr);
146 
147 
148 
149 
150 /// \overload
151 /// \deprecated Use form that takes TfSpan arguments.
153 bool
155  const VtMatrix4dArray& xforms,
156  VtMatrix4dArray* jointLocalXforms,
157  const GfMatrix4d* rootInverseXform=nullptr);
158 
159 
160 /// \overload
161 /// \deprecated Use form that takes TfSpan arguments.
163 bool
165  const GfMatrix4d* xforms,
166  const GfMatrix4d* inverseXforms,
167  GfMatrix4d* jointLocalXforms,
168  const GfMatrix4d* rootInverseXform=nullptr);
169 
170 
171 
172 /// Compute concatenated joint transforms.
173 /// This concatenates transforms from \p jointLocalXforms, providing joint
174 /// transforms in joint-local space. The resulting transforms are written to
175 /// \p jointLocalXforms, which must be the same size as \p topology.
176 /// If \p rootXform is not provided, or is the identity, the resulting joint
177 /// transforms will be given in skeleton space. Any additional transformations
178 /// may be provided on \p rootXform if an additional level of transformation
179 /// -- such as the skel local to world transform -- are desired.
180 /// Each transform array must be sized to the number of joints from \p topology.
182 bool
184  TfSpan<const GfMatrix4d> jointLocalXforms,
185  TfSpan<GfMatrix4d> xforms,
186  const GfMatrix4d* rootXform=nullptr);
187 
188 
189 /// \overload
191 bool
193  TfSpan<const GfMatrix4f> jointLocalXforms,
194  TfSpan<GfMatrix4f> xforms,
195  const GfMatrix4f* rootXform=nullptr);
196 
197 
198 
199 /// \overload
200 /// \deprecated Use the function form that takes TfSpan arguments.
202 bool
204  const VtMatrix4dArray& jointLocalXforms,
205  VtMatrix4dArray* xforms,
206  const GfMatrix4d* rootXform=nullptr);
207 
208 
209 /// \overload
210 /// \deprecated Use the form that takes a TfSpan argument.
212 bool
214  const GfMatrix4d* jointLocalXforms,
215  GfMatrix4d* xforms,
216  const GfMatrix4d* rootXform=nullptr);
217 
218 
219 /// Compute an extent from a set of skel-space joint transform.
220 /// The \p rootXform may also be set to provide an additional root
221 /// transformation on top of all joints, which is useful for computing
222 /// extent relative to a different space.
223 template <typename Matrix4>
225 bool
227  GfRange3f* extent,
228  float pad=0.0f,
229  const Matrix4* rootXform=nullptr);
230 
231 
232 
233 /// \overload
234 /// \deprecated Use form that takes a TfSpan.
236 bool
237 UsdSkelComputeJointsExtent(const VtMatrix4dArray& joints,
238  VtVec3fArray* extent,
239  float pad=0.0f,
240  const GfMatrix4d* rootXform=nullptr);
241 
242 
243 /// \overload
244 /// \deprecated Use form that takes a TfSpan.
246 bool
248  size_t numXforms,
249  VtVec3fArray* extent,
250  float pad=0.0f,
251  const GfMatrix4d* rootXform=nullptr);
252 
253 
254 /// @}
255 
256 
257 /// \defgroup UsdSkel_TransformCompositionUtils Transform Composition Utils
258 /// Utiltiies for converting transforms to and from component (translate,
259 /// rotate, scale) form.
260 /// @{
261 
262 
263 /// Decompose a transform into translate/rotate/scale components.
264 /// The transform order for decomposition is scale, rotate, translate.
265 template <typename Matrix4>
267 bool
268 UsdSkelDecomposeTransform(const Matrix4& xform,
269  GfVec3f* translate,
271  GfVec3h* scale);
272 
273 /// \overload
274 template <typename Matrix4>
276 bool
277 UsdSkelDecomposeTransform(const Matrix4& xform,
278  GfVec3f* translate,
279  GfQuatf* rotate,
280  GfVec3h* scale);
281 
282 
283 /// Decompose an array of transforms into translate/rotate/scale components.
284 /// All spans must be the same size.
286 bool
288  TfSpan<GfVec3f> translations,
289  TfSpan<GfQuatf> rotations,
290  TfSpan<GfVec3h> scales);
291 
292 /// \overload
294 bool
296  TfSpan<GfVec3f> translations,
297  TfSpan<GfQuatf> rotations,
298  TfSpan<GfVec3h> scales);
299 
300 
301 /// \overload
302 /// \deprecated Use form that takes TfSpan arguments.
304 bool
305 UsdSkelDecomposeTransforms(const VtMatrix4dArray& xforms,
306  VtVec3fArray* translations,
307  VtQuatfArray* rotations,
308  VtVec3hArray* scales);
309 
310 
311 /// \overload
312 /// \deprecated Use form that takes TfSpan arguments.
314 bool
316  GfVec3f* translations,
317  GfQuatf* rotations,
318  GfVec3h* scales,
319  size_t count);
320 
321 
322 /// Create a transform from translate/rotate/scale components.
323 /// This performs the inverse of UsdSkelDecomposeTransform.
324 template <typename Matrix4>
326 void
328  const GfMatrix3f& rotate,
329  const GfVec3h& scale,
330  Matrix4* xform);
331 
332 /// \overload
333 template <typename Matrix4>
335 void
337  const GfQuatf& rotate,
338  const GfVec3h& scale,
339  Matrix4* xform);
340 
341 /// Create transforms from arrays of components.
342 /// All spans must be the same size.
344 bool
346  TfSpan<const GfQuatf> rotations,
347  TfSpan<const GfVec3h> scales,
348  TfSpan<GfMatrix4d> xforms);
349 
350 
351 /// \overload
353 bool
355  TfSpan<const GfQuatf> rotations,
356  TfSpan<const GfVec3h> scales,
357  TfSpan<GfMatrix4f> xforms);
358 
359 
360 /// \overload
361 /// \deprecated Use form that takes TfSpan arguments.
363 bool
364 UsdSkelMakeTransforms(const VtVec3fArray& translations,
365  const VtQuatfArray& rotations,
366  const VtVec3hArray& scales,
367  VtMatrix4dArray* xforms);
368 
369 /// \overload
370 /// \deprecated Use form that takes TfSpan arguments.
372 bool
373 UsdSkelMakeTransforms(const GfVec3f* translations,
374  const GfQuatf* rotations,
375  const GfVec3h* scales,
376  GfMatrix4d* xforms,
377  size_t count);
378 
379 
380 /// @}
381 
382 
383 /// \defgroup UsdSkel_JointInfluenceUtils Joint Influence Utils
384 /// Collection of methods for working \ref UsdSkel_Terminology_JointInfluences
385 /// "joint influences", as stored through UsdSkelBindingAPI.`
386 /// @{
387 
388 
389 /// Helper method to normalize weight values across each consecutive run of
390 /// \p numInfluencesPerComponent elements.
391 /// If the total weight for a run of elements is smaller than \p eps, the
392 /// elements' weights are set to zero.
394 bool
395 UsdSkelNormalizeWeights(TfSpan<float> weights, int numInfluencesPerComponent,
396  float eps = std::numeric_limits<float>::epsilon());
397 
398 
399 /// \overload
400 /// \deprecated Use form that takes a TfSpan.
402 bool
403 UsdSkelNormalizeWeights(VtFloatArray* weights, int numInfluencesPerComponent);
404 
405 
406 /// Sort joint influences such that highest weight values come first.
408 bool
410  int numInfluencesPerComponent);
411 
412 /// \overload
413 /// \deprecated Use form that takes TfSpan arguments.
415 bool
416 UsdSkelSortInfluences(VtIntArray* indices, VtFloatArray* weights,
417  int numInfluencesPerComponent);
418 
419 
420 /// Convert an array of constant influences (joint weights or indices)
421 /// to an array of varying influences.
422 /// The \p size should match the size of required for 'vertex' interpolation
423 /// on the type geometry primitive. Typically, this is the number of points.
424 /// This is a convenience function for clients that don't understand
425 /// constant (rigid) weighting.
427 bool
429 
430 /// \overload
432 bool
433 UsdSkelExpandConstantInfluencesToVarying(VtFloatArray* weights, size_t size);
434 
435 /// Resize the number of influences per component in a weight or indices array,
436 /// which initially has \p srcNumInfluencesPerComponent influences to have
437 /// no more than \p newNumInfluencesPerComponent influences per component.
438 /// If the size decreases, influences are additionally re-normalized.
439 /// This is a convenience method for clients that require a fixed number of
440 /// of influences.
442 bool
443 UsdSkelResizeInfluences(VtIntArray* indices,
444  int srcNumInfluencesPerComponent,
445  int newNumInfluencesPerComponent);
446 
447 /// \overload
449 bool
450 UsdSkelResizeInfluences(VtFloatArray* weights,
451  int srcNumInfluencesPerComponent,
452  int newNumInfluencesPerComponent);
453 
454 /// Combine arrays of joint indices and weights into interleaved
455 /// (index,weight) vectors.
457 bool
459  const TfSpan<const float>& weights,
460  TfSpan<GfVec2f> interleavedInfluences);
461 
462 
463 /// @}
464 
465 
466 /// \defgroup UsdSkel_SkinningUtils Skinning Implementations
467 /// Reference skinning implementations for skinning points and transforms.
468 /// @{
469 
470 
471 /// Skin points using linear blend skinning (LBS) or dual quaternion skinning (DQS).
472 /// The \p jointXforms are \ref UsdSkel_Term_SkinningTransforms
473 /// "skinning transforms", given in _skeleton space_, while the
474 /// \p geomBindTransform provides the transform that transforms the initial
475 /// \p points into the same _skeleton space_ that the skinning transforms
476 /// were computed in.
478 bool
479 UsdSkelSkinPoints(const TfToken& skinningMethod,
480  const GfMatrix4d& geomBindTransform,
481  TfSpan<const GfMatrix4d> jointXforms,
482  TfSpan<const int> jointIndices,
483  TfSpan<const float> jointWeights,
484  int numInfluencesPerPoint,
486  bool inSerial=false);
487 
488 
489 /// \overload
491 bool
492 UsdSkelSkinPoints(const TfToken& skinningMethod,
493  const GfMatrix4f& geomBindTransform,
494  TfSpan<const GfMatrix4f> jointXforms,
495  TfSpan<const int> jointIndices,
496  TfSpan<const float> jointWeights,
497  int numInfluencesPerPoint,
499  bool inSerial=false);
500 
501 
502 /// Skin points using linear blend skinning, with interleaved influences.
504 bool
505 UsdSkelSkinPoints(const TfToken& skinningMethod,
506  const GfMatrix4d& geomBindTransform,
507  TfSpan<const GfMatrix4d> jointXforms,
508  TfSpan<const GfVec2f> influences,
509  int numInfluencesPerPoint,
511  bool inSerial=false);
512 
513 
514 /// \overload
516 bool
517 UsdSkelSkinPoints(const TfToken& skinningMethod,
518  const GfMatrix4f& geomBindTransform,
519  TfSpan<const GfMatrix4f> jointXforms,
520  TfSpan<const GfVec2f> influences,
521  int numInfluencesPerPoint,
523  bool inSerial=false);
524 
525 
526 /// \overload
527 /// \deprecated Use form that takes TfSpan arguments.
529 bool
530 UsdSkelSkinPoints(const TfToken& skinningMethod,
531  const GfMatrix4d& geomBindTransform,
532  const VtMatrix4dArray& jointXforms,
533  const VtIntArray& jointIndices,
534  const VtFloatArray& jointWeights,
535  int numInfluencesPerPoint,
536  VtVec3fArray* points);
537 
538 
539 /// \overload
540 /// \deprecated Use form that takes TfSpan arguments.
542 bool
543 UsdSkelSkinPoints(const TfToken& skinningMethod,
544  const GfMatrix4d& geomBindTransform,
545  const GfMatrix4d* jointXforms,
546  size_t numJoints,
547  const int* jointIndices,
548  const float* jointWeights,
549  size_t numInfluences,
550  int numInfluencesPerPoint,
551  GfVec3f* points,
552  size_t numPoints,
553  bool inSerial=false);
554 
555 
557 bool
558 UsdSkelSkinPointsLBS(const GfMatrix4d& geomBindTransform,
559  TfSpan<const GfMatrix4d> jointXforms,
560  TfSpan<const int> jointIndices,
561  TfSpan<const float> jointWeights,
562  int numInfluencesPerPoint,
564  bool inSerial=false);
565 
566 /// \overload
568 bool
569 UsdSkelSkinPointsLBS(const GfMatrix4f& geomBindTransform,
570  TfSpan<const GfMatrix4f> jointXforms,
571  TfSpan<const int> jointIndices,
572  TfSpan<const float> jointWeights,
573  int numInfluencesPerPoint,
575  bool inSerial=false);
576 
577 
578 /// Skin points using linear blend skinning, with interleaved influences.
580 bool
581 UsdSkelSkinPointsLBS(const GfMatrix4d& geomBindTransform,
582  TfSpan<const GfMatrix4d> jointXforms,
583  TfSpan<const GfVec2f> influences,
584  int numInfluencesPerPoint,
586  bool inSerial=false);
587 
588 /// \overload
590 bool
591 UsdSkelSkinPointsLBS(const GfMatrix4f& geomBindTransform,
592  TfSpan<const GfMatrix4f> jointXforms,
593  TfSpan<const GfVec2f> influences,
594  int numInfluencesPerPoint,
596  bool inSerial=false);
597 
598 
599 /// \overload
600 /// \deprecated Use form that takes TfSpan arguments.
602 bool
603 UsdSkelSkinPointsLBS(const GfMatrix4d& geomBindTransform,
604  const VtMatrix4dArray& jointXforms,
605  const VtIntArray& jointIndices,
606  const VtFloatArray& jointWeights,
607  int numInfluencesPerPoint,
608  VtVec3fArray* points);
609 
610 
611 /// \overload
612 /// \deprecated Use form that takes TfSpan arguments.
614 bool
615 UsdSkelSkinPointsLBS(const GfMatrix4d& geomBindTransform,
616  const GfMatrix4d* jointXforms,
617  size_t numJoints,
618  const int* jointIndices,
619  const float* jointWeights,
620  size_t numInfluences,
621  int numInfluencesPerPoint,
622  GfVec3f* points,
623  size_t numPoints,
624  bool inSerial=false);
625 
626 
627 /// Skin normals using linear blend skinning (LBS) or dual quaternion skinning (DQS),
628 /// for normals with _vertex_ or _varying_ interpolation.
629 /// Use UsdSkelSkinFaceVaryingNormals() for normals with _faceVarying__
630 /// interpolation.
631 /// The \p jointXforms are the *inverse transposes* of the 3x3 component
632 /// of the \ref UsdSkel_Term_SkinningTransforms" "skinning transforms",
633 /// given in _skeleton space_. The \p geomBindTransform is the
634 /// *inverse transpose* of the matrix that transforms points from a
635 /// bind pose ino the same _skeleton space_ that the skinning tranforms
636 /// were computed in.
638 bool
639 UsdSkelSkinNormals(const TfToken& skinningMethod,
640  const GfMatrix3d& geomBindTransform,
641  TfSpan<const GfMatrix3d> jointXforms,
642  TfSpan<const int> jointIndices,
643  TfSpan<const float> jointWeights,
644  int numInfluencesPerPoint,
645  TfSpan<GfVec3f> normals,
646  bool inSerial=false);
647 
648 
649 /// \overload
651 bool
652 UsdSkelSkinNormals(const TfToken& skinningMethod,
653  const GfMatrix3f& geomBindTransform,
654  TfSpan<const GfMatrix3f> jointXforms,
655  TfSpan<const int> jointIndices,
656  TfSpan<const float> jointWeights,
657  int numInfluencesPerPoint,
658  TfSpan<GfVec3f> normals,
659  bool inSerial=false);
660 
661 
662 /// \overload
664 bool
665 UsdSkelSkinNormals(const TfToken& skinningMethod,
666  const GfMatrix3d& geomBindTransform,
667  TfSpan<const GfMatrix3d> jointXforms,
668  TfSpan<const GfVec2f> influences,
669  int numInfluencesPerPoint,
670  TfSpan<GfVec3f> normals,
671  bool inSerial=false);
672 
673 
674 /// \overload
676 bool
677 UsdSkelSkinNormals(const TfToken& skinningMethod,
678  const GfMatrix3f& geomBindTransform,
679  TfSpan<const GfMatrix3f> jointXforms,
680  TfSpan<const GfVec2f> influences,
681  int numInfluencesPerPoint,
682  TfSpan<GfVec3f> normals,
683  bool inSerial=false);
684 
685 
686 /// Skin normals with _faceVarying_ interpolation using LBS or DQS
688 bool
689 UsdSkelSkinFaceVaryingNormals(const TfToken& skinningMethod,
690  const GfMatrix3d& geomBindTransform,
691  TfSpan<const GfMatrix3d> jointXforms,
692  TfSpan<const int> jointIndices,
693  TfSpan<const float> jointWeights,
694  int numInfluencesPerPoint,
695  TfSpan<const int> faceVertexIndices,
696  TfSpan<GfVec3f> normals,
697  bool inSerial=false);
698 
699 /// \overload
701 bool
702 UsdSkelSkinFaceVaryingNormals(const TfToken& skinningMethod,
703  const GfMatrix3f& geomBindTransform,
704  TfSpan<const GfMatrix3f> jointXforms,
705  TfSpan<const int> jointIndices,
706  TfSpan<const float> jointWeights,
707  int numInfluencesPerPoint,
708  TfSpan<const int> faceVertexIndices,
709  TfSpan<GfVec3f> normals,
710  bool inSerial=false);
711 
712 
714 bool
715 UsdSkelSkinNormalsLBS(const GfMatrix3d& geomBindTransform,
716  TfSpan<const GfMatrix3d> jointXforms,
717  TfSpan<const int> jointIndices,
718  TfSpan<const float> jointWeights,
719  int numInfluencesPerPoint,
720  TfSpan<GfVec3f> normals,
721  bool inSerial=false);
722 
723 
724 /// \overload
726 bool
727 UsdSkelSkinNormalsLBS(const GfMatrix3f& geomBindTransform,
728  TfSpan<const GfMatrix3f> jointXforms,
729  TfSpan<const int> jointIndices,
730  TfSpan<const float> jointWeights,
731  int numInfluencesPerPoint,
732  TfSpan<GfVec3f> normals,
733  bool inSerial=false);
734 
735 
736 /// \overload
738 bool
739 UsdSkelSkinNormalsLBS(const GfMatrix3d& geomBindTransform,
740  TfSpan<const GfMatrix3d> jointXforms,
741  TfSpan<const GfVec2f> influences,
742  int numInfluencesPerPoint,
743  TfSpan<GfVec3f> normals,
744  bool inSerial=false);
745 
746 
747 /// \overload
749 bool
750 UsdSkelSkinNormalsLBS(const GfMatrix3f& geomBindTransform,
751  TfSpan<const GfMatrix3f> jointXforms,
752  TfSpan<const GfVec2f> influences,
753  int numInfluencesPerPoint,
754  TfSpan<GfVec3f> normals,
755  bool inSerial=false);
756 
757 /// Skin normals with _faceVarying_ interpolation using linear blend skinning.
759 bool
760 UsdSkelSkinFaceVaryingNormalsLBS(const GfMatrix3d& geomBindTransform,
761  TfSpan<const GfMatrix3d> jointXforms,
762  TfSpan<const int> jointIndices,
763  TfSpan<const float> jointWeights,
764  int numInfluencesPerPoint,
765  TfSpan<const int> faceVertexIndices,
766  TfSpan<GfVec3f> normals,
767  bool inSerial=false);
768 
769 /// \overload
771 bool
772 UsdSkelSkinFaceVaryingNormalsLBS(const GfMatrix3f& geomBindTransform,
773  TfSpan<const GfMatrix3f> jointXforms,
774  TfSpan<const int> jointIndices,
775  TfSpan<const float> jointWeights,
776  int numInfluencesPerPoint,
777  TfSpan<const int> faceVertexIndices,
778  TfSpan<GfVec3f> normals,
779  bool inSerial=false);
780 
781 
782 /// Skin a transform using linear blend skinning (LBS) or dual quaternion skinning (DQS).
783 /// The \p jointXforms are \ref UsdSkel_Term_SkinningTransforms
784 /// "skinning transforms", given in _skeleton space_, while the
785 /// \p geomBindTransform provides the transform that initially places
786 /// a primitive in that same _skeleton space_.
788 bool
789 UsdSkelSkinTransform(const TfToken& skinningMethod,
790  const GfMatrix4d& geomBindTransform,
791  TfSpan<const GfMatrix4d> jointXforms,
792  TfSpan<const int> jointIndices,
793  TfSpan<const float> jointWeights,
794  GfMatrix4d* xform);
795 
796 /// \overload
798 bool
799 UsdSkelSkinTransform(const TfToken& skinningMethod,
800  const GfMatrix4f& geomBindTransform,
801  TfSpan<const GfMatrix4f> jointXforms,
802  TfSpan<const int> jointIndices,
803  TfSpan<const float> jointWeights,
804  GfMatrix4f* xform);
805 
806 /// Overload taking interleaved joint influences.
807 /// \overload
809 bool
810 UsdSkelSkinTransform(const TfToken& skinningMethod,
811  const GfMatrix4d& geomBindTransform,
812  TfSpan<const GfMatrix4d> jointXforms,
813  TfSpan<const GfVec2f> influences,
814  GfMatrix4d* xform);
815 
816 /// \overload
818 bool
819 UsdSkelSkinTransform(const TfToken& skinningMethod,
820  const GfMatrix4f& geomBindTransform,
821  TfSpan<const GfMatrix4f> jointXforms,
822  TfSpan<const GfVec2f> influences,
823  GfMatrix4f* xform);
824 
825 /// \overload
826 /// \deprecated Use form that takes TfSpan arguments.
828 bool
829 UsdSkelSkinTransform(const TfToken& skinningMethod,
830  const GfMatrix4d& geomBindTransform,
831  const GfMatrix4d* jointXforms,
832  size_t numJoints,
833  const int* jointIndices,
834  const float* jointWeights,
835  size_t numInfluences,
836  GfMatrix4d* xform);
837 
838 
840 bool
841 UsdSkelSkinTransformLBS(const GfMatrix4d& geomBindTransform,
842  TfSpan<const GfMatrix4d> jointXforms,
843  TfSpan<const int> jointIndices,
844  TfSpan<const float> jointWeights,
845  GfMatrix4d* xform);
846 
847 /// \overload
849 bool
850 UsdSkelSkinTransformLBS(const GfMatrix4f& geomBindTransform,
851  TfSpan<const GfMatrix4f> jointXforms,
852  TfSpan<const int> jointIndices,
853  TfSpan<const float> jointWeights,
854  GfMatrix4f* xform);
855 
856 /// Overload taking interleaved joint influences.
857 /// \overload
859 bool
860 UsdSkelSkinTransformLBS(const GfMatrix4d& geomBindTransform,
861  TfSpan<const GfMatrix4d> jointXforms,
862  TfSpan<const GfVec2f> influences,
863  GfMatrix4d* xform);
864 
865 /// \overload
867 bool
868 UsdSkelSkinTransformLBS(const GfMatrix4f& geomBindTransform,
869  TfSpan<const GfMatrix4f> jointXforms,
870  TfSpan<const GfVec2f> influences,
871  GfMatrix4f* xform);
872 
873 /// \overload
874 /// \deprecated Use form that takes TfSpan arguments.
876 bool
877 UsdSkelSkinTransformLBS(const GfMatrix4d& geomBindTransform,
878  const GfMatrix4d* jointXforms,
879  size_t numJoints,
880  const int* jointIndices,
881  const float* jointWeights,
882  size_t numInfluences,
883  GfMatrix4d* xform);
884 
885 
886 /// Apply a single blend shape to \p points.
887 /// The shape is given as a span of \p offsets. If the \p indices span is not
888 /// empty, it provides the index into the \p points span at which each offset
889 /// should be mapped. Otherwise, the \p offsets span must be the same size as
890 /// the \p points span.
892 bool
893 UsdSkelApplyBlendShape(const float weight,
897 
898 
900 
901 
902 #endif // PXR_USD_USD_SKEL_UTILS_H
USDSKEL_API bool UsdSkelSkinPoints(const TfToken &skinningMethod, const GfMatrix4d &geomBindTransform, TfSpan< const GfMatrix4d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< GfVec3f > points, bool inSerial=false)
USDSKEL_API bool UsdSkelComputeJointLocalTransforms(const UsdSkelTopology &topology, TfSpan< const GfMatrix4d > xforms, TfSpan< const GfMatrix4d > inverseXforms, TfSpan< GfMatrix4d > jointLocalXforms, const GfMatrix4d *rootInverseXform=nullptr)
USDSKEL_API bool UsdSkelInterleaveInfluences(const TfSpan< const int > &indices, const TfSpan< const float > &weights, TfSpan< GfVec2f > interleavedInfluences)
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glad.h:2676
USDSKEL_API bool UsdSkelDecomposeTransforms(TfSpan< const GfMatrix4d > xforms, TfSpan< GfVec3f > translations, TfSpan< GfQuatf > rotations, TfSpan< GfVec3h > scales)
Definition: vec3f.h:62
USDSKEL_API bool UsdSkelConcatJointTransforms(const UsdSkelTopology &topology, TfSpan< const GfMatrix4d > jointLocalXforms, TfSpan< GfMatrix4d > xforms, const GfMatrix4d *rootXform=nullptr)
USDSKEL_API bool UsdSkelIsSkinnablePrim(const UsdPrim &prim)
Definition: quatf.h:59
USDSKEL_API bool UsdSkelSkinFaceVaryingNormalsLBS(const GfMatrix3d &geomBindTransform, TfSpan< const GfMatrix3d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< const int > faceVertexIndices, TfSpan< GfVec3f > normals, bool inSerial=false)
Skin normals with faceVarying interpolation using linear blend skinning.
USDSKEL_API bool UsdSkelExpandConstantInfluencesToVarying(VtIntArray *indices, size_t size)
void pad(T &out, int n)
Definition: ImfXdr.h:490
USDSKEL_API bool UsdSkelResizeInfluences(VtIntArray *indices, int srcNumInfluencesPerComponent, int newNumInfluencesPerComponent)
GLuint GLsizei const GLuint const GLintptr * offsets
Definition: glcorearb.h:2621
GA_API const UT_StringHolder scale
GLfloat f
Definition: glcorearb.h:1926
Definition: token.h:87
USDSKEL_API void UsdSkelMakeTransform(const GfVec3f &translate, const GfMatrix3f &rotate, const GfVec3h &scale, Matrix4 *xform)
Definition: span.h:87
GT_API const UT_StringHolder topology
Definition: prim.h:135
USDSKEL_API bool UsdSkelSortInfluences(TfSpan< int > indices, TfSpan< float > weights, int numInfluencesPerComponent)
Sort joint influences such that highest weight values come first.
USDSKEL_API bool UsdSkelDecomposeTransform(const Matrix4 &xform, GfVec3f *translate, GfRotation *rotate, GfVec3h *scale)
#define USDSKEL_API
Definition: api.h:40
ImageBuf OIIO_API rotate(const ImageBuf &src, float angle, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ROI roi={}, int nthreads=0)
USDSKEL_API bool UsdSkelComputeJointsExtent(TfSpan< const Matrix4 > joints, GfRange3f *extent, float pad=0.0f, const Matrix4 *rootXform=nullptr)
USDSKEL_API bool UsdSkelApplyBlendShape(const float weight, const TfSpan< const GfVec3f > offsets, const TfSpan< const int > indices, TfSpan< GfVec3f > points)
GLsizeiptr size
Definition: glcorearb.h:664
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
USDSKEL_API bool UsdSkelSkinFaceVaryingNormals(const TfToken &skinningMethod, const GfMatrix3d &geomBindTransform, TfSpan< const GfMatrix3d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< const int > faceVertexIndices, TfSpan< GfVec3f > normals, bool inSerial=false)
Skin normals with faceVarying interpolation using LBS or DQS.
USDSKEL_API bool UsdSkelSkinTransformLBS(const GfMatrix4d &geomBindTransform, TfSpan< const GfMatrix4d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, GfMatrix4d *xform)
USDSKEL_API bool UsdSkelMakeTransforms(TfSpan< const GfVec3f > translations, TfSpan< const GfQuatf > rotations, TfSpan< const GfVec3h > scales, TfSpan< GfMatrix4d > xforms)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
USDSKEL_API bool UsdSkelSkinPointsLBS(const GfMatrix4d &geomBindTransform, TfSpan< const GfMatrix4d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< GfVec3f > points, bool inSerial=false)
USDSKEL_API bool UsdSkelSkinTransform(const TfToken &skinningMethod, const GfMatrix4d &geomBindTransform, TfSpan< const GfMatrix4d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, GfMatrix4d *xform)
USDSKEL_API bool UsdSkelSkinNormals(const TfToken &skinningMethod, const GfMatrix3d &geomBindTransform, TfSpan< const GfMatrix3d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< GfVec3f > normals, bool inSerial=false)
PUGI__FN char_t * translate(char_t *buffer, const char_t *from, const char_t *to, size_t to_length)
Definition: pugixml.cpp:8352
USDSKEL_API bool UsdSkelSkinNormalsLBS(const GfMatrix3d &geomBindTransform, TfSpan< const GfMatrix3d > jointXforms, TfSpan< const int > jointIndices, TfSpan< const float > jointWeights, int numInfluencesPerPoint, TfSpan< GfVec3f > normals, bool inSerial=false)
USDSKEL_API bool UsdSkelIsSkelAnimationPrim(const UsdPrim &prim)
Returns true if prim is a valid skel animation source.
Definition: vec3h.h:63
USDSKEL_API bool UsdSkelNormalizeWeights(TfSpan< float > weights, int numInfluencesPerComponent, float eps=std::numeric_limits< float >::epsilon())
GLint GLsizei count
Definition: glcorearb.h:405