public void UnloadMap() { Textures[0].AlbedoPath = "/env/evergreen2/layers/eg_gravel005_albedo.dds"; Textures[0].NormalPath = "/env/tundra/layers/tund_sandlight_normal.dds"; Textures[0].AlbedoScale = 4; Textures[0].NormalScale = 8.75f; Textures[1].AlbedoPath = ""; Textures[1].NormalPath = ""; Textures[1].AlbedoScale = 4; Textures[1].NormalScale = 4; Textures[2].AlbedoPath = ""; Textures[2].NormalPath = ""; Textures[2].AlbedoScale = 4; Textures[2].NormalScale = 4; Textures[3].AlbedoPath = ""; Textures[3].NormalPath = ""; Textures[3].AlbedoScale = 4; Textures[3].NormalScale = 4; Textures[4].AlbedoPath = ""; Textures[4].NormalPath = ""; Textures[4].AlbedoScale = 4; Textures[4].NormalScale = 4; Textures[5].AlbedoPath = ""; Textures[5].NormalPath = ""; Textures[5].AlbedoScale = 4; Textures[5].NormalScale = 4; Textures[6].AlbedoPath = ""; Textures[6].NormalPath = ""; Textures[6].AlbedoScale = 4; Textures[6].NormalScale = 4; Textures[7].AlbedoPath = ""; Textures[7].NormalPath = ""; Textures[7].AlbedoScale = 4; Textures[7].NormalScale = 4; Textures[8].AlbedoPath = ""; Textures[8].NormalPath = ""; Textures[8].AlbedoScale = 4; Textures[8].NormalScale = 4; Textures[9].AlbedoPath = "/env/evergreen/layers/macrotexture000_albedo.dds"; Textures[9].NormalPath = ""; Textures[9].AlbedoScale = 128; Textures[9].NormalScale = 4; EditMap.PropsInfo.UnloadProps(); EditMap.UnitsInfo.UnloadUnits(); Markers.MarkersControler.UnloadMarkers(); DecalsControler.Current.UnloadDecals(); GenerateControlTex.StopAllTasks(); }
void UpdateScmap(bool Maps) { ScmapEditor.Current.SetWater(); if (Maps) { GenerateControlTex.StopAllTasks(); TerrainMenu.RegenerateMaps(); } }
public void LoadHeights() { if (Teren) { DestroyImmediate(Teren.gameObject); } Teren = Terrain.CreateTerrainGameObject(Data).GetComponent <Terrain>(); Teren.gameObject.name = "TERRAIN"; Teren.materialType = Terrain.MaterialType.Custom; Teren.materialTemplate = TerrainMaterial; Teren.heightmapPixelError = 4f; Teren.basemapDistance = 10000; Teren.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; Teren.drawTreesAndFoliage = false; Teren.reflectionProbeUsage = UnityEngine.Rendering.ReflectionProbeUsage.Off; int xRes = MapLuaParser.Current.ScenarioLuaFile.Data.Size[0]; int zRes = MapLuaParser.Current.ScenarioLuaFile.Data.Size[1]; float yRes = (float)map.HeightScale; float HalfxRes = xRes / 10f; float HalfzRes = zRes / 10f; Data.heightmapResolution = (int)(xRes + 1); TerrainHeight = 1f / yRes; TerrainHeight *= 0.1f; TerrainHeight *= 2; Data.size = new Vector3( HalfxRes, TerrainHeight, HalfzRes ); Data.RefreshPrototypes(); Teren.Flush(); Teren.UpdateGIMaterials(); SyncHeightmap(); Teren.transform.localPosition = new Vector3(0, 0, -HalfzRes); heightsLength = (int)Mathf.Max((map.Height + 1), (map.Width + 1)); heights = new float[heightsLength, heightsLength]; float HeightWidthMultiply = (map.Height / (float)map.Width); int y = 0; int x = 0; int localY = 0; for (y = 0; y < heightsLength; y++) { for (x = 0; x < heightsLength; x++) { localY = (int)(((heightsLength - 1) - y) * HeightWidthMultiply); //heights[y, x] = (float)((((double)map.GetHeight(x, localY)) / HeightResize)); heights[y, x] = (float)(map.GetHeight(x, localY) / HeightResize); // 65536.0 / 2.0 // 32768.0 if (HeightWidthMultiply == 0.5f && y > 0 && y % 2f == 0) { heights[y - 1, x] = Mathf.Lerp(heights[y, x], heights[y - 2, x], 0.5f); } } } // Set terrain heights from heights array ApplyHeightmap(false); GenerateControlTex.StopAllTasks(); GenerateControlTex.GenerateNormal(); GenerateControlTex.GenerateWater(); }