OSM2Mesh is a lightweight utility that converts raw OpenStreetMap (OSM) vector data into game-ready 3D meshes (.obj / .mtl) with texture coordinates.
The project includes both a standalone command-line pipeline engine (osm_buildings.py) and an integrated interactive graphical interface (osm_gui.py) that handles map selection, live downloading via the Overpass API, and automated deployment package construction.
- Tier 1 (Generic Footprints): Automatically parses 2D footprints, resolves architectural height from OSM tag definitions (or level heuristics), extrudes vertical walls, and caps roofs with parametric geometry (Flat, Pyramidal, or Gabled structures).
- Tier 2 (Multi-part Setbacks): Naturally handles tiered structures, towers, and podiums by processing separate
building:parttags with accurate offset minimum heights. - Tier 3 (Landmark Synthesis): Employs a deterministic named landmark matching layout (using
wikidataor string keys) that lofts and skins continuous tapered or twisted multi-profile keyframe meshes instead of generic boxes. - Environment Components: Supports optional runtime toggles to generate flat, data-bounded ground planes, contoured ribbon meshes for highway/road networks, and unique water feature bodies (as supported by OSM).
- Stable Selection: Uses deterministic pseudo-random hashing seeded by the unique OSM way identification string to keep appearance consistent across generations.
- Contextual Material Selection: Prioritizes explicit tag mappings (
building:material,roof:colour). If missing, it applies height-weighted rules (e.g., favoring glass/concrete for high-rises, brick/generic tiles for low-rise areas). Not perfect, but better than everything being a monotony.
- Embedded Maps: Built-in interactive geographic navigation powered by
tkintermapview. - Flexible Selections: Look up locations using a search anchor or drag bounding boxes using
Shift+Left-Click Drag. - Threaded Compilation: Generates assets on a background worker thread to keep the interface smooth and responsive, compiling geometries and image dependencies into a single deployment-ready
.ziparchive.
The core procedural compilation engine is written entirely using pure Python standard libraries (e.g., xml.etree.ElementTree) to ensure there are no external mathematical or geodesy dependencies (such as NumPy or shapely). Why? Because it is easier to package without them.
Yes that's the whole reason.
- Python 3.14+
- certifi (for secure Overpass API downloads)
- tkintermapview (for the optional graphical user interface layer)
Install the necessary components via pip:
pip3 install certifi tkintermapviewAlternatively, you can acquire the stable built packages from the Releases section.