mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-13 05:37:18 +02:00
65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
//
|
|
// 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 <vector>
|
|
|
|
#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<AnimSkeleton> Pointer;
|
|
|
|
AnimSkeleton(const std::vector<FBXJoint>& 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<FBXJoint> _joints;
|
|
std::vector<AnimPose> _absoluteBindPoses;
|
|
std::vector<AnimPose> _relativeBindPoses;
|
|
|
|
// no copies
|
|
AnimSkeleton(const AnimSkeleton&) = delete;
|
|
AnimSkeleton& operator=(const AnimSkeleton&) = delete;
|
|
};
|
|
|
|
#endif
|