public static void SetFallof(int FallofId, float Rotation)
    {
        if (LastFallofId == FallofId && LastRotation == Rotation)
        {
            return;
        }

        BrushGenerator.Current.Brushes[FallofId].wrapMode   = TextureWrapMode.Clamp;
        BrushGenerator.Current.Brushes[FallofId].mipMapBias = -1f;
        BrushGenerator.Current.Brushes[FallofId].filterMode = FilterMode.Bilinear;
        BrushGenerator.Current.Brushes[FallofId].anisoLevel = 2;

        if (Rotation == 0)
        {
            BrushGenerator.Current.RotatedBrush = BrushGenerator.Current.Brushes[FallofId];
        }
        else
        {
            BrushGenerator.Current.RotatedBrush = BrushGenerator.rotateTexture(BrushGenerator.Current.Brushes[FallofId], Rotation);
        }

        LastFallofId = FallofId;
        LastRotation = Rotation;
        RegeneratePaintBrushIfNeeded(true);
    }
        public void UpdateMenu(bool Slider = false)
        {
            if (Slider)
            {
            }
            else
            {
            }

            Min = BrushMini.value / ScmapEditor.Current.Data.size.y;
            Max = BrushMax.value / ScmapEditor.Current.Data.size.y;

            Min /= 10f;
            Max /= 10f;

            if (LastRotation != BrushRotation.intValue)
            {
                LastRotation = BrushRotation.intValue;
                if (LastRotation == 0)
                {
                    BrushGenerator.Current.RotatedBrush = BrushGenerator.Current.Brushes[SelectedFalloff];
                }
                else
                {
                    BrushGenerator.Current.RotatedBrush = BrushGenerator.rotateTexture(BrushGenerator.Current.Brushes[SelectedFalloff], LastRotation);
                }

                TerrainMaterial.SetTexture("_BrushTex", (Texture)BrushGenerator.Current.RotatedBrush);
                BrushGenerator.RegeneratePaintBrushIfNeeded(true);
            }
        }
Esempio n. 3
0
        private void DrawChart()
        {
            if (plotArea == null)
            {
                return;
            }
            if (Series == null || Series.Count() == 0)
            {
                return;
            }
            if (Series.FirstOrDefault().Count() == 0)
            {
                return;
            }
            plotArea.Children.Clear();

            ChartPlotInfo plotInfo = CalculatePlotInfo();

            plotArea.Width  = plotInfo.Width + plotInfo.LeftMarginWidth + plotInfo.RightMarginWidth;
            plotArea.Height = plotInfo.MaxHeight + plotInfo.FooterHeight + plotInfo.HeaderHeight;

            DrawLegend();
            DrawBackground(plotInfo);
            DrawGrid(plotInfo);
            foreach (var seria in Series)
            {
                DrawSeria(seria, plotInfo, BrushGenerator.GetBrush());
            }
        }
        public void ChangeFalloff(int id)
        {
            SelectedFalloff = id;
            LastRotation    = BrushRotation.intValue;

            BrushGenerator.SetFallof(SelectedFalloff, LastRotation);

            TerrainMaterial.SetTexture("_BrushTex", (Texture)BrushGenerator.Current.RotatedBrush);
            //BrushGenerator.RegeneratePaintBrushIfNeeded(true);
        }
Esempio n. 5
0
        void SetBrush()
        {
            TerrainMaterial.SetInt("_Brush", 1);
            BrushGenerator.SetFallof(SelectedFalloff, LastRotation);
            TerrainMaterial.SetTexture("_BrushTex", (Texture)BrushGenerator.Current.Brushes[SelectedFalloff]);

            for (int i = 0; i < BrushTypes.Length; i++)
            {
                if (BrushTypes[i].isOn)
                {
                    ChangeBrush(i);
                    break;
                }
            }
        }
 public void ChangeFalloff(int id)
 {
     SelectedFalloff = id;
     BrushGenerator.Current.Brushes[SelectedFalloff].wrapMode   = TextureWrapMode.Clamp;
     BrushGenerator.Current.Brushes[SelectedFalloff].mipMapBias = -1f;
     BrushGenerator.Current.Brushes[SelectedFalloff].filterMode = FilterMode.Bilinear;
     BrushGenerator.Current.Brushes[SelectedFalloff].anisoLevel = 2;
     LastRotation = BrushRotation.intValue;
     if (LastRotation == 0)
     {
         BrushGenerator.Current.RotatedBrush = BrushGenerator.Current.Brushes[SelectedFalloff];
     }
     else
     {
         BrushGenerator.Current.RotatedBrush = BrushGenerator.rotateTexture(BrushGenerator.Current.Brushes[SelectedFalloff], LastRotation);
     }
     TerrainMaterial.SetTexture("_BrushTex", (Texture)BrushGenerator.Current.RotatedBrush);
     BrushGenerator.RegeneratePaintBrushIfNeeded(true);
 }
Esempio n. 7
0
        public void ChangeFalloff(int id)
        {
            if (!gameObject.activeSelf)
            {
                return;
            }

            SelectedFalloff = id;

            for (int i = 0; i < BrushToggles.Count; i++)
            {
                if (i == SelectedFalloff)
                {
                    continue;
                }
                BrushToggles[i].isOn = false;
            }
            LastRotation = BrushRotation.intValue;

            BrushGenerator.SetFallof(SelectedFalloff, LastRotation);

            TerrainMaterial.SetTexture("_BrushTex", (Texture)BrushGenerator.Current.RotatedBrush);
            //BrushGenerator.RegeneratePaintBrushIfNeeded(true);
        }
 private void Awake()
 {
     Current = this;
 }
        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();
        }
Esempio n. 10
0
        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();
        }
 void SetBrush()
 {
     TerrainMaterial.SetInt("_Brush", 1);
     BrushGenerator.SetFallof(SelectedFalloff, LastRotation);
     TerrainMaterial.SetTexture("_BrushTex", (Texture)BrushGenerator.Current.Brushes[SelectedFalloff]);
 }