// // AnimSkeleton.h // // Copyright 2015 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_AnimSkeleton #define hifi_AnimSkeleton #include #include "FBXReader.h" struct AnimPose { AnimPose() {} explicit AnimPose(const glm::mat4& mat); AnimPose(const glm::vec3& scaleIn, const glm::quat& rotIn, const glm::vec3& transIn) : scale(scaleIn), rot(rotIn), trans(transIn) {} static const AnimPose identity; glm::vec3 operator*(const glm::vec3& rhs) const; AnimPose operator*(const AnimPose& rhs) const; AnimPose inverse() const; operator glm::mat4() const; glm::vec3 scale; glm::quat rot; glm::vec3 trans; }; inline QDebug operator<<(QDebug debug, const AnimPose& pose) { debug << "AnimPose, trans = (" << pose.trans.x << pose.trans.y << pose.trans.z << "), rot = (" << pose.rot.x << pose.rot.y << pose.rot.z << pose.rot.w << "), scale = (" << pose.scale.x << pose.scale.y << pose.scale.z << ")"; return debug; } class AnimSkeleton { public: typedef std::shared_ptr Pointer; AnimSkeleton(const std::vector& joints); int nameToJointIndex(const QString& jointName) const; const QString& getJointName(int jointIndex) const; int getNumJoints() const; // absolute pose, not relative to parent AnimPose getAbsoluteBindPose(int jointIndex) const; // relative to parent pose AnimPose getRelativeBindPose(int jointIndex) const; int getParentIndex(int jointIndex) const; protected: std::vector _joints; std::vector _absoluteBindPoses; std::vector _relativeBindPoses; // no copies AnimSkeleton(const AnimSkeleton&) = delete; AnimSkeleton& operator=(const AnimSkeleton&) = delete; }; #endif