My Project
ParaXStaticBase.h
1 #pragma once
2 #include "IAttributeFields.h"
3 #include "ParaXMaterial.h"
4 #include "ParaXRefObject.h"
5 #include "ParaXModel/MeshHeader.h"
6 
7 namespace ParaEngine
8 {
9  class CEffectFile;
10  class CFaceGroup;
11  class XFileParser;
12 
13  namespace XFile
14  {
15  struct Node;
16  struct Mesh;
17  struct Scene;
18  struct Material;
19  }
20 
21  enum XModelFileType
22  {
23  FileType_ParaX,
24  FileType_FBX,
25  };
26 
27 
28 
29  using namespace std;
30 
31 
33  {
34  public:
35  CParaXStaticBase(const char* strName = nullptr);
36  virtual ~CParaXStaticBase();
37 
39  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
40 
41  ATTRIBUTE_METHOD1(CParaXStaticBase, DumpTextureUsage_s, const char**) { *p1 = cls->DumpTextureUsage(); return S_OK; }
42  ATTRIBUTE_METHOD1(CParaXStaticBase, GetPolyCount_s, int*) { *p1 = cls->GetPolyCount(); return S_OK; }
43  ATTRIBUTE_METHOD1(CParaXStaticBase, GetPhysicsCount_s, int*) { *p1 = cls->GetPhysicsCount(); return S_OK; }
44 
46  virtual int GetPolyCount() = 0;
48  virtual int GetPhysicsCount() = 0;
50  virtual const char* DumpTextureUsage() = 0;
51 
52 
59  virtual TextureEntity* GetDefaultReplaceableTexture(int ReplaceableTextureID) = 0;
60 
67  TextureEntity* GetReplaceableTexture(int ReplaceableTextureID);
68 
77  virtual bool SetReplaceableTexture(int ReplaceableTextureID, TextureEntity* pTextureEntity);
78 
79 
81  virtual int GetNextPhysicsGroupID(int nPhysicsGroup = -1) = 0;
82 
83 
90  virtual TextureEntity* LoadTextureByPath(const string& sFilePath, DWORD TextureType);
91 
92 
93  // Creation/destruction
98  HRESULT Create(RenderDevicePtr pd3dDevice, const char* strFilename, bool bCheckSecondUV = false);
99 
100  virtual HRESULT Create(RenderDevicePtr pd3dDevice, void* buffer, DWORD nFileSize, bool bCheckSecondUV = false) = 0;
101 #ifdef USE_DIRECTX_RENDERER
102  virtual HRESULT Create(RenderDevicePtr pd3dDevice, LPD3DXFILEDATA pFileData) = 0;
103 #endif
104  virtual HRESULT Create(RenderDevicePtr pd3dDevice, XFile::Scene* pFileData) = 0;
105 
106  virtual HRESULT Destroy();
107 
108 
109  // Initializing
110  virtual HRESULT InitDeviceObjects() = 0;
111  virtual HRESULT DeleteDeviceObjects() = 0;
112 
113  // -- Get Bounding sphere
114  virtual FLOAT ComputeBoundingSphere(Vector3* vObjectCenter, FLOAT* fObjectRadius) = 0;
115  virtual HRESULT ComputeBoundingBox(Vector3 *pMin, Vector3 *pMax) = 0;
116 
127  virtual HRESULT ClonePhysicsMesh(DWORD* pNumVertices, Vector3 ** ppVerts, DWORD* pNumTriangles, WORD** ppIndices, int* pnMeshPhysicsGroup = nullptr, int* pnTotalMeshGroupCount = nullptr) = 0;
128 
131 #ifdef USE_DIRECTX_RENDERER
132  virtual MeshHeader& GetMeshHeader(LPD3DXFILE pFileParser = nullptr) = 0;
133 #endif
134  virtual MeshHeader& GetMeshHeader(XFileParser* pFileParser = nullptr) = 0;
135 
136 #ifdef USE_DIRECTX_RENDERER
137 
138  virtual bool GetMeshHeaderFromFile(CParaFile& myFile, LPD3DXFILE pFileParser) = 0;
139 #endif
140  virtual bool GetMeshHeaderFromFile(CParaFile& myFile, XFileParser* pFileParser) = 0;
141 
142  // Rendering
143  virtual HRESULT Render(SceneState * pSceneState, RenderDevicePtr pd3dDevice,
144  bool bDrawOpaqueSubsets = true,
145  bool bDrawAlphaSubsets = true, float fAlphaFactor = 1.0f) = 0;
146  virtual HRESULT Render(SceneState * pSceneState, CEffectFile *pEffect,
147  bool bDrawOpaqueSubsets = true,
148  bool bDrawAlphaSubsets = true, float fAlphaFactor = 1.0f, CParameterBlock* materialParams = nullptr) = 0;
149 
150 
158  int GetNumReplaceableTextures();
159 
163  void SetMeshFileData(void * pData, int nSize);
164  void DeleteMeshFileData();
165 
167  int GetXRefObjectsCount() { return (int)m_XRefObjects.size(); }
169  const ParaXRefObject* GetXRefObjectsByIndex(int nIndex);
170 
171  // Rendering options
172  void UseMeshMaterials(bool bFlag) { m_bUseMaterials = bFlag; }
173 
174 
175  static XModelFileType GetFileTypeByFilename(const std::string& sFilename);
176  protected:
178  void ClearFaceGroups();
179  protected:
180  string m_strName;
181  MeshHeader m_header;
182 
184  char* m_pFileData;
188  vector<ParaXRefObject> m_XRefObjects;
190  vector<CFaceGroup*> m_faceGroups;
191 
192  DWORD m_dwNumMaterials; // Materials for the mesh
193 
194  bool m_bUseMaterials;
195 
196  vector< ref_ptr<TextureEntity> > m_ReplaceableTextures;
197  };
198 
199 } // end namespace
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
It&#39;s used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
Helper structure analogue to aiScene.
Definition: XFileHelper.h:123
vector< CFaceGroup * > m_faceGroups
a list of face group
Definition: ParaXStaticBase.h:190
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: minilua.c:352
char * m_pFileData
the file data from which to load the mesh
Definition: ParaXStaticBase.h:184
mesh header
Definition: MeshHeader.h:6
int GetXRefObjectsCount()
get the XRef Object in this model.
Definition: ParaXStaticBase.h:167
a very thin wrapper to DirectX device with a portable version of openGL implementation.
Definition: RenderDeviceDirectX.h:10
vector< ParaXRefObject > m_XRefObjects
get a list of XRef objects
Definition: ParaXStaticBase.h:188
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
The XFileParser reads a XFile either in text or binary form and builds a temporary data structure out...
Definition: XFileParser.h:19
Definition: effect_file.h:323
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
XRef Objects in X and ParaX model.
Definition: ParaXRefObject.h:6
int m_pFileDataSize
the file data size in bytes from which to load the mesh
Definition: ParaXStaticBase.h:186
Definition: ParaXStaticBase.h:32
a list of CParameter{name, value} pairs of anything.
Definition: ParameterBlock.h:108