metaforce/Runtime/Graphics/CModel.hpp

129 lines
3.4 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-30 19:16:01 +00:00
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
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-30 19:16:01 +00:00
class CBooSurface
{
};
2016-03-29 23:14:14 +00:00
class CBooModel
{
public:
2016-03-30 19:16:01 +00:00
/* urde addition: doesn't require hacky stashing of
* pointers within loaded CMDL buffer */
struct CSurfaceView
2016-03-29 23:14:14 +00:00
{
const u8* m_data;
CBooModel* m_parent = nullptr;
2016-03-30 19:16:01 +00:00
CSurfaceView* m_next = nullptr;
2016-03-29 23:14:14 +00:00
};
private:
2016-03-30 19:16:01 +00:00
std::vector<CSurfaceView>* x0_surfaces;
2016-03-29 23:14:14 +00:00
const u8* x4_matSet;
2016-03-30 19:16:01 +00:00
boo::IGraphicsBufferS* x8_vbo;
boo::IGraphicsBufferS* xc_ibo;
2016-03-29 23:14:14 +00:00
std::vector<TLockedToken<CTexture>>* x1c_textures;
zeus::CAABox x20_aabb;
2016-03-30 19:16:01 +00:00
CSurfaceView* x38_firstUnsortedSurface = nullptr;
CSurfaceView* x3c_firstSortedSurface = nullptr;
2016-03-29 23:14:14 +00:00
bool x40_24_ : 1;
bool x40_25_ : 1;
u8 x41_shortNormals;
2016-03-30 19:16:01 +00:00
/* urde addition: boo! */
boo::GraphicsDataToken m_gfxToken;
boo::IGraphicsBufferD* m_uniformBuffer;
boo::IShaderDataBinding* m_shaderDataBinding;
void DrawAlphaSurfaces(const CModelFlags& flags) const;
void DrawNormalSurfaces(const CModelFlags& flags) const;
void DrawSurfaces(const CModelFlags& flags) const;
void DrawSurface(const CBooSurface& surf, const CModelFlags& flags) const;
2016-03-29 23:14:14 +00:00
public:
2016-03-30 19:16:01 +00:00
CBooModel(std::vector<CSurfaceView>* surfaces,
std::vector<TLockedToken<CTexture>>* textures,
const u8* matSet,
boo::IGraphicsBufferS* vbo, boo::IGraphicsBufferS* ibo,
const zeus::CAABox& aabb,
2016-03-29 23:14:14 +00:00
u8 shortNormals, bool unk);
static void MakeTexuresFromMats(const u8* dataIn,
std::vector<TLockedToken<CTexture>>& toksOut,
IObjectStore& store);
2016-03-30 19:16:01 +00:00
void TryLockTextures() const;
void UnlockTextures() const;
void DrawAlpha(const CModelFlags& flags) const;
void DrawNormal(const CModelFlags& flags) const;
void Draw(const CModelFlags& flags) const;
2016-03-29 23:14:14 +00:00
const u8* GetMaterialByIndex(int idx) const;
2016-03-30 19:16:01 +00:00
static bool g_DrawingOccluders;
static void SetDrawingOccluders(bool occ) {g_DrawingOccluders = occ;}
2016-03-29 23:14:14 +00:00
};
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;
2016-03-30 19:16:01 +00:00
std::vector<CBooModel::CSurfaceView> x8_surfaces;
2016-03-29 23:14:14 +00:00
std::vector<SShader> x18_matSets;
std::unique_ptr<CBooModel> x28_modelInst;
CModel* x30_next = nullptr;
CModel* x34_prev = nullptr;
2016-03-30 19:16:01 +00:00
/* urde addition: boo! */
boo::GraphicsDataToken m_gfxToken;
boo::IGraphicsBufferS* m_vbo;
boo::IGraphicsBufferS* m_ibo;
2016-03-29 23:14:14 +00:00
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__