2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-04-13 06:07:23 +00:00
|
|
|
|
2019-09-28 02:53:03 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "Runtime/CToken.hpp"
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/Character/CAnimData.hpp"
|
|
|
|
#include "Runtime/Graphics/CModel.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CAABox.hpp>
|
|
|
|
#include <zeus/CColor.hpp>
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2016-04-13 06:07:23 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-04-14 03:32:27 +00:00
|
|
|
class CActorLights;
|
|
|
|
class CAnimData;
|
2019-09-28 02:53:03 +00:00
|
|
|
class CCharAnimTime;
|
2016-04-14 03:32:27 +00:00
|
|
|
class CModel;
|
2019-09-28 02:53:03 +00:00
|
|
|
class CRandom16;
|
2016-04-14 21:42:47 +00:00
|
|
|
class CSkinnedModel;
|
2019-09-28 02:53:03 +00:00
|
|
|
class CStateManager;
|
|
|
|
struct CModelFlags;
|
2016-04-14 21:42:47 +00:00
|
|
|
struct SAdvancementDeltas;
|
2016-04-13 06:07:23 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CStaticRes {
|
2022-02-19 13:04:45 +00:00
|
|
|
CAssetId x0_cmdlId;
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f x4_scale;
|
|
|
|
|
2016-04-27 19:59:38 +00:00
|
|
|
public:
|
2020-03-09 02:49:29 +00:00
|
|
|
constexpr CStaticRes() = default;
|
2018-12-08 05:30:43 +00:00
|
|
|
CStaticRes(CAssetId id, const zeus::CVector3f& scale) : x0_cmdlId(id), x4_scale(scale) {}
|
|
|
|
|
|
|
|
CAssetId GetId() const { return x0_cmdlId; }
|
|
|
|
const zeus::CVector3f& GetScale() const { return x4_scale; }
|
2020-03-09 02:49:29 +00:00
|
|
|
explicit operator bool() const { return x0_cmdlId.IsValid(); }
|
2016-04-14 03:32:27 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CAnimRes {
|
|
|
|
CAssetId x0_ancsId;
|
|
|
|
s32 x4_charIdx = -1;
|
|
|
|
zeus::CVector3f x8_scale;
|
|
|
|
bool x14_canLoop = false;
|
|
|
|
/* NOTE: x18_bodyType - Removed in retail */
|
|
|
|
s32 x18_defaultAnim = -1; /* NOTE: used to be x1c in demo */
|
2016-04-27 19:59:38 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CAnimRes() = default;
|
|
|
|
CAnimRes(CAssetId ancs, s32 charIdx, const zeus::CVector3f& scale, const s32 defaultAnim, bool loop)
|
|
|
|
: x0_ancsId(ancs), x4_charIdx(charIdx), x8_scale(scale), x14_canLoop(loop), x18_defaultAnim(defaultAnim) {}
|
|
|
|
|
|
|
|
CAssetId GetId() const { return x0_ancsId; }
|
|
|
|
s32 GetCharacterNodeId() const { return x4_charIdx; }
|
|
|
|
void SetCharacterNodeId(s32 id) { x4_charIdx = id; }
|
|
|
|
const zeus::CVector3f& GetScale() const { return x8_scale; }
|
|
|
|
bool CanLoop() const { return x14_canLoop; }
|
2020-04-07 11:13:16 +00:00
|
|
|
void SetCanLoop(bool loop) { x14_canLoop = loop; }
|
2018-12-08 05:30:43 +00:00
|
|
|
s32 GetDefaultAnim() const { return x18_defaultAnim; }
|
2019-03-24 08:06:59 +00:00
|
|
|
void SetDefaultAnim(s32 anim) { x18_defaultAnim = anim; }
|
2016-04-13 06:07:23 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CModelData {
|
|
|
|
friend class CActor;
|
|
|
|
zeus::CVector3f x0_scale;
|
|
|
|
std::unique_ptr<CAnimData> x10_animData;
|
2020-04-21 07:22:41 +00:00
|
|
|
bool x14_24_renderSorted : 1 = false;
|
|
|
|
bool x14_25_sortThermal : 1 = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CColor x18_ambientColor;
|
2016-09-02 19:32:57 +00:00
|
|
|
|
2020-09-14 00:07:24 +00:00
|
|
|
// were rstl::optional_object<TCachedToken<CModel>>
|
2018-12-08 05:30:43 +00:00
|
|
|
TLockedToken<CModel> x1c_normalModel;
|
|
|
|
TLockedToken<CModel> x2c_xrayModel;
|
|
|
|
TLockedToken<CModel> x3c_infraModel;
|
2016-04-15 03:02:21 +00:00
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EWhichModel { Normal, XRay, Thermal, ThermalHot };
|
|
|
|
|
2020-04-07 11:13:16 +00:00
|
|
|
void SetSortThermal(bool sort) { x14_25_sortThermal = sort; }
|
2018-12-08 05:30:43 +00:00
|
|
|
bool GetSortThermal() const { return x14_25_sortThermal; }
|
|
|
|
|
|
|
|
~CModelData();
|
2022-02-01 00:06:54 +00:00
|
|
|
explicit CModelData(const CStaticRes& res);
|
|
|
|
explicit CModelData(const CAnimRes& res);
|
2018-12-08 05:30:43 +00:00
|
|
|
CModelData(CModelData&&) = default;
|
|
|
|
CModelData& operator=(CModelData&&) = default;
|
|
|
|
CModelData();
|
|
|
|
static CModelData CModelDataNull();
|
|
|
|
|
|
|
|
SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const;
|
2022-02-25 07:45:25 +00:00
|
|
|
bool IsLoaded(int shaderIdx);
|
2018-12-08 05:30:43 +00:00
|
|
|
static EWhichModel GetRenderingModel(const CStateManager& stateMgr);
|
|
|
|
CSkinnedModel& PickAnimatedModel(EWhichModel which) const;
|
2022-02-25 07:45:25 +00:00
|
|
|
TLockedToken<CModel>& PickStaticModel(EWhichModel which);
|
|
|
|
const TLockedToken<CModel>& PickStaticModel(EWhichModel which) const {
|
|
|
|
return const_cast<CModelData*>(this)->PickStaticModel(which);
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
void SetXRayModel(const std::pair<CAssetId, CAssetId>& modelSkin);
|
|
|
|
void SetInfraModel(const std::pair<CAssetId, CAssetId>& modelSkin);
|
2019-08-14 10:04:11 +00:00
|
|
|
bool IsDefinitelyOpaque(EWhichModel) const;
|
2018-12-08 05:30:43 +00:00
|
|
|
bool GetIsLoop() const;
|
2020-04-07 11:13:16 +00:00
|
|
|
float GetAnimationDuration(int idx) const;
|
|
|
|
void EnableLooping(bool enable);
|
|
|
|
void AdvanceParticles(const zeus::CTransform& xf, float dt, CStateManager& stateMgr);
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CAABox GetBounds() const;
|
|
|
|
zeus::CAABox GetBounds(const zeus::CTransform& xf) const;
|
|
|
|
zeus::CTransform GetScaledLocatorTransformDynamic(std::string_view name, const CCharAnimTime* time) const;
|
|
|
|
zeus::CTransform GetScaledLocatorTransform(std::string_view name) const;
|
|
|
|
zeus::CTransform GetLocatorTransformDynamic(std::string_view name, const CCharAnimTime* time) const;
|
|
|
|
zeus::CTransform GetLocatorTransform(std::string_view name) const;
|
2020-04-07 11:13:16 +00:00
|
|
|
SAdvancementDeltas AdvanceAnimationIgnoreParticles(float dt, CRandom16& rand, bool advTree);
|
2018-12-08 05:30:43 +00:00
|
|
|
SAdvancementDeltas AdvanceAnimation(float dt, CStateManager& stateMgr, TAreaId aid, bool advTree);
|
|
|
|
bool IsAnimating() const;
|
|
|
|
bool IsInFrustum(const zeus::CTransform& xf, const zeus::CFrustum& frustum) const;
|
|
|
|
void RenderParticles(const zeus::CFrustum& frustum) const;
|
2022-02-25 07:45:25 +00:00
|
|
|
void Touch(EWhichModel, int shaderIdx);
|
|
|
|
void Touch(const CStateManager& stateMgr, int shaderIdx);
|
2018-12-08 05:30:43 +00:00
|
|
|
void RenderThermal(const zeus::CTransform& xf, const zeus::CColor& mulColor, const zeus::CColor& addColor,
|
2022-02-25 07:45:25 +00:00
|
|
|
const CModelFlags& flags);
|
2018-12-08 05:30:43 +00:00
|
|
|
void RenderUnsortedParts(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights,
|
2020-08-02 03:45:47 +00:00
|
|
|
const CModelFlags& drawFlags);
|
2022-02-25 07:45:25 +00:00
|
|
|
void Render(const CStateManager& stateMgr, const zeus::CTransform& xf, const CActorLights* lights,
|
|
|
|
const CModelFlags& drawFlags);
|
2020-08-02 03:45:47 +00:00
|
|
|
void Render(EWhichModel, const zeus::CTransform& xf, const CActorLights* lights, const CModelFlags& drawFlags);
|
2022-07-02 23:16:33 +00:00
|
|
|
void FlatDraw(EWhichModel which, const zeus::CTransform& xf, bool unsortedOnly, const CModelFlags& flags);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2022-03-08 22:21:15 +00:00
|
|
|
void MultiLightingDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
|
|
|
|
const zeus::CColor& alphaColor, const zeus::CColor& additiveColor);
|
|
|
|
void MultiPassDraw(EWhichModel which, const zeus::CTransform& xf, const CActorLights* lights,
|
|
|
|
const CModelFlags* flags, u32 count);
|
2022-03-12 15:47:20 +00:00
|
|
|
void DisintegrateDraw(const CStateManager& mgr, const zeus::CTransform& xf, CTexture& tex,
|
2018-12-08 05:30:43 +00:00
|
|
|
const zeus::CColor& addColor, float t);
|
2022-03-12 15:47:20 +00:00
|
|
|
void DisintegrateDraw(EWhichModel which, const zeus::CTransform& xf, CTexture& tex, const zeus::CColor& addColor,
|
|
|
|
float t);
|
2022-07-01 04:00:29 +00:00
|
|
|
static void ThermalDraw(CSkinnedModel& model, const zeus::CColor& mulColor, const zeus::CColor& addColor,
|
|
|
|
const CModelFlags& flags);
|
2022-08-09 06:10:51 +00:00
|
|
|
static void ThermalDraw(CSkinnedModel& model, TConstVectorRef positions, TConstVectorRef normals,
|
|
|
|
const zeus::CColor& mulColor, const zeus::CColor& addColor, const CModelFlags& flags);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2019-08-14 14:58:54 +00:00
|
|
|
CAnimData* GetAnimationData() { return x10_animData.get(); }
|
2018-12-08 05:30:43 +00:00
|
|
|
const CAnimData* GetAnimationData() const { return x10_animData.get(); }
|
|
|
|
const TLockedToken<CModel>& GetNormalModel() const { return x1c_normalModel; }
|
|
|
|
const TLockedToken<CModel>& GetXRayModel() const { return x2c_xrayModel; }
|
|
|
|
const TLockedToken<CModel>& GetThermalModel() const { return x3c_infraModel; }
|
|
|
|
bool IsNull() const { return !x10_animData && !x1c_normalModel; }
|
2019-11-09 23:48:46 +00:00
|
|
|
u32 GetNumMaterialSets() const;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
const zeus::CVector3f& GetScale() const { return x0_scale; }
|
|
|
|
void SetScale(const zeus::CVector3f& scale) { x0_scale = scale; }
|
|
|
|
bool HasAnimData() const { return x10_animData != nullptr; }
|
2020-03-09 01:10:15 +00:00
|
|
|
bool HasNormalModel() const { return x1c_normalModel.HasReference(); }
|
2019-08-14 10:04:11 +00:00
|
|
|
bool HasModel(EWhichModel which) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x10_animData) {
|
|
|
|
switch (which) {
|
|
|
|
case EWhichModel::Normal:
|
|
|
|
return true;
|
|
|
|
case EWhichModel::XRay:
|
2020-03-09 01:10:15 +00:00
|
|
|
return x10_animData->GetXRayModel() != nullptr;
|
2018-12-08 05:30:43 +00:00
|
|
|
case EWhichModel::Thermal:
|
2020-03-09 01:10:15 +00:00
|
|
|
return x10_animData->GetInfraModel() != nullptr;
|
2018-12-08 05:30:43 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2016-04-14 03:32:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (which) {
|
|
|
|
case EWhichModel::Normal:
|
2020-03-09 01:10:15 +00:00
|
|
|
return x1c_normalModel.HasReference();
|
2018-12-08 05:30:43 +00:00
|
|
|
case EWhichModel::XRay:
|
2020-03-09 01:10:15 +00:00
|
|
|
return x2c_xrayModel.HasReference();
|
2018-12-08 05:30:43 +00:00
|
|
|
case EWhichModel::Thermal:
|
2020-03-09 01:10:15 +00:00
|
|
|
return x3c_infraModel.HasReference();
|
2018-12-08 05:30:43 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2018-09-07 23:51:07 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-04-13 06:07:23 +00:00
|
|
|
};
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|