2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_CMODELDATA_HPP__
|
|
|
|
#define __URDE_CMODELDATA_HPP__
|
|
|
|
|
|
|
|
#include "zeus/CVector3f.hpp"
|
2016-04-14 03:32:27 +00:00
|
|
|
#include "zeus/CAABox.hpp"
|
2016-04-14 21:42:47 +00:00
|
|
|
#include "zeus/CColor.hpp"
|
2016-04-14 03:32:27 +00:00
|
|
|
#include "RetroTypes.hpp"
|
|
|
|
#include "CToken.hpp"
|
2016-04-19 00:17:49 +00:00
|
|
|
#include "CAnimData.hpp"
|
2016-09-02 19:32:57 +00:00
|
|
|
#include "Graphics/CModel.hpp"
|
2016-04-13 06:07:23 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
2016-04-14 03:32:27 +00:00
|
|
|
class CCharAnimTime;
|
|
|
|
class CStateManager;
|
|
|
|
class CActorLights;
|
2016-05-23 05:35:27 +00:00
|
|
|
struct CModelFlags;
|
2016-04-14 03:32:27 +00:00
|
|
|
class CRandom16;
|
|
|
|
class CAnimData;
|
|
|
|
class CModel;
|
2016-04-14 21:42:47 +00:00
|
|
|
class CSkinnedModel;
|
|
|
|
struct SAdvancementDeltas;
|
2016-04-13 06:07:23 +00:00
|
|
|
|
2016-04-27 19:59:38 +00:00
|
|
|
class CStaticRes
|
2016-04-14 03:32:27 +00:00
|
|
|
{
|
2016-04-19 21:25:26 +00:00
|
|
|
ResId x0_cmdlId = 0;
|
2016-04-19 00:17:49 +00:00
|
|
|
zeus::CVector3f x4_scale;
|
2016-04-27 19:59:38 +00:00
|
|
|
public:
|
|
|
|
CStaticRes(ResId id, const zeus::CVector3f& scale)
|
|
|
|
: x0_cmdlId(id),
|
|
|
|
x4_scale(scale)
|
|
|
|
{}
|
|
|
|
|
|
|
|
ResId GetId() const { return x0_cmdlId; }
|
|
|
|
const zeus::CVector3f& GetScale() const { return x4_scale; }
|
2016-08-31 23:08:09 +00:00
|
|
|
operator bool() const { return x0_cmdlId != 0; }
|
2016-04-14 03:32:27 +00:00
|
|
|
};
|
|
|
|
|
2016-04-27 19:59:38 +00:00
|
|
|
class CAnimRes
|
2016-04-13 06:07:23 +00:00
|
|
|
{
|
2016-04-27 19:59:38 +00:00
|
|
|
ResId x0_ancsId = -1;
|
|
|
|
s32 x4_charIdx = -1;
|
2016-04-19 00:17:49 +00:00
|
|
|
zeus::CVector3f x8_scale;
|
2016-04-27 19:59:38 +00:00
|
|
|
bool x14_canLoop = false;
|
|
|
|
/* NOTE: x18_bodyType - Removed in retail */
|
|
|
|
s32 x18_defaultAnim = -1; /* NOTE: used to be x1c in demo */
|
|
|
|
public:
|
|
|
|
CAnimRes() = default;
|
|
|
|
CAnimRes(ResId 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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ResId GetId() const { return x0_ancsId; }
|
|
|
|
s32 GetCharacterNodeId() const { return x4_charIdx; }
|
|
|
|
const zeus::CVector3f& GetScale() const { return x8_scale; }
|
|
|
|
bool CanLoop() const { return x14_canLoop; }
|
|
|
|
s32 GetDefaultAnim() const { return x18_defaultAnim; }
|
2016-04-13 06:07:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CModelData
|
|
|
|
{
|
2016-04-22 20:22:45 +00:00
|
|
|
friend class CActor;
|
2016-09-02 22:16:34 +00:00
|
|
|
zeus::CVector3f x0_scale;
|
2016-04-29 10:08:46 +00:00
|
|
|
bool xc_ = false;
|
|
|
|
std::unique_ptr<CAnimData> x10_animData;
|
2016-04-14 21:42:47 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool x14_24_renderSorted : 1;
|
|
|
|
bool x14_25_sortThermal : 1;
|
|
|
|
};
|
|
|
|
u32 _flags = 0;
|
|
|
|
};
|
|
|
|
zeus::CColor x18_ambientColor;
|
2016-09-02 19:32:57 +00:00
|
|
|
|
2016-04-14 03:32:27 +00:00
|
|
|
TLockedToken<CModel> x1c_normalModel;
|
|
|
|
TLockedToken<CModel> x2c_xrayModel;
|
|
|
|
TLockedToken<CModel> x3c_infraModel;
|
2016-04-15 03:02:21 +00:00
|
|
|
|
2016-09-02 19:32:57 +00:00
|
|
|
std::unique_ptr<CBooModel> m_normalModelInst;
|
|
|
|
std::unique_ptr<CBooModel> m_xrayModelInst;
|
|
|
|
std::unique_ptr<CBooModel> m_infraModelInst;
|
|
|
|
|
2016-09-12 04:53:28 +00:00
|
|
|
int m_drawInstCount;
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
public:
|
2016-04-14 03:32:27 +00:00
|
|
|
enum class EWhichModel
|
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
Normal,
|
|
|
|
XRay,
|
|
|
|
Thermal
|
2016-04-14 03:32:27 +00:00
|
|
|
};
|
|
|
|
|
2016-08-15 01:19:04 +00:00
|
|
|
void SetSortThermal(bool v) { x14_25_sortThermal = v; }
|
|
|
|
|
2016-04-15 03:02:21 +00:00
|
|
|
~CModelData();
|
2016-09-12 04:53:28 +00:00
|
|
|
CModelData(const CStaticRes& res, int instCount=1);
|
|
|
|
CModelData(const CAnimRes& res, int instCount=1);
|
2016-04-15 03:02:21 +00:00
|
|
|
CModelData(CModelData&&) = default;
|
2016-04-19 00:17:49 +00:00
|
|
|
CModelData& operator=(CModelData&&) = default;
|
|
|
|
CModelData();
|
2016-04-19 21:25:26 +00:00
|
|
|
static CModelData CModelDataNull();
|
2016-04-14 03:32:27 +00:00
|
|
|
|
2016-04-14 21:42:47 +00:00
|
|
|
SAdvancementDeltas GetAdvancementDeltas(const CCharAnimTime& a, const CCharAnimTime& b) const;
|
2016-04-14 03:32:27 +00:00
|
|
|
void Render(const CStateManager& stateMgr, const zeus::CTransform& xf,
|
2016-08-21 00:04:50 +00:00
|
|
|
const CActorLights* lights, const CModelFlags& drawFlags);
|
2016-04-14 21:42:47 +00:00
|
|
|
EWhichModel GetRenderingModel(const CStateManager& stateMgr) const;
|
2016-08-21 00:04:50 +00:00
|
|
|
CSkinnedModel& PickAnimatedModel(EWhichModel which) const;
|
2016-09-09 04:19:19 +00:00
|
|
|
const std::unique_ptr<CBooModel>& PickStaticModel(EWhichModel which) const;
|
2016-04-14 21:42:47 +00:00
|
|
|
void SetXRayModel(const std::pair<ResId, ResId>& modelSkin);
|
|
|
|
void SetInfraModel(const std::pair<ResId, ResId>& modelSkin);
|
2016-08-21 00:04:50 +00:00
|
|
|
bool IsDefinitelyOpaque(EWhichModel);
|
2016-04-14 03:32:27 +00:00
|
|
|
bool GetIsLoop() const;
|
|
|
|
float GetAnimationDuration(int) const;
|
|
|
|
void EnableLooping(bool);
|
|
|
|
void AdvanceParticles(const zeus::CTransform& xf, float, CStateManager& stateMgr);
|
|
|
|
zeus::CAABox GetBounds() const;
|
|
|
|
zeus::CAABox GetBounds(const zeus::CTransform& xf) const;
|
|
|
|
zeus::CTransform GetScaledLocatorTransformDynamic(const std::string& name, const CCharAnimTime* time) const;
|
|
|
|
zeus::CTransform GetScaledLocatorTransform(const std::string& name) const;
|
|
|
|
zeus::CTransform GetLocatorTransformDynamic(const std::string& name, const CCharAnimTime* time) const;
|
|
|
|
zeus::CTransform GetLocatorTransform(const std::string& name) const;
|
2016-09-02 17:50:03 +00:00
|
|
|
SAdvancementDeltas AdvanceAnimationIgnoreParticles(float dt, CRandom16&, bool advTree);
|
|
|
|
SAdvancementDeltas AdvanceAnimation(float dt, CStateManager& stateMgr, TAreaId aid, bool advTree);
|
2016-04-14 03:32:27 +00:00
|
|
|
bool IsAnimating() const;
|
2016-09-04 02:27:35 +00:00
|
|
|
bool IsInFrustum(const zeus::CTransform& xf, const zeus::CFrustum& frustum) const;
|
|
|
|
void RenderParticles(const zeus::CFrustum& frustum) const;
|
2016-08-21 00:04:50 +00:00
|
|
|
void Touch(EWhichModel, int shaderIdx);
|
|
|
|
void Touch(const CStateManager& stateMgr, int shaderIdx);
|
|
|
|
void RenderThermal(const zeus::CTransform& xf, const zeus::CColor& a, const zeus::CColor& b);
|
2016-04-14 03:32:27 +00:00
|
|
|
void RenderUnsortedParts(EWhichModel, const zeus::CTransform& xf,
|
2016-08-21 00:04:50 +00:00
|
|
|
const CActorLights* lights, const CModelFlags& drawFlags);
|
2016-04-14 03:32:27 +00:00
|
|
|
void Render(EWhichModel, const zeus::CTransform& xf,
|
2016-08-21 00:04:50 +00:00
|
|
|
const CActorLights* lights, const CModelFlags& drawFlags);
|
2016-04-22 20:22:45 +00:00
|
|
|
|
2016-04-29 10:08:46 +00:00
|
|
|
CAnimData* AnimationData() { return x10_animData.get(); }
|
2016-11-20 21:53:15 +00:00
|
|
|
const TLockedToken<CModel>& GetNormalModel() const { return x1c_normalModel; }
|
|
|
|
const TLockedToken<CModel>& GetXRayModel() const { return x2c_xrayModel; }
|
|
|
|
const TLockedToken<CModel>& GetThermalModel() const { return x3c_infraModel; }
|
2016-05-03 08:27:28 +00:00
|
|
|
bool IsNull() { return !x10_animData && !x1c_normalModel; }
|
2016-04-13 06:07:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __URDE_CMODELDATA_HPP__
|