Intro

Abstract

In Unity, a NavMesh is a set of convex Polygons covering all obstacle-free navigable areas. This project involves implementing an algorithm to generate a navigation mesh (NavMesh) for an environment and to construct a path network from the resulting mesh. A path graph can then be formed by connecting adjacent NavMesh polygons through shared edges AKA portals. The nodes (pathNodes) of the network are created at the midpoints of these portal edges.

TODO

  • Coverage- Generate adjacent polygons (triangles) to cover the entire navigable space
  • Reachability: Create a path graph from the navmesh
  • Mesh Optimization: Merge the triangles into larger and more efficient convex polygons
description
  • Using midpoints for the nodes is useful because you can move in a straight line between any 2 points in a convex polygon; there will never be a path returned that causes the agent to run into an obstacle
    • It might get close to the expanded geometry, but a raycast is sufficient to maintain clearance
    • So can be touching the sides of the expanded geometry (radius of agent)

Navigation Mesh

img

A navigation mesh is a means to automatically identify points at which to place path nodes. A navigation mesh is a set of convex hulls (polygons) overlayed on an environment such that the area wihin each hull is guaranteed to be obstacle-free. Note the relatively small number of convex hulls needed to map out navagable areas in the figure below. The convexity of the hulls is important because an agent within the area of a hull can move to any other point within the hull without crossing a hull boundary. https://faculty.cc.gatech.edu/~surban6/2015-cs4731/homeworks/homework2.html

Path Network

img

A path network is a set of path nodes and edges that facilitates obstacle avoidance. The path network discretizes a continuous space into a small number of points and edges that allow transitions between points. However, unlike a grid topology, a path network does not require the agent to be at one of the path nodes at all times. The agent can be at any point in the terrain. When the agent needs to move to a different location and an obstacle is in the way, the agent can move to the nearest path node accessible by straight-line movement and then find a path through the edges of the path network to another path node near to the desired destination.

Creating portals from midpoints

img

Furthermore, when two convex hulls are adjacent to each other (i.e., they share an edge), that edge can be thought of as a “portal”---an invisible door---from one safe navigation region to another. Connecting adjacent convex hulls into a network of safe passages results in a path node network through which an agent can travel between any two points in the environment without fear of collision. That is, a navigation mesh can be used to automatically place path nodes throughout a game map. The resulting network of path nodes creates a super-highway by which an agent can move from any safe area to any other safe area.

Setup

  • Open the Navmesh scene and the CreateNavMesh.cs file.
  • Follow the comments in CreateNavMesh.Create() to build a working navmesh generator

Create NavMesh

  • Starter code

Phase I- Brute force triangle formation

  • Form adjacent triangles that cover all the navigable space

Phase II

  • Merge triangles into larger, more efficient polygons that are also convex

Phase III

  • Create a path graph from the navmesh
description

Reference Implementation

Scene 1

img

Scene 2

img

Scene 3

img

Scene 4

img

Scene 5

img

Scene 6

img

Scene 7

img

Scene 8

img

Completed

TODO

  • Coverage- Generate adjacent polygons (triangles) to cover the entire navigable space
  • Reachability: Create a path graph from the navmesh
  • Mesh Optimization: Merge the triangles into larger and more efficient convex polygons