SkeletonPose.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Skeleton/Skeleton.h>
  5. #include <Skeleton/SkeletalAnimation.h>
  6. namespace JPH {
  7. #ifdef JPH_DEBUG_RENDERER
  8. class DebugRenderer;
  9. #endif // JPH_DEBUG_RENDERER
  10. /// Instance of a skeleton, contains the pose the current skeleton is in
  11. class SkeletonPose
  12. {
  13. public:
  14. using JointState = SkeletalAnimation::JointState;
  15. using JointStateVector = vector<JointState>;
  16. using Mat44Vector = vector<Mat44>;
  17. ///@name Skeleton
  18. ///@{
  19. void SetSkeleton(const Skeleton *inSkeleton);
  20. const Skeleton * GetSkeleton() const { return mSkeleton; }
  21. ///@}
  22. ///@name Properties of the joints
  23. ///@{
  24. const JointStateVector & GetJoints() const { return mJoints; }
  25. JointStateVector & GetJoints() { return mJoints; }
  26. const JointState & GetJoint(int inJoint) const { return mJoints[inJoint]; }
  27. JointState & GetJoint(int inJoint) { return mJoints[inJoint]; }
  28. ///@}
  29. ///@name Joint matrices
  30. ///@{
  31. void CalculateJointMatrices();
  32. const Mat44Vector & GetJointMatrices() const { return mJointMatrices; }
  33. Mat44Vector & GetJointMatrices() { return mJointMatrices; }
  34. const Mat44 & GetJointMatrix(int inJoint) const { return mJointMatrices[inJoint]; }
  35. Mat44 & GetJointMatrix(int inJoint) { return mJointMatrices[inJoint]; }
  36. ///@}
  37. #ifdef JPH_DEBUG_RENDERER
  38. /// Draw settings
  39. struct DrawSettings
  40. {
  41. bool mDrawJoints = true;
  42. bool mDrawJointOrientations = true;
  43. bool mDrawJointNames = false;
  44. };
  45. /// Draw current pose
  46. void Draw(const DrawSettings &inDrawSettings, DebugRenderer *inRenderer) const;
  47. #endif // JPH_DEBUG_RENDERER
  48. private:
  49. RefConst<Skeleton> mSkeleton; ///< Skeleton definition
  50. JointStateVector mJoints; ///< Local joint orientations (local to parent Joint)
  51. Mat44Vector mJointMatrices; ///< Local joint matrices (local to world matrix)
  52. };
  53. } // JPH