metaforce/Runtime/Character/CSkinRules.hpp

67 lines
1.9 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
#include <vector>
#include "Runtime/CFactoryMgr.hpp"
#include "Runtime/Character/CSegId.hpp"
#include "Runtime/Graphics/CCubeModel.hpp"
2022-02-01 00:06:54 +00:00
#include "Runtime/RetroTypes.hpp"
#include <zeus/CVector3f.hpp>
2016-04-09 23:19:17 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
class CCharLayoutInfo;
2016-08-21 20:39:18 +00:00
class CPoseAsTransforms;
class CModel;
2018-12-08 05:30:43 +00:00
struct SSkinWeighting {
2022-02-01 00:06:54 +00:00
CSegId x0_id;
float x4_weight;
explicit SSkinWeighting(CInputStream& in) : x0_id(in), x4_weight(in.ReadFloat()) {}
};
2018-12-08 05:30:43 +00:00
class CVirtualBone {
friend class CSkinnedModel;
2022-02-01 00:06:54 +00:00
rstl::reserved_vector<SSkinWeighting, 3> x0_weights;
u32 x1c_vertexCount;
zeus::CTransform x20_xf;
zeus::CMatrix3f x50_rotation;
2018-12-08 05:30:43 +00:00
public:
2022-02-01 00:06:54 +00:00
explicit CVirtualBone(CInputStream& in);
void BuildPoints(const zeus::CVector3f* in, TVectorRef out, u32 count) const;
void BuildNormals(const zeus::CVector3f* in, TVectorRef out, u32 count) const;
void BuildAccumulatedTransform(const CPoseAsTransforms& pose, const zeus::CVector3f* points);
[[nodiscard]] const auto& GetWeights() const { return x0_weights; }
[[nodiscard]] u32 GetVertexCount() const { return x1c_vertexCount; }
private:
void BuildFinalPosMatrix(const CPoseAsTransforms& pose, const zeus::CVector3f* points);
};
2018-12-08 05:30:43 +00:00
class CSkinRules {
friend class CSkinnedModel;
2022-02-01 00:06:54 +00:00
std::vector<CVirtualBone> x0_bones;
2022-02-21 00:03:38 +00:00
u32 x10_vertexCount = 0;
u32 x14_normalCount = 0;
2016-04-09 23:19:17 +00:00
public:
2018-12-08 05:30:43 +00:00
explicit CSkinRules(CInputStream& in);
void BuildPoints(TConstVectorRef positions, TVectorRef out);
void BuildNormals(TConstVectorRef normals, TVectorRef out);
void BuildAccumulatedTransforms(const CPoseAsTransforms& pose, const CCharLayoutInfo& info);
[[nodiscard]] u32 GetVertexCount() const { return x10_vertexCount; }
[[nodiscard]] u32 GetNormalCount() const { return x14_normalCount; }
};
CFactoryFnReturn FSkinRulesFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params,
CObjectReference* selfRef);
2021-04-10 08:42:06 +00:00
} // namespace metaforce