Files

150 lines
5.1 KiB
C++
Raw Permalink Normal View History

#ifndef _CMODELDATA
#define _CMODELDATA
2022-08-12 21:26:00 -04:00
#include "types.h"
#include "MetroidPrime/CAnimData.hpp"
2026-03-19 20:55:56 -06:00
#include "MetroidPrime/TGameTypes.hpp"
2022-08-12 21:26:00 -04:00
2022-11-26 15:51:04 +02:00
#include "Kyoto/Animation/IAnimReader.hpp"
2022-08-12 21:26:00 -04:00
#include "Kyoto/Graphics/CColor.hpp"
#include "Kyoto/Math/CTransform4f.hpp"
2022-08-15 00:51:06 -04:00
#include "Kyoto/Math/CVector3f.hpp"
2022-08-12 21:26:00 -04:00
#include "Kyoto/TToken.hpp"
#include "rstl/auto_ptr.hpp"
#include "rstl/optional_object.hpp"
#include "rstl/pair.hpp"
2022-11-15 22:06:18 +02:00
#include "rstl/string.hpp"
2022-08-12 21:26:00 -04:00
2022-08-15 00:51:06 -04:00
class CAABox;
2022-08-15 22:14:28 -04:00
class CActorLights;
2022-10-06 11:53:35 +03:00
class CAnimRes;
2022-08-15 22:14:28 -04:00
class CFrustumPlanes;
2022-08-12 21:26:00 -04:00
class CModel;
2022-08-15 22:14:28 -04:00
class CModelFlags;
2022-10-06 23:40:18 +03:00
class CStateManager;
class CTexture;
2022-11-25 14:41:28 +02:00
class CSkinnedModel;
2022-11-26 15:51:04 +02:00
class CRandom16;
2022-08-12 21:26:00 -04:00
// TODO move
#include "Kyoto/Math/CQuaternion.hpp"
2022-10-08 00:53:28 -04:00
struct CAdvancementDeltas {
public:
2022-10-08 00:53:28 -04:00
CAdvancementDeltas(const CVector3f& posDelta, const CQuaternion& rotDelta)
: x0_posDelta(posDelta), xc_rotDelta(rotDelta) {}
const CVector3f& GetOffsetDelta() const { return x0_posDelta; }
const CQuaternion& GetOrientationDelta() const { return xc_rotDelta; }
private:
CVector3f x0_posDelta;
CQuaternion xc_rotDelta;
};
2022-10-08 00:53:28 -04:00
CHECK_SIZEOF(CAdvancementDeltas, 0x1c)
class CStaticRes {
public:
CStaticRes(CAssetId id, const CVector3f& scale) : x0_cmdlId(id), x4_scale(scale) {}
const CAssetId GetId() const { return x0_cmdlId; }
const CVector3f GetScale() const { return x4_scale; }
private:
CAssetId x0_cmdlId;
CVector3f x4_scale;
};
2022-08-12 21:26:00 -04:00
class CModelData {
public:
2022-12-07 01:14:03 -05:00
enum EWhichModel {
kWM_Normal,
kWM_XRay,
kWM_Thermal,
kWM_ThermalHot,
};
2022-08-15 00:51:06 -04:00
// TODO these probably aren't real
bool HasNormalModel() const { return x1c_normalModel; }
2022-08-12 21:26:00 -04:00
2022-08-15 00:51:06 -04:00
CModelData();
2022-10-06 11:53:35 +03:00
CModelData(const CAnimRes&);
2022-11-14 16:16:52 +02:00
CModelData(const CStaticRes&);
2022-08-12 21:26:00 -04:00
~CModelData();
2022-10-08 00:53:28 -04:00
CAdvancementDeltas AdvanceAnimation(float dt, CStateManager& mgr, TAreaId aid, bool advTree);
2022-08-12 21:26:00 -04:00
void AdvanceParticles(const CTransform4f& xf, float dt, CStateManager& mgr);
2022-08-15 22:14:28 -04:00
void RenderParticles(const CFrustumPlanes& planes) const;
2022-09-18 02:05:46 -04:00
void RenderUnsortedParts(EWhichModel which, const CTransform4f& xf, const CActorLights* lights,
const CModelFlags& flags) const;
void RenderThermal(const CTransform4f& xf, const CColor& mulColor, const CColor& addColor,
const CModelFlags& flags) const;
void Render(const CStateManager&, const CTransform4f&, const CActorLights*,
const CModelFlags&) const;
2022-11-26 15:51:04 +02:00
void Render(EWhichModel, const CTransform4f&, const CActorLights*, const CModelFlags&) const;
2022-11-25 14:41:28 +02:00
void FlatDraw(EWhichModel which, const CTransform4f& xf, bool unsortedOnly,
const CModelFlags& flags) const;
CSkinnedModel& PickAnimatedModel(EWhichModel which) const;
void Touch(const CStateManager& mgr, int) const;
2022-11-26 15:51:04 +02:00
SAdvancementDeltas AdvanceAnimationIgnoreParticles(float dt, CRandom16& rand, bool advTree);
2022-08-12 21:26:00 -04:00
const CAnimData* GetAnimationData() const { return xc_animData.get(); }
CAnimData* AnimationData() {
CAnimData* ret = xc_animData.get();
return ret;
}
2022-08-15 00:51:06 -04:00
CAABox GetBounds(const CTransform4f& xf) const;
CAABox GetBounds() const;
2026-03-17 00:10:26 -06:00
bool IsInFrustum(const CTransform4f& xf, const CFrustumPlanes& planes) const;
2022-11-25 14:41:28 +02:00
bool IsLoaded(int shaderIdx) const;
2023-10-19 18:51:57 -04:00
bool IsDefinitelyOpaque(EWhichModel which) const;
2022-08-15 00:51:06 -04:00
2026-03-19 20:55:56 -06:00
CTransform4f GetLocatorTransformDynamic(const rstl::string& name,
const CCharAnimTime* time) const;
2026-03-17 01:01:21 -06:00
CTransform4f GetScaledLocatorTransformDynamic(const rstl::string& name,
const CCharAnimTime* time) const;
2023-10-19 18:51:57 -04:00
CTransform4f GetLocatorTransform(const rstl::string& name) const;
2022-11-15 22:06:18 +02:00
CTransform4f GetScaledLocatorTransform(const rstl::string& name) const;
2022-08-15 22:14:28 -04:00
bool HasAnimation() const { return !xc_animData.null(); }
bool IsNull() const { return xc_animData.null() && !x1c_normalModel; }
2026-03-03 23:11:47 -07:00
// TODO: maybe fake, but fixes CPatterned ctor codegen
bool IsNotNull() const { return !xc_animData.null() || x1c_normalModel; }
2022-08-12 21:26:00 -04:00
void SetXRayModel(const rstl::pair< CAssetId, CAssetId >& assets);
void SetInfraModel(const rstl::pair< CAssetId, CAssetId >& assets);
2022-09-13 00:26:54 -04:00
2022-08-12 21:26:00 -04:00
void SetAmbientColor(const CColor& color) { x18_ambientColor = color; }
2022-09-13 00:26:54 -04:00
bool GetSortThermal() const { return x14_25_sortThermal; }
2022-08-12 21:26:00 -04:00
void SetSortThermal(bool b) { x14_25_sortThermal = b; }
2026-01-23 00:18:58 -08:00
CVector3f ScaleCopy() const { return x0_scale; }
2026-01-18 10:42:11 -08:00
const CVector3f& GetScale() const { return x0_scale; }
void SetScale(const CVector3f& scale) { x0_scale = scale; }
2022-10-20 08:43:17 -07:00
bool GetIsLoop() const;
void EnableLooping(bool enable);
2022-09-13 22:25:08 -04:00
static CModelData CModelDataNull();
2022-08-15 22:14:28 -04:00
static EWhichModel GetRenderingModel(const CStateManager& mgr);
2025-12-01 17:47:08 -08:00
float GetAnimationDuration(int anim) const;
bool IsAnimating() const;
bool HasModel(EWhichModel which) const;
2026-03-19 20:55:56 -06:00
void DisintegrateDraw(const CStateManager&, const CTransform4f&, const CTexture&, const CColor&,
float) const;
2022-08-15 22:14:28 -04:00
2022-08-12 21:26:00 -04:00
private:
CVector3f x0_scale;
rstl::auto_ptr< CAnimData > xc_animData;
bool x14_24_renderSorted : 1;
bool x14_25_sortThermal : 1;
CColor x18_ambientColor;
rstl::optional_object< TLockedToken< CModel > > x1c_normalModel;
rstl::optional_object< TLockedToken< CModel > > x2c_xrayModel;
rstl::optional_object< TLockedToken< CModel > > x3c_infraModel;
2022-08-12 21:26:00 -04:00
};
CHECK_SIZEOF(CModelData, 0x4c)
2022-08-12 21:26:00 -04:00
#endif // _CMODELDATA