Skip to content

Road Generators

adhocmaster edited this page May 12, 2021 · 26 revisions

WFC-based generators

Steps

  1. Create some intersections
  2. Convert intersection to Direction Intersections by identifying incident roads in direction quadrants (top is North, left is West, bot is South, right is East)
  3. Create a grid and cells of it.
  4. Apply WFC to fill cells with Direction Intersections
  5. Get Direction Intersection positions based on the cell placement.
  6. Adjust the original intersections' positions based on their direction counterparts' positions.
  7. Connect incident roads based on their placement on the direction quadrant

2. Intersections -> Direction Intersections:

A direction intersection is defined by four direction quadrants (top is North, left is West, bot is South, right is East). An incident road is placed in a direction quadrant based on the outgoing heading at the incident point. Headings are calculated counter-clockwise from East.

The conversion tool is based one invariant in the intersections: no two incident roads ever overlap.

The process is shown here:

So, the direction intersection has only 4 properties each saving a reference to one direction quadrant. Each direction quadrant has two properties to save the number of incoming and the number of outgoing lanes.

3. Grid and Cells

This is a sample grid of (500m X 500m) and each cell is (100m X 100m). Initially no cell has any element placed.

Clone this wiki locally