OpenBarnyard
 
Loading...
Searching...
No Matches
AModelLoader.h
Go to the documentation of this file.
1#pragma once
6
7#include <Toshi/T2DList.h>
8#include <Render/TTMDBase.h>
9#include <Render/TModel.h>
10#include <Render/TTexture.h>
11#include <File/TTRB.h>
12
13#ifdef TOSHI_SKU_WINDOWS
14# include <Render/TTMDWin.h>
16#endif
17
18class AModelLoader : public Toshi::TObject
19 , public Toshi::TSingleton<AModelLoader>
20{
21public:
22 TDECLARE_CLASS( AModelLoader, Toshi::TObject );
23
24 struct MaterialNode : public Toshi::T2DList<MaterialNode>::Node
25 {
26 Toshi::TMaterial* pMaterial;
31 };
32
39
41 {
42 const TCHAR* szName;
43 void* Unknown;
44 };
45
46 static constexpr TUINT MAX_NUM_ALLOCATED_MATERIALS = 512;
47 static constexpr TUINT MAX_NUM_MODEL_MATERIALS = 150;
48
49 friend class AModelInstance;
50
51public:
54
55 static Toshi::TMaterial* CreateMaterial( Toshi::TShader* a_pShader, const TCHAR* a_szMaterialName );
56 static void DestroyMaterial( Toshi::TMaterial* a_pMaterial );
57
58 static void InitialiseStatic();
59
60private:
61 static void AddMaterial( const Toshi::TString8& a_rName, MaterialNode* a_pMaterialNode );
62 static Toshi::TMaterial* FindMaterial( const Toshi::TString8& a_rName );
63
64 static Toshi::TTMDBase::Material* FindMaterialInModel( const TCHAR* a_szName );
65
66 static void MaterialApplyFlags( Toshi::TMaterial* a_pMaterial, const TCHAR* a_szMaterialName );
67 static void MaterialApplyClamp( Toshi::TMaterial* a_pMaterial, const TCHAR* a_szMaterialName, Toshi::TTexture* a_pTexture );
68 static void MaterialApplyAlphaRef( Toshi::TMaterial* a_pMaterial, const TCHAR* a_szMaterialName, Toshi::TTexture* a_pTexture );
69
70 static void LoadGrassMeshTRB( Toshi::TModel* a_pModel, TINT a_iLODIndex, Toshi::TModelLOD* a_pLOD, Toshi::TTMDWin::TRBLODHeader* a_pLODHeader );
71 static void LoadWorldMeshTRB( Toshi::TModel* a_pModel, TINT a_iLODIndex, Toshi::TModelLOD* a_pLOD, Toshi::TTMDWin::TRBLODHeader* a_pLODHeader );
72 static void LoadSkinLOD( Toshi::TModel* a_pModel, TINT a_iLODIndex, Toshi::TModelLOD* a_pLOD, Toshi::TTMDWin::TRBLODHeader* a_pLODHeader );
73
74 static void InitialiseGrassLayersTextures();
75
76private:
77 static TBOOL AModelLoaderLoadTMDCallback( Toshi::TModel* a_pModel );
78 static TBOOL AModelLoaderLoadTRBCallback( Toshi::TModel* a_pModel );
79
80 inline static MaterialNode ms_oNodesAlloc[ MAX_NUM_ALLOCATED_MATERIALS ];
81 inline static Toshi::T2DList<MaterialNode> ms_oFreeMaterials;
82 inline static Toshi::T2DList<MaterialNode> ms_oUsedMaterials;
83
84 inline static Toshi::TTMDBase::MaterialsHeader ms_oCurrentModelMaterialsHeader;
85 inline static Toshi::TTMDBase::Material ms_oCurrentModelMaterials[ MAX_NUM_MODEL_MATERIALS ];
86 inline static TINT16 ms_oMaterialIds[ MAX_NUM_ALLOCATED_MATERIALS ];
87 inline static void* ms_pWorldEndRender;
88 inline static void* ms_pWorldStartRender;
89 inline static void* ms_pWorldUVOffsetsPerSec;
90 inline static const TCHAR** ms_pGlowMaterials;
91 inline static const TCHAR** ms_pDoubleSidedMaterials;
92 inline static AlphaRefMaterial* ms_pAlphaRefMaterials;
93 inline static ClampedMaterial* ms_pClampedMaterials;
94 inline static TINT ms_iNumGlowMaterials;
95 inline static TINT ms_iNumDoubleSidedMaterials;
96 inline static TINT ms_iNumCreatedMaterials;
97 inline static ASkinMaterial* ms_pDefaultSkinMaterial;
98 inline static AWorldMaterial* ms_pDefaultWorldMaterial;
99 inline static AStaticInstanceMaterial* ms_pDefaultStaticInstanceMaterial;
100
101private:
102 Toshi::TTRB m_oTRB;
103};
TRB (Toshi Relocatable Binary) resource system for the Toshi engine.
3D model system for the Toshi engine
Texture system for the Toshi engine.
uint16_t TUINT16
Definition Typedefs.h:15
unsigned int TUINT
Definition Typedefs.h:8
int16_t TINT16
Definition Typedefs.h:14
char TCHAR
Definition Typedefs.h:20
int TINT
Definition Typedefs.h:7
bool TBOOL
Definition Typedefs.h:6
static void DestroyMaterial(Toshi::TMaterial *a_pMaterial)
static constexpr TUINT MAX_NUM_ALLOCATED_MATERIALS
TDECLARE_CLASS(AModelLoader, Toshi::TObject)
static Toshi::TMaterial * CreateMaterial(Toshi::TShader *a_pShader, const TCHAR *a_szMaterialName)
static constexpr TUINT MAX_NUM_MODEL_MATERIALS
friend class AModelInstance
static void InitialiseStatic()
Toshi::TMaterial * pMaterial