metaforce/Runtime/Graphics/CSkinnedModel.hpp

70 lines
2.6 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "Runtime/CToken.hpp"
#include "Runtime/Character/CSkinRules.hpp"
#include "Runtime/Graphics/CModel.hpp"
#include <zeus/CVector3f.hpp>
2021-04-10 08:42:06 +00:00
namespace metaforce {
class CCharLayoutInfo;
class CModel;
class CPoseAsTransforms;
class CVertexMorphEffect;
class IObjectStore;
// Lambda instead of userdata pointer
using FCustomDraw = std::function<void(TVectorRef positions, TVectorRef normals)>;
2018-12-08 05:30:43 +00:00
class CSkinnedModel {
TLockedToken<CModel> x4_model;
TLockedToken<CSkinRules> x10_skinRules;
TLockedToken<CCharLayoutInfo> x1c_layoutInfo;
std::vector<zeus::CVector3f> x24_vertWorkspace; // was rstl::auto_ptr<float[]>
std::vector<zeus::CVector3f> x2c_normalWorkspace; // was rstl::auto_ptr<float[]>
bool x34_owned = true;
bool x35_disableWorkspaces = false;
2017-03-26 05:53:04 +00:00
2018-12-08 05:30:43 +00:00
public:
enum class EDataOwnership { Unowned, Owned };
CSkinnedModel(const TLockedToken<CModel>& model, const TLockedToken<CSkinRules>& skinRules,
const TLockedToken<CCharLayoutInfo>& layoutInfo /*, EDataOwnership ownership*/);
CSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo);
2018-12-08 05:30:43 +00:00
TLockedToken<CModel>& GetModel() { return x4_model; }
2018-12-08 05:30:43 +00:00
const TLockedToken<CModel>& GetModel() const { return x4_model; }
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 std::optional<CVertexMorphEffect>& morphEffect,
const float* morphMagnitudes);
void Draw(TVectorRef verts, TVectorRef normals, const CModelFlags& drawFlags);
void Draw(const CModelFlags& drawFlags);
void DoDrawCallback(const FCustomDraw& func) const;
2018-12-08 05:30:43 +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;
};
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:
CMorphableSkinnedModel(IObjectStore& store, CAssetId model, CAssetId skinRules, CAssetId layoutInfo);
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