├── Source
├── SharpNav.Examples
│ ├── .gitignore
│ ├── GwenSkin.png
│ ├── packages.config
│ ├── App.config
│ ├── example_ply.ply
│ ├── Program.cs
│ ├── OpenTK.dll.config
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── Resources.Designer.cs
│ └── ObjModel.cs
├── SharpNav.Tests
│ ├── .gitignore
│ ├── SharpNav.Tests.snk
│ ├── packages.config
│ ├── JsonTest.cs
│ ├── IO
│ │ └── Json
│ │ │ └── NavMeshJsonSerializerTests.cs
│ ├── Collections
│ │ └── Generic
│ │ │ ├── PriorityQueueTests.cs
│ │ │ ├── BufferedQueueTests.cs
│ │ │ └── BufferedStackTests.cs
│ ├── ContourTests.cs
│ ├── OpenTK.dll.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Geometry
│ │ ├── ContainmentTests.cs
│ │ ├── IntersectionTests.cs
│ │ └── DistanceTests.cs
│ ├── CompactSpanTests.cs
│ ├── RegionTests.cs
│ ├── MathHelperTests.cs
│ ├── HeightfieldTests.cs
│ └── CellTests.cs
├── SharpNav
│ ├── SharpNav.snk
│ ├── SharpNav.OpenTK.snk
│ ├── SharpNav.SharpDX.snk
│ ├── Pathfinding
│ │ ├── FindPathOptions.cs
│ │ ├── RaycastOptions.cs
│ │ ├── RaycastHit.cs
│ │ ├── PathBuildFlags.cs
│ │ ├── NavNode.cs
│ │ ├── NavQueryFilter.cs
│ │ ├── Link.cs
│ │ ├── NavPoint.cs
│ │ ├── NavPoly.cs
│ │ ├── NavPolyId.cs
│ │ ├── OffMeshConnection.cs
│ │ ├── StraightPathFlags.cs
│ │ ├── PathfindingCommon.cs
│ │ ├── Path.cs
│ │ ├── BoundarySide.cs
│ │ └── NavPolyIdManager.cs
│ ├── packages.config
│ ├── Collections
│ │ └── Generic
│ │ │ └── IValueWithCost.cs
│ ├── Crowds
│ │ ├── CrowdAgentState.cs
│ │ ├── UpdateFlags.cs
│ │ ├── TargetState.cs
│ │ └── Status.cs
│ ├── ContourBuildFlags.cs
│ ├── NodeFlags.cs
│ ├── IO
│ │ ├── Json
│ │ │ ├── AreaConverter.cs
│ │ │ ├── PolyIdConverter.cs
│ │ │ └── Vector3Converter.cs
│ │ ├── NavMeshSerializer.cs
│ │ └── NavMeshConfigurationFile.cs
│ ├── CompactCell.cs
│ ├── Geometry
│ │ ├── Containment.cs
│ │ ├── BBox2i.cs
│ │ └── Vector2i.cs
│ ├── Span.cs
│ ├── OpenTK.dll.config
│ ├── SpanReference.cs
│ ├── NavMesh.cs
│ ├── EdgeFlags.cs
│ ├── Direction.cs
│ ├── PolyBounds.cs
│ ├── Settings.StyleCop
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── ContourVertex.cs
│ ├── NodePool.cs
│ ├── CompactSpanReference.cs
│ ├── NavMeshGenerationSettings.cs
│ └── Area.cs
├── SharpNav.CLI
│ ├── SharpNav.CLI.snk
│ ├── packages.config
│ ├── App.config
│ ├── Properties
│ │ └── AssemblyInfo.cs
│ ├── Verbosity.cs
│ └── SharpNav.CLI.csproj
└── SharpNav.GUI
│ ├── SharpNav.GUI.snk
│ ├── App.config
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ ├── SharpNav.GUI.csproj
│ └── ObjModel.cs
├── Dependencies
├── Gwen.dll
└── Gwen.Renderer.OpenTK.dll
├── Graphics
└── Logo
│ ├── Full.png
│ ├── Logo.ico
│ ├── Logo.pdf
│ ├── NuGet.png
│ ├── LogoOnly.png
│ └── FullWhite.png
├── Build
├── NuGet
│ ├── .gitignore
│ ├── clean-nuget.ps1
│ ├── clean-nuget.sh
│ ├── SharpNav.nuspec
│ ├── SharpNav.OpenTK.nuspec
│ ├── SharpNav.SharpDX.nuspec
│ ├── SharpNav.MonoGame.nuspec
│ ├── publish-nuget.ps1
│ └── publish-nuget.sh
├── CI
│ ├── Standalone
│ │ └── packages.config
│ ├── OpenTK
│ │ └── packages.config
│ ├── SharpDX
│ │ └── packages.config
│ └── MonoGame
│ │ └── packages.config
├── CoreOnly.proj
└── build-docs.sh
├── Documentation
├── release-notes.md
├── Styles
│ └── SharpNav
│ │ ├── images
│ │ └── blacktocat.png
│ │ ├── html
│ │ └── PageHeader.cshtml
│ │ └── style.xml
├── overview.md
├── Release Notes
│ ├── v0.9.0.md
│ ├── v1.0.0-alpha.1.md
│ └── v1.0.0-alpha.2.md
├── config.xml
└── README.md
├── appveyor.yml
├── AUTHORS.md
├── .travis.yml
├── LICENSE
├── .gitignore
└── CONTRIBUTING.md
/Source/SharpNav.Examples/.gitignore:
--------------------------------------------------------------------------------
1 | !*.obj
--------------------------------------------------------------------------------
/Source/SharpNav.Tests/.gitignore:
--------------------------------------------------------------------------------
1 | test-results/
--------------------------------------------------------------------------------
/Dependencies/Gwen.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Dependencies/Gwen.dll
--------------------------------------------------------------------------------
/Graphics/Logo/Full.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Graphics/Logo/Full.png
--------------------------------------------------------------------------------
/Graphics/Logo/Logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Graphics/Logo/Logo.ico
--------------------------------------------------------------------------------
/Graphics/Logo/Logo.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Graphics/Logo/Logo.pdf
--------------------------------------------------------------------------------
/Graphics/Logo/NuGet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Graphics/Logo/NuGet.png
--------------------------------------------------------------------------------
/Build/NuGet/.gitignore:
--------------------------------------------------------------------------------
1 | # Don't commit the NuGet files, they are generated by the build script.
2 | *.nupkg
--------------------------------------------------------------------------------
/Graphics/Logo/LogoOnly.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Graphics/Logo/LogoOnly.png
--------------------------------------------------------------------------------
/Graphics/Logo/FullWhite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Graphics/Logo/FullWhite.png
--------------------------------------------------------------------------------
/Source/SharpNav/SharpNav.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Source/SharpNav/SharpNav.snk
--------------------------------------------------------------------------------
/Source/SharpNav.CLI/SharpNav.CLI.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Source/SharpNav.CLI/SharpNav.CLI.snk
--------------------------------------------------------------------------------
/Source/SharpNav.GUI/SharpNav.GUI.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Source/SharpNav.GUI/SharpNav.GUI.snk
--------------------------------------------------------------------------------
/Source/SharpNav/SharpNav.OpenTK.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Source/SharpNav/SharpNav.OpenTK.snk
--------------------------------------------------------------------------------
/Source/SharpNav/SharpNav.SharpDX.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Source/SharpNav/SharpNav.SharpDX.snk
--------------------------------------------------------------------------------
/Dependencies/Gwen.Renderer.OpenTK.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Dependencies/Gwen.Renderer.OpenTK.dll
--------------------------------------------------------------------------------
/Source/SharpNav.Examples/GwenSkin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Source/SharpNav.Examples/GwenSkin.png
--------------------------------------------------------------------------------
/Source/SharpNav.Tests/SharpNav.Tests.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Source/SharpNav.Tests/SharpNav.Tests.snk
--------------------------------------------------------------------------------
/Documentation/release-notes.md:
--------------------------------------------------------------------------------
1 | Every publicly released version of SharpNav includes a changelog and other
2 | miscellaneous information about itself.
3 |
--------------------------------------------------------------------------------
/Documentation/Styles/SharpNav/images/blacktocat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Robmaister/SharpNav/HEAD/Documentation/Styles/SharpNav/images/blacktocat.png
--------------------------------------------------------------------------------
/Source/SharpNav.CLI/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Source/SharpNav.Examples/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/Build/NuGet/clean-nuget.ps1:
--------------------------------------------------------------------------------
1 | ""
2 | " CLEANING "
3 | "========================================="
4 | ""
5 |
6 | Remove-Item *.nupkg
7 |
8 | ""
9 | "Done."
10 | ""
11 |
--------------------------------------------------------------------------------
/Documentation/overview.md:
--------------------------------------------------------------------------------
1 | SharpNav is a navigation mesh generation and pathfinding library. It started
2 | as a port of Mikko Monomen's [Recast Navigation][1] to C#.
3 |
4 | [1]: https://github.com/memononen/recastnavigation
5 |
--------------------------------------------------------------------------------
/Source/SharpNav.CLI/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Source/SharpNav.GUI/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Source/SharpNav.Examples/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Build/NuGet/clean-nuget.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo ""
4 | echo " CLEANING "
5 | echo "========================================="
6 | echo ""
7 |
8 | rm ./*.nupkg
9 |
10 | echo ""
11 | echo "Done."
12 | echo ""
13 |
--------------------------------------------------------------------------------
/Build/CI/Standalone/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Build/CI/OpenTK/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Source/SharpNav/Pathfinding/FindPathOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | namespace SharpNav.Pathfinding
7 | {
8 | [Flags]
9 | public enum FindPathOptions
10 | {
11 | None = 0x00,
12 | AnyAngle = 0x01
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/Build/CI/SharpDX/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Build/CI/MonoGame/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Source/SharpNav/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Documentation/Release Notes/v0.9.0.md:
--------------------------------------------------------------------------------
1 | v0.9.0 was released on October 11, 2014 and is the first publicly released
2 | versions of SharpNav. Due to packaging issues, there are two other versions
3 | available on NuGet - v0.9.1 and v0.9.2.
4 |
5 | v0.9.1 and v0.9.2 only differ from v0.9.0 in packaging on NuGet. The
6 | assemblies are still versioned as v0.9.0, though.
7 |
8 | ## Known Issues
9 |
10 | - Bug(s) that prevent proper triangulation in `PolyMeshDetail`
11 | - Excessive memory usage in rare cases
12 | - Unfinished public APIs, though the `SharpNav` namespace is mostly stable
13 |
--------------------------------------------------------------------------------
/Source/SharpNav.GUI/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 | using System.Windows.Forms;
6 |
7 | namespace SharpNav.GUI
8 | {
9 | class Program
10 | {
11 | [STAThread]
12 | static void Main(string[] args)
13 | {
14 | Application.EnableVisualStyles();
15 | Application.SetCompatibleTextRenderingDefault(false);
16 | Application.Run(new ConfigurationForm());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 1.0.0-alpha.2+appveyor.{build}
2 |
3 | branches:
4 | only:
5 | - master
6 |
7 | configuration:
8 | - Standalone
9 | - OpenTK
10 | - SharpDX
11 | - MonoGame
12 |
13 | before_build:
14 | - nuget restore Build/CI/%CONFIGURATION%/packages.config -SolutionDirectory Source/
15 |
16 | build_script:
17 | - cmd: msbuild "Build/CoreOnly.proj" /t:%CONFIGURATION% /verbosity:normal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
18 |
19 | test:
20 | categories:
21 | except:
22 | - BrokenButUnused
23 |
24 | deploy: off
25 |
--------------------------------------------------------------------------------
/AUTHORS.md:
--------------------------------------------------------------------------------
1 | SharpNav Contributors
2 | =====================
3 |
4 | (Sorted chronologically)
5 |
6 | - **[Robert Rouhani](https://github.com/Robmaister)**
7 | - Original author
8 | - Maintainer
9 |
10 | - **[Samuel Yuan](https://github.com/samuelyuan)**
11 | - Ported majority of Recast to C#
12 |
13 | - **[Renjie Xie](https://github.com/xrj800)**
14 | - Ported parts of Recast to C#
15 | - Added several missing test cases.
16 |
17 | See the [full list of contributors](https://github.com/Robmaister/SharpNav/graphs/contributors)
18 |
--------------------------------------------------------------------------------
/Source/SharpNav/Pathfinding/RaycastOptions.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | namespace SharpNav.Pathfinding
7 | {
8 | ///
9 | /// Options for raycasting.
10 | ///
11 | [Flags]
12 | public enum RaycastOptions
13 | {
14 | None = 0,
15 |
16 | ///
17 | /// Calculate and use movement costs across the ray.
18 | ///
19 | UseCosts = 0x01,
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Source/SharpNav.Examples/example_ply.ply:
--------------------------------------------------------------------------------
1 | ply
2 | format ascii 1.0
3 | comment cube.obj created by IVREAD.
4 | comment Original data in cube.iv
5 | comment converted from OBJ by obj2ply
6 | element vertex 8
7 | property float32 x
8 | property float32 y
9 | property float32 z
10 | element face 12
11 | property list uint8 int32 vertex_indices
12 | end_header
13 | -0.5 -0.5 1
14 | 0.5 -0.5 1
15 | 0.5 0.5 1
16 | -0.5 0.5 1
17 | 0.5 -0.5 0
18 | -0.5 -0.5 0
19 | -0.5 0.5 0
20 | 0.5 0.5 0
21 | 3 2 1 0
22 | 3 3 2 0
23 | 3 6 5 4
24 | 3 7 6 4
25 | 3 3 0 5
26 | 3 6 3 5
27 | 3 7 4 1
28 | 3 2 7 1
29 | 3 1 4 5
30 | 3 0 1 5
31 | 3 7 2 3
32 | 3 6 7 3
--------------------------------------------------------------------------------
/Source/SharpNav/Collections/Generic/IValueWithCost.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013-2014 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | namespace SharpNav.Collections.Generic
5 | {
6 | ///
7 | /// An interface that defines a class containing a cost associated with the instance.
8 | /// Used in
9 | ///
10 | public interface IValueWithCost
11 | {
12 | ///
13 | /// Gets the cost of this instance.
14 | ///
15 | float Cost { get; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Source/SharpNav.Tests/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Source/SharpNav.Examples/Program.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013, 2015 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | namespace SharpNav.Examples
7 | {
8 | class Program
9 | {
10 | [STAThread]
11 | static void Main(string[] args)
12 | {
13 | #if OPENTK || STANDALONE
14 | using (ExampleWindow ex = new ExampleWindow())
15 | {
16 | ex.Run();
17 | }
18 | #else
19 | Console.WriteLine("SharpNav.Examples does not support this configuration of SharpNav.");
20 | #endif
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/SharpNav/Crowds/CrowdAgentState.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | namespace SharpNav.Crowds
7 | {
8 | ///
9 | /// Describes the current state of a crowd agent
10 | ///
11 | [Flags]
12 | public enum AgentState
13 | {
14 | ///
15 | /// Not in any state
16 | ///
17 | Invalid,
18 |
19 | ///
20 | /// Walking on the navigation mesh
21 | ///
22 | Walking,
23 |
24 | ///
25 | /// Handling an offmesh connection
26 | ///
27 | Offmesh
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Source/SharpNav/ContourBuildFlags.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013, 2015 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | namespace SharpNav
7 | {
8 | ///
9 | /// A set of flags that control the way contours are built.
10 | ///
11 | [Flags]
12 | public enum ContourBuildFlags
13 | {
14 | /// Build normally.
15 | None = 0,
16 |
17 | /// Tessellate solid edges during contour simplification.
18 | TessellateWallEdges = 0x01,
19 |
20 | /// Tessellate edges between areas during contour simplification.
21 | TessellateAreaEdges = 0x02
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Source/SharpNav/NodeFlags.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | namespace SharpNav
8 | {
9 | ///
10 | /// Determine which list the node is in.
11 | ///
12 | [Flags]
13 | public enum NodeFlags
14 | {
15 | ///
16 | /// Open list contains nodes to examine.
17 | ///
18 | Open = 0x01,
19 |
20 | ///
21 | /// Closed list stores path.
22 | ///
23 | Closed = 0x02,
24 |
25 | ///
26 | /// Parent of the node is not adjacent. Found using raycast.
27 | ///
28 | ParentDetached = 0x04
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/SharpNav/Pathfinding/RaycastHit.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 | using System.Runtime.InteropServices;
6 |
7 | using SharpNav.Geometry;
8 |
9 | #if MONOGAME
10 | using Vector3 = Microsoft.Xna.Framework.Vector3;
11 | #elif OPENTK
12 | using Vector3 = OpenTK.Vector3;
13 | #elif SHARPDX
14 | using Vector3 = SharpDX.Vector3;
15 | #endif
16 |
17 | namespace SharpNav.Pathfinding
18 | {
19 | [Serializable]
20 | [StructLayout(LayoutKind.Sequential)]
21 | public struct RaycastHit
22 | {
23 | public float T;
24 | public Vector3 Normal;
25 | public int EdgeIndex;
26 |
27 | public bool IsHit { get { return T != float.MaxValue; } }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Source/SharpNav.Tests/JsonTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using Newtonsoft.Json;
7 |
8 | using NUnit.Framework;
9 |
10 | using SharpNav;
11 | using SharpNavTests;
12 | using SharpNav.Geometry;
13 |
14 | #if MONOGAME || XNA
15 | using Microsoft.Xna.Framework;
16 | #elif OPENTK
17 | using OpenTK;
18 | #elif SHARPDX
19 | using SharpDX;
20 | #elif UNITY3D
21 | using UnityEngine;
22 | #endif
23 |
24 | namespace SharpNavTests.Libraries
25 | {
26 | [TestFixture]
27 | class JsonTest
28 | {
29 | [Test]
30 | public void JsonNet_Test()
31 | {
32 | // Simple test to make sure that the JSON.Net library is working
33 | Triangle3 triangle = new Triangle3(new Vector3(3), new Vector3(4), new Vector3(5));
34 | string output = JsonConvert.SerializeObject(triangle);
35 |
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: csharp
2 | solution: Source/SharpNav.sln
3 | sudo: false # Use container-based infrastructure
4 |
5 | notifications:
6 | slack:
7 | secure: Evj0iL40Tipu47BZfCdbkZbW/8Y7NLRZRSjvLXhKH7Yc6DfYLWeF7+Y2h8E8Zdd2/bdP+LxlHTbqjam5IBONAAIwpN4TAXNqMmalXtXDfs3/Cu+pMKSN+ECymcX3bUa/cZyvjm8P4FfUWLDHKuk+I3C41DfXzTPRBg4z+qSg4kI=
8 |
9 | env:
10 | matrix:
11 | - XBUILD_TARGET=Standalone
12 | - XBUILD_TARGET=OpenTK
13 | - XBUILD_TARGET=SharpDX
14 | - XBUILD_TARGET=MonoGame
15 |
16 | install:
17 | - travis_retry nuget restore Build/CI/$XBUILD_TARGET/packages.config -SolutionDirectory Source/
18 | - travis_retry nuget install NUnit.Console -OutputDirectory test -ExcludeVersion
19 | script:
20 | - xbuild /t:$XBUILD_TARGET /verbosity:minimal ./Build/CoreOnly.proj
21 | - mono ./test/NUnit.ConsoleRunner/tools/nunit3-console.exe ./Binaries/Tests/$XBUILD_TARGET/SharpNav.Tests.dll --where "cat!=BrokenButUnused"
22 |
--------------------------------------------------------------------------------
/Build/CoreOnly.proj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Source/SharpNav/Pathfinding/PathBuildFlags.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015-2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | namespace SharpNav.Pathfinding
7 | {
8 | ///
9 | /// Flags for choosing how the path is built.
10 | ///
11 | [Flags]
12 | public enum PathBuildFlags
13 | {
14 | ///
15 | /// Build normally.
16 | ///
17 | None = 0x00,
18 |
19 | ///
20 | /// Adds a vertex to the path at each polygon edge crossing, but only when the areas of the two polygons are
21 | /// different.
22 | ///
23 | AreaCrossingVertices = 0x01,
24 |
25 | ///
26 | /// Adds a vertex to the path at each polygon edge crossing.
27 | ///
28 | AllCrossingVertices = 0x02
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Source/SharpNav.Tests/IO/Json/NavMeshJsonSerializerTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015-2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System.IO;
5 |
6 | using NUnit.Framework;
7 |
8 | using SharpNav.IO.Json;
9 |
10 | namespace SharpNav.Tests
11 | {
12 | [TestFixture]
13 | class NavMeshSerializationTests
14 | {
15 | [Test]
16 | public void JsonSerializationTest()
17 | {
18 | string objPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "nav_test.obj");
19 | string snjPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "mesh.snj");
20 |
21 | var objModel = new ObjModel(objPath);
22 | TiledNavMesh mesh = NavMesh.Generate(objModel.GetTriangles(), NavMeshGenerationSettings.Default);
23 | new NavMeshJsonSerializer().Serialize(snjPath, mesh);
24 |
25 | TiledNavMesh deserializedMesh = new NavMeshJsonSerializer().Deserialize(snjPath);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Source/SharpNav/IO/Json/AreaConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | using SharpNav;
7 |
8 | using Newtonsoft.Json;
9 | using Newtonsoft.Json.Linq;
10 |
11 | namespace SharpNav.IO.Json
12 | {
13 | public class AreaConverter : JsonConverter
14 | {
15 | public override bool CanConvert(Type objectType)
16 | {
17 | return objectType == typeof(Area);
18 | }
19 |
20 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
21 | {
22 | if (reader.TokenType == JsonToken.Null)
23 | return null;
24 |
25 | return new Area(serializer.Deserialize(reader));
26 | }
27 |
28 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
29 | {
30 | var area = (value as Area?).Value;
31 | serializer.Serialize(writer, (int)area.Id);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Source/SharpNav/Crowds/UpdateFlags.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | namespace SharpNav.Crowds
7 | {
8 | ///
9 | /// The UpdateFlag affects the way the agent moves acorss its path.
10 | ///
11 | [Flags]
12 | public enum UpdateFlags
13 | {
14 | ///
15 | /// The agent will be making turns in its path
16 | ///
17 | AnticipateTurns = 1,
18 |
19 | ///
20 | /// Avoid obstacles on the path
21 | ///
22 | ObstacleAvoidance = 2,
23 |
24 | ///
25 | /// Separate this agent from other agents
26 | ///
27 | Separation = 4,
28 |
29 | ///
30 | /// Optimize if the agent can see the next corner
31 | ///
32 | OptimizeVis = 8,
33 |
34 | ///
35 | /// Optimize the agent's path corridor
36 | ///
37 | OptimizeTopo = 16
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Source/SharpNav/IO/Json/PolyIdConverter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | using SharpNav.Pathfinding;
7 |
8 | using Newtonsoft.Json;
9 | using Newtonsoft.Json.Linq;
10 |
11 | namespace SharpNav.IO.Json
12 | {
13 | class PolyIdConverter : JsonConverter
14 | {
15 | public override bool CanConvert(Type objectType)
16 | {
17 | return objectType == typeof(NavPolyId);
18 | }
19 |
20 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
21 | {
22 | if (reader.TokenType == JsonToken.Null)
23 | return null;
24 |
25 | return new NavPolyId(serializer.Deserialize(reader));
26 | }
27 |
28 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
29 | {
30 | var polyId = (value as NavPolyId?).Value;
31 | serializer.Serialize(writer, (int)polyId.Id);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Source/SharpNav/IO/NavMeshSerializer.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 | using System.Reflection;
6 | using SharpNav;
7 |
8 | namespace SharpNav.IO
9 | {
10 | //TODO make an interface if it doesn't need to be extended
11 |
12 | ///
13 | /// Abstract class for nav mesh serializers
14 | ///
15 | public abstract class NavMeshSerializer
16 | {
17 | ///
18 | /// Serialize navigation mesh into external file
19 | ///
20 | /// path of file to serialize into
21 | /// mesh to serialize
22 | public abstract void Serialize(string path, TiledNavMesh mesh);
23 |
24 | ///
25 | /// Deserialize navigation mesh from external file
26 | ///
27 | /// file to deserialize from
28 | /// deserialized mesh
29 | public abstract TiledNavMesh Deserialize(string path);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/SharpNav.Tests/Collections/Generic/PriorityQueueTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 | using System.Collections;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 |
9 | using NUnit.Framework;
10 |
11 | using SharpNav.Collections.Generic;
12 |
13 | namespace SharpNav.Tests.Collections.Generic
14 | {
15 | [TestFixture]
16 | public class PriorityQueueTests
17 | {
18 | [Test]
19 | public void TopTest()
20 | {
21 | }
22 |
23 | [Test]
24 | public void PopTest()
25 | {
26 | }
27 |
28 | [Test]
29 | public void PushTest()
30 | {
31 | }
32 |
33 | [Test]
34 | public void ContainsTest()
35 | {
36 | }
37 |
38 | [Test]
39 | public void ModifyTest()
40 | {
41 | }
42 |
43 | [Test]
44 | public void ValidHeapTest()
45 | {
46 | }
47 |
48 | [Test]
49 | public void MiscICollectionTests()
50 | {
51 | }
52 |
53 | [Test]
54 | public void StatusAccessorTests()
55 | {
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Source/SharpNav/Crowds/TargetState.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | namespace SharpNav.Crowds
5 | {
6 | ///
7 | /// This state changes depending on what the crowd agent has to do next
8 | ///
9 | public enum TargetState
10 | {
11 | ///
12 | /// Not in any state
13 | ///
14 | None,
15 |
16 | ///
17 | /// Failed to find a new path
18 | ///
19 | Failed,
20 |
21 | ///
22 | /// Target destination reached.
23 | ///
24 | Valid,
25 |
26 | ///
27 | /// Requesting a new path
28 | ///
29 | Requesting,
30 |
31 | ///
32 | /// Add this agent to the crowd manager's path queue
33 | ///
34 | WaitingForQueue,
35 |
36 | ///
37 | /// The agent is in the path queue
38 | ///
39 | WaitingForPath,
40 |
41 | ///
42 | /// Changing its velocity
43 | ///
44 | Velocity
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Source/SharpNav/CompactCell.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System.Runtime.InteropServices;
5 |
6 | namespace SharpNav
7 | {
8 | ///
9 | /// Represents a cell in a .
10 | ///
11 | [StructLayout(LayoutKind.Sequential)]
12 | public struct CompactCell
13 | {
14 | ///
15 | /// The starting index of spans in a for this cell.
16 | ///
17 | public int StartIndex;
18 |
19 | ///
20 | /// The number of spans in a for this cell.
21 | ///
22 | public int Count;
23 |
24 | ///
25 | /// Initializes a new instance of the struct.
26 | ///
27 | /// The start index.
28 | /// The count.
29 | public CompactCell(int start, int count)
30 | {
31 | StartIndex = start;
32 | Count = count;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Build/NuGet/SharpNav.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SharpNav
5 | 1.0.0-alpha2
6 | Robert Rouhani
7 | Robert Rouhani
8 | https://raw.githubusercontent.com/Robmaister/SharpNav/master/Graphics/Logo/NuGet.png
9 | https://github.com/Robmaister/SharpNav/blob/master/LICENSE
10 | https://github.com/Robmaister/SharpNav
11 | false
12 | A fully-managed navigation mesh library.
13 |
14 | - JSON serialization for NavMesh
15 | - Started refactoring and cleaning up pathfinding and crowd APIs
16 | - Fixed a few crowd bugs
17 |
18 | For the full release notes, see http://sharpnav.com/docs/html/index.htm?page=release-notes-v1.0.0-alpha.2
19 |
20 | Copyright (c) 2013-2016 Robert Rouhani <robert.rouhani@gmail.com> and other contributors (see CONTRIBUTORS file).
21 | Navigation Pathfinding NavMesh Nav Mesh Crowd Agent AI Recast
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
4 |
5 | SharpNav contains some altered source code from Recast Navigation, Copyright (c) 2009 Mikko Mononen memon@inside.org
6 |
7 | Permission is hereby granted, free of charge, to any person obtaining a copy of
8 | this software and associated documentation files (the "Software"), to deal in
9 | the Software without restriction, including without limitation the rights to
10 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 | the Software, and to permit persons to whom the Software is furnished to do so,
12 | subject to the following conditions:
13 |
14 | The above copyright notice and this permission notice shall be included in all
15 | copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/Documentation/Release Notes/v1.0.0-alpha.1.md:
--------------------------------------------------------------------------------
1 | v1.0.0-alpha.1 was released on December 31, 2014. It is the second release of
2 | SharpNav and the first pre-release of v1.0.0. It fixes several bugs from
3 | v0.9.0 and makes several changes to the public API.
4 |
5 | ## Major Changes
6 |
7 | - Removed existing but broken XNA and Unity3D builds.
8 | - Raw contour vertices are no longer stored in the `Contour` class.
9 | - SharpNav now relies on NuGet to retrieve packages.
10 |
11 | ## Minor Changes
12 |
13 | - The `RegionId` enum is now the `Region` struct.
14 | - The `AreaId` enum is now the `Area` struct.
15 | - All vector types are now in the `SharpNav.Geometry` namespace in the
16 | Standalone build.
17 | - The `ContourSet` constructor no longer takes a `CompactHeightfield` as a
18 | parameter. It is instead handled in `CompactHeightfield.BuildContourSet`.
19 |
20 | ## Bugfixes
21 |
22 | - Fixed incorrect slope calculation in `AreaIdGenerator`.
23 | - Fixed most bugs preventing proper triangulation in `PolyMeshDetail`.
24 | - Fixed thread safety issue with triangle rasterization in `Heightfield`.
25 |
26 | ## Known Issues
27 |
28 | - With enough detail, `PolyMeshDetail` will still produce incorrectly
29 | triangulated meshes.
30 | - Edge cases consuming a lot of memory likely still exist.
31 | - public APIs are still unfinished.
32 |
--------------------------------------------------------------------------------
/Documentation/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | SharpNav
6 | A Pathfinding and Navigation Mesh Library for C#
7 | Copyright (c) 2013-2015 Robert Rouhani <robert.rouhani@gmail.com> and other contributors
8 |
9 | Styles/
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Build/NuGet/SharpNav.OpenTK.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SharpNav.OpenTK
5 | 1.0.0-alpha2
6 | Robert Rouhani
7 | Robert Rouhani
8 | https://raw.githubusercontent.com/Robmaister/SharpNav/master/Graphics/Logo/NuGet.png
9 | https://github.com/Robmaister/SharpNav/blob/master/LICENSE
10 | https://github.com/Robmaister/SharpNav
11 | false
12 | A fully-managed navigation mesh library.
13 |
14 | - JSON serialization for NavMesh
15 | - Started refactoring and cleaning up pathfinding and crowd APIs
16 | - Fixed a few crowd bugs
17 |
18 | For the full release notes, see http://sharpnav.com/docs/html/index.htm?page=release-notes-v1.0.0-alpha.2
19 |
20 | Copyright (c) 2013-2016 Robert Rouhani <robert.rouhani@gmail.com> and other contributors (see CONTRIBUTORS file).
21 | Navigation Pathfinding NavMesh Nav Mesh Crowd Agent AI Recast
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Source/SharpNav.Tests/ContourTests.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014-2015 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using SharpNav.Geometry;
8 |
9 | using NUnit.Framework;
10 |
11 | #if MONOGAME
12 | using Vector3 = Microsoft.Xna.Framework.Vector3;
13 | #elif OPENTK
14 | using Vector3 = OpenTK.Vector3;
15 | #elif SHARPDX
16 | using Vector3 = SharpDX.Vector3;
17 | #endif
18 |
19 | namespace SharpNav.Tests
20 | {
21 | [TestFixture]
22 | public class ContourTests
23 | {
24 | [Test]
25 | public void ContourConstructor()
26 | {
27 | //TODO directly build contours now that ContourSet allows it.
28 | //Build a 5x5 heightfield
29 | Heightfield hf = new Heightfield(new BBox3(Vector3.Zero, Vector3.One), (float)(1.0f / 5.0f), 0.02f);
30 | for (int i = 0; i < 5 * 5; i++)
31 | {
32 | hf[i].AddSpan(new Span(10, 20, Area.Default));
33 | hf[i].AddSpan(new Span(25, 30, Area.Default));
34 | }
35 | CompactHeightfield chf = new CompactHeightfield(hf, 2, 1);
36 |
37 | chf.BuildDistanceField();
38 | chf.BuildRegions(1, 1, 1);
39 |
40 | ContourSet contourSet = chf.BuildContourSet(1, 5, ContourBuildFlags.None);
41 |
42 | Assert.AreEqual(contourSet.Count, 2);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Build/NuGet/SharpNav.SharpDX.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SharpNav.SharpDX
5 | 1.0.0-alpha2
6 | Robert Rouhani
7 | Robert Rouhani
8 | https://raw.githubusercontent.com/Robmaister/SharpNav/master/Graphics/Logo/NuGet.png
9 | https://github.com/Robmaister/SharpNav/blob/master/LICENSE
10 | https://github.com/Robmaister/SharpNav
11 | false
12 | A fully-managed navigation mesh library.
13 |
14 | - JSON serialization for NavMesh
15 | - Started refactoring and cleaning up pathfinding and crowd APIs
16 | - Fixed a few crowd bugs
17 |
18 | For the full release notes, see http://sharpnav.com/docs/html/index.htm?page=release-notes-v1.0.0-alpha.2
19 |
20 | Copyright (c) 2013-2016 Robert Rouhani <robert.rouhani@gmail.com> and other contributors (see CONTRIBUTORS file).
21 | Navigation Pathfinding NavMesh Nav Mesh Crowd Agent AI Recast
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Build/NuGet/SharpNav.MonoGame.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | SharpNav.MonoGame
5 | 1.0.0-alpha2
6 | Robert Rouhani
7 | Robert Rouhani
8 | https://raw.githubusercontent.com/Robmaister/SharpNav/master/Graphics/Logo/NuGet.png
9 | https://github.com/Robmaister/SharpNav/blob/master/LICENSE
10 | https://github.com/Robmaister/SharpNav
11 | false
12 | A fully-managed navigation mesh library.
13 |
14 | - JSON serialization for NavMesh
15 | - Started refactoring and cleaning up pathfinding and crowd APIs
16 | - Fixed a few crowd bugs
17 |
18 | For the full release notes, see http://sharpnav.com/docs/html/index.htm?page=release-notes-v1.0.0-alpha.2
19 |
20 | Copyright (c) 2013-2016 Robert Rouhani <robert.rouhani@gmail.com> and other contributors (see CONTRIBUTORS file).
21 | Navigation Pathfinding NavMesh Nav Mesh Crowd Agent AI Recast
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/Source/SharpNav/Pathfinding/NavNode.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013-2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 |
6 | using SharpNav.Collections.Generic;
7 | using SharpNav.Geometry;
8 | using SharpNav.Pathfinding;
9 |
10 | #if MONOGAME
11 | using Vector3 = Microsoft.Xna.Framework.Vector3;
12 | #elif OPENTK
13 | using Vector3 = OpenTK.Vector3;
14 | #elif SHARPDX
15 | using Vector3 = SharpDX.Vector3;
16 | #endif
17 |
18 | namespace SharpNav
19 | {
20 | ///
21 | /// Every polygon becomes a Node, which contains a position and cost.
22 | ///
23 | public class NavNode : IValueWithCost
24 | {
25 | public const int NullIndex = ~0;
26 |
27 | public Vector3 Position;
28 |
29 | ///
30 | /// Cost from previous node/poly to current.
31 | ///
32 | public float PolyCost;
33 |
34 | ///
35 | /// Total cost up to this node
36 | ///
37 | public float TotalCost;
38 | public int ParentIndex; //index to parent node
39 | public byte State;
40 | public NodeFlags Flags = 0; //node flags 0/open/closed
41 | public NavPolyId Id; //polygon ref the node corresponds to
42 |
43 | //TODO should make more generic or move to Pathfinding namespace
44 |
45 | public float Cost
46 | {
47 | get
48 | {
49 | return TotalCost;
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Source/SharpNav/Pathfinding/NavQueryFilter.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 | using System.Collections.Generic;
6 |
7 | using SharpNav.Geometry;
8 |
9 | #if MONOGAME
10 | using Vector3 = Microsoft.Xna.Framework.Vector3;
11 | #elif OPENTK
12 | using Vector3 = OpenTK.Vector3;
13 | #elif SHARPDX
14 | using Vector3 = SharpDX.Vector3;
15 | #endif
16 |
17 | namespace SharpNav.Pathfinding
18 | {
19 | public class NavQueryFilter
20 | {
21 | private float[] areaCost;
22 |
23 | public NavQueryFilter()
24 | {
25 | areaCost = new float[Area.MaxValues];
26 | for (int i = 0; i < areaCost.Length; i++)
27 | areaCost[i] = 1;
28 | }
29 |
30 | public virtual bool PassFilter(NavPolyId polyId, NavTile tile, NavPoly poly)
31 | {
32 | return true;
33 | }
34 |
35 | public virtual float GetCost(Vector3 a, Vector3 b,
36 | NavPolyId prevRef, NavTile prevTile, NavPoly prevPoly,
37 | NavPolyId curRef, NavTile curTile, NavPoly curPoly,
38 | NavPolyId nextRef, NavTile nextTile, NavPoly nextPoly)
39 | {
40 | return (a - b).Length() * areaCost[(int)curPoly.Area.Id];
41 | }
42 |
43 | public float GetAreaCost(Area area)
44 | {
45 | return areaCost[area.Id];
46 | }
47 |
48 | public void SetAreaCost(Area area, float value)
49 | {
50 | areaCost[area.Id] = value;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Source/SharpNav/Geometry/Containment.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014-2015 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | #if MONOGAME
5 | using Vector3 = Microsoft.Xna.Framework.Vector3;
6 | #elif OPENTK
7 | using Vector3 = OpenTK.Vector3;
8 | #elif SHARPDX
9 | using Vector3 = SharpDX.Vector3;
10 | #endif
11 |
12 | namespace SharpNav.Geometry
13 | {
14 | ///
15 | /// Contains helper methods to check for containment of points or shapes.
16 | ///
17 | internal static class Containment
18 | {
19 | ///
20 | /// Determines whether a point is inside a polygon.
21 | ///
22 | /// A point.
23 | /// A set of vertices that define a polygon.
24 | /// The number of vertices to use from verts.
25 | /// A value indicating whether the point is contained within the polygon.
26 | internal static bool PointInPoly(Vector3 pt, Vector3[] verts, int nverts)
27 | {
28 | bool c = false;
29 |
30 | for (int i = 0, j = nverts - 1; i < nverts; j = i++)
31 | {
32 | Vector3 vi = verts[i];
33 | Vector3 vj = verts[j];
34 | if (((vi.Z > pt.Z) != (vj.Z > pt.Z)) &&
35 | (pt.X < (vj.X - vi.X) * (pt.Z - vi.Z) / (vj.Z - vi.Z) + vi.X))
36 | {
37 | c = !c;
38 | }
39 | }
40 |
41 | return c;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Source/SharpNav/Pathfinding/Link.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2014-2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | namespace SharpNav.Pathfinding
5 | {
6 | ///
7 | /// A link is formed between two polygons in a TiledNavMesh
8 | ///
9 | public class Link
10 | {
11 | ///
12 | /// Entity links to external entity.
13 | ///
14 | public const int External = unchecked((int)0x80000000);
15 |
16 | ///
17 | /// Doesn't link to anything.
18 | ///
19 | public const int Null = unchecked((int)0xffffffff);
20 |
21 | ///
22 | /// Gets or sets the neighbor reference (the one it's linked to)
23 | ///
24 | public NavPolyId Reference { get; set; }
25 |
26 | ///
27 | /// Gets or sets the index of polygon edge
28 | ///
29 | public int Edge { get; set; }
30 |
31 | ///
32 | /// Gets or sets the polygon side
33 | ///
34 | public BoundarySide Side { get; set; }
35 |
36 | ///
37 | /// Gets or sets the minimum Vector3 of the bounding box
38 | ///
39 | public int BMin { get; set; }
40 |
41 | ///
42 | /// Gets or sets the maximum Vector3 of the bounding box
43 | ///
44 | public int BMax { get; set; }
45 |
46 | public static bool IsExternal(int link)
47 | {
48 | return (link & Link.External) != 0;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Source/SharpNav.GUI/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SharpNav.Gui")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SharpNav.Gui")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("560205a7-8ed3-413e-9862-c5b8fae78e20")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Source/SharpNav/Pathfinding/NavPoint.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015-2016 Robert Rouhani and other contributors (see CONTRIBUTORS file).
2 | // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE
3 |
4 | using System;
5 | using System.Runtime.InteropServices;
6 |
7 | using SharpNav.Geometry;
8 |
9 | #if MONOGAME
10 | using Vector3 = Microsoft.Xna.Framework.Vector3;
11 | #elif OPENTK
12 | using Vector3 = OpenTK.Vector3;
13 | #elif SHARPDX
14 | using Vector3 = SharpDX.Vector3;
15 | #endif
16 |
17 | namespace SharpNav.Pathfinding
18 | {
19 | ///
20 | /// A point in a navigation mesh.
21 | ///
22 | [Serializable]
23 | [StructLayout(LayoutKind.Sequential)]
24 | public struct NavPoint
25 | {
26 | ///
27 | /// A null point that isn't associated with any polygon.
28 | ///
29 | public static readonly NavPoint Null = new NavPoint(NavPolyId.Null, Vector3.Zero);
30 |
31 | ///
32 | /// A reference to the polygon this point is on.
33 | ///
34 | public NavPolyId Polygon;
35 |
36 | ///
37 | /// The 3d position of the point.
38 | ///
39 | public Vector3 Position;
40 |
41 | ///
42 | /// Initializes a new instance of the struct.
43 | ///
44 | /// The polygon that the point is on.
45 | /// The 3d position of the point.
46 | public NavPoint(NavPolyId poly, Vector3 pos)
47 | {
48 | this.Polygon = poly;
49 | this.Position = pos;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Documentation/README.md:
--------------------------------------------------------------------------------
1 | SharpNav Documentation
2 | ======================
3 |
4 | If you came here looking for docs, you should go to http://sharpnav.com/docs
5 | for the compiled web documentation. This directory contains markdown versions
6 | of the pages included in the compiled docs as well as a configuration for
7 | [SharpDoc][1], the tool used to generate the documentation.
8 |
9 | ## Building Documentation
10 |
11 | Before anything else, make sure you have built at least one version of
12 | SharpNav (preferrably in the Standalone configuration).
13 |
14 | Almost everything you need is in this directory. There is no NuGet package for
15 | SharpDoc yet, so you should clone SharpDocs and compile the solution. If you'd
16 | like to take advantage of the `build-docs` script in the `Build/` directory,
17 | make sure SharpDocs is cloned in the same directory that SharpNav is cloned
18 | in. For example, if SharpNav were located in `C:\Projects\SharpNav`, then
19 | clone SharpDoc to `C:\Projects\SharpDoc`.
20 |
21 | **Note**: This process is not limited to Windows. Mono can do everything
22 | described here.
23 |
24 | With the script, you can simply call `./build-docs.sh` and
25 | `./build-docs.sh --clean` to generate and delete documentation, respectively.
26 | The generated docs will be output to the `/Binaries/Documentation` directory
27 | by default.
28 |
29 | If you aren't using the script, you can build documentation with the following
30 | command:
31 |
32 | ```
33 | SharpDoc.exe --config=/config.xml --output=