metaforce/Runtime/Graphics/CModel.hpp

91 lines
2.3 KiB
C++
Raw Normal View History

2016-02-13 09:02:47 +00:00
#ifndef __PSHAG_CMODEL_HPP__
#define __PSHAG_CMODEL_HPP__
2016-02-13 00:57:09 +00:00
#include "RetroTypes.hpp"
2016-03-04 23:04:53 +00:00
#include "zeus/CColor.hpp"
2016-03-29 23:14:14 +00:00
#include "CFactoryMgr.hpp"
#include "CToken.hpp"
#include "zeus/CAABox.hpp"
2016-02-13 00:57:09 +00:00
2016-03-04 23:04:53 +00:00
namespace urde
2016-02-13 00:57:09 +00:00
{
2016-03-29 23:14:14 +00:00
class IObjectStore;
class CTexture;
2016-02-13 00:57:09 +00:00
struct CModelFlags
{
2016-03-17 02:18:01 +00:00
u8 f1; /* Blend state 3/5 enable additive */
2016-02-13 00:57:09 +00:00
u8 f2;
2016-03-17 02:18:01 +00:00
u16 f3; /* Depth state */
zeus::CColor color; /* Set into kcolor slot specified by material */
/* depth flags
0x8: greater
0x10: non-inclusive
*/
2016-02-13 00:57:09 +00:00
};
2016-03-29 23:14:14 +00:00
class CBooModel
{
public:
struct CSurface
{
const u8* m_data;
CBooModel* m_parent = nullptr;
CSurface* m_next = nullptr;
};
private:
std::vector<CSurface>* x0_surfaces;
const u8* x4_matSet;
const void* x8_vbo;
const void* xc_ibo;
std::vector<TLockedToken<CTexture>>* x1c_textures;
zeus::CAABox x20_aabb;
CSurface* x38_firstUnsortedSurface = nullptr;
CSurface* x3c_firstSortedSurface = nullptr;
bool x40_24_ : 1;
bool x40_25_ : 1;
u8 x41_shortNormals;
public:
CBooModel(std::vector<CSurface>* surfaces, std::vector<TLockedToken<CTexture>>* textures,
const u8* matSet, const void* vbo, const void* ibo, const zeus::CAABox& aabb,
u8 shortNormals, bool unk);
static void MakeTexuresFromMats(const u8* dataIn,
std::vector<TLockedToken<CTexture>>& toksOut,
IObjectStore& store);
const u8* GetMaterialByIndex(int idx) const;
};
2016-02-13 00:57:09 +00:00
class CModel
{
public:
2016-03-29 23:14:14 +00:00
struct SShader
{
std::vector<TLockedToken<CTexture>> x0_textures;
const u8* x10_data;
};
private:
std::unique_ptr<u8[]> x0_data;
u32 x4_dataLen;
std::vector<CBooModel::CSurface> x8_surfaces;
std::vector<SShader> x18_matSets;
std::unique_ptr<CBooModel> x28_modelInst;
CModel* x30_next = nullptr;
CModel* x34_prev = nullptr;
public:
CModel(std::unique_ptr<u8[]>&& in, u32 dataLen, IObjectStore* store);
2016-02-13 00:57:09 +00:00
void Draw(const CModelFlags& flags) const;
2016-03-17 02:18:01 +00:00
void Touch(int) const;
bool IsLoaded(int) const;
2016-02-13 00:57:09 +00:00
};
2016-03-29 23:14:14 +00:00
CFactoryFnReturn FModelFactory(const urde::SObjectTag& tag,
std::unique_ptr<u8[]>&& in, u32 len,
const urde::CVParamTransfer& vparms);
2016-02-13 00:57:09 +00:00
}
2016-02-13 09:02:47 +00:00
#endif // __PSHAG_CMODEL_HPP__