Note that there are some explanatory texts on larger screens.

plurals
  1. POMapping a height map to a grid-based contour format
    text
    copied!<p>I have a 2D height map in the following format</p> <pre><code>06 36 39 42 43 55 ... 37 40 43 43 45 46 ... 40 43 44 45 46 48 ... 44 44 46 47 48 50 ... 41 44 45 47 48 48 ... ... </code></pre> <p>And I need to remap it into a grin based contour format (so it can further be mapped into sprites)</p> <pre><code>. . . . | . . . . . . \ . . . . . / / . . . . . | . . . . . . | . . . . / - / . . . </code></pre> <p>Here <code>.</code> meaning flat area, <code>|</code> and <code>-</code> straight cliffs, <code>/</code> and <code>\</code> cliff corners (each representing 2 different possibilities).</p> <p>I have tried a standard marching squares approach, but found that sampling only 3 neighbours leads to quite a lot of problems, due to overloading the adjacent cases. (Note the extra out of place straight cliffs below)</p> <pre><code>. . . . | . \ . . . . \ \ . . . . / / - . . . . | - . . . . . | . . . . / - / . . . </code></pre> <p>What I would like, is some references to algorithms/approaches that help deal with this sort of thing. I know that contour walking with some sort of depth first search is an option but have not tried it out yet, and would prefer to leave that as a last resort. There is also the questions of representation of some features, for example whether to include cliff ridges that are 1 element thick or just ignore them. Another option is to pass through the generated contours and change them so they smoothly fit together, but this seems really hacky...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload