Sample_TempObstacles.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #ifndef RECASTSAMPLETEMPOBSTACLE_H
  19. #define RECASTSAMPLETEMPOBSTACLE_H
  20. #include "Sample.h"
  21. #include "DetourNavMesh.h"
  22. #include "Recast.h"
  23. #include "ChunkyTriMesh.h"
  24. class Sample_TempObstacles : public Sample
  25. {
  26. protected:
  27. bool m_keepInterResults;
  28. struct LinearAllocator* m_talloc;
  29. struct FastLZCompressor* m_tcomp;
  30. struct MeshProcess* m_tmproc;
  31. class dtTileCache* m_tileCache;
  32. float m_cacheBuildTimeMs;
  33. int m_cacheCompressedSize;
  34. int m_cacheRawSize;
  35. int m_cacheLayerCount;
  36. unsigned int m_cacheBuildMemUsage;
  37. enum DrawMode
  38. {
  39. DRAWMODE_NAVMESH,
  40. DRAWMODE_NAVMESH_TRANS,
  41. DRAWMODE_NAVMESH_BVTREE,
  42. DRAWMODE_NAVMESH_NODES,
  43. DRAWMODE_NAVMESH_PORTALS,
  44. DRAWMODE_NAVMESH_INVIS,
  45. DRAWMODE_MESH,
  46. DRAWMODE_CACHE_BOUNDS,
  47. MAX_DRAWMODE
  48. };
  49. DrawMode m_drawMode;
  50. int m_maxTiles;
  51. int m_maxPolysPerTile;
  52. float m_tileSize;
  53. public:
  54. Sample_TempObstacles();
  55. virtual ~Sample_TempObstacles();
  56. virtual void handleSettings();
  57. virtual void handleTools();
  58. virtual void handleDebugMode();
  59. virtual void handleRender();
  60. virtual void handleRenderOverlay(double* proj, double* model, int* view);
  61. virtual void handleMeshChanged(class InputGeom* geom);
  62. virtual bool handleBuild();
  63. virtual void handleUpdate(const float dt);
  64. void getTilePos(const float* pos, int& tx, int& ty);
  65. void renderCachedTile(const int tx, const int ty, const int type);
  66. void renderCachedTileOverlay(const int tx, const int ty, double* proj, double* model, int* view);
  67. void addTempObstacle(const float* pos);
  68. void removeTempObstacle(const float* sp, const float* sq);
  69. void clearAllTempObstacles();
  70. void saveAll(const char* path);
  71. void loadAll(const char* path);
  72. private:
  73. // Explicitly disabled copy constructor and copy assignment operator.
  74. Sample_TempObstacles(const Sample_TempObstacles&);
  75. Sample_TempObstacles& operator=(const Sample_TempObstacles&);
  76. int rasterizeTileLayers(const int tx, const int ty, const rcConfig& cfg, struct TileCacheData* tiles, const int maxTiles);
  77. };
  78. #endif // RECASTSAMPLETEMPOBSTACLE_H