void OnGUI() { if (!Started) { return; } // Label Camera MainCam = CameraControler.Current.Cam; Rect CamRect = MainCam.pixelRect; Rect UiRect = new Rect(CamRect.x, CamRect.y + (Screen.height - CamRect.height), CamRect.width, CamRect.height); GUI.BeginScrollView(UiRect, Vector2.zero, new Rect(0, (Screen.height - CamRect.height), CamRect.width, CamRect.height), false, false); Vector3 Center = (Begin + End) / 2f; Vector3 ScBegin = ScmapEditor.WorldPosToScmap(Begin); Vector3 ScEnd = ScmapEditor.WorldPosToScmap(End); ScBegin.y = 0; ScEnd.y = 0; float Distance = Vector3.Distance(ScBegin, ScEnd); DrawGuiLabel(MainCam, CamRect, Center, Distance.ToString("N2"), LabelStyle); GUI.EndScrollView(); }
public void Bake() { //Group.Blueprint = GetGamedataFile.FixMapsPath(Group.Blueprint.Replace("\\", "/")); BlueprintPath = Group.Blueprint.Replace("\\", "/"); if (!BlueprintPath.StartsWith("/")) { BlueprintPath = "/" + BlueprintPath; } BlueprintPath = GetGamedataFile.FixMapsPath(BlueprintPath); Position = ScmapEditor.WorldPosToScmap(Obj.Tr.position); RotationX = Vector3.zero; RotationY = Vector3.zero; RotationZ = Vector3.zero; MassMath.QuaternionToRotationMatrix(Obj.Tr.localRotation, ref RotationX, ref RotationY, ref RotationZ); Scale = Obj.Tr.localScale; if (Group.PropObject.BP != null) { Scale.x /= Group.PropObject.BP.LocalScale.x; Scale.y /= Group.PropObject.BP.LocalScale.y; Scale.z /= Group.PropObject.BP.LocalScale.z; } }
public static void Generate(ref Texture2D WaterTex, ScmapEditor Map){ Color[] AllColors = WaterTex.GetPixels (); float WaterHeight = Map.map.Water.Elevation * 0.1f; if (WaterHeight == 0) WaterHeight = 1; float WaterDeep = Map.map.Water.ElevationAbyss * 0.1f; float DeepDifference = (WaterHeight - WaterDeep) / WaterHeight; float Width = WaterTex.width; float Height = WaterTex.height; int i = 0; int x = 0; int y = 0; float WaterDepth = 0; for (x = 0; x < WaterTex.width; x++) { for (y = 0; y < WaterTex.height; y++) { //int i = x + y * WaterTex.width; i = x + y * WaterTex.width; //i++; WaterDepth = Map.Data.GetInterpolatedHeight (x / Width, 1f - y / Height); WaterDepth = (WaterHeight - WaterDepth) / WaterHeight; WaterDepth /= DeepDifference; AllColors [i] = new Color (AllColors [i].r, Mathf.Clamp01 (WaterDepth), (1f - Mathf.Clamp01(WaterDepth * 100f)) , 0); } } WaterTex.SetPixels(AllColors) ; WaterTex.Apply (); }
GameObject[] ReadUnitsStorage(UnitsStorage Data) { List <GameObject> CreatedUnits = new List <GameObject>(); if (Data != null && Data.Units != null) { for (int i = 0; i < Data.Units.Length; i++) { SaveLua.Army.Unit NewUnit = new SaveLua.Army.Unit(); NewUnit.Name = SaveLua.Army.Unit.GetFreeName("UNIT_"); NewUnit.type = Data.Units[i].ID; NewUnit.orders = Data.Units[i].orders; NewUnit.platoon = Data.Units[i].platoon; if (!ScmapEditor.Current.Teren.terrainData.bounds.Contains(ScmapEditor.Current.Teren.transform.InverseTransformPoint(Data.Units[i].pos))) { Vector3 Offset = ScmapEditor.Current.Teren.transform.TransformPoint(ScmapEditor.Current.Teren.terrainData.bounds.center) - Data.Center; Offset.y = 0; Data.Units[i].pos += Offset; } NewUnit.Position = ScmapEditor.WorldPosToScmap(Data.Units[i].pos); NewUnit.Orientation = UnitInstance.ScmapRotationFromRotation(Data.Units[i].rot); FirstSelected.Source.AddUnit(NewUnit); NewUnit.Instantiate(); SnapAction(NewUnit.Instance.transform, NewUnit.Instance.gameObject); CreatedUnits.Add(NewUnit.Instance.gameObject); } } return(CreatedUnits.ToArray()); }
public void AddTerrainHeight() { int h = ScmapEditor.Current.Teren.terrainData.heightmapHeight; int w = ScmapEditor.Current.Teren.terrainData.heightmapWidth; ScmapEditor.GetAllHeights(ref beginHeights); MapLuaParser.Current.History.RegisterTerrainHeightmapChange(beginHeights); float Value = float.Parse(TerrainAdd.text) * 0.1f; Value /= ScmapEditor.TerrainHeight; float[,] heights = ScmapEditor.Current.Teren.terrainData.GetHeights(0, 0, ScmapEditor.Current.Teren.terrainData.heightmapWidth, ScmapEditor.Current.Teren.terrainData.heightmapHeight); for (int i = 0; i < ScmapEditor.Current.Teren.terrainData.heightmapWidth; i++) { for (int j = 0; j < ScmapEditor.Current.Teren.terrainData.heightmapWidth; j++) { heights[i, j] += Value; } } ScmapEditor.SetAllHeights(heights); //ScmapEditor.Current.Teren.terrainData.SetHeights(0, 0, heights); RegenerateMaps(); OnTerrainChanged(); }
void CursorUiPos() { Ray ray = Cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, MaxRaycastDistance, MaskCursor)) { GameplayCursorPos = hit.point; GameplayCursorPosScm = ScmapEditor.WorldPosToScmap(GameplayCursorPos); if (GameplayCursorPosScm.x == LastCursorPos.x && GameplayCursorPosScm.z == LastCursorPos.z) { return; } GameplayCursorPosScm.y = hit.point.y * 10; //GameplayCursorPosScm.z = ScmapEditor.Current.map.Height - GameplayCursorPosScm.z; string X = GameplayCursorPosScm.x.ToString("N2"); string Y = GameplayCursorPosScm.y.ToString("N2"); string Z = GameplayCursorPosScm.z.ToString("N2"); X = X.PadRight(8); Y = Y.PadRight(8); Z = Z.PadRight(8); CursorInfo.text = "x: " + X + "\ty: " + Y + "\tz: " + Z; SetToEmptyPos = false; } else if (!SetToEmptyPos) { SetToEmptyPos = true; CursorInfo.text = "x: -------- \ty: -------- \tz: -------- "; } }
void Awake() { Current = this; ResBrowser.Instantiate(); Data = Teren.terrainData; EnvPaths.CurrentGamedataPath = EnvPaths.GamedataPath; }
void ControlerDrag() { if (!Draged) { UndoRegisterMove(); Draged = true; } Ray ray = CameraControler.Current.Cam.ScreenPointToRay(Input.mousePosition); Vector3 NewPos = PosOnControler(ray); Vector3 Offset = NewPos - ControlerClickPoint; if (DragType == DragTypes.MoveZ) { Offset.x = 0; } if (DragType == DragTypes.MoveX) { Offset.z = 0; } if (SnapToGrid) { Offset = ScmapEditor.SnapToGrid(Offset); } Controls.position = ControlerBegin + Offset; Selection.OffsetPosition(Offset); for (int i = 0; i < SymetrySelection.Length; i++) { SymetrySelection[i].OffsetPosition(Offset); } }
public void UpdateSize() { Position = ScmapEditor.WorldPosToScmap(MapLuaParser.Current.MapCenterPoint); Scale = Mathf.Max(ScmapEditor.Current.map.Width, ScmapEditor.Current.map.Height) * 2.288245f; ScmapEditor.Current.Skybox.LoadSkybox(); }
public static void CreateMarker(SaveLua.Marker Owner, int mc) { GameObject NewMarker = Instantiate(Current.MarkerPrefab, Current.MasterChains[mc]); NewMarker.name = Owner.Name; MarkerObject NewObj = NewMarker.GetComponent <MarkerObject>(); NewObj.Owner = Owner; Owner.MarkerObj = NewObj; MarkerPropGraphic PropGraphic; if (Owner.MarkerType == SaveLua.Marker.MarkerTypes.BlankMarker && ArmyInfo.ArmyExist(Owner.Name)) { PropGraphic = Current.SpawnGraphic; } else { PropGraphic = GetPropByType(Owner.MarkerType); } NewObj.Mf.sharedMesh = PropGraphic.SharedMesh; NewObj.Mr.sharedMaterial = PropGraphic.SharedMaterial; NewObj.Bc.size = PropGraphic.SharedMesh.bounds.size; NewObj.Bc.center = PropGraphic.SharedMesh.bounds.center; NewObj.Tr.localPosition = ScmapEditor.ScmapPosToWorld(Owner.position); NewObj.Tr.localRotation = MarkerObject.ScmapRotToMarkerRot(Owner.orientation, Owner.MarkerType); NewMarker.SetActive(Current.MarkerLayersSettings.ActiveByType(Owner.MarkerType)); }
public static void CreateRanges() { //SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[0]].GetComponent<UnitInstance>() Count = SelectionManager.Current.Selection.Ids.Count; if (Count > MaxUnitRanges) { Count = MaxUnitRanges; } for (int i = 0; i < Count; i++) { GameObject UIobj = SelectionManager.Current.AffectedGameObjects[SelectionManager.Current.Selection.Ids[i]]; if (UIobj == null) { continue; } UnitInstance UI = UIobj.GetComponent <UnitInstance>(); if (UI == null) { UnitRanges[i].UnitTr = null; UnitRanges[i].Radius = 0; } else { UnitRanges[i].UnitTr = UI.transform; UnitRanges[i].Radius = ScmapEditor.ScmapPosToWorld(UI.UnitRenderer.BP.MaxRange); UnitRanges[i].MinRadius = ScmapEditor.ScmapPosToWorld(UI.UnitRenderer.BP.MinRange); } } }
public UnitInstance CreateUnitObject(MapLua.SaveLua.Army.Unit Source, MapLua.SaveLua.Army.UnitsGroup Group) { Vector3 position = ScmapEditor.ScmapPosToWorld(Source.Position); Vector3 RadianOrientation = Vector3.zero; Quaternion rotation = Quaternion.Euler(Source.Orientation * Mathf.Rad2Deg); GameObject Obj = Instantiate(UnitsInfo.Current.UnitInstancePrefab, transform) as GameObject; Obj.name = Source.Name; UnitInstance UInst = Obj.GetComponent <UnitInstance>(); //UInst.Owner = Owner; UInst.Group = Group; Group.UnitInstances.Add(UInst); UInst.orders = Source.orders; UInst.platoon = Source.platoon; UInst.UnitRenderer = this; UInst.SetMatrix(ScmapEditor.SnapToTerrain(position), rotation); if (BP.Footprint.x > 0 && BP.Footprint.y > 0) { UInst.Col.size = new Vector3(BP.Footprint.x * 0.1f, BP.Size.y * 0.1f, BP.Footprint.y * 0.1f); } else { UInst.Col.size = BP.Size * 0.1f; } UInst.Col.center = Vector3.up * (BP.Size.y * 0.05f); AddInstance(UInst); return(UInst); }
public void Place(Vector3[] Positions, Quaternion[] Rotations, Vector3[] Scales, bool RegisterUndo) { if (FirstSelected == null) { ShowGroupError(); return; } if (Positions.Length > 0 && RegisterUndo) { Undo.RegisterUndo(new UndoHistory.HistoryUnitsRemove(), new UndoHistory.HistoryUnitsRemove.UnitsRemoveParam(new SaveLua.Army.UnitsGroup[] { FirstSelected.Source })); } for (int i = 0; i < Positions.Length; i++) { if (RandomRotation.isOn) { Rotations[i] = GetRandomRotation; } SaveLua.Army.Unit NewUnit = new SaveLua.Army.Unit(); NewUnit.Name = SaveLua.Army.Unit.GetFreeName("UNIT_"); NewUnit.type = SelectedUnit.CodeName; NewUnit.orders = ""; NewUnit.platoon = ""; NewUnit.Position = ScmapEditor.WorldPosToScmap(Positions[i]); NewUnit.Orientation = Rotations[i].eulerAngles * Mathf.Deg2Rad; FirstSelected.Source.AddUnit(NewUnit); NewUnit.Instantiate(); FirstSelected.Refresh(); } }
public void AddTerrainHeight() { int h = ScmapEditor.Current.Teren.terrainData.heightmapResolution; int w = ScmapEditor.Current.Teren.terrainData.heightmapResolution; ScmapEditor.GetAllHeights(ref beginHeights); Undo.RegisterUndo(new UndoHistory.HistoryTerrainHeight(), new UndoHistory.HistoryTerrainHeight.TerrainHeightHistoryParameter(beginHeights)); float Value = float.Parse(TerrainAdd.text) * 0.1f; Value /= ScmapEditor.TerrainHeight; float[,] heights = ScmapEditor.Current.Teren.terrainData.GetHeights(0, 0, ScmapEditor.Current.Teren.terrainData.heightmapResolution, ScmapEditor.Current.Teren.terrainData.heightmapResolution); for (int i = 0; i < ScmapEditor.Current.Teren.terrainData.heightmapResolution; i++) { for (int j = 0; j < ScmapEditor.Current.Teren.terrainData.heightmapResolution; j++) { heights[i, j] += Value; } } ScmapEditor.SetAllHeights(heights); //ScmapEditor.Current.Teren.terrainData.SetHeights(0, 0, heights); RegenerateMaps(); OnTerrainChanged(); }
public Marker(Marker CopyMarker, string NewName = "") { ConnectedToChains = new List <Chain>(); AdjacentToMarker = new List <Marker>(); for (int i = 0; i < CopyMarker.ConnectedToChains.Count; i++) { ConnectedToChains.Add(CopyMarker.ConnectedToChains[i]); } for (int i = 0; i < CopyMarker.AdjacentToMarker.Count; i++) { AdjacentToMarker.Add(CopyMarker.AdjacentToMarker[i]); } if (string.IsNullOrEmpty(NewName)) { Name = GetLowestName(CopyMarker.MarkerType); } else { Name = NewName; } AddNewMarker(this); size = CopyMarker.size; amount = CopyMarker.amount; position = ScmapEditor.WorldPosToScmap(CopyMarker.MarkerObj.transform.position); orientation = Markers.MarkerObject.MarkerRotToScmapRot(CopyMarker.MarkerObj.Tr.localRotation, CopyMarker.MarkerType); prop = "/env/common/props/markers/M_Blank_prop.bp"; MarkerType = CopyMarker.MarkerType; type = MarkerTypeToString(CopyMarker.MarkerType); if (MarkerType == MarkerTypes.Mass) { resource = true; //amount = 100; prop = "/env/common/props/markers/M_Mass_prop.bp"; color = "ff808080"; } else if (MarkerType == MarkerTypes.Hydrocarbon) { //size = 3; resource = true; //amount = 100; prop = "/env/common/props/markers/M_Hydrocarbon_prop.bp"; color = "ff808080"; } else if (MarkerType == MarkerTypes.CameraInfo) { canSyncCamera = CopyMarker.canSyncCamera; canSetCamera = CopyMarker.canSetCamera; zoom = CopyMarker.zoom; } }
void ClampBottom() { //RecalcTerrainClamp(); ScmapEditor.ClampBottom((ScmapEditor.Current.Data.bounds.max.y - 5) / ScmapEditor.Current.Data.size.y); RegenerateMaps(); OnTerrainChanged(); }
void ClampTop() { //RecalcTerrainClamp(); ScmapEditor.ClampTop((ScmapEditor.Current.Data.bounds.min.y + 5) / ScmapEditor.Current.Data.size.y); RegenerateMaps(); OnTerrainChanged(); }
public void ImportMarkers() { var extensions = new[] { new ExtensionFilter("Faf Markers", "fafmapmarkers") }; var paths = StandaloneFileBrowser.OpenFilePanel("Import markers", DefaultPath, extensions, false); if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0])) { ExportMarkers ImpMarkers = JsonUtility.FromJson <ExportMarkers>(System.IO.File.ReadAllText(paths[0])); bool AnyCreated = false; int mc = 0; MapLua.SaveLua.Marker[] CreatedMarkers = new MapLua.SaveLua.Marker[ImpMarkers.Markers.Length]; for (int m = 0; m < ImpMarkers.Markers.Length; m++) { if (!AnyCreated) { Undo.Current.RegisterMarkersAdd(); } AnyCreated = true; if (SelectionManager.Current.SnapToGrid) { ImpMarkers.Markers[m].Pos = ScmapEditor.SnapToGridCenter(ImpMarkers.Markers[m].Pos, true, SelectionManager.Current.SnapToWater); } MapLua.SaveLua.Marker NewMarker = new MapLua.SaveLua.Marker(ImpMarkers.Markers[m].MarkerType); CreatedMarkers[m] = NewMarker; NewMarker.position = ScmapEditor.WorldPosToScmap(ImpMarkers.Markers[m].Pos); NewMarker.orientation = ImpMarkers.Markers[m].Rot.eulerAngles; MarkersControler.CreateMarker(NewMarker, mc); ChainsList.AddToCurrentChain(NewMarker); MapLuaParser.Current.SaveLuaFile.Data.MasterChains[mc].Markers.Add(NewMarker); } for (int m = 0; m < ImpMarkers.Markers.Length; m++) { CreatedMarkers[m].AdjacentToMarker = new List <MapLua.SaveLua.Marker>(); for (int c = 0; c < ImpMarkers.Markers[m].Connected.Length; c++) { CreatedMarkers[m].AdjacentToMarker.Add(CreatedMarkers[ImpMarkers.Markers[m].Connected[c]]); } } RenderMarkersConnections.Current.UpdateConnections(); EnvPaths.SetLastPath(ExportPathKey, System.IO.Path.GetDirectoryName(paths[0])); GenericInfoPopup.ShowInfo("Markers imported"); } }
public void CreateObject(bool AllowFarLod = true) { Obj = Group.PropObject.CreatePropGameObject( ScmapEditor.ScmapPosToWorld(Position), MassMath.QuaternionFromRotationMatrix(RotationX, RotationY, RotationZ), Scale, AllowFarLod ); Obj.Connected = this; }
public UnitInstance CreateUnitObject(MapLua.SaveLua.Army.Unit Source, MapLua.SaveLua.Army.UnitsGroup Group) { Vector3 position = ScmapEditor.ScmapPosToWorld(Source.Position); Vector3 RadianOrientation = Vector3.zero; Quaternion rotation = UnitInstance.RotationFromScmapRotation(Source.Orientation); GameObject Obj = Instantiate(UnitsInfo.Current.UnitInstancePrefab, transform) as GameObject; return(FillGameObjectValues(Obj, Source, Group, position, rotation)); }
bool UpdateBrushPosition(bool Forced = false, bool Size = true, bool Position = true) { //Debug.Log(Vector3.Distance(MouseBeginClick, Input.mousePosition)); if (Forced || Vector3.Distance(MouseBeginClick, Input.mousePosition) > 1) { } else { return(false); } float SizeXprop = MapLuaParser.GetMapSizeX() / 512f; float SizeZprop = MapLuaParser.GetMapSizeY() / 512f; float BrushSizeValue = BrushSize.value; if (BrushSizeValue < 0.2f) { BrushSizeValue = 0.2f; } if (Size) { TerrainMaterial.SetFloat("_BrushSize", BrushSizeValue / ((SizeXprop + SizeZprop) / 2f)); } MouseBeginClick = Input.mousePosition; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Position && Physics.Raycast(ray, out hit, 2000, TerrainMask)) { BrushPos = hit.point; if (SnapToGround.isOn && BrushSize.value < 1.5f) { //BrushPos = Vector3.Lerp(ScmapEditor.SnapToSmallGridCenter(BrushPos), BrushPos, (BrushSize.value - 0.2f) / 1.5f); BrushPos = ScmapEditor.SnapToSmallGrid(BrushPos + new Vector3(0.025f, 0, -0.025f)); } BrushPos.y = ScmapEditor.Current.Teren.SampleHeight(BrushPos); Vector3 tempCoord = ScmapEditor.Current.Teren.gameObject.transform.InverseTransformPoint(BrushPos); Vector3 coord = Vector3.zero; float SizeX = (int)((BrushSizeValue / SizeXprop) * 100) * 0.01f; float SizeZ = (int)((BrushSizeValue / SizeZprop) * 100) * 0.01f; coord.x = (tempCoord.x - SizeX * MapLuaParser.GetMapSizeX() * 0.0001f) / ScmapEditor.Current.Teren.terrainData.size.x; coord.z = (tempCoord.z - SizeZ * MapLuaParser.GetMapSizeY() * 0.0001f) / ScmapEditor.Current.Teren.terrainData.size.z; TerrainMaterial.SetFloat("_BrushUvX", coord.x); TerrainMaterial.SetFloat("_BrushUvY", coord.z); return(true); } return(false); }
public override void DoUndo() { if (!RedoGenerated) { float[,] UndoData_newheights = new float[0, 0]; ScmapEditor.GetAllHeights(ref UndoData_newheights); Undo.RegisterRedo(new HistoryTerrainHeight(), new TerrainHeightHistoryParameter(UndoData_newheights)); } RedoGenerated = true; DoRedo(); }
public override void DoUndo() { if (!RedoGenerated) { //Undo.UndoData_newheights = ScmapEditor.Current.Teren.terrainData.GetHeights(0, 0, ScmapEditor.Current.Teren.terrainData.heightmapWidth, ScmapEditor.Current.Teren.terrainData.heightmapHeight); ScmapEditor.GetAllHeights(ref Undo.UndoData_newheights); HistoryTerrainHeight.GenerateRedo(Undo.Current.Prefabs.TerrainHeightChange).Register(); } RedoGenerated = true; DoRedo(); }
public override void DoRedo() { Undo.Current.EditMenu.SetState(Editing.EditStates.TerrainStat); Undo.Current.EditMenu.EditTerrain.ChangePage(0); ScmapEditor.SetAllHeights(Pixels); Undo.Current.EditMenu.EditTerrain.OnTerrainChanged(); Undo.Current.EditMenu.EditTerrain.RegenerateMaps(); }
public void SnapAction(Transform tr, GameObject Connected) { UpdateSelectedMatrixes = true; if (Connected == null) { tr.localPosition = ScmapEditor.SnapToTerrain(tr.localPosition); } else { tr.localPosition = Connected.GetComponent <UnitInstance>().GetSnapPosition(tr.localPosition); } }
public void LoadSkybox() { SkyData = ScmapEditor.Current.map.AdditionalSkyboxData; CreateMesh(); transform.position = ScmapEditor.ScmapPosToWorld(SkyData.Data.Position) + Vector3.up * (SkyData.Data.HorizonHeight * 0.1f); transform.localScale = Vector3.one * (SkyData.Data.Scale * 0.1f); Mat.SetFloat("_HorizonHeight", SkyData.Data.HorizonHeight * 0.1f); Mat.SetColor("_HorizonColor", SkyData.Data.HorizonColor); Mat.SetFloat("_ZenithHeight", SkyData.Data.ZenithHeight * 0.1f); Mat.SetColor("_ZenithColor", SkyData.Data.ZenithColor); }
public void Bake() { _Dec.Type = _Dec.Shared.Type; _Dec.Position = ScmapEditor.WorldPosToScmap(GetPivotPoint()); _Dec.Scale = tr.localScale * 10f; _Dec.Rotation = tr.localEulerAngles * Mathf.Deg2Rad; _Dec.CutOffLOD = CutOffLOD; _Dec.NearCutOffLOD = NearCutOffLOD; _Dec.TexPathes = new string[2]; _Dec.Shared.FixPaths(); _Dec.TexPathes[0] = _Dec.Shared.Tex1Path; _Dec.TexPathes[1] = _Dec.Shared.Tex2Path; _Dec.Obj = this; }
public override void DoRedo() { if (Undo.Current.EditMenu.State != Editing.EditStates.TerrainStat) { Undo.Current.EditMenu.State = Editing.EditStates.TerrainStat; Undo.Current.EditMenu.ChangeCategory(1); } Undo.Current.EditMenu.EditTerrain.ChangePage(0); //ScmapEditor.Current.Teren.terrainData.SetHeights(0, 0, Pixels); ScmapEditor.SetAllHeights(Pixels); //Markers.MarkersControler.UpdateMarkersHeights(); Undo.Current.EditMenu.EditTerrain.OnTerrainChanged(); Undo.Current.EditMenu.EditTerrain.RegenerateMaps(); }
IEnumerator _GenerateShoreline() { var ts = System.TimeSpan.FromTicks(System.DateTime.Now.Ticks); //Load data heights = ScmapEditor.Heights; heightmapWidth = ScmapEditor.HeightmapWidth; heightmapHeight = ScmapEditor.HeightmapHeight; terrainSizeX = ScmapEditor.Current.Teren.terrainData.size.x; terrainSizeY = ScmapEditor.Current.Teren.terrainData.size.y; terrainSizeZ = ScmapEditor.Current.Teren.terrainData.size.z; worldWaterLevel = ScmapEditor.GetWaterLevel(); waterLevel = worldWaterLevel / terrainSizeY; //Clear ShoreLines.Clear(); allEdges.Clear(); thread = new Thread(ThreadWork); thread.Priority = System.Threading.ThreadPriority.AboveNormal; thread.IsBackground = false; thread.Start(); while (thread.IsAlive) { yield return(null); } thread = null; //ThreadWork(); //yield return null; //Clear heights = null; allEdges.Clear(); ShoreLineTask = null; IsShoreLineGenerated = true; GenericInfoPopup.ShowInfo("Shoreline generated in " + (System.TimeSpan.FromTicks(System.DateTime.Now.Ticks).TotalSeconds - ts.TotalSeconds).ToString("F4") + "s"); //Debug.Log("Shoreline generated in time: " + (System.TimeSpan.FromTicks(System.DateTime.Now.Ticks).TotalSeconds - ts.TotalSeconds).ToString("F4")); }
void LoadNeroxisHeightmap() { ScmapEditor.GetAllHeights(ref beginHeights); float[,] heights = ScmapEditor.Current.Teren.terrainData.GetHeights(0, 0, ScmapEditor.Current.Teren.terrainData.heightmapResolution, ScmapEditor.Current.Teren.terrainData.heightmapResolution); float[,] generatedHeights = neroxis.GenerateMapTask.GetGeneratedHeightmap(); for (int i = 0; i < ScmapEditor.Current.Teren.terrainData.heightmapResolution; i++) { for (int j = 0; j < ScmapEditor.Current.Teren.terrainData.heightmapResolution; j++) { heights[i, j] = generatedHeights[i, j]; } } Undo.RegisterUndo(new UndoHistory.HistoryTerrainHeight(), new UndoHistory.HistoryTerrainHeight.TerrainHeightHistoryParameter(beginHeights)); ScmapEditor.SetAllHeights(heights); }
public static void CreateGameObjectFromDecal(Decal Component) { GameObject NewDecalObject = Instantiate(Current.DecalPrefab, Current.DecalPivot); OzoneDecal Obj = NewDecalObject.GetComponent <OzoneDecal>(); Component.Obj = Obj; Obj.Dec = Component; Obj.tr = NewDecalObject.transform; Obj.tr.localRotation = Quaternion.Euler(Component.Rotation * Mathf.Rad2Deg); Obj.tr.localScale = new Vector3(Component.Scale.x * 0.1f, Component.Scale.x * 0.1f, Component.Scale.z * 0.1f); Obj.CutOffLOD = Component.CutOffLOD; Obj.NearCutOffLOD = Component.NearCutOffLOD; Obj.MovePivotPoint(ScmapEditor.ScmapPosToWorld(Component.Position)); Obj.Material = Component.Shared.SharedMaterial; Component.Shared.OnVisibilityChanged += Component.UpdateVisibility; }
public static void LoadProps(ScmapEditor HeightmapControler){ AllPropsTypes = new List<PropTypeGroup>(); List<Prop> Props = HeightmapControler.map.Props; Debug.Log("Found props: " + Props.Count); for(int i = 0; i < Props.Count; i++){ bool NewProp = false; int GroupId = 0; if(AllPropsTypes.Count == 0) NewProp = true; else{ NewProp = true; for(int g = 0; g < AllPropsTypes.Count; g++){ if(Props[i].BlueprintPath == AllPropsTypes[g].Blueprint){ NewProp = false; GroupId = g; break; } } } if(NewProp){ GroupId = AllPropsTypes.Count; AllPropsTypes.Add(new PropTypeGroup()); AllPropsTypes[GroupId].Blueprint = Props[i].BlueprintPath; } AllPropsTypes[GroupId].Props.Add(Props[i]); } Debug.Log("Props types: " + AllPropsTypes.Count); }