GithubHelp home page GithubHelp logo

tangram-unity's Introduction

Tangram Unity

screenshot

Tangram Unity is a library of tools for using OpenStreetMap data in the Unity3D game engine. This repository contains the code and GUI tools along with an example scene that demonstrates how to use them.

This project uses Unity version 2019.3.0f6.

Quickstart

  1. Create a Nextzen API Key
  2. Open the example scene Assets/Scenes/RegionMapExample.unity in Unity.
  3. Select the Map Builder object in the scene and enter your API key in the "Api Key" field in the inspector.
  4. Press the Download button in the inspector and wait a few seconds for the download to complete.

The scene should now contain geometry from New York City! To learn how to customize your own map with a different style or a different location, check out these documentation pages:

Roadmap

  • Terrain support
  • Tile streaming
  • Map data access from game objects

tangram-unity's People

Contributors

karimnaaji avatar matteblair avatar tallytalwar avatar

Stargazers

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

Watchers

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

tangram-unity's Issues

Custom Data Component

Add a SceneGroupData component that can be optionally aggregated to specific group object for use in gameplay mechanics. The class should also have a specific interface so users would be allowed to add more custom data to the initial data set or overwrite its default content.

For example, features could have information about the feature properties itself (properties),
tiles could have the tile identifier, geo location, bounding boxes etc..

Add README

Add information about the project, code style (documented in #12), how the project is currently setup and a screenshot of example usage.

Add CI statuses.

Add coordinate transform utilities

  • LngLat <-> MercatorMeters
  • MercatorMeters <-> Unity game coordinates
  • Unity developers will need a way to specify the relative transform from geographic coordinates to game coordinates

Add a MercatorMeters type

  • Probably want a struct value type
  • Enforce positive values?
  • toLngLat and fromLngLat (Or maybe these belong in static methods in a separate class?)

Determine attribution requirements

We probably need to attribute OpenStreetMap, but how should we display attribution? In the end, the user will be in control of what's displayed in their game, but we should make it easy to do the right thing.

  • Does attribution need to be visible whenever map data is displayed?
  • Can users include attribution in the credits or "about" sections of their game?

Ability to deactivate threading

For both debugging purposes and to be able to export a WebGL build (System.threading will not be available for those builds), it would be convenient to have a way to simply deactivate threading tasks and let the main thread handle those.

Add a TileAddress type

  • Probably want a struct value type
  • Equality and comparison operators
  • Get origin and size in MercatorMeters

Tile coverage for a fixed area

Given a fixed area as input, we should be able to output the list of tile addresses that cover that area.

Inputs could be:

  • A range of latitude and longitude plus a zoom level
  • A focus point and radius in meters plus a zoom level
  • (Later) The name of a location to geocode

Downloaded area is slightly different from raw OSM data

1
Figure 1 : Choose an area on OSM website and download it.
2
Figure 2: Type in the same longitude and latitude in tangram and download it.
3

In figure 3, the white lines are generated roads meshes based on raw osm data by myself (same with figure 1). The colorful area is generated by tangram-unity plugin. Here you can see that, although they have the same range of lon and lat, the area is different. The world coordinates origin points are same(min lat and min lon of the input area).

Is this slight difference caused by different decimal point precision? How can I let them have same lat and lon?

Incorrect buildings in Bratislava

Hi, this plugin looks very good :). I have tried to download Bratislava and some buildings are ok as 3D objects but most of them does not show as 3D objects but they are flat. I am attaching screenshot. Also you can see there coordinates, so you can try to reproduce it.

bratislava

MVT decoding support

For best performance, we will want to support decoding tile data in the MVT format and to recommend using MVT when multiple formats are available.

Add a LngLat type

  • Probably want a struct value type
  • Want methods for wrapping and clamping latitude and longitude

Geometry symbolization interfaces

The title is a bit abstract, but this is just a way of codifying the way that we specify rules for symbolizing feature geometry. What I'm thinking now is that a rule can be anything that satisfies a specific interface:

// Names subject to change
public interface IStyleRule
{
    StyleOptions StylizeFeature(Feature feature, StyleOptions currentOptions);
}

Where StyleOptions is a collection of fields like Material, Tint, Visible, etc. which are the styling options common to all geometries. Subclasses of StyleOptions could contain fields like Width for linestrings and Extrude for polygons.

An interface like this allows rules to be chained together, with composition that can be totally customized by a user.

The Master Plan

Part 0: Data types and utilities

  • LngLat
  • MercatorMeters
  • TileAddress
  • TileData
  • Coordinate transforms

Part 1: Data sources

  • Asynchronous file/http requests
  • Vector tile format parser(s)

Part 2: Vector data mesh generation

  • Polygon tesselation
  • Polygon extrusion
  • Polyline tesselation
  • Point quads

Part 3: Feature filtering

  • Feature property matching
  • Filter composition
  • Script filters

Part 4: Automatic tile coverage

  • Fixed coverage based on input bounds
  • Streaming coverage following a moving viewport

Part 5: Terrain data mesh generation

  • Elevation grid mesh with normal maps
  • Extruded polygon offsets by elevation grid
  • Polygon and polyline subdivision by elevation grid

Future Parts:

  • Custom location providers
  • Geocoding queries
  • Reverse geocoding queries
  • Routing queries
  • ???

TileIO 404: unable to get any data outside of manhattan

