Exemple #1
0
        public void ApplyTextureAsNewChannel(int x, int y, textureData texture, Multibrush.Triangle inside, Rectangle coverRectangle, Random ran)
        {
            Rectangle rec = new Rectangle(x, y, this.Width, this.Height);

            int  channel    = 0;
            int  coverage   = 0;
            bool firstCheck = true;

            double presure = (float)texture.Presure / 100.0;

            if (coverRectangle.IntersectsWith(rec))
            {
                for (int xCoor = x; xCoor < x + this.Width; xCoor++)
                {
                    double adjustedXCoor = xCoor * Constants.TextureSpacing;

                    for (int yCoor = y; yCoor < y + this.Height; yCoor++)
                    {
                        double adjustedYCoor = yCoor * Constants.TextureSpacing;

                        if (inside.insideTriangle(new Pair <double, double>(adjustedXCoor, adjustedYCoor)))
                        {
                            coverage = ran.Next(1, 100);
                            if (coverage <= texture.Coverage)
                            {
                                if (firstCheck)
                                {
                                    firstCheck = false;

                                    if (this.TextureNames.Count >= 6)
                                    {
                                        return;
                                    }

                                    this.TextureNames.Add(texture.ToString());
                                    channel = this.TextureNames.Count - 1;
                                }

                                try {
                                    this[xCoor % this.Width, yCoor % this.Height, channel] = (byte)(presure * 255f);
                                } catch (Exception e) {
                                    throw new Exception("DDSGroup error: X:" + xCoor + ", Y:" + yCoor + " Channel: " + channel + ". Error Message: " + e.Message);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
 void addBrush(object sender, EventArgs e)
 {
     /*
      * There is no theoretical limit on the number of repeat textures, but there needs to be a balance between
      * the number of textures you can select and the time it will take to paint them all.
      */
     if (textureList.Items.Count < NUM_TEXTURE_TOTAL)
     {
         if (canAdd())
         {
             textureData texture = new textureData(brushTextureList.SelectedItem.ToString());
             textureList.Items.Add(texture);
             textureList.SelectedItem = texture;
         }
     }
 }
Exemple #3
0
        void AcceptBrushClick(object sender, EventArgs e)
        {
            if (canAdd())
            {
                int   index = textureList.SelectedIndex;
                Point cov   = new Point((int)fromCoverageVar.Value, (int)toCoverageVar.Value);
                Point pres  = new Point((int)fromPresureVar.Value, (int)toPresureVar.Value);

                textureData texture = new textureData(brushTextureList.SelectedItem.ToString(),
                                                      presureTrack.Value,
                                                      coverageTrack.Value,
                                                      cov,
                                                      pres);
                skipReload = true;
                textureList.Items.Remove(textureList.SelectedItem);
                textureList.Items.Insert(index, texture);
                textureList.SelectedIndex = index;
            }
        }
Exemple #4
0
        void TextureListSelectedIndexChanged(object sender, EventArgs e)
        {
            if (!skipReload)
            {
                textureData texture = (textureData)textureList.SelectedItem;
                if (texture != null)
                {
                    brushTextureList.setListByName(texture.texture);
                    presureTrack.Value  = texture.getPresureUnmodified();
                    coverageTrack.Value = texture.getCoverageUnmodified();

                    // Variance
                    // I need to do this in "reverse" order, to ensure I won't get into any trouble with the minimum and maximum settings
                    setVariance(toCoverageVar, texture.varCoverage.Y);
                    setVariance(fromCoverageVar, texture.varCoverage.X);

                    setVariance(toPresureVar, texture.varPresure.Y);
                    setVariance(fromPresureVar, texture.varPresure.X);
                }
            }
            skipReload = false;
        }
Exemple #5
0
        public void ApplyTextureAsNewChannel(int x, int y, textureData texture, Multibrush.LineSegment linesegment, Rectangle coverRectangle, double inner)
        {
            Rectangle rec = new Rectangle(x, y, this.Width, this.Height);
            Random    ran = new Random();

            int  channel    = 0;
            int  coverage   = 0;
            bool firstCheck = true;
            bool painted    = false;

            double presure = (float)texture.Presure / 100.0;

            if (coverRectangle.IntersectsWith(rec))
            {
                for (int xCoor = x; xCoor < x + this.Width; xCoor++)
                {
                    double adjustedXCoor = xCoor * Constants.TextureSpacing;
                    painted = false;

                    for (int yCoor = y; yCoor < y + this.Height; yCoor++)
                    {
                        double adjustedYCoor = yCoor * Constants.TextureSpacing;

                        Pair <double, double> point = new Multibrush.Pair <double, double>(adjustedXCoor, adjustedYCoor);

                        if (linesegment.distance(point) <= inner)
                        {
                            coverage = ran.Next(1, 100);
                            if (coverage <= texture.Coverage)
                            {
                                if (firstCheck)
                                {
                                    firstCheck = false;
                                    painted    = true;

                                    if (this.TextureNames.Count >= 6)
                                    {
                                        return;
                                    }

                                    this.TextureNames.Add(texture.ToString());
                                    channel = this.TextureNames.Count - 1;
                                }

                                try {
                                    this[xCoor % this.Width, yCoor % this.Height, channel] = (byte)(presure * 255f);
                                } catch (Exception e) {
                                    throw new Exception("DDSGroup error: X:" + xCoor + ", Y:" + yCoor + " Channel: " + channel + ". Error Message: " + e.Message);
                                }
                            }

                            /* Since we are going over this in a linear fashion, we if we ever paint something, and then stop painting,
                             *      then we can be sure that we do not need to paint any more
                             */
                        }
                        else if (painted)
                        {
                            break;
                        }
                    }
                }
            }
        }
 void addBrush(object sender, EventArgs e)
 {
     /*
      * There is no theoretical limit on the number of repeat textures, but there needs to be a balance between
      * the number of textures you can select and the time it will take to paint them all.
      */
     if (textureList.Items.Count < NUM_TEXTURE_TOTAL) {
         if (canAdd()) {
             textureData texture = new textureData(brushTextureList.SelectedItem.ToString());
             textureList.Items.Add(texture);
             textureList.SelectedItem = texture;
         }
     }
 }
        void AcceptBrushClick(object sender, EventArgs e)
        {
            if (canAdd()) {
                int index = textureList.SelectedIndex;
                Point cov = new Point((int)fromCoverageVar.Value, (int)toCoverageVar.Value);
                Point pres = new Point((int)fromPresureVar.Value, (int)toPresureVar.Value);

                textureData texture = new textureData(brushTextureList.SelectedItem.ToString(),
                                                      presureTrack.Value,
                                                      coverageTrack.Value,
                                                      cov,
                                                      pres);
                skipReload = true;
                textureList.Items.Remove(textureList.SelectedItem);
                textureList.Items.Insert(index, texture);
                textureList.SelectedIndex = index;
            }
        }