Created: January10, 2024 Updated: January10, 2024
If you want to use coordinates or you are in need of Geo-refererenced terrain in edit mode, this tutorial is for you.
Before generating terrain enable 'Serialize heightmap'.
(Enable it only if you need the terrain data in edit mode or while you transfer terrain data from edit mode to play mode).
A new file will appear in the "Resources/HeightmapsData" folder that bears the same DEM name.
When you create a script for edit mode, you should have access to the container. Before doing any operation you should call GetStoredHeightmap() function to load data stored in HeightmapData.
Eg : var container = GameObject.FindObjectOfType<GISTerrainContainer>();
container.GetStoredHeightmap();
If you want to Get/Set a position use these API:
//Set a position
Player.transform.position = GISTerrainLoaderGeoConversion.RealWorldCoordinatesToUnityWorldSpace(container, Coordinates, StartElevation, SetElevationMode);
//Get a position
var pos = GISTerrainLoaderGeoConversion.UnityWorldSpaceToRealWorldCoordinates(Player.transform.position, container, true, GetElevationMode);
For more details check demo scene number 09 "Get_Set_Position_EditMode".
If you generate a terrain in edit mode and you want to manipulate coordinates in play mode, apply these steps :
From GTL Pro Editor Windows Enable Serialze Heightmap To Store Terrain Data into "GIS Tech\GIS Terrain Loader\Resources\HeightmapData" Folder.
Generate your terrain in edit mode.
In Start() void Call "container.GetStoredHeightmap();" to Read Terrain Data Stored in Edit Mode.
You Can now use any API for Geo-referencing your terrain.
For more details check demo scene number 08 ' GeoRef_LoadDataFromEditMode'