-
Notifications
You must be signed in to change notification settings - Fork 8
Quick introduction into libcity
Where to start when you want to build your own virtual city with libcity?
First of all, see the City
class. It's an interface that you'll need to implement while making your own city. As you can see, there are three member variables in the City
class. In these two the whole city will be stored :-).
First one, called map
, stores all the information about roads in the city. Where a certain roads are, where they go, where they intersect with other roads. See the documentation for StreetGraph
class for more information. What you'll need to do is create the streetgraph somehow. You do it manually or automatically or what's most common -- using combination of both. For automatic procedural creation of roads there are few road generators. See RasterRoadPattern
and OrganicRoadPattern
. Detailed overview is available at the road generators page.
Where will be the buildings placed? That's what the other one, zones
variable says. It stores information about spatial division of the whole city. On the top level are city zones. These are districts within the city. You can define your own or generate some using AreaExtractor
class that will go through StreetGraph and find closed loops in it.
When this is done it's up to you to generate some buildings on the created areas and then render everything. For buildings there is Building
class, that implements and L-system rewriting engine with some basic alphabet. You can expand the grammar and add your own rules and their geometrical interpretation for buildings.