2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-07-16 14:05:52 +00:00
metaforce/Runtime/Character/CCharLayoutInfo.cpp
2016-04-13 13:07:18 -10:00

63 lines
1.6 KiB
C++

#include "CCharLayoutInfo.hpp"
#include "CToken.hpp"
namespace urde
{
zeus::CVector3f CCharLayoutInfo::GetFromParentUnrotated(const CSegId& id) const
{
const CCharLayoutNode::Bone& bone = x0_node->GetBone(id);
const CSegId& prev = x0_node->GetPrevBone(bone.x0_parentId);
if (prev == 0xff)
return bone.x4_origin;
else
{
const CCharLayoutNode::Bone& pBone = x0_node->GetBone(bone.x0_parentId);
return bone.x4_origin - pBone.x4_origin;
}
}
void CCharLayoutNode::Bone::read(CInputStream& in)
{
x0_parentId = CSegId(in);
x4_origin.readBig(in);
u32 chCount = in.readUint32Big();
x10_children.reserve(chCount);
for (u32 i=0 ; i<chCount ; ++i)
x10_children.emplace_back(in);
}
CCharLayoutNode::CCharLayoutNode(CInputStream& in)
{
u32 count = in.readUint32Big();
for (u32 i=0 ; i<count ; ++i)
{
u32 thisId = in.readUint32Big();
Bone& bone = x6c_bones[thisId];
bone.read(in);
x8_prevBones[thisId] = x1_curPrevBone;
x1_curPrevBone = thisId;
++x0_boneCount;
}
}
CCharLayoutInfo::CCharLayoutInfo(CInputStream& in)
: x0_node(std::make_shared<CCharLayoutNode>(in)),
x8_segIdList(in)
{
atUint32 mapCount = in.readUint32Big();
for (int i=0 ; i<mapCount ; ++i)
{
std::string key = in.readString();
x18_segIdMap.emplace(key, in);
}
}
CFactoryFnReturn FCharLayoutInfo(const SObjectTag&, CInputStream& in, const CVParamTransfer&)
{
return TToken<CCharLayoutInfo>::GetIObjObjectFor(std::make_unique<CCharLayoutInfo>(in));
}
}