My Project
ParaWorldAsset.h
1 #pragma once
2 #include "TextureEntity.h"
3 #include "SpriteFontEntity.h"
4 #include "DatabaseEntity.h"
5 #include "ParaXEntity.h"
6 #include "MeshEntity.h"
7 #include "MiscEntity.h"
8 #include "SequenceManager.h"
9 #include "DynamicVertexBufferManager.h"
10 #include "effect_file.h"
11 #include "EffectManager.h"
12 
13 #ifdef USE_DIRECTX_RENDERER
14 #include "HTMLBrowserManager.h"
15 #ifdef USE_FLASH_MANAGER
16 #include "FlashTextureManager.h"
17 #endif
18 #include "VoxelMesh/VoxelTerrainManager.h"
19 #include "CadModel/CadModel.h"
20 #include <vector>
21 namespace ParaEngine
22 {
23  class LatentOcclusionQueryBank;
24 }
25 #endif
26 
27 namespace ParaEngine
28 {
29  class CVertexBufferPoolManager;
30  class BufferPickingManager;
31  struct CBufferPicking;
32  using namespace std;
33 
45  {
46  public:
47  CParaWorldAsset(void);
48  virtual ~CParaWorldAsset(void);
49 
50  ATTRIBUTE_DEFINE_CLASS(CParaWorldAsset);
51 
53  virtual IAttributeFields* GetChildAttributeObject(const std::string& sName);
55  virtual int GetChildAttributeObjectCount(int nColumnIndex = 0);
57  virtual int GetChildAttributeColumnCount();
58  virtual IAttributeFields* GetChildAttributeObject(int nRowIndex, int nColumnIndex = 0);
60  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
61 
62  ATTRIBUTE_METHOD1(CParaWorldAsset, IsAsyncLoading_s, bool*) { *p1 = cls->IsAsyncLoading(); return S_OK; }
63  ATTRIBUTE_METHOD1(CParaWorldAsset, SetAsyncLoading_s, bool) { cls->SetAsyncLoading(p1); return S_OK; }
64 
65  ATTRIBUTE_METHOD1(CParaWorldAsset, IsAssetManifestEnabled_s, bool*) { *p1 = cls->IsAssetManifestEnabled(); return S_OK; }
66  ATTRIBUTE_METHOD1(CParaWorldAsset, EnableAssetManifest_s, bool) { cls->EnableAssetManifest(p1); return S_OK; }
67 
68  ATTRIBUTE_METHOD1(CParaWorldAsset, IsUseLocalFileFirst_s, bool*) { *p1 = cls->IsUseLocalFileFirst(); return S_OK; }
69  ATTRIBUTE_METHOD1(CParaWorldAsset, SetUseLocalFileFirst_s, bool) { cls->SetUseLocalFileFirst(p1); return S_OK; }
70 
71  ATTRIBUTE_METHOD(CParaWorldAsset, DeleteTempDiskTextures_s) { cls->DeleteTempDiskTextures(); return S_OK; }
72  public:
73  static CParaWorldAsset* GetSingleton();
74 
75  TextureAssetManager& GetTextureManager();
76  CVertexBufferPoolManager& GetVertexBufferPoolManager();
77  TextureEntity* GetTexture(const string& sIdentifier);
78  TextureEntity* GetDefaultTexture(int nTextureID);
86  TextureEntity* LoadTexture(const string& sIdentifier, const string& sTextureFileName, TextureEntity::_SurfaceType nSurfaceType = TextureEntity::StaticTexture);
87 
88  SpriteFontAssetManager& GetFontManager();
89  SpriteFontEntity* GetFont(const string& sIdentifier);
90  SpriteFontEntity* LoadGDIFont(const string& sIdentifier, const string& pstrFont, DWORD dwSize, bool bIsBold = true);
91 
92  DatabaseAssetManager& GetDatabaseManager();
93  DatabaseEntity* GetDatabase(const string& sIdentifier);
94  DatabaseEntity* LoadDatabase(const string& sIdentifier, const string& fileName);
95 
96  MeshEntityManager& GetMeshManager();
97  MeshEntity* GetMesh(const string& sIdentifier);
98  MeshEntity* LoadMesh(const string& sIdentifier, const string& sMeshFileName);
99 
100  ParaXEntityManager& GetParaXManager();
101  ParaXEntity* GetParaX(const string& sIdentifier);
102  ParaXEntity* LoadParaX(const string& sIdentifier, const string& fileName);
104  ParaXEntity* LoadParaXByID(int nAssetID);
105 
106  CSequenceManager& GetSequenceManager(){ return m_SequenceManager; };
107  SequenceEntity* LoadSequence(const string& sName);
108 
109  EffectManager& GetEffectManager(){ return m_EffectsManager; };
110  CEffectFile* LoadEffectFile(const string& sIdentifier, const string& sEffectFile);
111 
112  DynamicVertexBufferEntity* GetDynamicBuffer(DynamicVBAssetType nBufferType);
113 
114  BufferPickingManager& GetBufferPickingManager();
115  CBufferPicking* GetBufferPick(const string& sIdentifier);
116  CBufferPicking* LoadBufferPick(const string& sIdentifier);
117 
118 #ifdef USE_DIRECTX_RENDERER
119  inline CHTMLBrowserManager& GetHTMLBrowserManager(){ return m_HTMLBrowserManager; };
120  inline VoxelTerrainManager& GetVoxelTerrainManager(){ return m_VoxelTerrainManager; };
121 #ifdef USE_FLASH_MANAGER
122  inline CFlashTextureManager& GetFlashManager(){ return m_FlashManager; };
123 #endif
124  //-- get resource primitives
125  D3DXSpriteEntity* GetD3DXSprite(const string& sIdentifier);
126  CadModel* LoadCadModel(const string& sIdentifier, const string& sMeshFileName);
127 
128  D3DXSpriteEntity* LoadD3DXSprite(const string& sIdentifier, int nFrames, int nRow, int nCol);
129 
133  void CreateXFileParser(LPD3DXFILE* ppParser);
135  LPD3DXFILE GetParaXFileParser();
136 
137  LPDIRECT3DVERTEXBUFFER9 GetShadowSquareVB(){ return m_pShadowSquareVB; }
138 
140  LPDIRECT3DQUERY9 GetOcclusionQuery(){ return m_pOcclusionQuery; }
147  LatentOcclusionQueryBank* GetOcclusionQueryBank(int nID = 0);
148 
155  int PrintToFile(CParaFile* pOutputFile, DWORD dwSelection = 0xffffffff);
156 #endif
157 
158  public:
162  bool RefreshAsset(const char* filename);
163 
168  void RenderFrameMove(float fElapsedTime);
169 
171  void LoadAsset();
173  void UnloadAsset();
174 
181  bool UnloadAssetByKeyName(const string& keyname);
182 
184  void GarbageCollectAll();
185 
186  void Cleanup();
187 
188  HRESULT InitDeviceObjects(); // device independent
189  HRESULT RestoreDeviceObjects(); // device dependent
190  HRESULT InvalidateDeviceObjects();
191  HRESULT DeleteDeviceObjects();
195  HRESULT RendererRecreated();
196 
207  bool DoAssetSearch(string& AssetFile, const char* searchDir);
208 
210  void CreateAttributeModel();
211 
213  bool IsAsyncLoading() const;
214  void SetAsyncLoading(bool val);
215 
217  bool IsAssetManifestEnabled() const;
218  void EnableAssetManifest(bool val);
219 
221  bool IsUseLocalFileFirst() const;
222  void SetUseLocalFileFirst(bool val);
223  private:
224  void SaveAssetFileMapping();
225  void DeleteTempDiskTextures();
226 
227  public:
228  typedef boost::signals2::signal<void()> DeviceEvent_Callback_t;
229 
230  DeviceEvent_Callback_t OnInitDeviceObjects;
231  DeviceEvent_Callback_t OnRestoreDeviceObjects;
232  DeviceEvent_Callback_t OnInvalidateDeviceObjects;
233  DeviceEvent_Callback_t OnDeleteDeviceObjects;
234  DeviceEvent_Callback_t OnRendererRecreated;
235  DeviceEvent_Callback_t OnCleanup;
236 
237  protected:
246 
252  map<string, string> m_AssetMap;
253 
254  private:
256  vector<IAttributeFields*> m_attribute_models;
257 
258  CSequenceManager m_SequenceManager;
259  EffectManager m_EffectsManager;
260  DynamicVertexBufferManager m_DynamicVBManager;
261  bool m_bAsyncLoading;
262 
263 #ifdef USE_DIRECTX_RENDERER
264  LPDIRECT3DVERTEXBUFFER9 m_pShadowSquareVB;
268  LPDIRECT3DQUERY9 m_pOcclusionQuery;
269  vector<LatentOcclusionQueryBank*> m_pOcclusionQueryBanks;
270 
271  AssetManager<D3DXSpriteEntity> m_D3DXSpriteManager;
272 #ifdef USE_FLASH_MANAGER
273  CFlashTextureManager m_FlashManager;
274 #endif
275  CHTMLBrowserManager m_HTMLBrowserManager;
276  VoxelTerrainManager m_VoxelTerrainManager;
277  AssetManager<CadModel> m_CadModelManager;
278  LPD3DXFILE m_pDXFile; // for parsing X file
279 #endif
280  };
281 
282 }
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
all picking buffers There is a default one called BufferPickingManager::GetInstance().GetEntity("backbuffer"); which is the current backbuffer Some predefined picking object can be retrieved via NPL script using
Definition: BufferPicking.h:143
picking from frame buffer (back buffer) When there is picking query, it will render scene again (if o...
Definition: BufferPicking.h:16
different physics engine has different winding order.
Definition: EventBinding.h:32
normal managed texture, with all mip-mapping level created
Definition: TextureEntity.h:61
bool m_bUseAssetSearch
this will be set to true when the manager class is created if there is a fill called temp/assetmap...
Definition: ParaWorldAsset.h:245
managing all voxel terrain entities used by any scenes
Definition: VoxelTerrainManager.h:13
When use DirectX, this is a real dynamic vertex buffer for rendering dynamic mesh When use OpenGL...
Definition: DynamicVertexBufferEntityDirectX.h:11
AssetManager manages a set of asset entities of a certain type.
Definition: AssetManager.h:13
a reusable entity of sequence which contains an array of sequence items.
Definition: SequenceEntity.h:11
buffer manager
Definition: DynamicVertexBufferManager.h:7
DynamicVBAssetType
ID of dynamic vertex buffer asset.
Definition: DynamicVertexBufferEntity.h:14
Definition: ParaXEntity.h:9
_SurfaceType
Definition: TextureEntity.h:55
Definition: effect_file.h:323
This is a bank of occlusion queries.
Definition: OcclusionQueryBank.h:48
A common interface for all classes implementing IAttributeFields By implementing this class&#39;s virtual...
Definition: IAttributeFields.h:59
it presents a real or virtual file in ParaEngine.
Definition: ParaFile.h:31
MeshEntity distinguish one template from other.
Definition: MeshEntity.h:38
manager all effects file used by the game engine.
Definition: EffectManager.h:16
managing HTML browsers.
Definition: HTMLBrowserManager.h:137
a manger of sequences
Definition: ParaVertexBufferPool.h:80
the asset manager class in ParaEngine.
Definition: ParaWorldAsset.h:44
a manger of sequences
Definition: SequenceManager.h:9
DataBaseEntity distinguish one template from other TODO: I should wrap the SQLite3 interface in Datab...
Definition: DatabaseEntity.h:12
map< string, string > m_AssetMap
this is only used when m_bUseAssetSearch is true.
Definition: ParaWorldAsset.h:252
managing flash textures.
Definition: FlashTextureManager.h:295
Definition: CadModel.h:77
Definition: SpriteFontEntity.h:26