Skip to main content

Python implementation of path finding algorithm in navigation meshes

Project description

What is it?

This is an implementation of algorithm for path finding in navigation mesh. The algorithm is based on Three Pathfinding library. In fact, all main ideas are the same, differs only small details. All done in Python and AssemblyScript. Path finding algorithm use three main concepts:

  • structure all polygons navigation mesh to a bvh (bounding volume hierarchy)
  • find closest path between centers of polygons by using A* algorithm in dual graph (vertices of this graph are centers of polygons, and two vertices are incident to one edge, iff corresponding polygons have a common edge)
  • combine two previous concepts to find the path between input points

It's important to understand that the algorithm does not guaranteer the optimality of the generated path. In most cases the path is plausible.

This library does not contains methods for generating (or baking) navigation meshes. It assumes that navigation mesh is already generated. There are many tools for this:

  • Recast Navigation This is the most famous navigation mesh solution. It allows generate mesh and find path in it
  • PyRecastDetour This is Python bindings for some functions in Recast Navigation. Allows to output generated navigation mesh triangulation and it polygonal description
  • Blender, Unity and so on

How to use

To install:

pip install pynavmesh

To create navigation mesh object:

import navmesh as nm
navmesh = nm.Navmesh(vertices, polygons)
  • vertices is an array of the form [(x1, y1, z1), (x2, y2, z2), ...] and contains vertex coordinates
  • polygons is an array of the form [[p11, p12, ..., p1n1], [p21, p22, p23, ..., p2n2], ...], where each array is a sequence of vertices, which form the polygon. Each pij is an integer - the index of the vertex in the vertices array

To find the path in the navigation mesh simply call

path = navmesh.serach_path(start, finish)

start and finish are tuples with coordinates. It return the array path, which contains the sequence of corners of it linear segments.

More details and examples on GitHub page.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynavmesh-1.0.2.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynavmesh-1.0.2-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file pynavmesh-1.0.2.tar.gz.

File metadata

  • Download URL: pynavmesh-1.0.2.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

File hashes

Hashes for pynavmesh-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b217693fef5e216ccdc4f91fa553dedb996e239cf01998b719bf72ba6cb8ecaa
MD5 5d77bcafad27d0f7bd23b6236f9abf16
BLAKE2b-256 9efd465ac293b9131bafeaee2c19917c3de09719f8efe0a6c4155163788e2e53

See more details on using hashes here.

File details

Details for the file pynavmesh-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pynavmesh-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

File hashes

Hashes for pynavmesh-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 712a4d0b8c40e3c957e0cd9d08362e90f30aab8e443eaef9cf8abf74c73e6900
MD5 d531d6acff894e45ea616062bd71658b
BLAKE2b-256 93028804faf5cf7e88c030d813b619d771f270e21b16f4d4c1c03b9127320afd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page