Implementation Cities

msteiger

Active Member
Contributor
World
Architecture
Logistics
Name: Cities
Summary: Procedural generation of settlements and infrastructure
Scope: Mod (extra content)
Current Goal: Detailed auto-generation of world content
Phase: Implementation (being worked)
Curator: msteiger
Related: Content: Fences, Soils, Minerals - Functionality: Quests, NameGenerator
Repository: https://github.com/Terasology/Cities

This module is about automatic generation of world content. Based on random number generators it creates the entities in the following order:
  • Terrain height map (in contrast to PerlinWorldGen, this is purely 2D)
  • Large-scale regions such as lakes, deserts, forests
  • Their shape is identifed using a contour tracing algo.
  • Settlements sites (a spot on the map)
  • Roads between settlements (yes, before most other content is created)
  • Town walls and gates
  • Important (central) buildings such as churches
  • Housings, etc.
I plan to do in the future:
  • Improved roads (requires Bresenham-Murphy)
  • Bridges (requires Bresenham-Murphy)
  • Quests (requires proper naming of entities and a working Quest module)
  • Improve the preview GUI (show heightmap, settlements, etc)
  • Add more parameter sliders to the GUI to enable the user to config the world like in DF
Please refer to the github page for the most recent updates.

NOTE: The content of post has been edited heavily to reflect recent changes
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Take a look at the legacy branch / build - there is a little more terrain gen stuff in there, in particular the "Perlin with Setup" option that includes a map of the spawn area before you start the game with a pile of configurable parameters. MPratt did that but has since gone MIA :(

We need that rewritten for the latest codebase and indeed with some related GUI improvements, maybe based on NUI?

I consider it a good example of a first step toward a more comprehensive (and configurable) world gen. A second pass might add options like world size / shape for finite world alternatives, like the one we expect to use for L&S. Then a way to plug in arbitrary generators at different stages like city and road generators, again configurable. Maybe a real-time generation world map a.k.a. DF :)

There is a ton of world gen info in the forum, but a bit all over the place. With Nym Traveel running too low on time to maintain the World Lead role we're really sort of hurting for a new organizer in that area.

The height map generator has been used creatively by creating height maps from converting images and such outside the game. Laurimann contributed the external PlaTec generator and Nym made a climate simulator to apply temperature to a height map.

Also: Yes the current Perlin is very hilly. That's fine for areas meant to be hilly, but we also need flatter areas.
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
I know one of our generators (not sure which) has different biomes (desert, hills, plains, etc).

The big thing is we need to change is the way world generation works to be friendly for extension. What I would envision is broadly splitting into two halves:
  1. The first provides an abstract description of the world. Height maps, road maps, vegetation density, locations of interest, caves, basically all the features of the world would be described here - but not at a block-by-block level.
  2. The second half provides the conversion from the abstract description to actual chunks and blocks (effectively, rasterises it).
Obviously there is overlap - if the first half provides road maps, the second half needs the ability to apply them. But separating these means you can replace the road map generating code with a different implementation or introduce a generator that adds extra roads, but not have to worry about how they are converted into the world. Or on the other end change how roads are applied to the world (add milestones and light posts) without having to mess with where they are placed.

So the goal then would be an architecture that allows modules to plug in different abstract generators and raterisers.

A third feature we need to look at is modules adding configuration options and ensuring world gen configuration is saved in a world - at the moment the generation config lives outside the world, which means you can change it, breaking existing worlds. This is probably dependent on NUI though.
 

msteiger

Active Member
Contributor
World
Architecture
Logistics
Ok, I've done a few things by now.

a) For resons of simplicity, the code related to this task is in a separate project (a module actually). I wonder where I should put it om github? A new project? to the other Modules in Terasology? Part of TS and PR later? I think that having it as a Module at github/Terasology might make sense ..

b) The first screenshot of the world generator is attached. I used swing to render for this, but I plan to properly integrate it into TS soon. It's a set of "settlements" that is connected by roads.Next step is to bundling parallel roads before I get into city modeling.
 

Attachments

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Nice! Yes ideally we'd put world gen implementation into modules that the engine knows how to load. Problem is .... it doesn't because the big overarching world gen framework doesn't exist yet, heh :)

If you'd still like a module to play around with just let me know a name and I'll create it under the Terasology organization. Could even make a job for it in Jenkins if it compiles without hacks (often these things uncover new things we need to hit with @API or even have to run experimentally with the security manager disabled)

Also: Pinging Skaldarnar for procedural goodness!
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
Hehe, great work msteiger :)

