Search Unity

Import real world terrain into Unity (FREE)

Discussion in 'Made With Unity' started by SmellyDogs, Sep 23, 2013.

  1. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    This is a free bit of code/tutorial for people who want to know how to import real world data into Unity. You will notice there are several packages about that are quite costly. But here I show you how do that for free.

    $terranator_4.jpg
    Import real world terrain into Unity with 2-3 mouse clicks.
    Downside of this project is that free online WMS (Web Mapping Services), isn't so common anymore and the only free ones have LOW RES terrain (maybe you can still use it for a flight sim). If we could re-wind to 2011 it would be a different story with NASA worldwind (better than Google earth and open source), but unfortunately they couldn't afford to keep servers up.

    If you want you can setup a WMS to run on your hard drive instead and acquire a data set from somewhere like USGS, that would be a better solution. You can buy the DVDs of data really cheap or just download it for free (takes a while cause the dataset is huge - terrabytes). Then you can have much higher res data.

    So I am still not happy with no good online WMS so I have made a Bing Maps one, that will be free too, in fact its against the rules to sell the data. You will have high res data to download. Bing Maps API uses JSON, a bit more of a current approach. I will upload if anyone is interested.

    All the source code is included, just download the zip, unzip it into your project and then a menu called "TerraNator" will appear.
    Just drag the white box over the region of interest then click download button.
     

    Attached Files:

  2. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
    Hello. Exelent system.

    But there are some problems.
    You can't use namespace for Monobehavior scripts.
    So :

    Code (csharp):
    1.  
    2. namespace SmellyDogs
    3. {
    4. public class TerraNator : EditorWindow
    5. }
    6.  
    throw error :

    Code (csharp):
    1.  
    2. Instance of TerraNator couldn't be created because there is no script with that name.
    3. UnityEditor.EditorWindow:GetWindow(Type)
    4. SmellyDogs.TerraNator:CreateWindow() (at Assets/TerraNator/TerraNator.cs:54)
    5.  
    And : window.maximized = false; // Doesn't exist in unity < 4.2. use IF_DEF UNITY_4_2
     
  3. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    I should point out this ran fine on Unity 4.1 (if Unity did indeed remove that method then...wow...what can I say).
    But theres no monobehaviors here, so the namespace is fine (he says, using 4.1 here).
     
  4. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    Yes you can. Looks like you're using an older version.
     
  5. ChristianLinnell

    ChristianLinnell

    Joined:
    Jan 7, 2013
    Posts:
    18
    Yeah!!
     
  6. miniduck

    miniduck

    Joined:
    Sep 27, 2012
    Posts:
    117
    Good work :)
    I thought Bing licence doesn't allow storing the tiles locally?
     
  7. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    Yes we need to be careful not to break any license agreements with Bing. In short I'm not clear if you can use this data for your games, unless you buy a commerical license. Its probably ok to use for free stuff. With my free license it prints a big "copyright" embedded into the textures so that's a clear indication.

    http://www.microsoft.com/maps/product/terms.html

    As far as storing files locally goes, I don't see anywhere where it says that you cannot do that, which would be a little odd anyway because their API serves data direct to your HD. Although I have seen people writing that it breaks the agreement, it seems to refer to offline usage rather than using a local storage. So yes you are probably correct that you couldn't use Bing for games without a special license.
     
    Last edited: Sep 26, 2013
  8. jeffmorris1956

    jeffmorris1956

    Joined:
    Jul 3, 2012
    Posts:
    276
    The map window in TerraNator tool is either too small or I can't zoom into the area where I want to download the data from. Any suggestions?
     
  9. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    Great stuff Smelly Dog.

    Yes a zoom on the maps tool would be great.

    I seemed to have run into an error. When importing terrain, it took forever and never did it. Possibly find way to make a smaller selection.

    I had to force quit.

    Then I went to do it again and the tab did not show up. I re-imported the asset again ...still no go.
     
    Last edited: Sep 28, 2013
  10. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    Yep that's because the servers are down, this is a big problem with free WMS. Try again later.

    I'm working on one that pulls data from a more reliable source, using the ESRI REST servers.

    Even though it works very well, I pulled the plug on Bing as I'm wary of the copyright issues. :(

    As far as map size is concerned well....I guess I can give a bigger map next time.
     
  11. pixelsteam

    pixelsteam

    Joined:
    May 1, 2009
    Posts:
    924
    I think a smaller map...not so much terrain.
    When I did my selection from the map it was like all of Portugal;)
     
    Last edited: Sep 28, 2013
  12. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    Uh, WMS only gives you textures, so your terrain is 2D. Am I missing something important here? Even for a flight sim, in the 21st century you'd want 3D terrain (mountains at least).
     
  13. SmellyDogs

    SmellyDogs

    Joined:
    Jul 16, 2013
    Posts:
    387
    Technically you want WCS but there's no reason a WMS cannot serve heights, e.g. Geotiff, greyscale heights, whatever - its just a raster the same as a map, you just need to interpret the data differently. In this case height is just inferred from GTOPO30.
     
  14. Jasper1900

    Jasper1900

    Joined:
    Mar 15, 2013
    Posts:
    26
    I was wondering whether you are still updating this amazing asset?

    Can I import Google Earth maps for better detail?
     
  15. allenwyma

    allenwyma

    Joined:
    Jul 15, 2014
    Posts:
    1
    Was trying to get this too work. In my project folder, I have several folders. Do I just drop it in the project's root directory or into Assets or what? I'm using the latest version of Unity. Even if I have to modify the source, it's fine with me, I'm just not getting thse files to register at all.

    Can someone has has successfully imported theses files point me in the right direction?

    Thanks.
     
  16. Gav122

    Gav122

    Joined:
    Jul 22, 2014
    Posts:
    1
    ummm... im new to untiy and i have a question... how do I import it?
     
  17. KheltonHeadley

    KheltonHeadley

    Joined:
    Oct 19, 2010
    Posts:
    1,685
    Pretty cool.
     
    Deleted User likes this.
  18. bcros

    bcros

    Joined:
    Mar 17, 2013
    Posts:
    1
    Hello,

    Could someone tell me if it runs on Unity 4.5, please ?
    Menu doesn't display.

    Thank you

    Bruno
     
  19. kejsistruga

    kejsistruga

    Joined:
    Apr 1, 2017
    Posts:
    1
    Hello , how were you able to install this asset ? Seems it doesnt work in Unity 5.6 @SmellyDogs
     
  20. TerraUnity

    TerraUnity

    Joined:
    Aug 3, 2012
    Posts:
    1,251