Search code examples
c#unity-game-engineqgisprocedural-generation

Procedural modeling of 3d road network geometry and present it on Unity


Edit: As comments said, this question is way too complex so I only hope to get answers which focus on one certain part of this question. Welcome to any ideas in your mind.

I'm working on a project where I am supposed to analysis GIS (vector) data to extract road features like axis and border in a large scale city road network, then procedurally generate the 3D road model representation based on these features, and the objective is a 3d editable road network geometry in Unity which I can easily adjust the position/width/height... of each road in it(and of course get immediate proper feedback like what we can see in SimCity or City:Skyline, in other words, we can set procedural modeling parameters in Unity and directly see how it influence the result geometry).

Since I'm quite new to these things like GIS, Unity, and Maya, I'm wondering if you know what is the correct workflow? And do you have recommended tools for doing these? Especially, where and in which step should I write the algorithms for procedural modeling? Because it seems that Unity is just a rending/gaming tool and can't build a complex model itself so maybe I must build up the geometry before importing it to Unity3D, but can I adjust just the model and get immediate feedback inside unity if I do so?

In my assumption, I guess I need to:

  • use GIS tools like Qgis to export roadmap data in shapefile format--usually points and lines
  • then find somewhere to transform it into spatial coordinates and do the math things to extract road features

  • do the procedural modeling things to get a "dynamic" model

  • finally, render it in Unity

If so, which tool/platform is good for each step?

Thanks a lot!


Solution

  • There are Unity extensions available that can generate roads. A couple examples I've looked into:

    • Easy Roads 3d
      • can import from Open Street Maps (OSM)
      • Assuming you need to use a source other than OSM, you could translate from your GIS data to OSM format and import that
      • I don't have a lot of experience with this tool myself, but there are some threads on the Unity community forums and the author seems to be very responsive.
    • Mapbox Unity SDK.
      • if you are required to use your GIS data you won't be able to use this
      • open source, so you can always look at the source to see how the transforms are done.
      • There are many hooks available and several tutorials that demonstrate how to hook into the pipeline and extract features from the incoming data and perform procedural generation of scene geometry (see the tutorials). The team behind it has been very helpful in answering questions.
      • I've done a bit of work with this tool, and the biggest downside (for me) is that it can only generate a map at runtime, i.e. not in the editor. This is due to licensing restrictions on the data.

    Both of the options I mentioned do the transform from GIS coordinates to Unity-space in Unity. Unity runs fully-featured C# code and is capable of building complex geometry. Obviously that takes computational time, so you need to trade off that against performance. You should only need to build the geometry once, however (or at least only once after each edit/modification), not per-frame. In my use I've modeled buildings in SketchUp and imported those into Unity, then used the Mapbox utilities to map their locations to the correct spot (elevation and lat/long coordinates). You could do a similar thing with Maya models.

    Some of what you need to do depends on:

    • you need to dynamically generate the roads every time you launch the program
      • you are better off building the code into Unity to translate from GIS to Unity scene coordinates and dynamically generate road geometry
    • you are doing a one-time import of road networks and then modifying that static network.
      • build a tool to convert from your GIS and generate road geometry as a one-time task
      • you'll still probably want to use Unity since in includes many utilities to work with vectors and generate geometry