예제 #1
0
 public static Brush SetCurrentBrush(BrushType _bType)
 {
     Brush b = null;
     switch (_bType)
     {
         case BrushType.Aqua:
             b = AquaBrush();
             break;
         case BrushType.Brown:
             b = BrownBrush();
             break;
         case BrushType.ConfettiGreen:
             b = ConfettiBrush();
             break;
         case BrushType.GrayDivot:
             b = GrayDivotBrush();
             break;
         case BrushType.RedDiag:
             b = RedDiagBrush();
             break;
         default:
             break;
     }
     return b;
 }
예제 #2
0
 public Brush Convert(DateTime dateTime, bool isSelected, Brush defaultValue, BrushType brushType)
 {
     if (brushType == BrushType.Background)
     {
         if (dateTime == new DateTime(DateTime.Today.Year, DateTime.Today.Month, 5))
         {
             return new SolidColorBrush(Colors.Yellow);
         }
         else
         {
             return defaultValue;
         }
     }
     else
     {
         if (dateTime == new DateTime(DateTime.Today.Year, DateTime.Today.Month, 6))
         {
             return new SolidColorBrush(Colors.Red);
         }
         else
         {
             return defaultValue;
         }
     }
 }
예제 #3
0
 // Implement IDateToBrushConverter.
 // This method is used to change Forground & Background color of CalendarItem
 public Brush Convert(DateTime dateTime, bool isSelected, Brush defaultValue, BrushType brushType)
 {
     if (brushType == BrushType.Background)
     {
         if (CalDates != null && CalDates.Where(one => one.CalendarItemDate.Date == dateTime.Date).Any() && !isSelected)
         {
             return new SolidColorBrush(Colors.Blue);
         }
         else
         {
             return defaultValue;
         }
     }
     else
     {
         if (CalDates != null && CalDates.Where(one => one.CalendarItemDate.Date == dateTime.Date).Any() && !isSelected)
         {
             return new SolidColorBrush(Colors.Red);
         }
         else
         {
             return defaultValue;
         }
     }
 }
예제 #4
0
        public Brush Convert(DateTime dateTime, bool isSelected, PeriodDayTypeEnum dayType, Brush defaultValue, BrushType brushType)
        {
            string uri = string.Empty;
            WPControls.Models.PeriodDayTypeEnum periodDayType = dayType;
            double pastAndCurrentOpacity = 0.6;
            double futureOpacity = 0.6;
               // double futureOpacity = 0.25;

            if (brushType == BrushType.Background)
            {

                uri = string.Format("/Images/Dark/{0}{1}.png", periodDayType != WPControls.Models.PeriodDayTypeEnum.RegularDay ?
                    periodDayType.ToString() : string.Empty, isSelected ? "_selected" : dateTime == DateTime.Today? "_today": string.Empty);

                //if (dateTime == DateTime.Today)
                //    uri = string.Format("/Images/Dark/{0}{1}.png", periodDayType != WPControls.Models.PeriodDayTypeEnum.RegularDay ?
                //        periodDayType.ToString() : string.Empty, "_today");
                //else
                //    uri = string.Format("/Images/Dark/{0}{1}.png", periodDayType != WPControls.Models.PeriodDayTypeEnum.RegularDay ?
                //        periodDayType.ToString() : string.Empty, isSelected ? "_selected" : string.Empty);

                return new ImageBrush()
                {
                    ImageSource = new BitmapImage(new Uri(uri, UriKind.Relative)),
                    Opacity = dateTime > DateTime.Today ? futureOpacity : pastAndCurrentOpacity
                } as Brush;
            }
            else
            {
                SolidColorBrush highlightForeground = new SolidColorBrush(Color.FromArgb(255,191,82,121));

                if (dateTime == DateTime.Today)
                    return highlightForeground;
                    /* switch (periodDayType)
                    {

                        case WPControls.Models.PeriodDayTypeEnum.FertilityStartDay:
                        case WPControls.Models.PeriodDayTypeEnum.FertilityDay:
                        case WPControls.Models.PeriodDayTypeEnum.FertilityEndDay:
                            {
                                return highlightForeground;
                            }
                        case WPControls.Models.PeriodDayTypeEnum.CycleStartDay:
                        case WPControls.Models.PeriodDayTypeEnum.CycleDay:
                        case WPControls.Models.PeriodDayTypeEnum.CycleEndDay:
                            {
                                return highlightForeground;
                            }
                        case WPControls.Models.PeriodDayTypeEnum.RegularDay:
                        default:
                            return new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)) as Brush;

                    } * */
                else
                    return defaultValue;
            }
        }
예제 #5
0
        public Brush Convert(DateTime dateTime, bool isSelected, Brush defaultValue, BrushType brushType)
        {
            if (isSelected)
            {
                return brushType == BrushType.Background ? new SolidColorBrush(Colors.White) : new SolidColorBrush(Colors.Black);
            }

            return defaultValue;
        }
예제 #6
0
파일: NodeEditor.cs 프로젝트: beneon/Quixel
        /// <summary>
        /// Applies a brush to the terrain.
        /// </summary>
        /// <param name="type">The type/shape of the brush.</param>
        /// <param name="size">The size (radius) of the brush.</param>
        /// <param name="pos">The (real world) position to apply the brush.</param>
        /// <param name="val">Density to apply.</param>
        public static void applyBrush(BrushType type, int size, Vector3 pos, float val)
        {
            List<Node> changedNodes = new List<Node>();
            Vector3 realPos = new Vector3();
            //Vector3I point = new Vector3I((int)Math.Round(pos.x / nodeWidth),
                //(int)Math.Round(pos.y / nodeWidth),
                //(int)Math.Round(pos.z / nodeWidth));

            List<Vector3> points = getPoints(type, size, pos);
            for (int o = 0; o < points.Count; o++)
            {
                realPos = points[o];
                Node[] editNodes = NodeManager.searchNodeContainingDensity(realPos, 0);
                Debug.Log("in applyBrush, realPos at o:"+o+", is "+realPos+",original pos:"+pos);
                /*
                Returns a node containing the point as close as possible to the requested LOD.
                a list of node[]
                <param name="pos"></param>
                <param name="searchLOD"></param>
                */

                for (int i = 0; i < editNodes.Length; i++)
                {
                    Node editNode = editNodes[i];
                    if (editNode != null && editNode.LOD == 0)
                    {
                        if (!changedNodes.Contains(editNode))
                            changedNodes.Add(editNode);

                        /*
                        Attempting to make spheres actually round, experiment failed
                        if (type == BrushType.SPHERE)
                        {
                            float v = val;
                            float dist = Vector3.Distance(pos, realPos);

                            if (val > MeshFactory.isolevel)
                                v = 10f - ((dist / (float)size) * 5f);
                            if (val < MeshFactory.isolevel)
                                v = 10f + ((dist / (float)size) * 5f);
                        }
                        */

                        editNode.setDensityFromWorldPos(realPos, val);
                        editNode.setMaterialFromWorldPos(realPos, materialID);

                    }
                }
            }

            applyPaint(type, size + 1, pos, false);
            for (int i = 0; i < changedNodes.Count; i++)
                changedNodes[i].regenerateChunk();
        }
예제 #7
0
    void SetDataSource(BrushType selected)
    {
      this.BeginUpdate();

      Items.Clear();
      foreach (BrushType o in Enum.GetValues(typeof(BrushType)))
        Items.Add(o);

      SelectedItem = selected;

      this.EndUpdate();
    }
