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:
Click Here to visit OpenStreetMap.
Search the name of the location you wish to model in the textbox.
Alternatively, click and drag the map around until you find a location you like.
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.
Everything displayed on screen screen will be downloaded into the map file.
OpenStreetMaps has a downloadable limit of 50,000 nodes.
To bring up the export UI, select the upper
To download the map file, select the UI
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:
OpenStreetMap files are
.osmfiles and must be converted into a text file by renaming the file extension to
Open up Traffic3D in Unity and add your
Bring up the GUI to import map data:
Import OpenStreetMap File.
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.
Note: You will be unable to select
Import OpenStreetMap Fileif you are not in a new Unity Scene.
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.
First Child Object - Contains the road mesh, a
Road Mesh Updatercomponent and has a child object positioned above the centre node, which displays the road name.
Second Child Object - Contains a
Pathcomponent and has child objects representing nodes; information about the
Pathcomponent 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¶
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
- Path Object - A game object with the Path component attached, and shares the same parent object as
- 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
Roadfield to match the shape of the path in the
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.