| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef RECASTSAMPLETILEMESH_H |
| 20 |
#define RECASTSAMPLETILEMESH_H |
| 21 |
|
| 22 |
#include "Sample.h" |
| 23 |
#include "DetourNavMesh.h" |
| 24 |
#include "Recast.h" |
| 25 |
#include "ChunkyTriMesh.h" |
| 26 |
|
| 27 |
class Sample_TileMesh : public Sample |
| 28 |
{ |
| 29 |
protected: |
| 30 |
bool m_keepInterResults; |
| 31 |
bool m_buildAll; |
| 32 |
float m_totalBuildTimeMs; |
| 33 |
|
| 34 |
unsigned char* m_triareas; |
| 35 |
rcHeightfield* m_solid; |
| 36 |
rcCompactHeightfield* m_chf; |
| 37 |
rcContourSet* m_cset; |
| 38 |
rcPolyMesh* m_pmesh; |
| 39 |
rcPolyMeshDetail* m_dmesh; |
| 40 |
rcConfig m_cfg; |
| 41 |
|
| 42 |
enum DrawMode |
| 43 |
{ |
| 44 |
DRAWMODE_NAVMESH, |
| 45 |
DRAWMODE_NAVMESH_TRANS, |
| 46 |
DRAWMODE_NAVMESH_BVTREE, |
| 47 |
DRAWMODE_NAVMESH_NODES, |
| 48 |
DRAWMODE_NAVMESH_PORTALS, |
| 49 |
DRAWMODE_NAVMESH_INVIS, |
| 50 |
DRAWMODE_MESH, |
| 51 |
DRAWMODE_VOXELS, |
| 52 |
DRAWMODE_VOXELS_WALKABLE, |
| 53 |
DRAWMODE_COMPACT, |
| 54 |
DRAWMODE_COMPACT_DISTANCE, |
| 55 |
DRAWMODE_COMPACT_REGIONS, |
| 56 |
DRAWMODE_REGION_CONNECTIONS, |
| 57 |
DRAWMODE_RAW_CONTOURS, |
| 58 |
DRAWMODE_BOTH_CONTOURS, |
| 59 |
DRAWMODE_CONTOURS, |
| 60 |
DRAWMODE_POLYMESH, |
| 61 |
DRAWMODE_POLYMESH_DETAIL, |
| 62 |
MAX_DRAWMODE |
| 63 |
}; |
| 64 |
|
| 65 |
DrawMode m_drawMode; |
| 66 |
|
| 67 |
int m_maxTiles; |
| 68 |
int m_maxPolysPerTile; |
| 69 |
float m_tileSize; |
| 70 |
|
| 71 |
unsigned int m_tileCol; |
| 72 |
float m_lastBuiltTileBmin[3]; |
| 73 |
float m_lastBuiltTileBmax[3]; |
| 74 |
float m_tileBuildTime; |
| 75 |
float m_tileMemUsage; |
| 76 |
int m_tileTriCount; |
| 77 |
|
| 78 |
unsigned char* buildTileMesh(const int tx, const int ty, const float* bmin, const float* bmax, int& dataSize); |
| 79 |
|
| 80 |
void cleanup(); |
| 81 |
|
| 82 |
void saveAll(const char* path, const dtNavMesh* mesh); |
| 83 |
dtNavMesh* loadAll(const char* path); |
| 84 |
|
| 85 |
public: |
| 86 |
Sample_TileMesh(); |
| 87 |
virtual ~Sample_TileMesh(); |
| 88 |
|
| 89 |
virtual void handleSettings(); |
| 90 |
virtual void handleTools(); |
| 91 |
virtual void handleDebugMode(); |
| 92 |
virtual void handleRender(); |
| 93 |
virtual void handleRenderOverlay(double* proj, double* model, int* view); |
| 94 |
virtual void handleMeshChanged(class InputGeom* geom); |
| 95 |
virtual bool handleBuild(); |
| 96 |
virtual void collectSettings(struct BuildSettings& settings); |
| 97 |
|
| 98 |
void getTilePos(const float* pos, int& tx, int& ty); |
| 99 |
|
| 100 |
void buildTile(const float* pos); |
| 101 |
void removeTile(const float* pos); |
| 102 |
void buildAllTiles(); |
| 103 |
void removeAllTiles(); |
| 104 |
|
| 105 |
private: |
| 106 |
|
| 107 |
Sample_TileMesh(const Sample_TileMesh&); |
| 108 |
Sample_TileMesh& operator=(const Sample_TileMesh&); |
| 109 |
}; |
| 110 |
|
| 111 |
|
| 112 |
#endif |