예제 #8
0
        public BrushSwitch(Int32 size, BrushType type)
        {
            InitializeComponent();

            Brushtype = type;
            Brushsize = size;
            TRACK_Size.Value = size;

            if (type == BrushType.Square)
                RB_Square.Checked = true;
            else
                RB_Circle.Checked = true;

            UpdatePreview();
        }
예제 #9
0
파일: NodeEditor.cs 프로젝트: beneon/Quixel
        /// <summary>
        /// Applies a brush to the terrain.
        /// </summary>
        /// <param name="type">The type/shape of the brush.</param>
        /// <param name="size">The size (radius) of the brush.</param>
        /// <param name="pos">The (real world) position to apply the brush.</param>
        /// <param name="val">Density to apply.</param>
        public static void applyBrush(BrushType type, int size, Vector3 pos, float val)
        {
            List<Node> changedNodes = new List<Node>();
            float nodeWidth = NodeManager.LODSize[0];
            Vector3 realPos = new Vector3();
            Vector3I point = new Vector3I((int)Math.Round(pos.x / nodeWidth),
                (int)Math.Round(pos.y / nodeWidth),
                (int)Math.Round(pos.z / nodeWidth));

            List<Vector3> points = getPoints(type, size, pos);
            for (int o = 0; o < points.Count; o++)
            {
                realPos = points[o];
                Node[] editNodes = NodeManager.searchNodeContainingDensity(realPos, 0);

                for (int i = 0; i < editNodes.Length; i++)
                {
                    Node editNode = editNodes[i];
                    if (editNode != null && editNode.LOD == 0)
                    {
                        if (!changedNodes.Contains(editNode))
                            changedNodes.Add(editNode);

                        if (type == BrushType.SPHERE)
                        {
                            float v = val;
                            float dist = Vector3.Distance(pos, realPos);

                            if (val > MeshFactory.isolevel)
                                v = 10f - ((dist / (float)size) * 5f);
                            if (val < MeshFactory.isolevel)
                                v = 10f + ((dist / (float)size) * 5f);

                        }

                        editNode.setDensityFromWorldPos(realPos, val);
                        editNode.setMaterialFromWorldPos(realPos, materialID);

                    }
                }
            }

            applyPaint(type, size + 1, pos, false);
            for (int i = 0; i < changedNodes.Count; i++)
                changedNodes[i].regenerateChunk();
        }
예제 #10
0
        public BrushItem(float thickness, BrushType brushType, Android.Graphics.Color brushColor, Context c)
        {
            this.Thickness = thickness;
            this.BrushType = brushType;
            this.BrushColor = brushColor;
            context = c;

            if (this.BrushType == BrushType.Spray) {

                this.IsSprayBrushActive = true;

            }//end if

            /*this.inactiveColor = new Android.Graphics.Color (DrawingCanvasViewEx.InactiveColorValues [0],
                                             DrawingCanvasViewEx.InactiveColorValues [1],
                                             DrawingCanvasViewEx.InactiveColorValues [2],
                                             DrawingCanvasViewEx.InactiveColorValues [3]);*/
        }
예제 #11
0
        public DrawLimits(Map map)
        {
            InitializeComponent();
            this.map = map;

            using (XNAUtils utils = new XNAUtils())
            {
                PN_Map.BackgroundImage = utils.ConvertToImage(map.DrawMap());
                PN_Map.Size = new Size(map.MapSize.Width * 32, map.MapSize.Height * 32);

                Buffer = new Bitmap(PN_Map.Size.Width, PN_Map.Size.Height);
                using (Graphics g = Graphics.FromImage(Buffer))
                {
                    g.Clear(Color.White);
                    if (map.Limits != null) g.DrawImage(utils.ConvertToImage(map.Limits), new Point(0, 0));
                }
                Buffer.MakeTransparent(Color.White);

                Brushsize = 10;
                Brushtype = BrushType.Circle;
                brushcolor = Color.Black;
            }
        }
예제 #12
0
 public void DrawWeapon()
 {
     _currentSelection = "";
     drawType          = DrawType.Add;
     brushType         = BrushType.Weapon;
 }
예제 #13
0
 GdipGetBrushType(GpBrush brush, out BrushType type);
예제 #14
0
파일: NodeEditor.cs 프로젝트: beneon/Quixel
        /// <summary>
        /// Applies 'paint' to the area around the brush.
        /// </summary>
        /// <param name="type">The type/shape of the brush.</param>
        /// <param name="size">The size (radius) of the brush.</param>
        /// <param name="pos">The (real world) position to apply the brush.</param>
        /// <param name="regen">Set to true to have the engine regen the chunk after painting.</param>
        public static void applyPaint(BrushType type, int size, Vector3 pos, bool regen)
        {
            List<Node> changedNodes = new List<Node>();
            float nodeWidth = NodeManager.LODSize[0];
            Vector3 realPos = new Vector3();
            Vector3I point = new Vector3I((int)Math.Round(pos.x / nodeWidth),
                (int)Math.Round(pos.y / nodeWidth),
                (int)Math.Round(pos.z / nodeWidth));

            List<Vector3> points = getPoints(type, size, pos);
            for (int o = 0; o < points.Count; o++)
            {
                realPos = points[o];
                Node[] editNodes = NodeManager.searchNodeContainingDensity(realPos, 0);

                for (int i = 0; i < editNodes.Length; i++)
                {
                    Node editNode = editNodes[i];
                    if (editNode != null && editNode.LOD == 0)
                    {
                        if (!changedNodes.Contains(editNode))
                            changedNodes.Add(editNode);

                        editNode.setMaterialFromWorldPos(realPos, materialID);

                    }
                }
            }

            if (regen)
                for (int i = 0; i < changedNodes.Count; i++)
                    changedNodes[i].regenerateChunk();
        }
예제 #15
0
 public Brush Convert(DateTime dateTime, bool isSelected, bool isMarked, Brush defaultValue, BrushType brushType)
 {
     return defaultValue;
 }
예제 #16
0
 public void DrawItem()
 {
     _currentSelection = "";
     drawType          = DrawType.Add;
     brushType         = BrushType.Item;
 }
		public void InitTextureImage(ImageProxy proxy, BrushType imageType)
		{
			_cbTextureImage.TextureImageType = imageType;
			_cbTextureImage.TextureImage = proxy;
		}
예제 #18
0
 public void DrawGround()
 {
     _currentSelection = "";
     drawType          = DrawType.Add;
     brushType         = BrushType.Ground;
 }
예제 #19
0
 public Brush Convert(DateTime dateTime, bool isSelected, Brush defaultValue, BrushType brushType)
 {
     throw new NotImplementedException();
 }
