TreeEditor.Perlin.SetSeed C# (CSharp) Method

SetSeed() public method

public SetSeed ( int seed ) : void
seed int
return void
        public void SetSeed(int seed)
        {
            int num2;
            Random random = new Random(seed);
            int index = 0;
            while (index < 0x100)
            {
                this.p[index] = index;
                this.g1[index] = ((float) (random.Next(0x200) - 0x100)) / 256f;
                num2 = 0;
                while (num2 < 2)
                {
                    this.g2[index, num2] = ((float) (random.Next(0x200) - 0x100)) / 256f;
                    num2++;
                }
                this.normalize2(ref this.g2[index, 0], ref this.g2[index, 1]);
                num2 = 0;
                while (num2 < 3)
                {
                    this.g3[index, num2] = ((float) (random.Next(0x200) - 0x100)) / 256f;
                    num2++;
                }
                this.normalize3(ref this.g3[index, 0], ref this.g3[index, 1], ref this.g3[index, 2]);
                index++;
            }
            while (--index != 0)
            {
                int num3 = this.p[index];
                this.p[index] = this.p[num2 = random.Next(0x100)];
                this.p[num2] = num3;
            }
            for (index = 0; index < 0x102; index++)
            {
                this.p[0x100 + index] = this.p[index];
                this.g1[0x100 + index] = this.g1[index];
                num2 = 0;
                while (num2 < 2)
                {
                    this.g2[0x100 + index, num2] = this.g2[index, num2];
                    num2++;
                }
                for (num2 = 0; num2 < 3; num2++)
                {
                    this.g3[0x100 + index, num2] = this.g3[index, num2];
                }
            }
        }

Usage Example

Example #1
0
 public static void SetNoiseSeed(int seed)
 {
     if (noiseSeed != seed)
     {
         perlin.SetSeed(seed);
     }
 }