NavigationMesh.pkg 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. $#include "Navigation/NavigationMesh.h"
  2. $#include "IO/VectorBuffer.h"
  3. enum NavmeshPartitionType
  4. {
  5. NAVMESH_PARTITION_WATERSHED = 0,
  6. NAVMESH_PARTITION_MONOTONE
  7. };
  8. struct NavigationGeometryInfo
  9. {
  10. Component* component_ @ component;
  11. unsigned lodLevel_ @ lodLevel;
  12. Matrix3x4 transform_ @ transform;
  13. BoundingBox boundingBox_ @ boundingBox;
  14. };
  15. class NavigationMesh : public Component
  16. {
  17. void SetTileSize(int size);
  18. void SetCellSize(float size);
  19. void SetCellHeight(float height);
  20. void SetAgentHeight(float height);
  21. void SetAgentRadius(float radius);
  22. void SetAgentMaxClimb(float maxClimb);
  23. void SetAgentMaxSlope(float maxSlope);
  24. void SetRegionMinSize(float size);
  25. void SetRegionMergeSize(float size);
  26. void SetEdgeMaxLength(float length);
  27. void SetEdgeMaxError(float error);
  28. void SetDetailSampleDistance(float distance);
  29. void SetDetailSampleMaxError(float error);
  30. void SetPadding(const Vector3& padding);
  31. void SetAreaCost(unsigned areaID, float cost);
  32. bool Allocate(const BoundingBox& boundingBox, unsigned maxTiles);
  33. bool Build();
  34. bool Build(const BoundingBox& boundingBox);
  35. bool Build(const IntVector2& from, const IntVector2& to);
  36. tolua_outside VectorBuffer NavigationMeshGetTileData @ GetTileData(const IntVector2& tile) const;
  37. tolua_outside bool NavigationMeshAddTile @ AddTile(const VectorBuffer& tileData);
  38. void RemoveTile(const IntVector2& tile);
  39. void RemoveAllTiles();
  40. bool HasTile(const IntVector2& tile) const;
  41. BoundingBox GetTileBoundingBox(const IntVector2& tile) const;
  42. IntVector2 GetTileIndex(const Vector3& position) const;
  43. void SetPartitionType(NavmeshPartitionType aType);
  44. void SetDrawOffMeshConnections(bool enable);
  45. void SetDrawNavAreas(bool enable);
  46. Vector3 FindNearestPoint(const Vector3& point, const Vector3& extents = Vector3::ONE);
  47. Vector3 MoveAlongSurface(const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE, int maxVisited = 3);
  48. tolua_outside const PODVector<Vector3>& NavigationMeshFindPath @ FindPath(const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE);
  49. Vector3 GetRandomPoint();
  50. Vector3 GetRandomPointInCircle(const Vector3& center, float radius, const Vector3& extents = Vector3::ONE);
  51. float GetDistanceToWall(const Vector3& point, float radius, const Vector3& extents = Vector3::ONE);
  52. Vector3 Raycast(const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE);
  53. void DrawDebugGeometry(bool depthTest);
  54. int GetTileSize() const;
  55. float GetCellSize() const;
  56. float GetCellHeight() const;
  57. float GetAgentHeight() const;
  58. float GetAgentRadius() const;
  59. float GetAgentMaxClimb() const;
  60. float GetAgentMaxSlope() const;
  61. float GetRegionMinSize() const;
  62. float GetRegionMergeSize() const;
  63. float GetEdgeMaxLength() const;
  64. float GetEdgeMaxError() const;
  65. float GetDetailSampleDistance() const;
  66. float GetDetailSampleMaxError() const;
  67. const Vector3& GetPadding() const;
  68. float GetAreaCost(unsigned areaID) const;
  69. bool IsInitialized() const;
  70. const BoundingBox& GetBoundingBox() const;
  71. BoundingBox GetWorldBoundingBox() const;
  72. IntVector2 GetNumTiles() const;
  73. NavmeshPartitionType GetPartitionType();
  74. bool GetDrawOffMeshConnections() const;
  75. bool GetDrawNavAreas() const;
  76. tolua_property__get_set int tileSize;
  77. tolua_property__get_set float cellSize;
  78. tolua_property__get_set float cellHeight;
  79. tolua_property__get_set float agentHeight;
  80. tolua_property__get_set float agentRadius;
  81. tolua_property__get_set float agentMaxClimb;
  82. tolua_property__get_set float agentMaxSlope;
  83. tolua_property__get_set float regionMinSize;
  84. tolua_property__get_set float regionMergeSize;
  85. tolua_property__get_set float edgeMaxLength;
  86. tolua_property__get_set float edgeMaxError;
  87. tolua_property__get_set float detailSampleDistance;
  88. tolua_property__get_set float detailSampleMaxError;
  89. tolua_property__get_set Vector3& padding;
  90. tolua_property__get_set NavmeshPartitionType partitionType;
  91. tolua_property__get_set bool drawOffMeshConnections;
  92. tolua_property__get_set bool drawNavAreas;
  93. tolua_readonly tolua_property__is_set bool initialized;
  94. tolua_readonly tolua_property__get_set BoundingBox& boundingBox;
  95. tolua_readonly tolua_property__get_set BoundingBox worldBoundingBox;
  96. tolua_readonly tolua_property__get_set IntVector2 numTiles;
  97. };
  98. ${
  99. VectorBuffer NavigationMeshGetTileData(const NavigationMesh* navMesh, const IntVector2& tile)
  100. {
  101. VectorBuffer buffer;
  102. buffer.SetData(navMesh->GetTileData(tile));
  103. return buffer;
  104. }
  105. bool NavigationMeshAddTile(NavigationMesh* navMesh, const VectorBuffer& tileData)
  106. {
  107. return navMesh->AddTile(tileData.GetBuffer());
  108. }
  109. const PODVector<Vector3>& NavigationMeshFindPath(NavigationMesh* navMesh, const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE)
  110. {
  111. static PODVector<Vector3> dest;
  112. dest.Clear();
  113. navMesh->FindPath(dest, start, end, extents);
  114. return dest;
  115. }
  116. $}