예제 #20
0
        private void PN_Map_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                using (Brush b = new SolidBrush(brushcolor))
                using (Graphics g = Graphics.FromImage(Buffer))
                using (Graphics gmap = PN_Map.CreateGraphics())
                {
                    if (Brushtype == BrushType.Circle)
                    {
                        g.FillEllipse(b, e.X - Brushsize / 2, e.Y - Brushsize / 2, Brushsize, Brushsize);
                        gmap.FillEllipse(b, e.X - Brushsize / 2, e.Y - Brushsize / 2, Brushsize, Brushsize);
                    }
                    else if (Brushtype == BrushType.Square)
                    {
                        g.FillRectangle(b, e.X - Brushsize / 2, e.Y - Brushsize / 2, Brushsize, Brushsize);
                        gmap.FillRectangle(b, e.X - Brushsize / 2, e.Y - Brushsize / 2, Brushsize, Brushsize);
                    }
                }

            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                BrushSwitch dlg = new BrushSwitch(Brushsize, Brushtype);
                dlg.StartPosition = FormStartPosition.Manual;
                dlg.Location = MousePosition;
                dlg.ShowDialog();

                Brushsize = dlg.Brushsize;
                Brushtype = dlg.Brushtype;
            }
        }
예제 #21
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            var tile_map = target as Tower.TileMap;

            if (tile_map != null)
            {
                EditorGUILayout.LabelField(string.Format("TileSize = (row = {0}, column = {1})", tile_map.Row, tile_map.Column));

                EditorGUILayout.BeginHorizontal();

                EditorGUIUtility.labelWidth = 30;
                mRow = EditorGUILayout.IntField("Row", mRow);
                EditorGUIUtility.labelWidth = 50;
                mColumn = EditorGUILayout.IntField("Column", mColumn);
                EditorGUIUtility.labelWidth = 0;

                if (GUILayout.Button("SetSize"))
                {
                    tile_map.SetSize(mRow, mColumn);
                }

                EditorGUILayout.EndHorizontal();

                mFoldOut = EditorGUILayout.Foldout(mFoldOut, "Tile Data");
                if (mFoldOut)
                {
                    EditorGUI.indentLevel++;
                    for (var r = tile_map.Row - 1; r >= 0; --r)
                    {
                        GUILayout.BeginHorizontal();
                        for (var c = 0; c < tile_map.Column; ++c)
                        {
                            var tile = tile_map.GetTileAt(r, c);
                            GUILayout.Label(tile == null ? "0" : "#");
                        }
                        GUILayout.EndHorizontal();
                    }
                    EditorGUI.indentLevel--;
                }

                if (GUILayout.Button("UpdateChild"))
                {
                    tile_map.UpdateChild();
                }

                mCreateBkFoldOut = EditorGUILayout.Foldout(mCreateBkFoldOut, "Create Background");
                if (mCreateBkFoldOut)
                {
                    mBkTile = EditorGUILayout.ObjectField(mBkTile, typeof(GameObject), false);
                    if (mBkTile != null && GUILayout.Button("CreateBackground"))
                    {
                        for (var r = 0; r < tile_map.Row; ++r)
                        {
                            for (var c = 0; c < tile_map.Column; ++c)
                            {
                                var tile_go = PrefabUtility.InstantiatePrefab(mBkTile) as GameObject;
                                tile_go.name             = mBkTile.name;
                                tile_go.transform.parent = tile_map.transform;

                                var tile = tile_go.GetComponent <Tower.Tile>();
                                tile.Row    = r;
                                tile.Column = c;
                            }
                        }
                    }
                }

                mDrawTileFoldOut = EditorGUILayout.Foldout(mDrawTileFoldOut, "Draw Tile");
                if (mDrawTileFoldOut)
                {
                    mBrushTile = EditorGUILayout.ObjectField("Brush", mBrushTile, typeof(GameObject), false) as GameObject;
                    if (Event.current.type == EventType.Repaint)
                    {
                        mLastRect = GUILayoutUtility.GetLastRect();
                    }
                    GUILayout.Box(string.Empty, GUILayout.Width(tile_map.Column * 16), GUILayout.Height(tile_map.Row * 16));
                    for (var r = tile_map.Row - 1; r >= 0; --r)
                    {
                        for (var c = 0; c < tile_map.Column; ++c)
                        {
                            var rect     = new Rect(mLastRect.x + c * 16, mLastRect.yMax + 5 + (tile_map.Row - 1 - r) * 16, 16, 16);
                            var old_tile = tile_map.GetTileAt(r, c);
                            if (old_tile != null)
                            {
                                var spr = old_tile.GetComponent <SpriteRenderer>().sprite;
                                GUI.DrawTextureWithTexCoords(rect, spr.texture,
                                                             new Rect(spr.textureRect.x / spr.texture.width, spr.textureRect.y / spr.texture.height, spr.textureRect.width / spr.texture.width, spr.textureRect.height / spr.texture.height));
                            }
                            else
                            {
                                GUI.Box(rect, string.Empty);
                            }

                            if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
                            {
                                mInDragBrush = true;
                                if (Event.current.button == 0)
                                {
                                    mBrushType = BrushType.Draw;
                                }
                                else
                                {
                                    mBrushType = BrushType.Erase;
                                }
                            }
                            else if (Event.current.type == EventType.MouseUp)
                            {
                                mInDragBrush = false;
                            }

                            if (mInDragBrush && rect.Contains(Event.current.mousePosition))
                            {
                                tile_map.DeleteTile(old_tile, false);
                                if (mBrushType == BrushType.Draw)
                                {
                                    if (mBrushTile != null)
                                    {
                                        var tile_go = PrefabUtility.InstantiatePrefab(mBrushTile) as GameObject;
                                        tile_go.name             = mBrushTile.name;
                                        tile_go.transform.parent = tile_map.transform;

                                        var tile = tile_go.GetComponent <Tower.Tile>();
                                        tile.Row    = r;
                                        tile.Column = c;

                                        tile_map.SetTile(tile, true);
                                    }
                                }

                                Repaint();
                            }
                        }
                    }
                }
            }
        }
예제 #22
0
		public static DrawingImage GetImage(BrushType val)
		{
			double height = 1;
			double width = 2;

			//
			// Create the Geometry to draw.
			//
			GeometryGroup geometryGroup = new GeometryGroup();
			geometryGroup.Children.Add(new RectangleGeometry(new Rect(0, 0, width, height)));

			var geometryDrawing = new GeometryDrawing() { Geometry = geometryGroup };

			switch (val)
			{
				case BrushType.SolidBrush:
					geometryDrawing.Brush = new SolidColorBrush(Colors.Black);
					break;

				case BrushType.LinearGradientBrush:
					geometryDrawing.Brush = new LinearGradientBrush(Colors.Black, Colors.White, 0);
					break;

				case BrushType.TriangularShapeLinearGradientBrush:
					{
						var gStops = new GradientStopCollection();
						gStops.Add(new GradientStop(Colors.Black, 0));
						gStops.Add(new GradientStop(Colors.White, 0.5));
						gStops.Add(new GradientStop(Colors.Black, 1));
						geometryDrawing.Brush = new LinearGradientBrush(gStops, 0);
					}
					break;

				case BrushType.SigmaBellShapeLinearGradientBrush:
					{
						var gStops = new GradientStopCollection();
						gStops.Add(new GradientStop(Colors.Black, 0));
						gStops.Add(new GradientStop(Colors.White, 0.5));
						gStops.Add(new GradientStop(Colors.Black, 1));
						geometryDrawing.Brush = new LinearGradientBrush(gStops, 0);
					}
					break;

				case BrushType.PathGradientBrush:
				case BrushType.TriangularShapePathGradientBrush:
				case BrushType.SigmaBellShapePathGradientBrush:
					geometryDrawing.Brush = new RadialGradientBrush(Colors.Black, Colors.White);
					break;

				case BrushType.HatchBrush:
				case BrushType.SyntheticTextureBrush:
				case BrushType.TextureBrush:
					geometryDrawing.Brush = new SolidColorBrush(Colors.Black);
					break;

				default:
					break;
			}

			DrawingImage geometryImage = new DrawingImage(geometryDrawing);

			// Freeze the DrawingImage for performance benefits.
			geometryImage.Freeze();
			return geometryImage;
		}
