metaforce/DataSpec/DNACommon/RigInverter.hpp

43 lines
1.4 KiB
C++
Raw Normal View History

2018-10-06 20:42:33 -07:00
#pragma once
2016-04-06 20:40:25 -07:00
#include "zeus/CVector3f.hpp"
2016-04-07 20:37:14 -07:00
#include "zeus/CMatrix3f.hpp"
2016-04-06 20:40:25 -07:00
#include "zeus/CQuaternion.hpp"
2017-12-29 00:08:12 -08:00
#include "hecl/hecl.hpp"
2019-04-06 22:14:48 -07:00
#include <unordered_map>
2016-04-06 20:40:25 -07:00
2018-12-07 21:30:43 -08:00
namespace DataSpec::DNAANIM {
2016-04-06 20:40:25 -07:00
/** One-shot process to invert CINF armature into connected rig,
* inverting rotations/translations of ANIM data to match */
template <class CINFType>
2018-12-07 21:30:43 -08:00
class RigInverter {
2016-04-06 20:40:25 -07:00
public:
2018-12-07 21:30:43 -08:00
struct Bone {
const typename CINFType::Bone& m_origBone;
zeus::CQuaternion m_inverter;
zeus::CQuaternion m_restorer;
2018-12-07 21:30:43 -08:00
zeus::CVector3f m_tail;
zeus::CVector3f m_parentDelta;
Bone(const CINFType& cinf, const typename CINFType::Bone& origBone);
};
2016-04-06 20:40:25 -07:00
private:
2018-12-07 21:30:43 -08:00
const CINFType& m_cinf;
std::vector<Bone> m_bones;
2016-04-06 20:40:25 -07:00
public:
2018-12-07 21:30:43 -08:00
RigInverter(const CINFType& cinf);
RigInverter(const CINFType& cinf, const std::unordered_map<std::string, hecl::blender::Matrix3f>& matrices);
const CINFType& getCINF() const { return m_cinf; }
const std::vector<Bone>& getBones() const { return m_bones; }
2016-04-08 16:11:26 -07:00
2018-12-07 21:30:43 -08:00
zeus::CQuaternion invertRotation(atUint32 boneId, const zeus::CQuaternion& origRot) const;
zeus::CVector3f invertPosition(atUint32 boneId, const zeus::CVector3f& origPos, bool subDelta) const;
2016-04-08 16:11:26 -07:00
2018-12-07 21:30:43 -08:00
zeus::CQuaternion restoreRotation(atUint32 boneId, const zeus::CQuaternion& origRot) const;
zeus::CVector3f restorePosition(atUint32 boneId, const zeus::CVector3f& origPos, bool subDelta) const;
2016-04-06 20:40:25 -07:00
};
2018-12-07 21:30:43 -08:00
} // namespace DataSpec::DNAANIM