Repository navigation
Navigation Mesh
scriptfiles/3dandreas/navmesh.db tells where a pedestrian can walk on the whole map and in the interiors: the ground, the floors, the stairs, the bridges and the roofs, around buildings, walls and fences. It is optional. With it, walks start and end where the points are, short walks take the shortest way, and A3D_GetNearestWalkPoint, A3D_GetRandomWalkPoint and A3D_WalkRayCast answer. Without it, they fail and walks keep to the paths.

The mesh around Grove Street: the blue polygons are where a pedestrian can walk, the dark holes are buildings, walls and parked objects, the lighter polygons are higher, and the green and orange lines are the paths and the roads of the game.
The mesh is built for a person 1.8 metres tall who keeps 35 centimetres from walls, climbs steps up to 45 centimetres and walks up slopes up to 45 degrees. Water deeper than a metre is left out, and shallow water at the edge of a beach is not.
The release holds 20,695 tiles of 38.4 metres and 288,276 polygons, in a file of 60 MB. The component reads it on a thread of its own when the server starts, in about half a second, and the server takes about 65 MB more memory with it. A question asked before the file is read waits for it.
navbuild is built with the component. It reads the map database and writes the mesh:
navbuild world.db navmesh.db --threads 4
It builds the tiles on as many threads as --threads gives, every core when left out, and takes about a minute for the whole map on four threads. Then the file goes to scriptfiles/3dandreas, or 3dandreas.navmesh points at it. See Configuration.
| Option | Description |
|---|---|
--threads n |
Threads that build the tiles. |
--area minX minY maxX maxY |
Builds only the tiles within the rectangle, for a quick try. |
--cell size |
Size of the cells the collision is cut into, 0.2 metres by default. Larger cells make a smaller file with less detail around walls and doors. |
--detail distance error |
How often the height is sampled across a polygon and how far it may stray from the ground, 4 and 0.5 metres by default. |
--simplify error length |
How far the outline of a polygon may stray from the walls, and the longest edge, 2 and 24 metres by default. |
--region cells |
The side of the smallest area kept, in cells, 16 by default. Smaller areas, such as the tops of walls, are left out. |
--dump file |
Writes the polygons as text, for tools that draw them. |
Recast cuts the collision of the map into cells of 20 centimetres, keeps the cells a person can stand on and fit above, takes away the cells under deep water and those too close to a wall, and turns the rest into polygons, one tile at a time. Detour then finds paths across the polygons, from tile to tile.
- The mesh is the map of the game. Objects that scripts create and buildings removed with A3D_RemoveBuilding do not change it.
- The interiors stand in the sky above the city, and their doors lead nowhere in the world, so a walk never goes from a street into an interior.
- Roofs are on the mesh, but a walk reaches them only where stairs or ramps lead up.
3DAndreas 0.7.1 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Physics objects
- Model settings
- World queries
- The screen
- Routes
- Navigation mesh
- Map database
- Coming from ColAndreas
- Performance
Reference
Functions