Ejemplo n.º 1
0
    private CoherentNoise.Generator GetNoise(int seed)
    {
        BillowNoise noise = new BillowNoise(seed);
        Turbulence  b     = new Turbulence(noise, seed);

        return(b);
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the <see cref="Generator"/> assigned to this instance based on the
        /// set <see cref="MapGeneratorType"/> and returns it.
        /// </summary>
        /// <returns>Generator if set, null if <see cref="MapGeneratorType.Custom"/>
        /// is set and no <see cref="CustomGenerator"/> is specified</returns>
        public void UpdateGenerator()
        {
            int       seed = TerraConfig.GenerationSeed;
            Generator gen;

            switch (MapType)
            {
            case MapGeneratorType.Perlin:
                gen = new GradientNoise(seed).ScaleShift(0.5f, 0.5f);
                break;

            case MapGeneratorType.Fractal:
                gen = new PinkNoise(seed).ScaleShift(0.5f, 0.5f);
                break;

            case MapGeneratorType.Billow:
                gen = new BillowNoise(seed).ScaleShift(0.5f, 0.5f);
                break;

            case MapGeneratorType.Custom:
                if (Graph == null)
                {
                    return;
                }
                gen = Graph.GetEndGenerator();
                break;

            default:
                return;
            }

            _generator = gen;
        }
Ejemplo n.º 3
0
        public override Generator GetGenerator()
        {
            BillowNoise noise = new BillowNoise(TerraConfig.Instance.Seed);

            noise.Frequency   = Frequency;
            noise.Lacunarity  = Lacunarity;
            noise.OctaveCount = OctaveCount;
            noise.Persistence = Persistence;

            return(noise);
        }
Ejemplo n.º 4
0
        public override Generator GetGenerator()
        {
            BillowNoise noise = new BillowNoise(TerraSettings.GenerationSeed);

            noise.Frequency   = Frequency;
            noise.Lacunarity  = Lacunarity;
            noise.OctaveCount = OctaveCount;
            noise.Persistence = Persistence;

            return(noise);
        }
    private Generator GetTestGenerator()
    {
        RidgeNoise rn = new RidgeNoise(1337);

        rn.Frequency = 2;
        PinkNoise n = new PinkNoise(234);

        Add added = new Add(rn, n);

        BillowNoise bn = new BillowNoise(534);

        return(bn - added);
    }
Ejemplo n.º 6
0
    void BillowFillMap()
    {
        if (useRandomSeed)
        {
            seed = Time.time.ToString() + transform.position.ToString();
        }

        System.Random pseudoRandom = new System.Random(seed.GetHashCode());
        BillowNoise   billow       = new BillowNoise(pseudoRandom.Next(0, 100));

        for (int x = 0; x < width; x++)
        {
            for (int y = 0; y < height; y++)
            {
                for (int z = 0; z < depth; z++)
                {
                    if (x == 0 || x == width - 1 || y == 0 || y == height - 1 || z == 0 || z == depth - 1)
                    {
                        map[x, y, z] = 1;
                    }
                    else
                    {
                        Debug.Log(billow.GetValue(x, y, z));
                        if (billow.GetValue(x, y, z) > billowFillCutoff)
                        {
                            map[x, y, z] = 1;
                        }
                        else
                        {
                            map[x, y, z] = 0;
                        }
                    }
                }
            }
        }
    }