Exemplo n.º 1
0
 public void ClearColor(BrushMask bm)
 {
     foreach (var uvi in vertices)
     {
         bm.SetValuesOn(ref uvi.color, Color.black);
     }
 }
Exemplo n.º 2
0
 public void ClearColor(BrushMask bm)
 {
     foreach (Vertex uvi in uvpoints)
     {
         bm.Transfer(ref uvi._color, Color.black);
     }
 }
Exemplo n.º 3
0
        public void SetEdges(Color col, BrushMask mask)
        {
            if (!Pixels.IsNullOrEmpty())
            {
                for (int XSection = 0; XSection <= 1; XSection++)
                {
                    int x = XSection * width - 1;
                    for (int y = 0; y < height; y++)
                    {
                        var pix = PixelUnSafe(x, y);
                        mask.SetValuesOn(ref pix, col);
                        SetPixelUnSafe(x, y, pix);
                    }
                }

                for (int YSection = 0; YSection <= 1; YSection++)
                {
                    int y = YSection * height - 1;
                    for (int x = 0; x < height; x++)
                    {
                        var pix = PixelUnSafe(x, y);
                        mask.SetValuesOn(ref pix, col);
                        SetPixelUnSafe(x, y, pix);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public bool ChannelSlider(BrushMask m, ref float channel)
        {
            pegi.write(m.getIcon(), 25);
            bool changed = pegi.edit(ref channel, 0, 1).nl();

            return(changed);
        }
Exemplo n.º 5
0
 public void SetColorOnLine(Color col, BrushMask bm, MeshPoint other)
 {
     foreach (var u in vertices)
     {
         if (u.ConnectedTo(other))
         {
             bm.SetValuesOn(ref u.color, col);   //val *= u._color.GetChanel01(chan) * u.GetConnectedUVinVertex(other)._color.GetChanel01(chan);
         }
     }
 }
Exemplo n.º 6
0
 public void SetColorOnLine(Color col, BrushMask bm, MeshPoint other)
 {
     foreach (Vertex u in uvpoints)
     {
         if (u.ConnectedTo(other))
         {
             bm.Transfer(ref u._color, col);   //val *= u._color.GetChanel01(chan) * u.GetConnectedUVinVert(other)._color.GetChanel01(chan);
         }
     }
 }
Exemplo n.º 7
0
 public void MaskSet(BrushMask flag, bool to)
 {
     if (to)
     {
         mask |= flag;
     }
     else
     {
         mask &= ~flag;
     }
 }
Exemplo n.º 8
0
        public void SetShadowAll(LinearColor col)
        {
            BrushMask bm = Cfg.brushConfig.mask;//glob.getBrush().brushMask;
            Color     c  = col.ToGamma();

            foreach (MeshPoint v in meshPoints)
            {
                bm.Transfer(ref v.shadowBake, c);
            }

            Dirty = true;
        }
Exemplo n.º 9
0
        public bool ChannelSlider(BrushMask inspectedMask, ref Color col, Texture icon, bool slider)
        {
            var changed = false;

            var channel = inspectedMask.ToColorChannel();

            if (!icon)
            {
                icon = channel.GetIcon();
            }

            var label          = inspectedMask.ToText();
            var channelEnabled = mask.HasFlag(inspectedMask);

            if (InspectedPainter && InspectedPainter.meshEditing && MeshMGMT.MeshTool == VertexColorTool.inst)
            {
                var mat = InspectedPainter.Material;
                if (mat)
                {
                    var tag = mat.Get(inspectedMask.ToString(), ShaderTags.VertexColorRole);

                    if (!tag.IsNullOrEmpty())
                    {
                        if (channelEnabled)
                        {
                            (tag + ":").nl();
                        }
                        else
                        {
                            label = tag + " ";
                        }
                    }
                }
            }

            if (channelEnabled ? icon.Click(label) : "{0} channel ignored".F(label).toggleIcon(ref channelEnabled, true).changes(ref changed))
            {
                mask ^= inspectedMask;
            }

            if (slider && channelEnabled)
            {
                float val = channel.GetValueFrom(col);
                if (pegi.edit(ref val, 0, 1).nl(ref changed))
                {
                    channel.SetValueOn(ref col, val);
                }
            }

            return(changed);
        }
Exemplo n.º 10
0
        public override bool Decode(string tg, string data)
        {
            switch (tg)
            {
            case "typeGPU": _inGpuBrushType = data.ToInt(); break;

            case "typeCPU": _inCpuBrushType = data.ToInt(); break;

            case "size2D": brush2DRadius = data.ToFloat(); break;

            case "size3D": brush3DRadius = data.ToFloat(); break;

            case "useMask": useMask = data.ToBool(); break;

            case "mask": mask = (BrushMask)data.ToInt(); break;

            case "modeCPU": _inCpuBlitMode = data.ToInt(); break;

            case "modeGPU": _inGpuBlitMode = data.ToInt(); break;

            case "bc": Color = data.ToColor(); break;

            case "source": selectedSourceTexture = data.ToInt(); break;

            case "blur": blurAmount = data.ToFloat(); break;

            case "decA": decalAngle = data.ToFloat(); break;

            case "decNo": selectedDecal = data.ToInt(); break;

            case "Smask": selectedSourceMask = data.ToInt(); break;

            case "maskTil": maskTiling = data.ToFloat(); break;

            case "maskFlip": flipMaskAlpha = data.ToBool(); break;

            case "hard": hardness = data.ToFloat(); break;

            case "Speed": _dSpeed.SetValue(data.ToFloat()); break;

            case "dSpeed": _dSpeed.Decode(data); break;

            case "dyn": data.Decode(out brushDynamic, BrushDynamic.all); break;

            case "maskOff": maskOffset = data.ToVector2(); break;

            default: return(false);
            }
            return(true);
        }
Exemplo n.º 11
0
        public static Texture GetIcon(this BrushMask icon)
        {
            var ind = 0;

            switch (icon)
            {
            case BrushMask.G: ind = 1; break;

            case BrushMask.B: ind = 2; break;

            case BrushMask.A: ind = 3; break;
            }

            return(ColorIcon(ind));
        }
Exemplo n.º 12
0
        public static string ToText(this BrushMask icon)
        {
            switch (icon)
            {
            case BrushMask.R: return("Red");

            case BrushMask.G: return("Green");

            case BrushMask.B: return("Blue");

            case BrushMask.A: return("Alpha");

            default: return("Unknown channel");
            }
        }
Exemplo n.º 13
0
        public void PaintAll(LinearColor col)
        {
            BrushMask bm = Cfg.brushConfig.mask;//glob.getBrush().brushMask;
            Color     c  = col.ToGamma();

            foreach (MeshPoint v in meshPoints)
            {
                foreach (Vertex uv in v.uvpoints)
                {
                    bm.Transfer(ref uv._color, c);
                }
            }
            //Debug.Log("Dirty");
            Dirty = true;
        }
Exemplo n.º 14
0
        public bool ChannelSlider(BrushMask m, ref float chanel, Texture icon, bool slider)
        {
            if (icon == null)
            {
                icon = m.getIcon();
            }

            string letter  = m.ToString();
            bool   maskVal = mask.GetFlag(m);

            if (InspectedPainter != null && InspectedPainter.meshEditing && MeshMGMT.MeshTool == VertexColorTool.inst)
            {
                var mat = InspectedPainter.Material;
                if (mat != null)
                {
                    var tag = mat.GetTag(PainterDataAndConfig.vertexColorRole + letter, false, null);
                    if (tag != null && tag.Length > 0)
                    {
                        if (maskVal)
                        {
                            (tag + ":").nl();
                        }
                        else
                        {
                            letter = tag + " ";
                        }
                    }
                }
            }

            bool changed = false;

            if (maskVal ? pegi.Click(icon, 25) : pegi.Click(letter + " disabled"))
            {
                MaskToggle(m);
                changed = true;
            }

            if ((slider) && (mask.GetFlag(m)))
            {
                changed |= pegi.edit(ref chanel, 0, 1);
            }

            pegi.newLine();

            return(changed);
        }
Exemplo n.º 15
0
 public void ToV4(ref Vector4 to, BrushMask bm)
 {
     if ((bm & BrushMask.R) != 0)
     {
         to.x = r;
     }
     if ((bm & BrushMask.G) != 0)
     {
         to.y = g;
     }
     if ((bm & BrushMask.B) != 0)
     {
         to.z = b;
     }
     if ((bm & BrushMask.A) != 0)
     {
         to.w = a;
     }
 }
Exemplo n.º 16
0
        public static ColorChanel ToColorChannel(this BrushMask bm)
        {
            switch (bm)
            {
            case BrushMask.R:
                return(ColorChanel.R);

            case BrushMask.G:
                return(ColorChanel.G);

            case BrushMask.B:
                return(ColorChanel.B);

            case BrushMask.A:
                return(ColorChanel.A);
            }

            return(ColorChanel.A);
        }
 public static void Transfer(this BrushMask bm, ref Color col, Color c)
 {
     if ((bm & BrushMask.R) != 0)
     {
         col.r = c.r;
     }
     if ((bm & BrushMask.G) != 0)
     {
         col.g = c.g;
     }
     if ((bm & BrushMask.B) != 0)
     {
         col.b = c.b;
     }
     if ((bm & BrushMask.A) != 0)
     {
         col.a = c.a;
     }
 }
Exemplo n.º 18
0
 public static void SetValuesOn(this BrushMask bm, ref Color target, Color source)
 {
     if ((bm & BrushMask.R) != 0)
     {
         target.r = source.r;
     }
     if ((bm & BrushMask.G) != 0)
     {
         target.g = source.g;
     }
     if ((bm & BrushMask.B) != 0)
     {
         target.b = source.b;
     }
     if ((bm & BrushMask.A) != 0)
     {
         target.a = source.a;
     }
 }
 public static void Transfer(this BrushMask bm, ref Vector4 col, Color c)
 {
     if ((bm & BrushMask.R) != 0)
     {
         col.x = c.r;
     }
     if ((bm & BrushMask.G) != 0)
     {
         col.y = c.g;
     }
     if ((bm & BrushMask.B) != 0)
     {
         col.z = c.b;
     }
     if ((bm & BrushMask.A) != 0)
     {
         col.w = c.a;
     }
 }
Exemplo n.º 20
0
 public static void SetValuesOn(this BrushMask bm, ref Vector4 target, Color source)
 {
     if ((bm & BrushMask.R) != 0)
     {
         target.x = source.r;
     }
     if ((bm & BrushMask.G) != 0)
     {
         target.y = source.g;
     }
     if ((bm & BrushMask.B) != 0)
     {
         target.z = source.b;
     }
     if ((bm & BrushMask.A) != 0)
     {
         target.w = source.a;
     }
 }
Exemplo n.º 21
0
 public void From(LinearColor c, BrushMask bm)
 {
     if ((bm & BrushMask.R) != 0)
     {
         r = c.r;
     }
     if ((bm & BrushMask.G) != 0)
     {
         g = c.g;
     }
     if ((bm & BrushMask.B) != 0)
     {
         b = c.b;
     }
     if ((bm & BrushMask.A) != 0)
     {
         a = c.a;
     }
 }
Exemplo n.º 22
0
        public ImageMeta SetPixels(Color col, BrushMask mask)
        {
            var p = Pixels;

            bool r = mask.HasFlag(BrushMask.R);
            bool g = mask.HasFlag(BrushMask.G);
            bool b = mask.HasFlag(BrushMask.B);
            bool a = mask.HasFlag(BrushMask.A);

            for (var i = 0; i < p.Length; i++)
            {
                var pix = p[i];
                pix.r = r ? col.a : pix.r;
                pix.g = g ? col.g : pix.g;
                pix.b = b ? col.b : pix.b;
                pix.a = a ? col.a : pix.a;
                p[i]  = pix;
            }

            return(this);
        }
Exemplo n.º 23
0
 public static bool HasFlag(this BrushMask mask, BrushMask flag) => (mask & flag) != 0;
Exemplo n.º 24
0
 public static Texture GetIcon(this BrushMask icon) => icon.ToColorChannel().GetIcon();
Exemplo n.º 25
0
 public static bool HasFlag(this BrushMask mask, int flag) => (mask & (BrushMask)(Mathf.Pow(2, flag))) != 0;
Exemplo n.º 26
0
 public BrushConfig()
 {
     Color = Color.green;
     mask  = new BrushMask();
     mask |= BrushMask.R | BrushMask.G | BrushMask.B;
 }
Exemplo n.º 27
0
 public BrushConfig()
 {
     colorLinear = new LinearColor(Color.green);
     mask        = new BrushMask();
     mask       |= BrushMask.R | BrushMask.G | BrushMask.B;
 }
Exemplo n.º 28
0
 public static bool GetFlag(this BrushMask mask, BrushMask flag)
 {
     return((mask & flag) != 0);
 }
Exemplo n.º 29
0
 public static bool GetFlag(this BrushMask mask, int flag)
 {
     return((mask & (BrushMask)(Mathf.Pow(2, flag))) != 0);
 }
Exemplo n.º 30
0
        //  public const string storyTag = "brush";
        //  public override string GetDefaultTagName() { return storyTag; }

        public void MaskToggle(BrushMask flag)
        {
            mask ^= flag;
        }