public IEnumerator CreateTerrainZoom(int zoom) { Terrain t1 = GetComponent <Terrain>(); t1.basemapDistance = 10000; Latlong RBLl = HarvenSin.pixelToLatlong(new Vector2(512 * 16, 512 * 16), latlongLT, zoom); ElevationData evData = new ElevationData(); //string ElvURL = "http://dev.virtualearth.net/REST/v1/Elevation/Bounds?bounds="+ RBLl.lati+","+latlongLT.longti+","+latlongLT.lati+","+ RBLl.longti+"&rows=32&cols=32&heights=ellipsoid&key="+bingKey; //yield return StartCoroutine(evData.GetDataFormUrl(ElvURL)); yield return(StartCoroutine(evData.GetElv(latlongLT, zoom))); float[,] heightmap = evData.GetHeightMap(); //float[,] heightmap = evData.GetHeightMap(32, 32); t1.terrainData.heightmapResolution = evData.size; t1.terrainData.SetHeights(0, 0, heightmap); //yield return StartCoroutine(GetImageFormTile(latlongLT,16,16,19)); yield return(StartCoroutine(ImageDataP.GetImageFormUrl(latlongLT, 16, 16, zoom))); SplatPrototype[] sp = new SplatPrototype[1]; t1.terrainData.size = new Vector3((float)HarvenSin.Distance(latlongLT.lati, latlongLT.longti, latlongLT.lati, RBLl.longti) * 1000, 10000f, (float)HarvenSin.Distance(RBLl.lati, latlongLT.longti, latlongLT.lati, latlongLT.longti) * 1000f); sp[0] = CreateSplatPrototype(imageCombined, new Vector2(t1.terrainData.size.x, t1.terrainData.size.z), new Vector2(0f, 0f)); File.WriteAllBytes("Assets/TerrainTexture/test.jpg", imageCombined.EncodeToJPG());//output Texture t1.terrainData.splatPrototypes = sp; }
public void OnClick(string message) { if (message == "distance") { double widthD = HarvenSin.Distance(GetTerrain.latlongLT.lati, GetTerrain.latlongLT.longti, GetTerrain.latlongLT.lati, GetTerrain.latlongRB.longti); double heightD = HarvenSin.Distance(GetTerrain.latlongLT.lati, GetTerrain.latlongLT.longti, GetTerrain.latlongRB.lati, GetTerrain.latlongLT.longti); width.text = widthD.ToString("0.000"); height.text = heightD.ToString("0.000"); } if (message == "CreateTerrain") { CreatTerrain = true; } }