My Project
StaticMesh.h
1 #pragma once
2 #include "ParaXStaticBase.h"
3 
4 namespace ParaEngine
5 {
6  class CEffectFile;
7  class CFaceGroup;
8  using namespace std;
9 
10  //-----------------------------------------------------------------------------
11  // Name: class CParaXStaticMesh
13  //-----------------------------------------------------------------------------
15  {
16  public:
21  CParaXStaticMesh(const char* strName = nullptr, LPD3DXFILE pDXFileParser = nullptr);
22  virtual ~CParaXStaticMesh();
23 
24 
26  virtual int GetAttributeClassID() { return ATTRIBUTE_CLASSID_CDXUTMesh; }
28  virtual const char* GetAttributeClassName() { static const char name[] = "CDXUTMesh"; return name; }
30  virtual const char* GetAttributeClassDescription() { static const char desc[] = ""; return desc; }
31 
33  virtual int GetPolyCount();
35  virtual int GetPhysicsCount();
37  virtual const char* DumpTextureUsage();
38 
39 
41  virtual int GetNextPhysicsGroupID(int nPhysicsGroup = -1);
42 
49  virtual TextureEntity* GetDefaultReplaceableTexture(int ReplaceableTextureID);
50 
51 
52  // Creation/destruction
57  virtual HRESULT Create(RenderDevicePtr pd3dDevice, void* buffer, DWORD nFileSize, bool bCheckSecondUV = false);
58 #ifdef USE_DIRECTX_RENDERER
59  virtual HRESULT Create(RenderDevicePtr pd3dDevice, LPD3DXFILEDATA pFileData);
60 #endif
61  virtual HRESULT Create(RenderDevicePtr pd3dDevice, XFile::Scene* pFileData) { return S_FALSE; };
62 
63  virtual HRESULT Destroy();
64 
65  // Initializing
66  virtual HRESULT InitDeviceObjects();
67  virtual HRESULT DeleteDeviceObjects();
68 
69  // -- Get Bounding sphere
70  virtual FLOAT ComputeBoundingSphere(Vector3* vObjectCenter, FLOAT* fObjectRadius);
71  virtual HRESULT ComputeBoundingBox(Vector3 *pMin, Vector3 *pMax);
72 
83  virtual HRESULT ClonePhysicsMesh(DWORD* pNumVertices, Vector3 ** ppVerts, DWORD* pNumTriangles, WORD** ppIndices, int* pnMeshPhysicsGroup = nullptr, int* pnTotalMeshGroupCount = nullptr);
84 
85 
88 #ifdef USE_DIRECTX_RENDERER
89  virtual MeshHeader& GetMeshHeader(LPD3DXFILE pFileParser = nullptr);
90 #endif
91  virtual MeshHeader& GetMeshHeader(XFileParser* pFileParser = nullptr);
92 
93 #ifdef USE_DIRECTX_RENDERER
94 
95  virtual bool GetMeshHeaderFromFile(CParaFile& myFile, LPD3DXFILE pFileParser);
96 #endif
97  virtual bool GetMeshHeaderFromFile(CParaFile& myFile, XFileParser* pFileParser) { return false; };
98 
99  // Rendering
100  virtual HRESULT Render(SceneState * pSceneState, RenderDevicePtr pd3dDevice,
101  bool bDrawOpaqueSubsets = true,
102  bool bDrawAlphaSubsets = true, float fAlphaFactor = 1.0f);
103  virtual HRESULT Render(SceneState * pSceneState, CEffectFile *pEffect,
104  bool bDrawOpaqueSubsets = true,
105  bool bDrawAlphaSubsets = true, float fAlphaFactor = 1.0f, CParameterBlock* materialParams = nullptr);
106  public:
107  // Mesh access
108  LPD3DXMESH GetSysMemMesh() { return m_pSysMemMesh; }
109  LPD3DXMESH GetLocalMesh() { return m_pLocalMesh; }
110 
111  LPD3DXMESH& GetSysMemMeshRef() { return m_pSysMemMesh; }
112  LPD3DXMESH& GetLocalMeshRef() { return m_pLocalMesh; }
113 
115  static HRESULT GetMeshHeader(LPCSTR strFilename, LPD3DXFILE pFileParser, Vector3& vMin, Vector3& vMax, bool& bHasNormal, bool& bHasTex2);
116  protected:
117  HRESULT CreateMaterials(const char* strPath, IDirect3DDevice9 *pd3dDevice, ID3DXBuffer *pAdjacencyBuffer, ID3DXBuffer *pMtrlBuffer);
119  HRESULT DrawSubSetEx(int nIndex, D3DXATTRIBUTERANGE* pAtts);
120  protected:
121  CParaXMaterial* m_pMaterials;
122 
123  LPD3DXFILE m_pDXFileParser; // x file template parsing
124  LPD3DXMESH m_pSysMemMesh; // SysMem mesh, lives through resize
125  LPD3DXMESH m_pLocalMesh; // Local mesh, rebuilt on resize
126  };
127 
128 
129 #ifdef USE_DIRECTX_RENDERER
130  typedef asset_ptr<CParaXStaticMesh> CParaXStaticModelPtr;
132 #endif
133 }
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
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
different physics engine has different winding order.
Definition: EventBinding.h:32
mesh header
Definition: MeshHeader.h:6
a very thin wrapper to DirectX device with a portable version of openGL implementation.
Definition: RenderDeviceDirectX.h:10
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
virtual const char * GetAttributeClassDescription()
a static string, describing the attribute class object
Definition: StaticMesh.h:30
The ref_ptr class template stores a pointer to a dynamically allocated (AssetEntity|CRefCounted|BaseA...
Definition: PERefPtr.h:13
Definition: effect_file.h:323
the material information for ParaX file
Definition: ParaXMaterial.h:9
it presents a real or virtual file in ParaEngine.
Definition: ParaFile.h:31
Desc: Class for loading and rendering file-based meshes.
Definition: ParaXStaticModel.h:26
virtual int GetAttributeClassID()
attribute class ID should be identical, unless one knows how overriding rules work.
Definition: StaticMesh.h:26
Definition: ParaXStaticBase.h:32
virtual const char * GetAttributeClassName()
a static string, describing the attribute class object&#39;s name
Definition: StaticMesh.h:28
a list of CParameter{name, value} pairs of anything.
Definition: ParameterBlock.h:108
Desc: Class for loading and rendering file-based meshes.
Definition: StaticMesh.h:14