#pragma once #include #include "Vector.hpp" #include "KDTree.hpp" #include "xmlParser.h" class Material; class TriangleMesh; class PathMapEffect; class Mesh { friend class SubMesh; friend class SubEntity; friend class Entity; friend class FinalCompositionRenderStrategy; PathMapEffect* pathMapEffect; char name[256]; wchar_t ogreFileName[256]; int prmAtlasSize; std::vector subMeshes; LPD3DXMESH mesh; //!< D3D mesh LPDIRECT3DVERTEXBUFFER9 edgeVertexBuffer; //!< a set of line primitives for atlas (PRM) rendering int nEdges; //!< number of line primitives in edgeVertexBuffer HRESULT setVertexFormat(DWORD fvf); //!< rebuild D3D to have different vertex format void buildEdgeVertexBuffer(); //!< compute line primitives to edgeVertexBuffer HRESULT partitionMesh(unsigned int nDesiredPartitions, LPD3DXBUFFER& partitioningBuffer, unsigned int& nPartitions); //!< partition mesh HRESULT computeTangentFrame(); unsigned int nSubsets; //!< number of submeshes (with possible different material) static void addShaderString(D3DXEFFECTINSTANCE& e, LPCSTR name, LPCSTR value); public: Mesh( PathMapEffect* pathMapEffect, DWORD fileFormat, LPCWSTR xFileName, LPCWSTR ogreFileName, int prmAtlasSize, const char* name, unsigned int nDesiredPartitions, bool generateUV, bool generateTBN); ~Mesh(void); void saveMesh(); const char* getName(); static HRESULT loadMeshFromOgreXML( LPCWSTR filename, DWORD options, LPDIRECT3DDEVICE9 device, LPD3DXBUFFER *materialBuffer, LPD3DXBUFFER *shaderBuffer, DWORD *nMaterials, XMLNode& xMaterials, wchar_t**& materialNames, LPD3DXMESH *mesh); static const DWORD OgreXMLMesh; static const DWORD DirectXMesh; void saveSceneInfo(std::ofstream& psf); };