| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <Jolt/Skeleton/Skeleton.h> |
| 8 |
#include <Jolt/Skeleton/SkeletalAnimation.h> |
| 9 |
|
| 10 |
JPH_NAMESPACE_BEGIN |
| 11 |
|
| 12 |
#ifdef JPH_DEBUG_RENDERER |
| 13 |
class DebugRenderer; |
| 14 |
#endif |
| 15 |
|
| 16 |
|
| 17 |
class JPH_EXPORT SkeletonPose |
| 18 |
{ |
| 19 |
public: |
| 20 |
JPH_OVERRIDE_NEW_DELETE |
| 21 |
|
| 22 |
using JointState = SkeletalAnimation::JointState; |
| 23 |
using JointStateVector = Array<JointState>; |
| 24 |
using Mat44Vector = Array<Mat44>; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
void SetSkeleton(const Skeleton *inSkeleton); |
| 29 |
const Skeleton * GetSkeleton() const { return mSkeleton; } |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
void SetRootOffset(RVec3Arg inOffset) { mRootOffset = inOffset; } |
| 34 |
RVec3 GetRootOffset() const { return mRootOffset; } |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
uint GetJointCount() const { return (uint)mJoints.size(); } |
| 39 |
const JointStateVector & GetJoints() const { return mJoints; } |
| 40 |
JointStateVector & GetJoints() { return mJoints; } |
| 41 |
const JointState & GetJoint(int inJoint) const { return mJoints[inJoint]; } |
| 42 |
JointState & GetJoint(int inJoint) { return mJoints[inJoint]; } |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
const Mat44Vector & GetJointMatrices() const { return mJointMatrices; } |
| 48 |
Mat44Vector & GetJointMatrices() { return mJointMatrices; } |
| 49 |
const Mat44 & GetJointMatrix(int inJoint) const { return mJointMatrices[inJoint]; } |
| 50 |
Mat44 & GetJointMatrix(int inJoint) { return mJointMatrices[inJoint]; } |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
void CalculateJointMatrices(); |
| 55 |
|
| 56 |
|
| 57 |
void CalculateJointStates(); |
| 58 |
|
| 59 |
|
| 60 |
void CalculateLocalSpaceJointMatrices(Mat44 *outMatrices) const; |
| 61 |
|
| 62 |
#ifdef JPH_DEBUG_RENDERER |
| 63 |
|
| 64 |
struct DrawSettings |
| 65 |
{ |
| 66 |
bool mDrawJoints = true; |
| 67 |
bool mDrawJointOrientations = true; |
| 68 |
bool mDrawJointNames = false; |
| 69 |
}; |
| 70 |
|
| 71 |
|
| 72 |
void Draw(const DrawSettings &inDrawSettings, DebugRenderer *inRenderer, RMat44Arg inOffset = RMat44::sIdentity()) const; |
| 73 |
#endif |
| 74 |
|
| 75 |
private: |
| 76 |
RefConst<Skeleton> mSkeleton; |
| 77 |
RVec3 mRootOffset { RVec3::sZero() }; |
| 78 |
JointStateVector mJoints; |
| 79 |
Mat44Vector mJointMatrices; |
| 80 |
}; |
| 81 |
|
| 82 |
JPH_NAMESPACE_END |