This is a bizarre issue on an abandoned project, but I get TileIO error 404 on any area that's even a decent bit away from the default parameters, and its rather confusing that any latitude and longitude I provide to it that isn't inside or very close to the provided manhattan coordinates immediately break it.

example: montreal:
-73.9550392744427, 45.3263071892754
-73.4566024965003, 45.7194063912574

Add a VectorTileData type

  • Container of FeatureCollections (like GeoJSON "layers")
  • Feature has a geometry container and a dictionary of properties
  • Geometry container needs a list of 2D points and ring indices (and maybe a geometry type, but that could be a derived property)
  • Properties could just be all strings now, not sure about the state of variant types in C# (if we care about compactness we could intern all of the strings in a container within the over-arching VectorTileData structure)
  • Maybe there's an interface that VectorTileData and ImageTileData could both implement (ITileData)?

Fix scaling with real world units

Scale the mesh based on user provided representation for a unity unit.

UI should include a numeric property along with real world units, to answer a question like one unity unit correspond to how many kms, meters or other distance units.

Demos

  • Physics demo (Simple tile with a camera rotating, tapping would throw a cube/sphere on the buildings).
  • Post rendering effect on a simple scene (Initial demo available in this branch).
  • More advanced demos with simple game mechanics.

Host those demos either through a web interface, or app for osx/windows/android online.

Document 3rd-party code

Code like Earcut.cs that was not written by the authors of this repo should retain the original copyright notice and license. We may also want to keep 3rd-party code in distinct folders (it feels a little misleading to keep it in a folder named "Mapzen").

LineString triangulation

Given a LineString as input, we should be able to output vertex positions and indices for a mesh that represents that LineString, with configurable width and other construction options.

TileIO Error: HTTP Error with errorcode: 403

With unity 2017.2.0.f3

25 same errors:

TileIO Error: HTTP Error with errorcode: 403
UnityEngine.Debug:Log(Object)
Mapzen.c__AnonStorey2:<>m__0(Response) (at Assets/RegionMap.cs:119)
Mapzen.Unity.c__Iterator0:MoveNext() (at Assets/Mapzen/Unity/IO.cs:65)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

Apply an epsilon offset to layers

To solve z-fighting issues, each layer that uses different materials and lay on the same plane or have the same extrusion height should be applied an epsilon offset:

screen shot 2017-08-11 at 15 16 46

Add vector tile format parsers

  • JSON formats are probably simplest
  • Latest release of protobuf can generate C# parsers, but requires re-writing mvt.proto in "proto3" syntax
  • Use C# until performance becomes a measurable problem

Custom OpenStreetMap Vector tile server as a replacement for Nextzen?

Hi!
This project seems to be using OpenStreetMap, but the demo scene uses Mapzen / Nextzen.
I have a self-hosted OpenStreetMap tileserver, serving vector tiles and raster tiles rendered by MapBox GL.
Is it possible to use those servers for this project?

I have tried hardcoding the URL to my own server, but I get a lot of these errors when I try to download. I am not sure if the vector formats are incompatible, or if something else needs to change?

Google.Protobuf.InvalidProtocolBufferException: SkipLastField called on an end-group tag, indicating that the corresponding start-group was missing
  at Google.Protobuf.CodedInputStream.SkipLastField () [0x0005f] in <6a29324cea0643159788c5bcf6a69768>:0 
  at Mvtcs.Tile.MergeFrom (Google.Protobuf.CodedInputStream input) [0x0000d] in C:\XXX\Assets\Mapzen\VectorData\Formats\Mvt.cs:146 
  at Google.Protobuf.MessageExtensions.MergeFrom (Google.Protobuf.IMessage message, System.Byte[] data) [0x00020] in <6a29324cea0643159788c5bcf6a69768>:0 
  at Google.Protobuf.MessageParser`1[T].ParseFrom (System.Byte[] data) [0x00019] in <6a29324cea0643159788c5bcf6a69768>:0 
  at Mapzen.VectorData.Formats.MvtTile..ctor (Mapzen.TileAddress address, System.Byte[] data) [0x00073] in C:\XXX\tangram-unity\Assets\Mapzen\VectorData\Formats\MvtTile.cs:34 
  at Mapzen.RegionMap+<>c__DisplayClass16_4.<DownloadTilesAsync>b__2 () [0x00030] in C:\XXX\tangram-unity\Assets\RegionMap.cs:144 
  at Mapzen.Unity.AsyncWorker.ThreadMain () [0x0006e] in C:\XXX\tangram-unity\Assets\Mapzen\Unity\AsyncWorker.cs:124 
UnityEngine.Debug:LogError(Object)
Mapzen.Unity.AsyncWorker:ThreadMain() (at Assets/Mapzen/Unity/AsyncWorker.cs:128)
System.Threading.ThreadHelper:ThreadStart()

Structure for grouping and symbolizing features in a scene

For both a fixed and streaming set of map tiles, we will want to visualize the incoming feature data with a set of rules that are applied systematically. This involves organizing the features into groups (or a hierarchy) using filters, then symbolizing the geometry from those features based on the group(s) they are in and the properties of the features.

In Tangram, this roughly corresponds to the layer hierarchy. We could use a similar hierarchical approach for this library as well.

For a development workflow, this requires that the user can use the Unity Editor to structure the arrangement of groups, the filters for each group, and the symbolizing rules for each group.

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.