1 | #pragma once
|
---|
2 | #include "./Node.h"
|
---|
3 | #include <string>
|
---|
4 | #include <boost/shared_ptr.hpp>
|
---|
5 | #include <vector>
|
---|
6 | #include "NxCooking.h"
|
---|
7 | #include "Stream.h"
|
---|
8 |
|
---|
9 | using namespace std;
|
---|
10 |
|
---|
11 | #define SPTR boost::shared_ptr
|
---|
12 |
|
---|
13 | class Object3d : public Node {
|
---|
14 | public:
|
---|
15 | Object3d(void);
|
---|
16 | Object3d(std::string file);
|
---|
17 | ~Object3d(void);
|
---|
18 |
|
---|
19 | LPD3DXMESH* getMesh();
|
---|
20 | void setMesh(LPD3DXMESH *mesh);
|
---|
21 | LPD3DXPMESH* getProgressiveMesh();
|
---|
22 | void loadMeshFromFile(std::string filename);
|
---|
23 | void computeNormals();
|
---|
24 |
|
---|
25 | LPD3DXMESH myMesh;
|
---|
26 | LPD3DXPMESH myProgressiveMesh;
|
---|
27 |
|
---|
28 | bool isModelLoaded();
|
---|
29 | void setModelLoaded(bool value);
|
---|
30 | void setXFilename(std::string _xfilename);
|
---|
31 | void generateAndUsePMesh();
|
---|
32 | void generateAndUsePMesh(float *weights);
|
---|
33 | bool isPMesh();
|
---|
34 | void setDetail(Vector ObjectCenter);
|
---|
35 | DWORD *adjacencyInfo;
|
---|
36 |
|
---|
37 | std::vector<D3DMATERIAL9> Materials;
|
---|
38 | std::vector<IDirect3DTexture9*> Textures;
|
---|
39 | DWORD g_dwNumMaterials; // Number of materials
|
---|
40 |
|
---|
41 | bool isManagedByResourceManager;
|
---|
42 |
|
---|
43 |
|
---|
44 | //Physic Stuff
|
---|
45 | static const int COL_MESH = 0;
|
---|
46 | static const int COL_HEIGHTFIELD= 1;
|
---|
47 | static const int COL_CONVEX = 2;
|
---|
48 | static const int COL_PMAP = 3;
|
---|
49 | virtual void generatePhysicMesh(int type=0);
|
---|
50 | NxShapeDesc* getPhysicShape();
|
---|
51 |
|
---|
52 | virtual Node* clone();
|
---|
53 | //public that Terrain can update the patches
|
---|
54 | NxTriangleMeshShapeDesc pMeshShapeDesc;
|
---|
55 |
|
---|
56 | virtual void OnDestroyDevice( void* pUserContext );
|
---|
57 | virtual HRESULT OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
|
---|
58 | protected:
|
---|
59 | Object3d* cloneObject3d(Object3d* obj);
|
---|
60 | std::string xfilename;
|
---|
61 |
|
---|
62 | void computeAdjacency();
|
---|
63 |
|
---|
64 | bool isAPMesh;
|
---|
65 | bool modelLoaded;
|
---|
66 | bool deleteMesh;
|
---|
67 |
|
---|
68 | int maxFaces;
|
---|
69 | int minFaces;
|
---|
70 | int numFacesPerStage[10];
|
---|
71 | int currentFaces;
|
---|
72 |
|
---|
73 | //PhysicStuff
|
---|
74 | DWORD* pIndices;
|
---|
75 | NxVec3* pVertices;
|
---|
76 | NxTriangleMesh* pTriangleMesh;
|
---|
77 | NxTriangleMeshDesc pTriangleMeshDesc;
|
---|
78 |
|
---|
79 | NxConvexMeshDesc pConvexDesc;
|
---|
80 | NxConvexShapeDesc pConvexShapeDesc;
|
---|
81 | MemoryWriteBuffer* writeBuffer;
|
---|
82 | int shapeType;
|
---|
83 | NxU32 getFileSize(const char* name);
|
---|
84 | }; |
---|