This Unity package generates real-world and synthetic environments for a bicycle simulator, using OpenStreetMap (.osm) data and optional realistic terrain via .asc elevation files. It features a custom Unity Editor window for easy map import and infrastructure generation.
-
🗺️ OSM Integration
Procedurally builds roads, buildings, and terrain using.osmmap data. -
🌍 Terrain Support
Create either flat or real-world terrain from ASC elevation files with UTM conversion. -
🌾 Dynamic Grass Placement
Grass is placed based on OSMlanduseand polygon boundaries. -
🛠️ Editor Tool
Import map files and generate scenes via a Unity Editor window (Window → Import OpenStreetMap Data). -
🧱 Modular Infrastructure System
Easily extendable mesh pipeline for roads, buildings, etc. -
🧠 Tag-Aware OSM Parsing
Understands traffic signs, cycleways, sidewalks, crossings, building types, and more.
-
Download or clone the repository
https://github.com/rwth-irt/osm2unity -
Open Unity Package Manager:
Window → Package Manager → + → Add package from disk
- Select
osm2unity/package.json
- Open Unity Package Manager:
Window → Package Manager → + → Add package from git URL
- Paste
https://github.com/rwth-irt/osm2unity.git
- Go to OpenStreetMap.
- Select the required region on map.
- Export the
.osmfile inxmlformat.
or
Go toSamples -> Mapsand choose one of the provided.osmexamples.
Use the provided python script generate_osm.py in Samples -> Maps to generate synthetic road geometries:
- Straight roads
- Sinusoidal roads
- Circular roads
⚠️ CopyBicycle,EventSystem,Post-Processing VolumeandWindZoneGameObjects from the provided Sample ScenesCampusMelatenorStraightRoadbefore importing map in a new Scene.
- Open Unity.
- Go to
Window → Import OpenStreetMap Data. - Select your
.osmfile. - (Optional) Enable
Import Real Terrainto use elevation data. - Click Import.
Roads, Buildings and Terrain GameObjects will be generated automatically in your current scene.
Activate the FreeRoam.cs script in the bike GameObject to enable manual control with terrain-aware alignment.
| Input | Action |
|---|---|
| W/A/S/D | Move forward/back/turn |
| Shift | Faster movement |
| Mouse | Free-look camera |
- Install SteamVR.
- Connect your VR hardware.
- Enable
ViveController.csscript in the bike GameObject to control it using VR input from Vive or other OpenXR-compatible devices.
| Input | Action |
|---|---|
| Right Trigger | Analog Acceleration |
| Left Trigger | Analog Braking |
| Trackpad x-axis | Analog Steering |
com.irt.osm2unity/
|── Editor/
| ├── OpenStreetMapImporter/
| | ├── Infrastructure/
| | | ├── Buildings/
| | | | ├── BuildingMaker.cs
| | | | ├── Roof.cs
| | | | └── Window.cs
| | | |
| | | ├── Roads/
| | | | ├── RoadMaker.cs
| | | | ├── Intersection.cs
| | | | ├── Lane.cs
| | | | └── Sidewalk.cs
| | | |
| | | ├── Semantic/
| | | | ├── ObjectPlacer.cs
| | | | ├── TrafficSign.cs
| | | | └── TrafficSignal.cs
| | | |
| | | ├── Terrain/
| | | | └── TerrainMaker.cs
| | |
| | ├── Deserialization/
| | | ├── BaseOsm.cs
| | | ├── OsmBounds.cs
| | | ├── OsmNode.cs
| | | ├── OsmRelation.cs
| | | └── OsmWay.cs
| | |
| | ├── ImportMapDataEditorWindow.cs
| | ├── ImportMapWrapper.cs
| | ├── MapReader.cs
| | └── MercatorProjection.cs
| |
| ├── Bicycle/
| | └── Bicycle.cs
|
|── Runtime/
| ├── FreeRoam.cs
| └── ViveController.cs
The following OSM tags are parsed and used in procedural generation:
| Element | Tags Used | Description |
|---|---|---|
| Roads | highway, surface, lanes, sidewalk |
Classifies cycleway, lanes, sidewalks, etc. |
| Buildings | building, building:levels, roof:shape |
Controls height and type |
| Terrain | N/A | Optional ASC file for real elevation |
| Grass | landuse=grass |
Adds detail grass layer |
| Signals | highway=traffic_signals, traffic_signals:direction |
Determines signal placement |
| Signs | traffic_sign, highway=stop |
Determines traffic sign type and placement |
Ride through a procedurally generated version of reality, powered by OpenStreetMap.
