#pragma once #include "./Node.h" #include #include #include #include "NxCooking.h" #include "Stream.h" using namespace std; #define SPTR boost::shared_ptr class Object3d : public Node { public: Object3d(void); Object3d(std::string file); ~Object3d(void); LPD3DXMESH* getMesh(); void setMesh(LPD3DXMESH *mesh); LPD3DXPMESH* getProgressiveMesh(); void loadMeshFromFile(std::string filename); void computeNormals(); LPD3DXMESH myMesh; LPD3DXPMESH myProgressiveMesh; bool isModelLoaded(); void setModelLoaded(bool value); void setXFilename(std::string _xfilename); void generateAndUsePMesh(); void generateAndUsePMesh(float *weights); bool isPMesh(); void setDetail(Vector ObjectCenter); DWORD *adjacencyInfo; std::vector Materials; std::vector Textures; DWORD g_dwNumMaterials; // Number of materials bool isManagedByResourceManager; //Physic Stuff static const int COL_MESH = 0; static const int COL_HEIGHTFIELD= 1; static const int COL_CONVEX = 2; static const int COL_PMAP = 3; virtual void generatePhysicMesh(int type=0); NxShapeDesc* getPhysicShape(); virtual Node* clone(); //public that Terrain can update the patches NxTriangleMeshShapeDesc pMeshShapeDesc; virtual void OnDestroyDevice( void* pUserContext ); virtual HRESULT OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ); protected: Object3d* cloneObject3d(Object3d* obj); std::string xfilename; void computeAdjacency(); bool isAPMesh; bool modelLoaded; bool deleteMesh; int maxFaces; int minFaces; int numFacesPerStage[10]; int currentFaces; //PhysicStuff DWORD* pIndices; NxVec3* pVertices; NxTriangleMesh* pTriangleMesh; NxTriangleMeshDesc pTriangleMeshDesc; NxConvexMeshDesc pConvexDesc; NxConvexShapeDesc pConvexShapeDesc; MemoryWriteBuffer* writeBuffer; int shapeType; NxU32 getFileSize(const char* name); };