Startseite | Blog | Detailseite

Unity3D OpenStreetMap Terrain

Building terrains at runtime using OpenStreetMap data...


Abstract: Creating 3D-Terrains with Unity3D and OpenStreetMap data at runtime.

Inspired from the google glasses project we started with the development of an AR application a few months ago. The idea behind the app was to create a virtual running partner which is mapped in the real world through your glasses.

While the “real” runner uses GPS and Gyro data to manage positions and camera views the “virtual” runner should run on a predefined track with various pace options. Components for fun and stimulation are a lot of build-in interactions between the two competitors.

Everyone knows that working with GPS data from a normal device like a smartphone is very disappointing due to the lack of accuracy. In our case the major challenge exists in mapping the current position of the real runner in the 3D world. It should be possible to run next to or behind the virtual runner with a continuous pace – we don’t want the camera to jump around because of quick changing GPS-Signals.

Facing this and a lot of other troubles we realized that it would be very comfortable to have real time access to information about excising map data like streets ore buildings and we started with the development of a real time OpenStreetMap component for unity. Especially the usage of “virtual” streets helped us cleaning up the incoming GPS-Signal as we now could use them as references. (read line: unpolished GPS, green line: polished GPS)

The basic concept the OpenStreetMap component can be described as follows:

  • Export a map segment with bounds as *.xml.

  • If altitude is needed: Get the altitude for each point node using existing web services and update the values in the *.xml.

  • Load the map file and convert each point node from lat/lon to ECEF system(x, y, z)

  • Load a map configuration xml which can be used to manage individual materials or settings depending to the given OpenStreetMap tags.

  • For building the meshes we clustered the map segments in streets, areas and buildings.

  • Using the map configuration xml as well as the OpenStreetMap tags to define the properties of each map segment.

    For example:
    If the map *.xml provides a closed way with the landuse tag set to parking: Create an area map segment with an individual material.

    If the map *.xml provides an open way with the highway tag set to residential: Create a street map segment with individual properties like street width.

  • Creating the single map segments:

    Build a flat ground mesh from the given points using a constrained triangulation algorithm.

    Check if the new created mesh intersects with existing meshes like other areas or streets.

    If intersects: Using polygon clippers to recalculate the meshes and create the new points.

    Triangulate again.

    If is building: Create the building from the ground mesh.

    Finalize map segments: Create collider for example (information from the configuration xml)


Where to go from here:

Actually the library sources are full of To Do notes. Also some basic features like exporting the runtime generated meshes for areas, streets or buildings into one big mesh to refine it afterwards in programs like C4D or Blender are still missing. We keep you up to date and upload a live demo here as soon as possible!








Einen Kommentar schreiben