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(); } }
void Awake() { Current = this; }
public void RegenerateMaps() { GenerateControlTex.GenerateWater(); GenerateControlTex.GenerateNormal(); }
void Update() { Invert = Input.GetKey(KeyCode.LeftAlt); Smooth = Input.GetKey(KeyCode.LeftShift); if (CurrentPage != 0) { return; } if (PaintStarted && Input.GetMouseButtonUp(0)) { ScmapEditor.Current.Teren.ApplyDelayedHeightmapModification(); ScmapEditor.Current.Teren.Flush(); } if (Edit.MauseOnGameplay || ChangingStrength || ChangingSize) { if (!ChangingSize && (Input.GetKey(KeyCode.M) || ChangingStrength)) { // Change Strength if (Input.GetMouseButtonDown(0)) { ChangingStrength = true; BeginMousePos = Input.mousePosition; StrengthBeginValue = BrushStrength.value; } else if (Input.GetMouseButtonUp(0)) { ChangingStrength = false; } if (ChangingStrength) { BrushStrength.SetValue((int)Mathf.Clamp(StrengthBeginValue - (BeginMousePos.x - Input.mousePosition.x), 0, 100)); //BrushStrengthSlider.value = Mathf.Clamp(StrengthBeginValue - (BeginMousePos.x - Input.mousePosition.x), 0, 100); UpdateMenu(true); //UpdateBrushPosition(true); } } else if (Input.GetKey(KeyCode.B) || ChangingSize) { // Change Size if (Input.GetMouseButtonDown(0)) { ChangingSize = true; BeginMousePos = Input.mousePosition; SizeBeginValue = BrushSize.value; } else if (Input.GetMouseButtonUp(0)) { ChangingSize = false; } if (ChangingSize) { BrushSize.SetValue(Mathf.Clamp(SizeBeginValue - (BeginMousePos.x - Input.mousePosition.x), 1, 256)); //BrushSizeSlider.value = Mathf.Clamp(SizeBeginValue - (BeginMousePos.x - Input.mousePosition.x), 1, 256); UpdateMenu(true); UpdateBrushPosition(true); } } else { if (!PaintStarted && Input.GetKey(KeyCode.LeftControl)) { if (CameraControler.Current.DragStartedGameplay) { if (UpdateBrushPosition(false)) { } } if (Input.GetMouseButton(0)) { BrushTarget.SetValue(CameraControler.GetLastScmHeight()); } else if (Input.GetMouseButton(1)) { BrushMini.SetValue(CameraControler.GetLastScmHeight()); } else if (Input.GetMouseButton(2)) { BrushMax.SetValue(CameraControler.GetLastScmHeight()); } } else if (Edit.MauseOnGameplay && Input.GetMouseButtonDown(0)) { if (UpdateBrushPosition(true)) { ScmapEditor.Current.Teren.heightmapPixelError = 20; GenerateControlTex.StopGenerateNormal(); ScmapEditor.Current.TerrainMaterial.SetFloat("_GeneratingNormal", 1); PaintStarted = true; SymmetryPaint(); } } else if (Input.GetMouseButton(0)) { if (CameraControler.Current.DragStartedGameplay) { if (UpdateBrushPosition(false)) { } SymmetryPaint(); } } else if (Input.GetMouseButtonUp(0)) { PaintStarted = false; ScmapEditor.Current.Teren.heightmapPixelError = 4; if (Painting) { Painting = false; RegenerateMaps(); } } else { UpdateBrushPosition(true); } } } if (TerainChanged && Input.GetMouseButtonUp(0)) { MapLuaParser.Current.History.RegisterTerrainHeightmapChange(beginHeights); TerainChanged = false; } BrushGenerator.RegeneratePaintBrushIfNeeded(); }
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(); }
void Update() { Invert = Input.GetKey(KeyCode.LeftAlt); Smooth = Input.GetKey(KeyCode.LeftShift); if (CurrentPage != 0) { return; } if (PaintStarted && Input.GetMouseButtonUp(0)) { ScmapEditor.SyncHeightmap(true); } if (Edit.MauseOnGameplay || ChangingStrength || ChangingSize) { if (!ChangingSize && (KeyboardManager.BrushStrengthHold() || ChangingStrength)) { // Change Strength if (Input.GetMouseButtonDown(0)) { ChangingStrength = true; BeginMousePos = Input.mousePosition; StrengthBeginValue = BrushStrength.value; } else if (Input.GetMouseButtonUp(0)) { ChangingStrength = false; } if (ChangingStrength) { BrushStrength.SetValue((int)Mathf.Clamp(StrengthBeginValue - (BeginMousePos.x - Input.mousePosition.x), 0, 100)); //BrushStrengthSlider.value = Mathf.Clamp(StrengthBeginValue - (BeginMousePos.x - Input.mousePosition.x), 0, 100); UpdateMenu(true); //UpdateBrushPosition(true); } } else if (KeyboardManager.BrushSizeHold() || ChangingSize) { // Change Size if (Input.GetMouseButtonDown(0)) { ChangingSize = true; BeginMousePos = Input.mousePosition; SizeBeginValue = BrushSize.value; } else if (Input.GetMouseButtonUp(0)) { ChangingSize = false; } if (ChangingSize) { BrushSize.SetValue(Mathf.Clamp(SizeBeginValue - (BeginMousePos.x - Input.mousePosition.x), 1, 256)); //BrushSizeSlider.value = Mathf.Clamp(SizeBeginValue - (BeginMousePos.x - Input.mousePosition.x), 1, 256); UpdateMenu(true); UpdateBrushPosition(true); } } else { if (!PaintStarted && Input.GetKey(KeyCode.LeftControl)) { if (CameraControler.Current.DragStartedGameplay) { if (UpdateBrushPosition(false)) { } } if (Input.GetMouseButton(0)) { BrushTarget.SetValue(CameraControler.GetLastScmHeight()); } else if (Input.GetMouseButton(1)) { BrushMini.SetValue(CameraControler.GetLastScmHeight()); } else if (Input.GetMouseButton(2)) { BrushMax.SetValue(CameraControler.GetLastScmHeight()); } } else if (Edit.MauseOnGameplay && Input.GetMouseButtonDown(0)) { if (UpdateBrushPosition(true)) { ScmapEditor.Current.Teren.heightmapPixelError = 20; GenerateControlTex.StopGenerateNormal(); ScmapEditor.Current.TerrainMaterial.SetFloat("_GeneratingNormal", 1); PaintStarted = true; RecalcTerrainClamp(); SymmetryPaint(); } } else if (Input.GetMouseButton(0)) { if (CameraControler.Current.DragStartedGameplay) { if (UpdateBrushPosition(false)) { } RecalcTerrainClamp(); SymmetryPaint(); } } else if (Input.GetMouseButtonUp(0)) { } else { UpdateBrushPosition(true); } } } if (!CameraControler.IsInputFieldFocused()) // Ignore all unput { if (Input.GetMouseButton(0)) { } else if (KeyboardManager.SwitchTypeNext()) { int SelectedBrush = 0; for (int i = 0; i < BrushTypes.Length; i++) { if (BrushTypes[i].isOn) { SelectedBrush = i; //BrushTypes[i].isOn = false; } } SelectedBrush++; if (SelectedBrush >= BrushTypes.Length) { SelectedBrush = 0; } BrushTypes[SelectedBrush].isOn = true; } else if (KeyboardManager.SwitchType1()) { BrushTypes[0].isOn = true; } else if (KeyboardManager.SwitchType2()) { BrushTypes[1].isOn = true; } else if (KeyboardManager.SwitchType3()) { BrushTypes[2].isOn = true; } else if (KeyboardManager.SwitchType4()) { BrushTypes[3].isOn = true; } if (KeyboardManager.IncreaseTarget()) { if (BrushTarget.value < 256) { BrushTarget.SetValue((int)BrushTarget.value + 1); } } else if (KeyboardManager.DecreaseTarget()) { if (BrushTarget.value > 0) { BrushTarget.SetValue((int)BrushTarget.value - 1); } } } if (Input.GetMouseButtonUp(0)) { if (TerainChanged) { Undo.RegisterUndo(new UndoHistory.HistoryTerrainHeight(), new UndoHistory.HistoryTerrainHeight.TerrainHeightHistoryParameter(beginHeights)); TerainChanged = false; } if (Painting) { Painting = false; RegenerateMaps(); } PaintStarted = false; ScmapEditor.Current.Teren.heightmapPixelError = 4; } BrushGenerator.RegeneratePaintBrushIfNeeded(); }
public void RegenerateMaps() { GenerateControlTex.GenerateWater(); GenerateControlTex.GenerateNormal(); WavesRenderer.ClearShoreLine(); }