2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-04-05 01:51:25 +00:00
|
|
|
|
2019-09-28 02:53:03 +00:00
|
|
|
#include <memory>
|
2019-06-12 02:05:17 +00:00
|
|
|
#include <optional>
|
2019-09-28 02:53:03 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/CToken.hpp"
|
2020-03-26 05:10:51 +00:00
|
|
|
#include "Runtime/Character/CSkinRules.hpp"
|
2019-09-28 02:53:03 +00:00
|
|
|
#include "Runtime/Graphics/CModel.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2016-04-05 01:51:25 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-04-05 01:51:25 +00:00
|
|
|
class CCharLayoutInfo;
|
2019-09-28 02:53:03 +00:00
|
|
|
class CModel;
|
2016-04-05 01:51:25 +00:00
|
|
|
class CPoseAsTransforms;
|
|
|
|
class CVertexMorphEffect;
|
|
|
|
class IObjectStore;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CSkinnedModel {
|
|
|
|
friend class CBooModel;
|
|
|
|
std::unique_ptr<CBooModel> m_modelInst;
|
|
|
|
TLockedToken<CModel> x4_model;
|
|
|
|
TLockedToken<CSkinRules> x10_skinRules;
|
|
|
|
TLockedToken<CCharLayoutInfo> x1c_layoutInfo;
|
|
|
|
std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>> m_vertWorkspace;
|
|
|
|
bool m_modifiedVBO = false;
|
2017-03-26 05:53:04 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
public:
|
|
|
|
enum class EDataOwnership { Zero, One };
|
|
|
|
CSkinnedModel(TLockedToken<CModel> model, TLockedToken<CSkinRules> skinRules,
|
2022-02-01 00:06:54 +00:00
|
|
|
TLockedToken<CCharLayoutInfo> layoutInfo, int shaderIdx);
|
|
|
|
CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo, int shaderIdx);
|
|
|
|
std::unique_ptr<CSkinnedModel> Clone(int shaderIdx = 0) const {
|
|
|
|
return std::make_unique<CSkinnedModel>(x4_model, x10_skinRules, x1c_layoutInfo, shaderIdx);
|
2019-03-24 08:06:59 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
const TLockedToken<CModel>& GetModel() const { return x4_model; }
|
|
|
|
const std::unique_ptr<CBooModel>& GetModelInst() const { return m_modelInst; }
|
|
|
|
const TLockedToken<CSkinRules>& GetSkinRules() const { return x10_skinRules; }
|
2018-12-31 08:37:52 +00:00
|
|
|
void SetLayoutInfo(const TLockedToken<CCharLayoutInfo>& inf) { x1c_layoutInfo = inf; }
|
2018-12-08 05:30:43 +00:00
|
|
|
const TLockedToken<CCharLayoutInfo>& GetLayoutInfo() const { return x1c_layoutInfo; }
|
|
|
|
|
|
|
|
void Calculate(const CPoseAsTransforms& pose, const CModelFlags& drawFlags,
|
2019-06-12 02:05:17 +00:00
|
|
|
const std::optional<CVertexMorphEffect>& morphEffect, const float* morphMagnitudes);
|
2018-12-08 05:30:43 +00:00
|
|
|
void Draw(const CModelFlags& drawFlags) const;
|
|
|
|
|
2020-04-01 04:06:49 +00:00
|
|
|
using FPointGenerator = void (*)(void* item, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn);
|
2018-12-08 05:30:43 +00:00
|
|
|
static void SetPointGeneratorFunc(void* ctx, FPointGenerator func) {
|
|
|
|
g_PointGenFunc = func;
|
|
|
|
g_PointGenCtx = ctx;
|
|
|
|
}
|
|
|
|
static void ClearPointGeneratorFunc() { g_PointGenFunc = nullptr; }
|
|
|
|
static FPointGenerator g_PointGenFunc;
|
|
|
|
static void* g_PointGenCtx;
|
2016-04-05 01:51:25 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CMorphableSkinnedModel : public CSkinnedModel {
|
|
|
|
std::unique_ptr<float[]> x40_morphMagnitudes;
|
|
|
|
|
2016-04-15 03:02:21 +00:00
|
|
|
public:
|
2022-02-01 00:06:54 +00:00
|
|
|
CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo, int shaderIdx);
|
2018-12-08 05:30:43 +00:00
|
|
|
const float* GetMorphMagnitudes() const { return x40_morphMagnitudes.get(); }
|
2016-04-15 03:02:21 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|