Recast Navigation
Navigation-mesh Toolset for Games
Sample_TileMesh.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 // Permission is granted to anyone to use this software for any purpose,
8 // including commercial applications, and to alter it and redistribute it
9 // freely, subject to the following restrictions:
10 // 1. The origin of this software must not be misrepresented; you must not
11 // claim that you wrote the original software. If you use this software
12 // in a product, an acknowledgment in the product documentation would be
13 // appreciated but is not required.
14 // 2. Altered source versions must be plainly marked as such, and must not be
15 // misrepresented as being the original software.
16 // 3. This notice may not be removed or altered from any source distribution.
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:
31  bool m_buildAll;
33 
34  unsigned char* m_triareas;
41 
42  enum DrawMode
43  {
63  };
64 
66 
69  float m_tileSize;
70 
71  unsigned int m_tileCol;
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:
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  // Explicitly disabled copy constructor and copy assignment operator.
108  Sample_TileMesh& operator=(const Sample_TileMesh&);
109 };
110 
111 
112 #endif // RECASTSAMPLETILEMESH_H
Definition: InputGeom.h:73
Definition: Sample_TileMesh.h:28
float m_lastBuiltTileBmin[3]
Definition: Sample_TileMesh.h:72
float m_totalBuildTimeMs
Definition: Sample_TileMesh.h:32
float m_tileMemUsage
Definition: Sample_TileMesh.h:75
virtual void handleRenderOverlay(double *proj, double *model, int *view)
Definition: Sample_TileMesh.cpp:549
rcHeightfield * m_solid
Definition: Sample_TileMesh.h:35
virtual bool handleBuild()
Definition: Sample_TileMesh.cpp:589
DrawMode
Definition: Sample_TileMesh.h:43
@ DRAWMODE_REGION_CONNECTIONS
Definition: Sample_TileMesh.h:56
@ DRAWMODE_NAVMESH_PORTALS
Definition: Sample_TileMesh.h:48
@ DRAWMODE_NAVMESH_BVTREE
Definition: Sample_TileMesh.h:46
@ DRAWMODE_NAVMESH_TRANS
Definition: Sample_TileMesh.h:45
@ DRAWMODE_CONTOURS
Definition: Sample_TileMesh.h:59
@ DRAWMODE_MESH
Definition: Sample_TileMesh.h:50
@ DRAWMODE_NAVMESH_NODES
Definition: Sample_TileMesh.h:47
@ DRAWMODE_COMPACT_DISTANCE
Definition: Sample_TileMesh.h:54
@ DRAWMODE_RAW_CONTOURS
Definition: Sample_TileMesh.h:57
@ DRAWMODE_VOXELS
Definition: Sample_TileMesh.h:51
@ DRAWMODE_NAVMESH
Definition: Sample_TileMesh.h:44
@ DRAWMODE_NAVMESH_INVIS
Definition: Sample_TileMesh.h:49
@ MAX_DRAWMODE
Definition: Sample_TileMesh.h:62
@ DRAWMODE_BOTH_CONTOURS
Definition: Sample_TileMesh.h:58
@ DRAWMODE_POLYMESH
Definition: Sample_TileMesh.h:60
@ DRAWMODE_COMPACT
Definition: Sample_TileMesh.h:53
@ DRAWMODE_POLYMESH_DETAIL
Definition: Sample_TileMesh.h:61
@ DRAWMODE_COMPACT_REGIONS
Definition: Sample_TileMesh.h:55
@ DRAWMODE_VOXELS_WALKABLE
Definition: Sample_TileMesh.h:52
virtual void handleTools()
Definition: Sample_TileMesh.cpp:300
void getTilePos(const float *pos, int &tx, int &ty)
Definition: Sample_TileMesh.cpp:688
Sample_TileMesh()
Definition: Sample_TileMesh.cpp:177
unsigned char * m_triareas
Definition: Sample_TileMesh.h:34
rcPolyMesh * m_pmesh
Definition: Sample_TileMesh.h:38
int m_maxPolysPerTile
Definition: Sample_TileMesh.h:68
virtual void handleSettings()
Definition: Sample_TileMesh.cpp:226
rcPolyMeshDetail * m_dmesh
Definition: Sample_TileMesh.h:39
rcCompactHeightfield * m_chf
Definition: Sample_TileMesh.h:36
virtual void handleRender()
Definition: Sample_TileMesh.cpp:421
void removeAllTiles()
Definition: Sample_TileMesh.cpp:775
void saveAll(const char *path, const dtNavMesh *mesh)
bool m_keepInterResults
Definition: Sample_TileMesh.h:30
virtual void handleMeshChanged(class InputGeom *geom)
Definition: Sample_TileMesh.cpp:567
virtual void collectSettings(struct BuildSettings &settings)
Definition: Sample_TileMesh.cpp:639
virtual ~Sample_TileMesh()
Definition: Sample_TileMesh.cpp:203
rcContourSet * m_cset
Definition: Sample_TileMesh.h:37
rcConfig m_cfg
Definition: Sample_TileMesh.h:40
void buildTile(const float *pos)
Definition: Sample_TileMesh.cpp:646
unsigned int m_tileCol
Definition: Sample_TileMesh.h:71
void cleanup()
Definition: Sample_TileMesh.cpp:210
dtNavMesh * loadAll(const char *path)
bool m_buildAll
Definition: Sample_TileMesh.h:31
float m_tileBuildTime
Definition: Sample_TileMesh.h:74
void removeTile(const float *pos)
Definition: Sample_TileMesh.cpp:699
int m_tileTriCount
Definition: Sample_TileMesh.h:76
DrawMode m_drawMode
Definition: Sample_TileMesh.h:65
int m_maxTiles
Definition: Sample_TileMesh.h:67
virtual void handleDebugMode()
Definition: Sample_TileMesh.cpp:339
float m_lastBuiltTileBmax[3]
Definition: Sample_TileMesh.h:73
void buildAllTiles()
Definition: Sample_TileMesh.cpp:724
unsigned char * buildTileMesh(const int tx, const int ty, const float *bmin, const float *bmax, int &dataSize)
Definition: Sample_TileMesh.cpp:794
float m_tileSize
Definition: Sample_TileMesh.h:69
Definition: Sample.h:100
A navigation mesh based on tiles of convex polygons.
Definition: DetourNavMesh.h:339
Definition: InputGeom.h:35
A compact, static heightfield representing unobstructed space.
Definition: Recast.h:354
Specifies a configuration to use when performing Recast builds.
Definition: Recast.h:217
Represents a group of related contours.
Definition: Recast.h:433
A dynamic heightfield representing obstructed space.
Definition: Recast.h:313
Contains triangle meshes that represent detailed height data associated with the polygons in its asso...
Definition: Recast.h:487
Represents a polygon mesh suitable for use in building a navigation mesh.
Definition: Recast.h:457