DotRecast Documentation

repository·main·Indexed 21 days ago

https://github.com/ikpil/dotrecast

A C# port of the Recast & Detour libraries for generating navigation meshes and performing runtime pathfinding, agent movement, and crowd simulation. It includes modular components such as DotRecast.Recast for navmesh generation, DotRecast.Detour for runtime queries, and specialized modules for tile caching, crowd simulation, and dynamic navmeshes.

Tokens
1.2K
Snippets
3
Records
8
Agent score
25%

What's inside DotRecast

  1. Overview of DotRecast modules

    main

    DotRecast is a C# port of Recast & Detour, providing industry-standard navigation mesh (navmesh) generation and runtime pathfinding. The project is modular, allowing you to use only the components you need:

    • DotRecast.Core: Core utility functions.
    • DotRecast.Recast: Tools for generating navmeshes from geometry.
    • DotRecast.Detour: Runtime loading of navmesh data, pathfinding, and navmesh queries.
    • DotRecast.Detour.TileCache: Supports navmesh streaming, ideal for large levels or open-world games.
    • DotRecast.Detour.Crowd: Handles agent movement, collision avoidance, and crowd simulation.
    • DotRecast.Detour.Dynamic: Provides support for dynamic navmeshes by combining pre-built voxels with dynamic objects that can be added or removed.
    • DotRecast.Detour.Extras: A tool to import navmeshes created with the A* Pathfinding Project.
    • DotRecast.Recast.Toolset: Includes all modules.
    • DotRecast.Recast.Demo: A standalone demo application showcasing all functionalities.
  2. How Recast navmesh generation works

    main

    Recast generates a navigation mesh through a multi-step mesh rasterization process:

    1. Voxelization: Input triangle meshes are rasterized into voxels.
    2. Filtering: Voxels in areas where agents cannot move are filtered and removed.
    3. Region Partitioning: The walkable areas in the voxel grid are divided into sets of polygonal regions.
    4. Triangulation: Navigation polygons are generated by re-triangulating the polygonal regions into a final navmesh.
    • Single Mesh: Suitable for simple, static environments. Easier to implement and work with.
    • Tiled Navmesh: Better for large or dynamic environments. Supports advanced Detour features like re-baking, hierarchical path-planning, and data-streaming.
  3. Getting started with DotRecast

    main

    To begin using DotRecast in your project, refer to the following resources:

    • Building and Integration: For instructions on how to build the library or integrate it into your own C# project, see the BuildingAndIntegrating.md guide.
    • Creating a NavMesh: For a practical example of generating a navmesh, examine the RecastSoloMeshTest.cs test file.
    • Testing Pathfinding: To see how to implement and test pathfinding queries, examine the FindPathTest.cs test file.
  4. Integrate DotRecast via Source

    main

    Source integration is the most flexible method and is recommended for most use cases. You can add specific source directories directly into your project depending on your requirements.

    Module Descriptions

    • DotRecast.Core: Core Utils
    • DotRecast.Recast: Core navmesh building system.
    • DotRecast.Detour: Runtime navmesh interface and query system.
    • DotRecast.Detour.TileCache: Runtime movement, obstacle avoidance, and crowd simulation systems.
    • DotRecast.Detour.Crowd: Runtime navmesh dynamic obstacle and re-baking system.
    • DotRecast.Detour.Dynamic: Robust support for dynamic nav meshes combining pre-built voxels with dynamic objects.
    • DotRecast.Detour.Extras: Tool to import navmeshes created with A* Pathfinding Project.

    Integration Examples

    • Level Building Tool: Include DotRecast.Core, DotRecast.Recast, and DotRecast.Detour.
    • Game Runtime: Include only DotRecast.Detour.
  5. Build DotRecast

    main

    To build DotRecast, you must have the .NET 8 SDK installed. You can build using the Command Prompt or an IDE.

    Using Command Prompt

    Run the following command to build the solution in Release mode:

    dotnet build -c Release

    Using an IDE

    1. Launch your C# IDE (e.g., Visual Studio).
    2. Select File > Open Solution and select DotRecast.sln.
    3. Select Build > Build Solution from the menu.
  6. Install DotRecast via NuGet

    main

    You can install DotRecast modules using NuGet. The following packages are available:

    • DotRecast.Core
    • DotRecast.Recast
    • DotRecast.Detour
    • DotRecast.Detour.TileCache
    • DotRecast.Detour.Crowd
    • DotRecast.Detour.Dynamic
    • DotRecast.Detour.Extras
    • DotRecast.Recast.Toolset
    • DotRecast.Recast.Demo