Mesh generation

 

Mesh generation

Unity


I'm fascinated by mesh generation. This is not my first and last project about it :) Mesh generation allows us to easily create dynamic worlds that would automatically re-mesh existing roads, buildings and automatically generate navigation routes.

In this Unity project I experimented with generating mesh between multiple game objects. I defined which material to use for each segment inside a custom plane view:

You can also define how often and where to place other prefabs on top of generated mesh, like lamposts, drain covers and other street like objects. You can put navigation path points for cars or pedestrians.

Generated roads supports transition between the different amount of lanes, you can add pedestrian crossings, one-way roads, bus stops and even roundabouts.

In first video I implemented basic car logic, which simply follows generated path which was also generated together with road mesh. I also experimented with terrain generation below road mesh - it was fine, but sometimes would go through road mesh. Improvement needed.

In second video I made texture mapping way more precise and also corrected prefab placement.

What still needs to be perfected:
  • More user friendlier road connection editor. Now it is way too complex.
  • Have a single mesh controller for whole scene. Now it is hard to find which game object is responsible for generating specific mesh.
  • Easier detection when mesh needs to be regenerated. Now code is a mess and requires to manually track each of the property.

Comments