// Copyright (c) 2014 Robert Rouhani and other contributors (see CONTRIBUTORS file). // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE using System.Collections.Generic; using SharpNav.Geometry; namespace SharpNav { //TODO right now this is basically an alias for TiledNavMesh. Fix this in the future. /// /// A TiledNavMesh generated from a collection of triangles and some settings /// public class NavMesh : TiledNavMesh { /// /// Initializes a new instance of the class. /// /// The NavMeshBuilder data public NavMesh(NavMeshBuilder builder) : base(builder) { } /// /// Generates a given a collection of triangles and some settings. /// /// The triangles that form the level. /// The settings to generate with. /// A . public static NavMesh Generate(IEnumerable triangles, NavMeshGenerationSettings settings, out PolyMesh polyMesh, out PolyMeshDetail polyMeshDetail) { BBox3 bounds = triangles.GetBoundingBox(settings.CellSize); var hf = new Heightfield(bounds, settings); hf.RasterizeTriangles(triangles); hf.FilterLedgeSpans(settings.VoxelAgentHeight, settings.VoxelMaxClimb); hf.FilterLowHangingWalkableObstacles(settings.VoxelMaxClimb); hf.FilterWalkableLowHeightSpans(settings.VoxelAgentHeight); var chf = new CompactHeightfield(hf, settings); chf.Erode(settings.VoxelAgentRadius); chf.BuildDistanceField(); chf.BuildRegions(2, settings.MinRegionSize, settings.MergedRegionSize); var cont = chf.BuildContourSet(settings); polyMesh = new PolyMesh(cont, settings); polyMeshDetail = new PolyMeshDetail(polyMesh, chf, settings); var buildData = new NavMeshBuilder(polyMesh, polyMeshDetail, new Pathfinding.OffMeshConnection[0], settings); var navMesh = new NavMesh(buildData); return navMesh; } } }