11 #ifndef hifi_AnimSkeleton
12 #define hifi_AnimSkeleton
15 #include <glm/glm.hpp>
16 #include <glm/gtc/quaternion.hpp>
18 #include <FBXSerializer.h>
23 using Pointer = std::shared_ptr<AnimSkeleton>;
24 using ConstPointer = std::shared_ptr<const AnimSkeleton>;
26 explicit AnimSkeleton(
const HFMModel& hfmModel);
27 explicit AnimSkeleton(
const std::vector<HFMJoint>& joints,
const QMap<int, glm::quat> jointOffsets);
29 int nameToJointIndex(
const QString& jointName)
const;
30 const QString& getJointName(
int jointIndex)
const;
31 int getNumJoints()
const;
32 int getChainDepth(
int jointIndex)
const;
34 static const int INVALID_JOINT_INDEX { -1 };
37 const AnimPose& getRelativeDefaultPose(
int jointIndex)
const;
38 const AnimPoseVec& getRelativeDefaultPoses()
const {
return _relativeDefaultPoses; }
39 const AnimPose& getAbsoluteDefaultPose(
int jointIndex)
const;
40 const AnimPoseVec& getAbsoluteDefaultPoses()
const {
return _absoluteDefaultPoses; }
41 const glm::mat4& getGeometryOffset()
const {
return _geometryOffset; }
44 const AnimPose& getPreRotationPose(
int jointIndex)
const;
47 const AnimPose& getPostRotationPose(
int jointIndex)
const;
49 int getParentIndex(
int jointIndex)
const {
50 return _parentIndices[jointIndex];
53 std::vector<int> getChildrenOfJoint(
int jointIndex)
const;
55 AnimPose getAbsolutePose(
int jointIndex,
const AnimPoseVec& relativePoses)
const;
57 void convertRelativePosesToAbsolute(AnimPoseVec& poses)
const;
58 void convertAbsolutePosesToRelative(AnimPoseVec& poses)
const;
60 void convertRelativeRotationsToAbsolute(std::vector<glm::quat>& rotations)
const;
61 void convertAbsoluteRotationsToRelative(std::vector<glm::quat>& rotations)
const;
63 void saveNonMirroredPoses(
const AnimPoseVec& poses)
const;
64 void restoreNonMirroredPoses(AnimPoseVec& poses)
const;
66 void mirrorRelativePoses(AnimPoseVec& poses)
const;
67 void mirrorAbsolutePoses(AnimPoseVec& poses)
const;
69 void dump(
bool verbose)
const;
70 void dump(
const AnimPoseVec& poses)
const;
72 std::vector<int> lookUpJointIndices(
const std::vector<QString>& jointNames)
const;
73 const HFMCluster getClusterBindMatricesOriginalValues(
const int meshIndex,
const int clusterIndex)
const {
return _clusterBindMatrixOriginalValues[meshIndex][clusterIndex]; }
76 void buildSkeletonFromJoints(
const std::vector<HFMJoint>& joints,
const QMap<int, glm::quat> jointOffsets);
78 std::vector<HFMJoint> _joints;
79 std::vector<int> _parentIndices;
80 int _jointsSize { 0 };
81 AnimPoseVec _relativeDefaultPoses;
82 AnimPoseVec _absoluteDefaultPoses;
83 AnimPoseVec _relativePreRotationPoses;
84 AnimPoseVec _relativePostRotationPoses;
85 mutable AnimPoseVec _nonMirroredPoses;
86 std::vector<int> _nonMirroredIndices;
87 std::vector<int> _mirrorMap;
88 QHash<QString, int> _jointIndicesByName;
89 std::vector<std::vector<HFMCluster>> _clusterBindMatrixOriginalValues;
90 glm::mat4 _geometryOffset;
93 AnimSkeleton(
const AnimSkeleton&) =
delete;
94 AnimSkeleton& operator=(
const AnimSkeleton&) =
delete;
A single binding to a joint.
Definition: HFM.h:123
The runtime model format.
Definition: HFM.h:302