Skip to content

Repository files navigation

OSM2Mesh - Procedural 3D City Generator

Project logo

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.

Features

Procedural Generation Architecture

  • 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:part tags with accurate offset minimum heights.
  • Tier 3 (Landmark Synthesis): Employs a deterministic named landmark matching layout (using wikidata or 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).

Intelligent Material Inference

  • 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.

Interactive GUI Workspace

  • 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 .zip archive.

Installation & Requirements

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.

1. Requirements

  • Python 3.14+
  • certifi (for secure Overpass API downloads)
  • tkintermapview (for the optional graphical user interface layer)

2. Setup

Install the necessary components via pip:

pip3 install certifi tkintermapview

Alternatively, you can acquire the stable built packages from the Releases section.

About

An OSM to 3D Model Ready City Generator

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages