6

I was wondering:

Has anyone used spatial data as an input source to build 3D environments and interactive applications with Unity?

The geospatial 3D world is very young, and somewhat immature, while the gaming industry is much more robust and developed. Unity is more highly developed and provides a lot of great options for building 3D environments. However, the typical data sources used in the geospatial world (vectors, imagery, DEMs) are foreign to Unity. I have seen some round about ways to use this data in a Unity project, but I was wondering if anyone has experience or success with this process, and would be willing to share.

  • Ryan, did you get any further with this? I was told that Unreal and Blender could also be possible software. – CARTOS Oct 8 '15 at 5:54
  • Not too much further. I heard the same thing – Ryan Garnett Oct 8 '15 at 10:51
  • Have you tried MapBox SDK for Unity? mapbox.com/unity – Vasanth Reddy Apr 23 '18 at 13:19
3

I've done some work on a prototype that extracts data from the UK Open Survey public DEM data sets for Britain. They have their DSM and DTM files downloadable in ASC format which is quite easy to read into Unity via a C# StreamReader loop. The data can each be stored as float[,] which can easily be applied to Unity terrain heightmaps.

Also using these two arrays of floats, I created a diff array which can then be filtered by a "tolerance" of say 5 metres to figure out likely roof lines, tall trees, etc. If you then run an algorithm to find the edges, you can extrude downwards from the DSM height to the DTM floor to get some approximate building footprints and a point cloud of roof heights. From those you can make some basic Unity meshes for the building outlines. At some point I intend to go back and write an algorithm to calculate where the straight planes are in order to reduce vertices inside a plane.

Open Survey UK also provide a bunch of other data sets, such as Open Map Local, which contains road information and records of building footprints that I found to be somewhat more complete than Open Street Map. I downloaded this data in GML format, which again is quite amenable to being read in by StreamReader (or XmlReader if you want to do the work with XML attributes etc). Other formats such as ESRI and LAZ files, I found harder to get hold of decent file format information, and there are a number of libraries you could probably pull into Unity to handle many of those. I grabbed DotSpatial.Projections from nuget, for example, and that just goes right into a Unity Plugins/ folder and works off the bat. (For nuget libraries with dependencies you may need to put in more effort to get those working.) Anyway with the GML data for roads and buildings, I wrote a parser that basically converted the "geometry" tags into vectors and went from there.

As for other sources of DEM that might not be in ASC or similarly useful formats, one trick is to download and install QGIS, and save out layers in the format you prefer. I'm not an expert in GIS or that software, but it seemed to work when I tried it for an ESRI shapefile. I'd recommend you can also use the command line lastools utilities to pre-convert other types of files such as LAZ and turn them into ASC, rather than try to process the LAZ format natively in Unity itself.

TLDR advice I suppose would be: obtain (or pre-convert) DEM or shape geometry data in a text format that you can read into Unity and then process it further from there.

One other cool thing I tried in the prototype was hooking up the resulting terrain with a Google Street View (all you need is to sign up to a free Google Maps developer API key) and using DotSpatial to convert the British National Grid coordinates to WGS84 to get the street view panorama. I made a render camera for the street view tiles and presto - looking around the blobby textures and seeing how they roughly lined up with the street view actual image!

Anyway, hope that helps and gives you some idea about approaches to try.

2

I once used a DEM raster of a GIS project area and converted it to a height map in photoshop, and then created a Unity Terrain GameObject with it. It actually turned out quite nice. As far as adding other features to a 3d scene in Unity. You can get away with this by setting up a sort of psuedo CRS in which everything in your scene is positioned based on an interpolation of actual projected CRS coordinates. I did this by converting x/y coordinates from a state plane projection to Unity Units, essentially just dividing both x & y by a rather large factor to get the Unity Unit representation closer to zero. This allowed me to put objects into the scene without having massive transform.position objects in the order of hundreds of thousands of units. Of course, after all this was said and done, scaling objects by hand became a rather intensive process.

  • I believe there is also a way to take a DEM raster in Blender and apply a modifier to large subdivided plane to create a "real world" terrain .blend. Unity can then easily import the .blend file. – GeoJohn Aug 23 '16 at 16:33
  • This is an odd thread for GIS SE... I guess it is on topic but kind of a gray area... – GeoJohn Aug 23 '16 at 18:57
1

ESRI's CityEngine has a C++ SDK found on GitHub here which would tie in nicely with Unity and/or Blender. -- Bring them both into a VS project and transform from CGA shape grammar to Unity objects.

This notional method should be effective for Buildings and street-scapes expecially.

1

Melown Technologies is working on integrating their VTS geospatial software stack browser into Unity 3D.

Check it out at https://assetstore.unity.com/packages/tools/terrain/vts-landscape-streaming-plugin-125885

It allows for physical collisions, shadows, optional custom atmosphere, real world coordinate transformations, searching, navigation, etc.

It is, as of now, based on 3D meshes and textures rather than vector graphics.

0

I suggest you take a look at AreaCAD-GIS project. GitHub repository facilitates a project related to INOVA AreaCAD-GIS concept - a set of software tools for design, maintenance and analysis of urban spatially-related structures. Based on popular CAD, GIS and BIM platforms, project integrates expert knowledge on spatial planning and infrastructure networks design using Unity 3D, Autodesk Revit and AutoCAD applications and related APIs. The goal is to create beforementioned platform bindings using INSPIRE data specifications, while leveraging game-like ease of use when it comes to design, simulation and reporting workflows.

0

I suggest you take a look at the following video demonstrating CAD/GIS/BIM technology integration targeting city centre's overall design, modeling and simulation. Software packages used for demonstration: Autodesk Building and Infrastructure Design Suites (AutoCAD, Map 3D, Revit, ...), INOVA AreaCAD-GIS (Client/Server), Unity engine, Autodesk Vasari.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.