Have you seen the resoures on city/village modelling in the other threads by chance? I've found a lot of papers regarding city generation and road networks, maybe they are helpful to you ;)

I wish I could spent more time on the project right now, but exams are near.... :/
 

msteiger

Active Member
Contributor
World
Architecture
Logistics
Skaldarnar - No I didn't - thanks for the hint. I will check that. Maybe we can have a chat about urban modeling? On IRC or direct conversation (forum) maybe?

Cervator - Thanks too :) I called it "Cities" but I could live with a different name, too. It should run as-is, but I will double-check asap..

@everybody: Roads now mutually attract each other. If they are close enough (on the same block) they are merged into a new and bigger one.
merged_roads.png
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Done!

https://github.com/Terasology/Cities
http://jenkins.movingblocks.net/view/ModulesPending/job/Cities/

Team "Cities" on GitHub also created with msteiger in it for access.

Name isn't too important just yet, I imagine long-term the different pieces that come out of it will split off akin to Portals (spinning off Spawning and Holdings)

Edit: Forgot to mention - if you have unit tests let me know. I have to enable those in Jenkins as leaving the option enabled with no actual unit tests causes failures :)

Feel free to spin up an incubator for the module as well
 

msteiger

Active Member
Contributor
World
Architecture
Logistics
Short update: Merging roads was buggy and an implementation that supports merging arbitrary roads is quite challenging. This is why I decided to remove it for now :(
The good news is that

  • with some randomness to the road segments they look ok
  • a spline interpolator with thickness makes them look quite nice. Note that the roads are actually connected at the center centers. Also crossings look very nice.
  • LotGenerators create allotments for buildings (black squares)
  • Intersection tests so that no building is placed on a road
2013-12-09_road_splines.png


As discussed with Skaldarnar, the next thing on my ToDo list is to get this properly into TS.
  • Modules needs to be able to register WorldGenerators
  • WorldGenerator need specific config components
  • Convert Swing BufferedImage to actual blocks
  • Define a map between block types and blocks, for example ( "townhall/wall/front" -> "block:concrete" )
I will keep you posted on how it guys and feedback is always welcome :)
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Nice! Have a World badge :)

Are you up for looking at the overall world gen "flow" framework we need, or hoping somebody else will get that working?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
We've talked about it on IRC and in assorted world gen related threads now and then, as well as on GitHub - in short it is the engine support for plugging in world gen modules at different phases, both at the high level (no blocks yet) and low level (blocks). Or in other words the "modding API" for world gen stuff.

Several efforts started on the topic, you're currently it for this round :)

Previous rounds included piecing out the different phases like world --> continents / height map --> river placement --> city placement --> road placement --> lot placement --> etc etc etc. With each layer pluggable for alternative implementations.
 

msteiger

Active Member
Contributor
World
Architecture
Logistics
Hooray! The first rasterized sectors made it into TS ...



The roads in the picture above (yes, these are roads!) are rasterized manually, but it's faster than I expected.
Next step is to define a few sample buildings. Can here who can sketch a church/townhall/inn/sawmill? :rolleyes:
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Nice work!

Badgering of SuperSnark for sketches successful! He has some existing Light & Shadow building sketches too :)

The grammar system by Skaldarnar should be able to actually put the individual buildings together in a procedural fashion. Drawback is that I don't think it is ready for the new structure (particularly could use the batched lighting updates), Skaldarnar himself has been low on time (or are exams about to finish?), and sdab who was helping might be MIA :(
 

msteiger

Active Member
Contributor
World
Architecture
Logistics
Great, thanks! Can you draw some rasterized blueprints of theses? Maybe even including height? I have a 3D painter ready and it works like this:
Code:
fill(Vector3i from, Vector3i to, BlockType type)
You can draw a wall that is 10 blocks long and 5 high like this:
Code:
fill([0, 0, 0], [10, 5, 1], Type.BRICK)
If we had code like this for different building types, I could integrate them easily in TS. Towers and castle walls would be quite cool..
Here's what it looks like with simple housings (rectangular blueprint, 1 door, half-flat roof)

 

msteiger

Active Member
Contributor
World
Architecture
Logistics
It looks a lot better in Terasology ...


I could use more assets, though. There are a few in the "Soils" and "Minerals" projects, but only a few and not building-related. Any ideas?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps

glasz

Active Member
Contributor
Art
msteiger : maybe you could do a short list of textures you'd like to use? I'm not very good at texturing myself, but maybe i could give it a try. These are still 16x16 textures, right?
 
Top