예제 #23
0
 public BrushInfo(BrushType brushType, HatchStyle hatchStyle)
 {
     this.brushType  = brushType;
     this.hatchStyle = hatchStyle;
 }
 public void SetBrush(BrushType brushType)
 {
     CurrentBrush = brushes[brushType];
 }
예제 #25
0
 public void DrawArmour()
 {
     _currentSelection = "";
     drawType          = DrawType.Add;
     brushType         = BrushType.Armour;
 }
예제 #26
0
파일: lmMap.cs 프로젝트: sfszh/littleMap
	//set the type of Tile
	public int SetTileType(Point2 Pos,BrushType Type, Orientation ori = Orientation.None)
	{
		//map.tile[Pos.x,Pos.y].
		return 0;
	}
예제 #27
0
        private void RB_Square_CheckedChanged(object sender, EventArgs e)
        {
            if (RB_Square.Checked) Brushtype = BrushType.Square;

            UpdatePreview();
        }
예제 #28
0
 public void DrawCharacter()
 {
     _currentSelection = "";
     drawType          = DrawType.Add;
     brushType         = BrushType.Character;
 }
예제 #29
0
파일: Brushes.cs 프로젝트: misiek/foo
 public static extern GpStatus GdipGetBrushType(GpBrush brush, out BrushType type);
예제 #30
0
파일: NodeEditor.cs 프로젝트: beneon/Quixel
        /// <summary>
        /// Returns a list of points inside of a given brush type and size.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="size"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        private static List<Vector3> getPoints(BrushType type, int size, Vector3 pos)
        {
            float nodeWidth = NodeManager.LODSize[0];
            //这里是不是少了一个nodesize呢?先加上去看看
            //但是仍旧还是一样的呢
            Vector3I point = new Vector3I((int)Math.Round(pos.x / nodeWidth),
                (int)Math.Round(pos.y / nodeWidth),
                (int)Math.Round(pos.z / nodeWidth));

            List<Vector3> ret = new List<Vector3>();
            switch (type)
            {
                case BrushType.BOX:
                    for (int x = 0; x <= size; x++)
                    {
                        for (int y = 0; y <= size; y++)
                        {
                            for (int z = 0; z <= size; z++)
                            {
                                Vector3 realPos = new Vector3();
                                realPos.x = ((point.x + x) * nodeWidth);
                                realPos.y = ((point.y + y) * nodeWidth);
                                realPos.z = ((point.z + z) * nodeWidth);
                                //这里就类似*nodesize了,所以上面应该是不用加
                                ret.Add(realPos);
                            }
                        }
                    }
                    break;

                case BrushType.SPHERE:
                    for (int x = -size; x < size; x++)
                    {
                        for (int y = -size * 2; y < size; y++)
                        {
                            for (int z = -size; z < size; z++)
                            {
                                Vector3 realPos = new Vector3();
                                realPos.x = ((point.x + x) * nodeWidth);
                                realPos.y = ((point.y + y) * nodeWidth);
                                realPos.z = ((point.z + z) * nodeWidth);

                                if (Vector3.Distance(realPos, pos) < size * nodeWidth)
                                {
                                    ret.Add(realPos);
                                }
                            }
                        }
                    }
                    break;
            }
            string retStr = type+","+size+",";
            foreach(Vector3 v in ret){
              retStr+=v+",";
            }
            Debug.Log(retStr);
            return ret;
        }
예제 #31
0
		/// 
		/// <param name="brushType"></param>
		public Brush BrushType(BrushType brushType){
		     this.brushType=brushType;
		return this; 
		}
예제 #32
0
 public Brush Convert(DateTime currentCalendarCaseDate, bool isSelected, Brush defaultValue, BrushType brushType)
 {
     if (brushType == BrushType.Background)
     {
         // background brush color when the calendar case is selected
         if (currentCalendarCaseDate == DateTime.Today)
             return todayColorBrush;
         else
             return blackColorBrush;
     }
     else
     {
         if (currentCalendarCaseDate == DateTime.Today)
             return blackColorBrush;
         return Foreground;
     }
 }
예제 #33
0
GdipGetBrushType(GpBrush brush, out BrushType type);
예제 #34
0
 /// <param name="brushType"></param>
 public RippleEffect BrushType(BrushType brushType)
 {
     this.brushType = brushType;
     return this;
 }
예제 #35
0
 public PaintBrush()
 {
     isOn         = false;
     currentBrush = BrushType.Off;
 }
예제 #36
0
 public EmfPlusBrushDataBase(BrushType type)
 {
     BrushType = type;
 }
예제 #37
0
 public void SetPaintMode()
 {
     brushType = BrushType.Paint;
 }
예제 #38
0
 public PaintBrush()
 {
     isOn = false;
     currentBrush = BrushType.Off;
 }
예제 #39
0
 public BrushInfo(BrushType brushType, HatchStyle hatchStyle)
 {
     this.brushType = brushType;
     this.hatchStyle = hatchStyle;
 }
