Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I haven't actually started programming for this one yet, but I wanted to see how I would go about doing this anyway.

Say I have a grid of tiles, all of the same size, some traversable and some not. How would I go about creating a navigation mesh of polygons from this grid?

My idea was to take the non-traversable tiles out and extend lines from there edges to make polygons... that's all I have got so far. Any advice?

share|improve this question
2  
Technically the grid is pretty much equivalent to a navigation mesh. I suspect you're actually asking for a way to optimise the grid and coalesce adjacent squares. – Kylotan Nov 16 '12 at 8:50
    
@Kylotan Yes that is exactly what I meant, just a way to combine adjacent polygons. – Ross Hays Nov 17 '12 at 4:53
up vote 21 down vote accepted

Here's one of the methods I came up with when doing navmesh for an RTS game. Note that it is homebrew, no third-party tools were used, it took me about 3 weeks to implement and bugfix:

  1. Use Marching Squares algorithm to convert obstacle tiles into outlines (purple lines)
  2. Reduce number of points in outlines using Douglas-Peucker algorithm
  3. Feed all points into Delaunay triangulation (to get most uniform triangles)
  4. Add more points in empty areas and along the map edges to get more even coverage
  5. Check along obstacle outlines and flip polygons produced by Delaunay to match outlines
  6. Clip obstacles innards
  7. Fill in connectivity data between remaining polys - thats your navmesh

Result:

tilemap navmesh

share|improve this answer
1  
This is exactly what I was looking for. Thank you! – Ross Hays Nov 17 '12 at 4:52

Meshes are typically implemented as graphs. If you wish to implement path-finding in a map based on a grid do the following:

Create a graph where each traversable square is represented as a vertex. Each pair of adjacent traversable squares represented as vertices, will have an edge between them. And you're done.

share|improve this answer
1  
This is not how navmeshes are typically implemented. The purpose of a navmesh (and, I imagine, the reason the asker even asked their question here) is to optimize the graph down to a minimal required number of polygons (usually triangles) that span the most useful spaces to reduce both the number of steps required to find a good path, and the memory footprint required to define the mesh. A raw implementation would both eat up a ton more memory, and would waste valuable AI processing time. – Gurgadurgen Jul 9 at 21:21
    
You are correct. Of course decimation (polygon reduction) is a reasonable and desired optimization. It is just that when you read the op's question, you are getting the sense he just wants to turn a grid into a graph. – zehelvion Jul 12 at 9:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.