Skip to content

MeshTool

MeshTool.exe is a command line tool for working with .navmesh files.

MeshTool <command> [options]
MeshTool <command> -h

-v / --verbose turns on debug logging for any command.

Commands

convert

MeshTool convert <input> [output] [--version N]

Loads a navmesh and saves it with a different header version. --version defaults to the latest version. If output is omitted, the input file is overwritten.

validate

MeshTool validate <mesh> [--json] [--pretty]

Loads a navmesh and prints its header version, tile and polygon counts, walkable area, and the number of off-mesh connections and convex volumes. Fails if the file can't be loaded, has no tiles, or can't be queried.

export

MeshTool export <mesh> <output.json> [--json] [--pretty]

Dumps the off-mesh connections, convex volumes, area types and build settings to a JSON file. Missing directories in the output path are created, and an existing file is overwritten.

Coordinates in the exported file are in mesh space, [x, y, z] with y up, the same way the navmesh stores them.

diff

MeshTool diff <old> <new> [--tolerance N] [--strict] [--json] [--pretty]

Compares two navmeshes. The main use is checking a rebuilt mesh against the previous one to make sure none of the hand-placed connections and volumes were removed.

Item Matched by
Off-mesh connections Start and end points. If either connection is two-way, they also match with the ends swapped.
Convex volumes Outline and height range. Vertex order doesn't matter (any starting vertex, either winding).
Area types Id

Each of these is reported as removed, added or changed. A matched connection counts as changed if its name, area, type or direction differs, a volume if its name or area differs, and an area type if any of its properties differ. When several items are close together, the closest pairs are matched first.

The diff also lists build settings that differ (including partitionType), and compares tile/polygon counts and per-tile geometry. A tile counts as changed if its vertex positions (rounded to 0.1) or its polygons (vertices, area, flags) differ.

--tolerance is the maximum distance between two points (and between volume heights) for them to count as the same. Default is 0.5. It must be zero or positive.

Note that a mesh with hand-edited tiles will always show changed tiles after a full rebuild, even if every connection and volume made it across.

Exit codes:

  • 0: nothing removed
  • 1: error (bad arguments, file couldn't be loaded, etc.)
  • 2: one or more connections, volumes or area types were removed. With --strict, also returned when settings or tile geometry changed.

Example:

MeshTool diff resources\MQ2Nav\<zone>.navmesh out\MQ2Nav\<zone>.navmesh

JSON output

Passing --json to validate, export or diff prints a single JSON object to stdout instead of the normal text output. All log output, including errors, goes to stderr as plain text, so stdout only ever contains the JSON. On failure the exit code is 1.

By default the JSON is printed on one line. Supply --pretty to pretty-print it.

Locations in diff output (startPos, endPos, firstVertPos) are in /loc order: Y, X, Z. At most 50 changed tiles are listed, but the changed count is the full total.