예제 #40
0
 protected void Start()
 {
     _brushType = BrushType.Normal;
     _brush     = BrushNormal;
     ResizeBrush();
 }
    public void HandleKeyboard()
    {
        if (Event.current.keyCode == KeyCode.Alpha1)
        {
            brushType = BrushType.Brush1;
        }
        if (Event.current.keyCode == KeyCode.Alpha2)
        {
            brushType = BrushType.Brush3;
        }
        if (Event.current.keyCode == KeyCode.Alpha3)
        {
            brushType = BrushType.Brush5;
        }
        if (Event.current.keyCode == KeyCode.RightBracket)
        {
            brushType = (BrushType)((int)brushType < 2 ? (int)brushType + 1 : 0);
        }
        if (Event.current.keyCode == KeyCode.LeftBracket)
        {
            brushType = (BrushType)((int)brushType > 0 ? (int)brushType - 1 : 2);
        }
        if (Event.current.keyCode == KeyCode.RightArrow && (Event.current.control || Event.current.command) && Event.current.type == EventType.keyDown)
        {
            selection = null;
            selectionActive = false;
            ragePixelSprite.shiftCell(1, true);
            ragePixelSprite.refreshMesh();
            animStripGUI.isDirty = true;
            Event.current.Use();
        }
        if (Event.current.keyCode == KeyCode.LeftArrow && (Event.current.control || Event.current.command) && Event.current.type == EventType.keyDown)
        {
            selection = null;
            selectionActive = false;
            ragePixelSprite.shiftCell(-1, true);
            ragePixelSprite.refreshMesh();
            animStripGUI.isDirty = true;
            Event.current.Use();
        }
        if (Event.current.keyCode == KeyCode.Z && (Event.current.control || Event.current.command) && Event.current.alt && Event.current.type == EventType.keyDown)
        {
            DoPaintUndo();
            animStripGUI.isDirty = true;
            spriteSheetGUI.isDirty = true;
            atlasTextureIsDirty = true;
            Event.current.Use();
        }
        if (Event.current.keyCode == KeyCode.D && (Event.current.control || Event.current.command) && Event.current.alt && Event.current.type == EventType.keyDown && mode == Mode.Select)
        {
            backBuffer.PasteBitmap(selection.X, selection.Y, frontBuffer);
            animStripGUI.isDirty = true;
            spriteSheetGUI.isDirty = true;
            atlasTextureIsDirty = true;
            Event.current.Use();
        }
        if (Event.current.keyCode == KeyCode.X && (Event.current.control || Event.current.command) && Event.current.alt && Event.current.type == EventType.keyDown && mode == Mode.Select)
        {
            SavePaintUndo();
            RagePixelUtil.Settings.clipboard = new RagePixelBitmap(frontBuffer.pixels, frontBuffer.Width(), frontBuffer.Height());
            selectionActive = false;
            Rect currentUV = ragePixelSprite.GetCurrentCell().uv;
            Rect selectionUV = new Rect(
                currentUV.xMin + (float)selection.X / (float)spritesheetTexture.width,
                currentUV.yMin + (float)selection.Y / (float)spritesheetTexture.height,
                (float)(selection.X2 - selection.X + 1) / (float)spritesheetTexture.width,
                (float)(selection.Y2 - selection.Y + 1) / (float)spritesheetTexture.height
                );
            RagePixelUtil.clearPixels(spritesheetTexture, selectionUV);
            spritesheetTexture.Apply();
            atlasTextureIsDirty = true;

            selection = null;
            Event.current.Use();
        }
        if (Event.current.keyCode == KeyCode.C && (Event.current.control || Event.current.command) && Event.current.alt && Event.current.type == EventType.keyDown && mode == Mode.Select)
        {
            RagePixelUtil.Settings.clipboard = new RagePixelBitmap(frontBuffer.pixels, frontBuffer.Width(), frontBuffer.Height());
            selection = null;
            selectionActive = false;
            Event.current.Use();
        }
        if (Event.current.keyCode == KeyCode.V && (Event.current.control || Event.current.command) && Event.current.alt && Event.current.type == EventType.keyDown)
        {
            if (RagePixelUtil.Settings.clipboard != null)
            {
                mode = Mode.Select;

                SavePaintUndo();

                Rect spriteUV = ragePixelSprite.GetCurrentCell().uv;

                selection = new RagePixelTexelRect(
                    0,
                    0,
                    Mathf.Min(RagePixelUtil.Settings.clipboard.Width(), ragePixelSprite.GetCurrentRow().pixelSizeX),
                    Mathf.Min(RagePixelUtil.Settings.clipboard.Height(), ragePixelSprite.GetCurrentRow().pixelSizeY)
                    );

                backBuffer = GrabSprite(spriteUV);
                frontBuffer = RagePixelUtil.Settings.clipboard;

                frontBufferPosition = new RagePixelTexel(0, 0);
                frontBufferDragStartPosition = new RagePixelTexel(0, 0);

                PasteBitmapToSpritesheetAlpha(frontBufferPosition, spriteUV, frontBuffer);

                selectionActive = true;
                spritesheetTexture.Apply();

                Event.current.Use();
            }
        }
    }
예제 #42
0
    // MORE INTERNAL
    // Painting
    private void PaintClick(BrushType brushType)
    {
        switch(brushType)
        {
            ////
        case BrushType.Off:
            break;

            ////
        case BrushType.DrawSingle:
            Mark();
            break;

        case BrushType.DrawMed:
            Mark();
            MarkAllNeighbors();
            break;

        case BrushType.DrawWide:
            Mark();
            MarkAllNeighbors();
            for(int x = 0; x < tileNeighbors.Count; x++)
            {
                if(null != tileNeighbors[x])
                {
                    tileNeighbors[x].MarkAllNeighbors();
                }
            }
            break;

            ////
        case BrushType.EraseSingle:
            Erase();
            break;

        case BrushType.EraseMed:
            Erase();
            EraseAllNeighbors();
            break;

        case BrushType.EraseWide:
            Erase();
            EraseAllNeighbors();
            for(int x = 0; x < tileNeighbors.Count; x++)
            {
                if(null != tileNeighbors[x])
                {
                    tileNeighbors[x].EraseAllNeighbors();
                }
            }
            break;
        }
    }
예제 #43
0
		static internal extern Status GdipGetBrushType (IntPtr brush, out BrushType type);
예제 #44
0
 public void SetBlurMode()
 {
     brushType = BrushType.Blur;
 }
예제 #45
0
 public BrushX(Color c)
 {
     this._brushType = BrushType.SolidBrush;
     this._foreColor = c;
 }
    public void HandlePaintGUI()
    {
        int guiPosX = 5;
        int guiPosY = (int)(scenePixelHeight / 2f - defaultSceneButtonWidth * 5f * 0.5f);

        GUI.color = GetSceneButtonColor(mode == Mode.Default);
        if (GUI.Button(new Rect(guiPosX, guiPosY, defaultSceneButtonWidth, defaultSceneButtonWidth), RagePixelGUIIcons.Cursor))
        {
            selection = null;
            selectionActive = false;
            paintColorPickerGUI.gizmoVisible = false;
            mode = Mode.Default;
            Tools.current = Tool.Move;
        }

        GUI.color = GetSceneButtonColor(mode == Mode.Pen);
        if (GUI.Button(new Rect(guiPosX, guiPosY += defaultSceneButtonHeight, defaultSceneButtonWidth, defaultSceneButtonWidth), RagePixelGUIIcons.Pen))
        {
            selection = null;
            selectionActive = false;
            paintColorPickerGUI.gizmoVisible = true;
            mode = Mode.Pen;
            Tools.current = Tool.None;
        }
        if (mode == Mode.Pen)
        {

            GUI.color = GetSceneButtonColor(brushType == BrushType.Brush1);
            if (GUI.Button(new Rect(guiPosX + defaultSceneButtonWidth + 2, guiPosY, 9, 8), ""))
            {
                brushType = BrushType.Brush1;
            }

            GUI.color = GetSceneButtonColor(brushType == BrushType.Brush3);
            if (GUI.Button(new Rect(guiPosX + defaultSceneButtonWidth + 2, guiPosY + 10, 12, 10), ""))
            {
                brushType = BrushType.Brush3;
            }
            GUI.color = GetSceneButtonColor(brushType == BrushType.Brush5);
            if (GUI.Button(new Rect(guiPosX + defaultSceneButtonWidth + 2, guiPosY + 20, 15, 12), ""))
            {
                brushType = BrushType.Brush5;
            }
        }

        GUI.color = GetSceneButtonColor(mode == Mode.Fill);
        if (GUI.Button(new Rect(guiPosX, guiPosY += defaultSceneButtonWidth, defaultSceneButtonWidth, defaultSceneButtonWidth), RagePixelGUIIcons.Fill))
        {
            selection = null;
            selectionActive = false;
            paintColorPickerGUI.gizmoVisible = true;
            mode = Mode.Fill;
            Tools.current = Tool.None;
        }

        GUI.color = GetSceneButtonColor(mode == Mode.Select);
        if (ragePixelSprite.mode == RagePixelSprite.Mode.Grid9)
        {
            GUI.color = new Color(1f, 1f, 1f, 0.1f);
        }
        if (GUI.Button(new Rect(guiPosX, guiPosY += defaultSceneButtonWidth, defaultSceneButtonWidth, defaultSceneButtonWidth), RagePixelGUIIcons.Select) && ragePixelSprite.mode != RagePixelSprite.Mode.Grid9)
        {
            selection = null;
            selectionActive = false;
            mode = Mode.Select;
            Tools.current = Tool.None;
        }

        GUI.color = GetSceneButtonColor(mode == Mode.Resize);
        if (ragePixelSprite.mode == RagePixelSprite.Mode.Grid9)
        {
            GUI.color = new Color(1f, 1f, 1f, 0.1f);
        }
        if (GUI.Button(new Rect(guiPosX, guiPosY += defaultSceneButtonWidth, defaultSceneButtonWidth, defaultSceneButtonWidth), RagePixelGUIIcons.Resize) && ragePixelSprite.mode != RagePixelSprite.Mode.Grid9)
        {
            ragePixelSprite.SnapToScale();
            selection = null;
            selectionActive = false;
            mode = Mode.Resize;
            Tools.current = Tool.None;
        }
    }
