$#include "NavigationMesh.h" /// Description of a navigation mesh geometry component, with transform and bounds information. struct NavigationGeometryInfo { /// Component. Component* component_; /// Geometry LOD level if applicable. unsigned lodLevel_; /// Transform relative to the navigation mesh root node. Matrix3x4 transform_; /// Bounding box relative to the navigation mesh root node. BoundingBox boundingBox_; }; /// Navigation mesh component. Collects the navigation geometry from child nodes with the Navigable component and responds to path queries. class NavigationMesh : public Component { public: /// Set tile size. void SetTileSize(int size); /// Set cell size. void SetCellSize(float size); /// Set cell height. void SetCellHeight(float height); /// Set navigation agent height. void SetAgentHeight(float height); /// Set navigation agent radius. void SetAgentRadius(float radius); /// Set navigation agent max vertical climb. void SetAgentMaxClimb(float maxClimb); /// Set navigation agent max slope. void SetAgentMaxSlope(float maxSlope); /// Set region minimum size. void SetRegionMinSize(float size); /// Set region merge size. void SetRegionMergeSize(float size); /// Set edge max length. void SetEdgeMaxLength(float length); /// Set edge max error. void SetEdgeMaxError(float error); /// Set detail sampling distance. void SetDetailSampleDistance(float distance); /// Set detail sampling maximum error. void SetDetailSampleMaxError(float error); /// Set padding of the navigation mesh bounding box. Having enough padding allows to add geometry on the extremities of the navigation mesh when doing partial rebuilds. void SetPadding(const Vector3& padding); /// Rebuild the navigation mesh. Return true if successful. bool Build(); /// Rebuild part of the navigation mesh contained by the world-space bounding box. Return true if successful. bool Build(const BoundingBox& boundingBox); /// Find a path between world space points. Return non-empty list of points if successful. Extents specifies how far off the navigation mesh the points can be. // void FindPath(PODVector& dest, const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE); tolua_outside PODVector NavigationMeshFindPath @ FindPath(const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE); /// Return a random point on the navigation mesh. Vector3 GetRandomPoint(); /// Return a random point on the navigation mesh within a circle. The circle radius is only a guideline and in practice the returned point may be further away. Vector3 GetRandomPointInCircle(const Vector3& center, float radius, const Vector3& extents = Vector3::ONE); /// Return distance to wall from a point. Maximum search radius must be specified. float GetDistanceToWall(const Vector3& point, float radius, const Vector3& extents = Vector3::ONE); /// Perform a walkability raycast on the navigation mesh between start and end and return the point where a wall was hit, or the end point if no walls. Vector3 Raycast(const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE); /// Return tile size. int GetTileSize() const { return tileSize_; } /// Return cell size. float GetCellSize() const { return cellSize_; } /// Return cell height. float GetCellHeight() const { return cellHeight_; } /// Return navigation agent height. float GetAgentHeight() const { return agentHeight_; } /// Return navigation agent radius. float GetAgentRadius() const { return agentRadius_; } /// Return navigation agent max vertical climb. float GetAgentMaxClimb() const { return agentMaxClimb_; } /// Return navigation agent max slope. float GetAgentMaxSlope() const { return agentMaxSlope_; } /// Return region minimum size. float GetRegionMinSize() const { return regionMinSize_; } /// Return region merge size. float GetRegionMergeSize() const { return regionMergeSize_; } /// Return edge max length. float GetEdgeMaxLength() const { return edgeMaxLength_; } /// Return edge max error. float GetEdgeMaxError() const { return edgeMaxError_; } /// Return detail sampling distance. float GetDetailSampleDistance() const { return detailSampleDistance_; } /// Return detail sampling maximum error. float GetDetailSampleMaxError() const { return detailSampleMaxError_; } /// Return navigation mesh bounding box padding. const Vector3& GetPadding() const { return padding_; } /// Return whether has been initialized with valid navigation data. bool IsInitialized() const { return navMesh_ != 0; } /// Return local space bounding box of the navigation mesh. const BoundingBox& GetBoundingBox() const { return boundingBox_; } /// Return world space bounding box of the navigation mesh. BoundingBox GetWorldBoundingBox() const; /// Return number of tiles. IntVector2 GetNumTiles() const { return IntVector2(numTilesX_, numTilesZ_); } // Properties: tolua_property__get_set int tileSize; tolua_property__get_set float cellSize; tolua_property__get_set float cellHeight; tolua_property__get_set float agentHeight; tolua_property__get_set float agentRadius; tolua_property__get_set float agentMaxClimb; tolua_property__get_set float agentMaxSlope; tolua_property__get_set float regionMinSize; tolua_property__get_set float regionMergeSize; tolua_property__get_set float edgeMaxLength; tolua_property__get_set float edgeMaxError; tolua_property__get_set float detailSampleDistance; tolua_property__get_set float detailSampleMaxError; tolua_property__get_set const Vector3& padding; tolua_readonly tolua_property__is_set bool initialized; tolua_readonly tolua_property__get_set const BoundingBox& boundingBox; tolua_readonly tolua_property__get_set BoundingBox worldBoundingBox; tolua_readonly tolua_property__get_set IntVector2 numTiles; }; ${ PODVector NavigationMeshFindPath(NavigationMesh* navMesh, const Vector3& start, const Vector3& end, const Vector3& extents = Vector3::ONE) { PODVector dest; navMesh->FindPath(dest, start, end, extents); return dest; } // Patch for NavigationMesh.worldBoundingBox property. #define TOLUA_DISABLE_tolua_get_NavigationMesh_worldBoundingBox #define tolua_get_NavigationMesh_worldBoundingBox tolua_NavigationLuaAPI_NavigationMesh_GetWorldBoundingBox00 // Patch for NavigationMesh.numTiles property. #define TOLUA_DISABLE_tolua_get_NavigationMesh_numTiles #define tolua_get_NavigationMesh_numTiles tolua_NavigationLuaAPI_NavigationMesh_GetNumTiles00 $}