Skip to content

Build scenes with OpenStreetMap

OpenStreetMap allows road networks around the globe to be downloaded as a map file and these files can be imported into Traffic3D to quickly generate scenes at a large scale.

Download an OpenStreetMap file

Follow the instructions below to download a map file from OpenStreetMap:

  1. Click Here to visit OpenStreetMap.

  2. Search the name of the location you wish to model in the textbox.

    OpenStreetMap Searchbar

    Alternatively, click and drag the map around until you find a location you like.

  3. Zoom into the page using the icons provided by OpenStreetMaps or your middle mouse scroll wheel, to capture the part of the road network you wish to model.

    OpenStreetMap Zoom Buttons

    Everything displayed on screen screen will be downloaded into the map file.

    OpenStreetMaps has a downloadable limit of 50,000 nodes.

  4. To bring up the export UI, select the upper Export button.

    OpenStreetMap Upper Export Button

  5. To download the map file, select the UI Export button.

    OpenStreetMap UI Export Button

    If download failed due to the file exceeding 50,000 nodes, zoom into the page or drag the map around until less roads and buildings are visible.

Import an OpenStreetMap file

Follow the instructions below to import a file from OpenStreetMap into Traffic3D:

  1. OpenStreetMap files are .osm files and must be converted into a text file by renaming the file extension to .txt.

  2. Open up Traffic3D in Unity and add your .txt file.

    OpenStreetMap file in unity

  3. Bring up the GUI to import map data: Window > Import OpenStreetMap File.

    Import OpenStreetMap Tabs

  4. Select your desired map file and the textures/materials to apply to the roads, buildings and floor.

    Select the circular buttons on the right to choose your textures.

    Import OpenStreetMap GUI

    Note: You will be unable to select Import OpenStreetMap File if you are not in a new Unity Scene.

  5. After a few seconds, your scene will render and the only remaining requirement is to customise the Vehicle Factory.

    Information about the Vehicle Factory can be found at Traffic3D Assets.

    After modifying the Vehicle Factory the simulation can be run.

    Note: It is advised that the top-speed and turning speed of vehicles are reduced to prevent vehicles accelerating too quickly towards corners and driving off the roads.

Modify a road's mesh

In the Unity inspector you will find a list of game objects.

A road will consist of a parent object, with two child objects.

Road with two child objects

  • First Child Object - Contains the road mesh, a Road Mesh Updater component and has a child object positioned above the centre node, which displays the road name.

  • Second Child Object - Contains a Path component and has child objects representing nodes; information about the Path component can be found at Traffic3D Assets.

After modifying a path, the road's mesh can be quickly updated by selecting the Update Road Mesh button in the Road Mesh Updater component.

Road Mesh Updater attached to game object

Road Mesh Updater

Road Mesh Updater Component

This is used to quickly update a road mesh by only requiring nodes in a Path to be modified, and will automatically modify the mesh when the Update Road Mesh button is selected.

The script has the following fields:

  • Road - The game object the script is attached too, which should also contain the Mesh Renderer and Mesh Filter components.
  • Path Object - A game object with the Path component attached, and shares the same parent object as Road.
  • Num Lanes - The number of lanes in the road.
  • Lane Width - The width of each lane in meters.
  • Update Road Mesh - A button which will change the shape of the mesh in the Road field to match the shape of the path in the Path Object field.

Limitations

The current version of the import system has some restrictions on the types of networks which can be modelled:

  • Only grid systems, such as those found in American cities, can currently be modelled as the system only supports cross junctions.

  • Variations in road heights, such as tunnels and bridges, are not supported and as all roads will be generated at the same Y-level.