예제 #47
0
 public void SetEdgesMode()
 {
     brushType = BrushType.Edges;
 }
예제 #48
0
        public EffectBrush(System.Windows.Media.Brush brush)
        {
            if (brush is System.Windows.Media.SolidColorBrush)
            {
                type = BrushType.Solid;

                wrap = BrushWrap.Repeat;

                colorGradients.Add(0.0f, Utils.ColorUtils.MediaColorToDrawingColor((brush as System.Windows.Media.SolidColorBrush).Color));
                colorGradients.Add(1.0f, Utils.ColorUtils.MediaColorToDrawingColor((brush as System.Windows.Media.SolidColorBrush).Color));
            }
            else if (brush is System.Windows.Media.LinearGradientBrush)
            {
                type = BrushType.Linear;

                System.Windows.Media.LinearGradientBrush lgb = (brush as System.Windows.Media.LinearGradientBrush);

                start  = new System.Drawing.PointF((float)lgb.StartPoint.X, (float)lgb.StartPoint.Y);
                end    = new System.Drawing.PointF((float)lgb.EndPoint.X, (float)lgb.EndPoint.Y);
                center = new System.Drawing.PointF(0.0f, 0.0f);

                switch (lgb.SpreadMethod)
                {
                case (System.Windows.Media.GradientSpreadMethod.Pad):
                    wrap = BrushWrap.None;
                    break;

                case (System.Windows.Media.GradientSpreadMethod.Repeat):
                    wrap = BrushWrap.Repeat;
                    break;

                case (System.Windows.Media.GradientSpreadMethod.Reflect):
                    wrap = BrushWrap.Reflect;
                    break;
                }

                foreach (var grad in lgb.GradientStops)
                {
                    if (!colorGradients.ContainsKey((float)grad.Offset) && ((float)grad.Offset >= 0.0f && (float)grad.Offset <= 1.0f))
                    {
                        colorGradients.Add(
                            (float)grad.Offset,
                            Utils.ColorUtils.MediaColorToDrawingColor(grad.Color)
                            );
                    }
                }
            }
            else if (brush is System.Windows.Media.RadialGradientBrush)
            {
                type = BrushType.Radial;

                System.Windows.Media.RadialGradientBrush rgb = (brush as System.Windows.Media.RadialGradientBrush);

                start  = new System.Drawing.PointF(0, 0);
                end    = new System.Drawing.PointF((float)rgb.RadiusX * 2.0f, (float)rgb.RadiusY * 2.0f);
                center = new System.Drawing.PointF(
                    (float)rgb.Center.X,
                    (float)rgb.Center.Y
                    );

                switch (rgb.SpreadMethod)
                {
                case (System.Windows.Media.GradientSpreadMethod.Pad):
                    wrap = BrushWrap.None;
                    break;

                case (System.Windows.Media.GradientSpreadMethod.Repeat):
                    wrap = BrushWrap.Repeat;
                    break;

                case (System.Windows.Media.GradientSpreadMethod.Reflect):
                    wrap = BrushWrap.Reflect;
                    break;
                }

                foreach (var grad in rgb.GradientStops)
                {
                    if (!colorGradients.ContainsKey((float)grad.Offset) && ((float)grad.Offset >= 0.0f && (float)grad.Offset <= 1.0f))
                    {
                        colorGradients.Add(
                            (float)grad.Offset,
                            Utils.ColorUtils.MediaColorToDrawingColor(grad.Color)
                            );
                    }
                }
            }
            else
            {
            }

            if (colorGradients.Count > 0)
            {
                bool firstFound = false;
                System.Drawing.Color first_color = new System.Drawing.Color();
                System.Drawing.Color last_color  = new System.Drawing.Color();

                foreach (var kvp in colorGradients)
                {
                    if (!firstFound)
                    {
                        first_color = kvp.Value;
                        firstFound  = true;
                    }

                    last_color = kvp.Value;
                }

                if (!colorGradients.ContainsKey(0.0f))
                {
                    colorGradients.Add(0.0f, first_color);
                }

                if (!colorGradients.ContainsKey(1.0f))
                {
                    colorGradients.Add(1.0f, last_color);
                }
            }
            else
            {
                if (!colorGradients.ContainsKey(0.0f))
                {
                    colorGradients.Add(0.0f, System.Drawing.Color.Transparent);
                }

                if (!colorGradients.ContainsKey(1.0f))
                {
                    colorGradients.Add(1.0f, System.Drawing.Color.Transparent);
                }
            }
        }
예제 #49
0
 public EffectBrush SetBrushType(BrushType type)
 {
     this.type = type;
     return(this);
 }
예제 #50
0
 private void toolStripButtonPaintBrush_Click(object sender, EventArgs e)
 {
     toolStripButtonPaintBrush.Checked = true;
                 toolStripButtonEraser.Checked = false;
                 toolStripButton1.Checked = false;
                 groupBoxPaintBucket.Visible = false;
                 brushType = BrushType.Brush;
 }
