metaforce/DataSpec/DNACommon/RigInverter.hpp

45 lines
1.4 KiB
C++
Raw Normal View History

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