One script generates the whole village — Blender as our level editor
Devlog #3. In #2 we showed point lights placed in Blender traveling inside the .glb. That raised an obvious question: if lights can be authored there, why not the whole city?
One command, one village
blender -b -P gen_cena.py -- --seed 7 — headless, deterministic. The same seed always produces the same village: house variants (5 footprints), trees, rocks, water channels, laid out on a grid. Change the seed, get a different layout. No manual placement, no editor session needed for bulk content.
The terrain problem: nothing floats, nothing buries
A generated village over flat ground looks fake; over real relief it breaks naive placement. So the script builds actual terrain (terrain.build_relief) and then raycasts every instance against it (BVH tree snap):
- Houses anchor at the lowest corner — the floor never dips below terrain; a 120px foundation ring covers the gap. The script even warns itself when a hill intrudes more than the foundation can hide.
- Props center on their midpoint.
- Water sinks to the bottom of its channel.
No blind Z coordinates anywhere — the ground decides where things stand.
The output IS the engine's map format
Here's the part that makes the pipeline special: the script doesn't emit a scene for Blender — it emits placements.json, which is literally our engine's MapDef layer format. Every entry is a layer: file, x, y, z (the snapped height), floor, hideIn, sortY — plus the entities and collision footprints. The runtime reads it directly. Blender isn't a content tool that exports assets; it's the level editor that exports the map.
Details worth stealing
- Roofs are separate GLBs (
casa_*_teto.glb) — aligned by x,y,z with the body. When the player walks inside, the engine hides exactly that roof (hideIn) without touching the mesh. - Door lights come free — each house gets a warm point light at the entrance (KHR_lights_punctual, the trick from devlog #2) — the street lights itself.
- One grayscale texture, all the tints — pixel-art tileable textures with NEAREST sampling; the color lives in the material factor, so one texture serves every house variant.
- Self-checking preview — the script also renders a tilt-shift QC shot (100mm, DoF f/2.8, bloom) so we can eyeball the layout before the engine ever sees it.
Why this matters
A small team can't hand-place a city. But a script that knows our collision footprints, our texture rules, our light conventions and our map format can generate one — and regenerate it when the design changes. The artist curates the rules; the seed produces the content.
What's next
Devlog #4: interactive doors — how a static mesh became a walkable interior with its own camera rules.