예제 #51
0
        public EffectBrush(System.Drawing.Brush brush)
        {
            if (brush is System.Drawing.SolidBrush)
            {
                type = BrushType.Solid;

                colorGradients.Add(0.0f, (brush as System.Drawing.SolidBrush).Color);
                colorGradients.Add(1.0f, (brush as System.Drawing.SolidBrush).Color);

                wrap = BrushWrap.Repeat;
            }
            else if (brush is System.Drawing.Drawing2D.LinearGradientBrush)
            {
                type = BrushType.Linear;

                System.Drawing.Drawing2D.LinearGradientBrush lgb = (brush as System.Drawing.Drawing2D.LinearGradientBrush);

                start  = lgb.Rectangle.Location;
                end    = new System.Drawing.PointF(lgb.Rectangle.Width, lgb.Rectangle.Height);
                center = new System.Drawing.PointF(0.0f, 0.0f);

                switch (lgb.WrapMode)
                {
                case (System.Drawing.Drawing2D.WrapMode.Clamp):
                    wrap = BrushWrap.None;
                    break;

                case (System.Drawing.Drawing2D.WrapMode.Tile):
                    wrap = BrushWrap.Repeat;
                    break;

                case (System.Drawing.Drawing2D.WrapMode.TileFlipXY):
                    wrap = BrushWrap.Reflect;
                    break;
                }

                try
                {
                    if (lgb.InterpolationColors != null && lgb.InterpolationColors.Colors.Length == lgb.InterpolationColors.Positions.Length)
                    {
                        for (int x = 0; x < lgb.InterpolationColors.Colors.Length; x++)
                        {
                            if (!colorGradients.ContainsKey(lgb.InterpolationColors.Positions[x]) && (lgb.InterpolationColors.Positions[x] >= 0.0f && lgb.InterpolationColors.Positions[x] <= 1.0f))
                            {
                                colorGradients.Add(
                                    lgb.InterpolationColors.Positions[x],
                                    lgb.InterpolationColors.Colors[x]
                                    );
                            }
                        }
                    }
                }
                catch (Exception exc)
                {
                    colorGradients.Clear();

                    for (int x = 0; x < lgb.LinearColors.Length; x++)
                    {
                        float pos = x / (float)(lgb.LinearColors.Length - 1);

                        if (!colorGradients.ContainsKey(pos))
                        {
                            colorGradients.Add(
                                pos,
                                lgb.LinearColors[x]
                                );
                        }
                    }
                }
            }
            else if (brush is System.Drawing.Drawing2D.PathGradientBrush)
            {
                type = BrushType.Radial;

                System.Drawing.Drawing2D.PathGradientBrush pgb = (brush as System.Drawing.Drawing2D.PathGradientBrush);

                start  = pgb.Rectangle.Location;
                end    = new System.Drawing.PointF(pgb.Rectangle.Width, pgb.Rectangle.Height);
                center = new System.Drawing.PointF(
                    pgb.CenterPoint.X,
                    pgb.CenterPoint.Y
                    );


                switch (pgb.WrapMode)
                {
                case (System.Drawing.Drawing2D.WrapMode.Clamp):
                    wrap = BrushWrap.None;
                    break;

                case (System.Drawing.Drawing2D.WrapMode.Tile):
                    wrap = BrushWrap.Repeat;
                    break;

                case (System.Drawing.Drawing2D.WrapMode.TileFlipXY):
                    wrap = BrushWrap.Reflect;
                    break;
                }

                try
                {
                    if (pgb.InterpolationColors != null && pgb.InterpolationColors.Colors.Length == pgb.InterpolationColors.Positions.Length)
                    {
                        for (int x = 0; x < pgb.InterpolationColors.Colors.Length; x++)
                        {
                            if (!colorGradients.ContainsKey(pgb.InterpolationColors.Positions[x]) && (pgb.InterpolationColors.Positions[x] >= 0.0f && pgb.InterpolationColors.Positions[x] <= 1.0f))
                            {
                                colorGradients.Add(
                                    pgb.InterpolationColors.Positions[x],
                                    pgb.InterpolationColors.Colors[x]
                                    );
                            }
                        }
                    }
                }
                catch (Exception exc)
                {
                    colorGradients.Clear();

                    for (int x = 0; x < pgb.SurroundColors.Length; x++)
                    {
                        float pos = x / (float)(pgb.SurroundColors.Length - 1);

                        if (!colorGradients.ContainsKey(pos))
                        {
                            colorGradients.Add(
                                pos,
                                pgb.SurroundColors[x]
                                );
                        }
                    }
                }
            }
            else
            {
            }

            if (colorGradients.Count > 0)
            {
                bool firstFound = false;
                System.Drawing.Color first_color = new System.Drawing.Color();
                System.Drawing.Color last_color  = new System.Drawing.Color();

                foreach (var kvp in colorGradients)
                {
                    if (!firstFound)
                    {
                        first_color = kvp.Value;
                        firstFound  = true;
                    }

                    last_color = kvp.Value;
                }

                if (!colorGradients.ContainsKey(0.0f))
                {
                    colorGradients.Add(0.0f, first_color);
                }

                if (!colorGradients.ContainsKey(1.0f))
                {
                    colorGradients.Add(1.0f, last_color);
                }
            }
            else
            {
                if (!colorGradients.ContainsKey(0.0f))
                {
                    colorGradients.Add(0.0f, System.Drawing.Color.Transparent);
                }

                if (!colorGradients.ContainsKey(1.0f))
                {
                    colorGradients.Add(1.0f, System.Drawing.Color.Transparent);
                }
            }
        }
예제 #52
0
파일: NodeEditor.cs 프로젝트: beneon/Quixel
        /// <summary>
        /// Returns a list of points inside of a given brush type and size.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="size"></param>
        /// <param name="pos"></param>
        /// <returns></returns>
        private static List<Vector3> getPoints(BrushType type, int size, Vector3 pos)
        {
            float nodeWidth = NodeManager.LODSize[0];
            Vector3I point = new Vector3I((int)Math.Round(pos.x / nodeWidth),
                (int)Math.Round(pos.y / nodeWidth),
                (int)Math.Round(pos.z / nodeWidth));

            List<Vector3> ret = new List<Vector3>();
            switch (type)
            {
                case BrushType.BOX:
                    for (int x = 0; x <= size; x++)
                    {
                        for (int y = 0; y <= size; y++)
                        {
                            for (int z = 0; z <= size; z++)
                            {
                                Vector3 realPos = new Vector3();
                                realPos.x = ((point.x + x) * nodeWidth);
                                realPos.y = ((point.y + y) * nodeWidth);
                                realPos.z = ((point.z + z) * nodeWidth);
                                ret.Add(realPos);
                            }
                        }
                    }
                    break;

                case BrushType.SPHERE:
                    for (int x = -size; x < size; x++)
                    {
                        for (int y = -size * 2; y < size; y++)
                        {
                            for (int z = -size; z < size; z++)
                            {
                                Vector3 realPos = new Vector3();
                                realPos.x = ((point.x + x) * nodeWidth);
                                realPos.y = ((point.y + y) * nodeWidth);
                                realPos.z = ((point.z + z) * nodeWidth);

                                if (Vector3.Distance(realPos, pos) < size * nodeWidth)
                                {
                                    ret.Add(realPos);
                                }
                            }
                        }
                    }
                    break;
            }

            return ret;
        }
