Giter Club home page Giter Club logo

geojsoncitybuilder's Introduction

GeoJSON City Builder

OpenUPM version GitHub issues

Unity Package to recreate a 3D-city from GeoJSON files. Currently allows to create extruded objects (e.g. buildings) from polygons and to place prefabs on points.

See for an example on what can be achieved and how to use it, the Waterlooplein 3D project.

Installation

Option 1: Using OpenUPM cli

This package is listed in the OpenUPM repository. Installation:

npm install -g openupm-cli
cd YOUR_UNITY_PROJECT_FOLDER
openupm add com.virgis.geojson.net
openupm add nl.elmarjansen.geojsoncitybuilder

Note that this package depends on the geojson package com.virgis.geojson.net being installed.

Option 2: As a git-link in Unity package manager

  1. Click Window -> Package Manager
  2. Click + -> Add Package from git URL
  3. Type https://github.com/ViRGIS-Team/GeoJSON.Net and click Add
  4. Type https://github.com/ElmarJ/GeoJsonCityBuilder and click Add

Usage

See https://github.com/ElmarJ/geojsoncitybuilder.devenv for a simple working example in Unity. See https://github.com/ElmarJ/Waterlooplein3D/ for a more advanced example (using the Unity HDRP pipeline).

Blocks from geojson polygons

  1. Create an empty GameObject
  2. Click Add Component and add Scripts/GeoJsonCityBuilder/Position on World Coordinates
  3. Set the desired Lat/Long-coordinates for the Unity world origin in the "Position on World Coordinates" component (choose a location central to the area that you want to reconstruct).
  4. Click Add Component and add Scripts/GeoJsonCityBuilder/Blocks From Geo Json
  5. Drag your geojson-file into "Geo Json File". Make sure it has a ".json"-extension; ".geojson" will not work.
  6. Set other settings and materials
  7. Click Generate

Prefabs from geojson polygons

  1. Create an empty GameObject
  2. Click Add Component and add Scripts/GeoJsonCityBuilder/Position on World Coordinates
  3. Set the desired Lat/Long-coordinates for the Unity world origin in the "Position on World Coordinates" component (choose a location central to the area that you want to reconstruct).
  4. Click Add Component and add Scripts/GeoJsonCityBuilder/Blocks From Geo Json
  5. Drag your geojson-file into "Geo Json File". Make sure it has a ".json"-extension; ".geojson" will not work)
  6. Drag your prefab into "Prefab"
  7. Click Generate

Open source credits

This package makes use of the JSONObject library by Matt Schoen

Links

Links kept for reference to similar or otherwise relevant projects:

geojsoncitybuilder's People

Contributors

elmarj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

hengle iamzhai

geojsoncitybuilder's Issues

Refactor code

Code needs a good round of refactoring. E.g.: lots of code duplication in "builder"-classes.

Experiment with Blender Geometry Nodes

Blender 3.0 introduced Geomentry Nodes, which allows (Houdini like) procedural generation of 3D-objects, e.g. depending on dimensions. This could be ideal for the generation of many elements, e.g. bridges, fences and even entire facades.

Unity now has (experimental, beta) support for importing Geometry Nodes (https://docs.unity3d.com/Packages/[email protected]/manual/GeometryNodes.html), which opens up this powerful feature for usage in Unity.

Example of how city-generation is accomplished with Houdini: https://www.sidefx.com/tutorials/city-building-with-osm-data/

Settings (height, rendering etc.) on a per (random) facade-type basis.

Allow users to specify different custom building specification, including (but not limited to) the facade material, default height, UV-settings and pointed roof-settings as basis for random seection. This further expands the current random selection of only the facade material, and allows users to specify several "types" of buildings, each with their own specifications, to randomly choose from.

Particularly necessary to implement realistic pointed rooftops, as these settings have to be customized on a per-material-basis (see also ElmarJ/waterlooplein-timemachine#3).

Support .geojson extension

Currently, the UI only accepts .geojson with a .json extension (because automatically supported by Unity's text-source UI element). Obviously, the .geojson extension is more common and should be supported as well. Additionally: saves me another small step in the process of integrating changes from the https://github.com/ElmarJ/Amsterdam.1892.GeoJSON project.

Move Json & GeoJSON code to Editor assembly

As there is no runtime evaluation of Json or GeoJSON, leaving this code in the runtime assemblies is not necessary. Moreover, since the used JSON submodule now includes editor-only-code, keeping it in the runtime assembly prevents the project from compiling (as it can't access the unity editor libraries).

Templating of prefabs

Introduce "templating" of prefabs, which would allow us to set arbitrary fields on prefabs per geojson-feature from arbitrary feature properties (or even geometries - converted to unity-vectors and polygons).

This would allow for a much more decoupled, flexible and generic code-base, and also for merging the prefab-builder with the polygon-builders.

E.g.:

  • property:name -> GameObject Name
  • property:start-year -> ExistenceController Start
  • geometry:polygon -> BlocksFromPolygon floorPolygon (converted to Unity polygon)

etc.

Use ECS for Time Machine functionality

Migrate to an Entity Component System (DOTS) approach for filtering GameObjects for time machine functionality. This approach is very similar to what we're already doing here, but than using a formally supported approach (that might also come with some perfomrance benefits).

Probably not before migrating to 2022 LTS (by the time that gets released)

Move all mesh generation logic to Editor assembly

Most of the logic now resides in runtime classes, even though none of it will ever be used at runtime. We should aim at making the runtime-classes just an empty shell, and move all the generation code to editor classes.

Make length of material-list UI dynamic

Currently, the number of alternative (randomly chosen) materials is hard coded into the settings UI. Make this a flexible list that allows users to "add" or "remove" to have any arbitrary number of materials.

Generate mesh around line or polygon border

Allow to generate a shape (mesh) around the lines (borders) of a Polygon (and potential also geojson LineString). Specifically: generate along each line four faces (inner/outer/top/left) at specified distances from the line to create shapes that resamble a squared donut. This would, for example, allow to easily generate a stone band / border along canals, generate sidewalks around building blocks and generate curbs around sidewalks.

Redesign coordinate-provider

Current architecture, with "Position on World Coordinates" component in parent gameobject is not ideal: because of its implicit nature, it's difficult to discover intuitively and it's difficult to debug. Probably better to implement this with an explicit link to a world-position-provider.

Scale objects

Would like to have a way to place bridges - which can be stretched and rotated into the right (compass) direction. Two possible solutions:

  • Add heading, height and scale as options in geojson properties, affecting placement in Unity. Disadvantage: heading has to be typed in (instead of graphically placed) in GIS programs like QGIS.

  • Support placement of prefoab based on a single line (heading + scale) or 4 -sided polygon (heading, + 2D scale). [not convinced yet that this would work, but would be great to be able to simply 'draw' how you expect the prefab to appear).

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.