2018-10-06 20:42:33 -07:00
|
|
|
#pragma once
|
2016-04-04 18:51:25 -07:00
|
|
|
|
2019-09-27 19:53:03 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/CFactoryMgr.hpp"
|
2022-03-09 22:33:17 -08:00
|
|
|
#include "Runtime/Character/CSegId.hpp"
|
|
|
|
#include "Runtime/Graphics/CCubeModel.hpp"
|
2022-01-31 16:06:54 -08:00
|
|
|
#include "Runtime/RetroTypes.hpp"
|
2019-09-27 19:53:03 -07:00
|
|
|
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2016-04-09 16:19:17 -07:00
|
|
|
|
2021-04-10 01:42:06 -07:00
|
|
|
namespace metaforce {
|
2022-03-09 22:33:17 -08:00
|
|
|
class CCharLayoutInfo;
|
2016-08-21 13:39:18 -07:00
|
|
|
class CPoseAsTransforms;
|
2017-08-20 22:46:59 -07:00
|
|
|
class CModel;
|
|
|
|
|
2018-12-07 21:30:43 -08:00
|
|
|
struct SSkinWeighting {
|
2022-01-31 16:06:54 -08:00
|
|
|
CSegId x0_id;
|
|
|
|
float x4_weight;
|
2022-02-17 23:37:54 -08:00
|
|
|
explicit SSkinWeighting(CInputStream& in) : x0_id(in), x4_weight(in.ReadFloat()) {}
|
2017-08-20 22:46:59 -07:00
|
|
|
};
|
|
|
|
|
2018-12-07 21:30:43 -08:00
|
|
|
class CVirtualBone {
|
2022-02-24 23:45:25 -08:00
|
|
|
friend class CSkinnedModel;
|
|
|
|
|
2022-01-31 16:06:54 -08:00
|
|
|
rstl::reserved_vector<SSkinWeighting, 3> x0_weights;
|
|
|
|
u32 x1c_vertexCount;
|
|
|
|
zeus::CTransform x20_xf;
|
2022-03-09 22:33:17 -08:00
|
|
|
zeus::CMatrix3f x50_rotation;
|
2018-12-07 21:30:43 -08:00
|
|
|
|
2017-08-20 22:46:59 -07:00
|
|
|
public:
|
2022-01-31 16:06:54 -08:00
|
|
|
explicit CVirtualBone(CInputStream& in);
|
|
|
|
|
2022-03-09 22:33:17 -08:00
|
|
|
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);
|
2017-08-20 22:46:59 -07:00
|
|
|
};
|
2016-04-04 18:51:25 -07:00
|
|
|
|
2018-12-07 21:30:43 -08:00
|
|
|
class CSkinRules {
|
2022-02-24 23:45:25 -08:00
|
|
|
friend class CSkinnedModel;
|
|
|
|
|
2022-01-31 16:06:54 -08:00
|
|
|
std::vector<CVirtualBone> x0_bones;
|
2022-02-20 16:03:38 -08:00
|
|
|
u32 x10_vertexCount = 0;
|
|
|
|
u32 x14_normalCount = 0;
|
2017-08-20 22:46:59 -07:00
|
|
|
|
2016-04-09 16:19:17 -07:00
|
|
|
public:
|
2018-12-07 21:30:43 -08:00
|
|
|
explicit CSkinRules(CInputStream& in);
|
2017-08-20 22:46:59 -07:00
|
|
|
|
2022-03-09 22:33:17 -08:00
|
|
|
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; }
|
2016-04-04 18:51:25 -07:00
|
|
|
};
|
|
|
|
|
2016-09-02 12:32:57 -07:00
|
|
|
CFactoryFnReturn FSkinRulesFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& params,
|
|
|
|
CObjectReference* selfRef);
|
2016-04-12 15:28:08 -07:00
|
|
|
|
2021-04-10 01:42:06 -07:00
|
|
|
} // namespace metaforce
|