예제 #53
0
    public static void GenerateMesh(List <TubeVertex> vertices, int dataIndex, bool Flat, bool Web, BrushType brushType, Vector2 ExtendsMultiplier,
                                    List <Vector3> meshVertices, List <Vector4> meshTangents,
                                    List <Vector3> meshNormals, List <Vector2> uvs, List <Color> colors, ref int[] indices, ref float length)
    {
        int additionalVertices = brushType == BrushType.Sphere ? 8 : 2;
        int actualVertexCount  = vertices.Count + additionalVertices;


        List <int> tris = new List <int>();

        float currentTotalLength = 0;

        Action <int, TubeVertex, TubeVertex, TubeVertex> addPointFunc = (int i, TubeVertex v, TubeVertex prev, TubeVertex next) =>
        {
            var prevPoint = prev.point;
            var nextPoint = next.point;

            float dist = Vector3.Distance(prevPoint, v.point);
            currentTotalLength += dist;

            if (float.IsNaN(v.point.x) || float.IsNaN(v.point.z) || float.IsNaN(v.point.z))
            {
                return;
            }

            meshVertices[i] = v.point;
            if (Flat)
            {
                meshNormals[i] = v.orientation * Vector3.up * Mathf.Clamp(ExtendsMultiplier.y * v.extends.y, 0, .005f);
            }
            else
            {
                meshNormals[i] = v.orientation * Vector3.up * ExtendsMultiplier.y * v.extends.y;
            }
            // Tangents for hermite interpolation
            Vector3 dir = 0.5f * (nextPoint - prevPoint);
            // Width of the line
            meshTangents[i] = new Vector4(dir.x, dir.y, dir.z, v.extends.x * ExtendsMultiplier.x);

            uvs[i]    = new Vector2(dataIndex, currentTotalLength);
            colors[i] = v.color;

            if (i < actualVertexCount - 1)
            {
                tris.Add(i);
                tris.Add(i + 1);
            }

            if (Web && i < actualVertexCount - 7)
            {
                tris.Add(i);
                tris.Add(i + 7);
            }
        };

        if (brushType == BrushType.Sphere)
        {
            TubeVertex firstAddVert = vertices[0];
            var        startPoint   = vertices[0].point;
            firstAddVert.point -= firstAddVert.orientation * Vector3.forward * firstAddVert.extends.x * 0.5f;
            var endPoint = firstAddVert.point;

            Vector2 smallExtends = brushType == BrushType.Sphere ? firstAddVert.extends * 0.001f : firstAddVert.extends;
            var     prevExtends  = firstAddVert.extends;

            Func <float, float> t      = (float v) => v;
            Func <float, float> height = (float v) => Mathf.Sqrt(1.0f - (1.0f - v) * (1.0f - v));

            {
                firstAddVert.extends = firstAddVert.extends * 0.001f;

                var   lastVert = firstAddVert;
                float interp   = ((float)1.0f) / (0.5f * additionalVertices + 1);


                firstAddVert.extends = Vector2.Lerp(smallExtends, prevExtends, height(t(interp)));
                firstAddVert.point   = Vector3.Lerp(endPoint, startPoint, t(interp));
                var thisVert = firstAddVert;

                addPointFunc(0, lastVert, lastVert, thisVert);


                interp = ((float)2.0f) / (0.5f * additionalVertices + 1);
                firstAddVert.extends = Vector2.Lerp(smallExtends, prevExtends, height(t(interp)));
                firstAddVert.point   = Vector3.Lerp(endPoint, startPoint, t(interp));

                var nextVert = firstAddVert;

                for (int i = 1; i <= additionalVertices / 2; i++)
                {
                    addPointFunc(i, thisVert, lastVert, nextVert);
                    lastVert = thisVert;
                    thisVert = nextVert;

                    interp           = ((float)i + 2) / (0.5f * additionalVertices + 1);
                    nextVert.extends = Vector2.Lerp(smallExtends, prevExtends, height(t(interp)));
                    nextVert.point   = Vector3.Lerp(endPoint, startPoint, t(interp));
                }

                firstAddVert = lastVert;
            }

            TubeVertex lastAddVert = vertices[vertices.Count - 1];
            startPoint         = lastAddVert.point;
            lastAddVert.point += lastAddVert.orientation * Vector3.forward * lastAddVert.extends.x * 0.5f;
            endPoint           = lastAddVert.point;
            prevExtends        = lastAddVert.extends;

            smallExtends = brushType == BrushType.Sphere ? lastAddVert.extends * 0.001f : lastAddVert.extends;

            lastAddVert.extends = Vector2.Lerp(prevExtends, smallExtends, 1.0f / (0.5f * additionalVertices));
            lastAddVert.point   = Vector3.Lerp(startPoint, endPoint, 1.0f / (0.5f * additionalVertices));

            int firstIndex = additionalVertices / 2;
            for (int i = 1; i < vertices.Count - 1; i++)
            {
                addPointFunc(firstIndex + i, vertices[i], i == 1 ? firstAddVert : vertices[i - 1], i == vertices.Count - 2 ? lastAddVert : vertices[i + 1]);
            }


            {
                float interp = 0.0f / (0.5f * additionalVertices + 1);

                var lastVert = vertices[vertices.Count - 2];
                lastAddVert.extends = Vector2.Lerp(prevExtends, smallExtends, 1.0f - height(1.0f - t(interp)));
                lastAddVert.point   = Vector3.Lerp(startPoint, endPoint, t(interp));

                var thisVert = lastAddVert;

                interp = 1.0f / (0.5f * additionalVertices + 1);
                lastAddVert.extends = Vector2.Lerp(prevExtends, smallExtends, 1.0f - height(1.0f - t(interp)));
                lastAddVert.point   = Vector3.Lerp(startPoint, endPoint, t(interp));
                var nextVert = lastAddVert;

                for (int i = actualVertexCount - additionalVertices / 2 - 1; i < actualVertexCount - 1; i++)
                {
                    addPointFunc(i, thisVert, lastVert, nextVert);
                    interp           = 1.0f - ((float)actualVertexCount - i - 3) / (0.5f * additionalVertices + 1);
                    lastVert         = thisVert;
                    thisVert         = nextVert;
                    nextVert.extends = Vector2.Lerp(prevExtends, smallExtends, 1.0f - height(1.0f - t(interp)));
                    nextVert.point   = Vector3.Lerp(startPoint, endPoint, t(interp));
                }

                lastAddVert.extends = vertices[vertices.Count - 1].extends * 0.001f;
                lastAddVert.point   = endPoint;
                addPointFunc(actualVertexCount - 1, lastAddVert, lastVert, lastAddVert);
            }
        }
        else
        {
            var firstPoint = vertices[0];
            firstPoint.point -= firstPoint.orientation * Vector3.forward * firstPoint.extends.x * 0.5f;

            var nextPoint = firstPoint;
            firstPoint.extends *= 0.00001f;

            addPointFunc(0, firstPoint, firstPoint, nextPoint);

            addPointFunc(1, nextPoint, firstPoint, vertices[1]);

            var lastPoint = vertices[vertices.Count - 1];
            lastPoint.point += lastPoint.orientation * Vector3.forward * lastPoint.extends.x * 0.5f;

            var closingPoint = lastPoint;
            closingPoint.extends *= 0.00001f;

            var lastAddedPoint = nextPoint;

            for (int i = 1; i < vertices.Count - 1; i++)
            {
                addPointFunc(i + 1, vertices[i], lastAddedPoint, i == vertices.Count - 2 ? lastPoint : vertices[i + 1]);
                lastAddedPoint = vertices[i];
            }

            addPointFunc(vertices.Count, lastPoint, lastAddedPoint, closingPoint);
            addPointFunc(vertices.Count + 1, closingPoint, lastPoint, closingPoint);
        }


        indices = tris.ToArray();
        length  = currentTotalLength;
    }
예제 #54
0
파일: NodeEditor.cs 프로젝트: beneon/Quixel
 /// <summary>
 /// 'Heals' the terrain around a given point, essentially returning the terrain to it's original state.
 /// </summary>
 /// <param name="type">The type/shape of the brush.</param>
 /// <param name="size">The size (radius) of the brush.</param>
 /// <param name="pos">The (real world) position to apply the brush.</param>
 public static void applyHeal(BrushType type, int size, Vector3 pos)
 {
     byte mID = materialID;
     materialID = 0;
     applyBrush(type, size, pos, -100000f);
     materialID = mID;
 }
예제 #55
0
 void Update()
 {
     curType = (BrushType)brushTypeDropDown.value;
     Printer.instance.SetBrushData(curType, (int)brushSizeSlider.value, concentrationSlider.value);
 }