Giter Club home page Giter Club logo

zerocity's Introduction

zeroCity

Demonstration.mp4

Procedural City-Generation Project.

This project is a sub-project of the FindingYonghee project.

  • FindingYonghee project has further implemented a Crowd Simulation based on Reinforcement Learning.
  • This project only handles City-Generation.

About the code

[Warning] Because this project was developed with paid assets (3D models, toolkits), we intentionally did not upload them to this repository, so even if you download those assets and run the project, it may not work properly. If you want to test this project, please use released executable file.

Dependencies

Reference Paper
Citygen: An Interactive System for Procedural City Generation

Generation Step Description

Table of Contents

  1. Generate Initial Point & Voronoi Diagram
  2. Set Boundary of Voronoi as Primary Road
  3. Group Voronoi as City Cell & Set City Cell Boundary as Primary Road
  4. Generate Secondary Road & Graph
  1. Generate Primary Road Spline
  2. Generate Secondary Road Spline
  3. Reposition Connector
  1. Generate Primary Buildings
  2. Generate Secondary Buildings

Generate Road and City Cell Data

shapes1

1. Generate Initial Point & Voronoi Diagram

  • Generate initial points with an appropriate distribution using Poisson disk sampling and use them to create a Voronoi diagram.

  • Afther that, use Lloyd's Algorithm to relax Voronoi Diagram with specified iteration count.

2. Set Boundary of Voronoi as Primary Road

  • Set the outermost edges of the Voronoi Diagram as the Primary Road.

  • Primary Road is a wide road, from which the Secondary Road, a narrower road, branches off.

3. Group Voronoi as City Cell & Set City Cell Boundary as Primary Road

  • First, find a bounding rectangle that contains all of the sites in the previously created Voronoi Diagram, and make it 3 times the distance between the centers of each site compared to original Voronoi Diagram, so that each site is larger.

  • This will result in two Voronoi Diagrams, grouping all the Lower Voronoi Diagram sites inside the sites of the Upper Voronoi Diagram (the larger one), which we call City Cells.

    • City Cell is not a site in the Upper Voronoi Diagram, but rather to a set of sites in a grouped Lower Voronoi Diagram. In the following steps, the City Cell is used as the basic unit.
  • After that, All of the outer edges of this City Cell are then set as Primary Roads.

4. Generate Secondary Road & Graph

  • Recursively create a Secondary Road from the Boundary of the City Cell created above.
shapes
  • Each Loop creates a straight road, with the number and direction of roads to be created from the current vertex determined based on a specified Probability.
    • The directions are Left, Forward, and Right, and a Random Angle Offset is added to these to create various shapes of roads.
shapes2
  • Once we know which direction and what size roads will be generated, we need to validate that they are valid. Below, the new vertex is the end point of the road that will be created.

    • Check 01. Is the new vertex inside the site?
      • If not, cancel the road.
    • Check 02. Is the new vertex close enough to other vertices?
      • If the nearest vertex is already connected to more than 4 edges, cancel.
      • If any road intersects the current road, cancel.
      • Otherwise, merge the two vertices.
    • Check 03. Is the new vertex close enough to another edge?
      • If yes, divide the new vertex by the point where it intersects the nearest edge.
    • Check 04. Is the new road intersect with another road?
      • If yes, divide divide the intersecting roads. (new one and old one)
    • If none of the above conditions apply, create the road as is.
  • Repeat this procedure until reached at specified Dimension(Stack).

Generate Road Mesh

shapes3

5. Generate Primary Road Spline

  • Create the actual road mesh based on the road data we have created so far.

  • Use B-Spline to connect the straight roads into a single spline, and if there is an intersection, place a Pre-Defined Intersection Prefab at the location and connect the splines.

    • At this time, if you create a spline using only the previously created points, it will look quite rough, so we create a natural spline by creating Sub-Points using the vectors to the previous and next points based on the created points.
    • Also, if there are vertices that are too close, including sub-points, during the creation process, merge them to maintain the structure.

6. Generate Secondary Road Spline

  • Same as above generation.

7. Reposition Connector

  • Since the previously created road mesh does not fully match the road vertex data, it is possible that the created roads may go off-site or not be attached, so check and fix this.

Generate Buildings

shapes4

8. Generate Primary Buildings

  • Primary Building is a building that is created next to a Primary Road.

  • It tries to place the building within a specified width area based on the vertex pair of the created Primary Road Spline.

    • If there is an overlap or insufficient space, the placement is canceled, and the rotation is set to face the road after placement.

9. Generate Secondary Buildings

  • Secondary Building is a building that is created next to a Secondary Road, placement method is the same as above.

  • Additionally, Parks are placed at regular intervals, and if space is not available, buildings in that space are deleted and Park is placed.

zerocity's People

Contributors

w298 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.