Exemplo n.º 1
0
        private NoiseMap GenerateNoiseMap(int width, int height)
        {
            //module::Perlin myModule;
            var module = new LibNoise.Primitive.SimplexPerlin();

            //var module = new LibNoise.Primitive.BevinsGradient();
            //var module = new LibNoise.Primitive.ImprovedPerlin();
            module.Quality = NoiseQuality.Best;
            //module.Seed = PrimitiveModule.DefaultSeed;
            var random = new Random();

            module.Seed = random.Next();

            //ScaleBias scale = null;

            FilterModule fModule = new Pipe();

            fModule.Primitive3D = (IModule3D)module;
            fModule.OctaveCount = random.Next(1, 6);
            // 1;
            // FilterModule.DEFAULT_OCTAVE_COUNT;
            //fModule.Frequency = FilterModule.DEFAULT_FREQUENCY;
            //fModule.Gain = FilterModule.DEFAULT_GAIN;
            //fModule.Lacunarity = FilterModule.DEFAULT_LACUNARITY;
            //fModule.Offset = FilterModule.DEFAULT_OFFSET;
            //fModule.SpectralExponent = FilterModule.DEFAULT_SPECTRAL_EXPONENT;
            fModule.Frequency        = random.Next(1, 5);
            fModule.Gain             = 10;
            fModule.Lacunarity       = 10;
            fModule.Offset           = 10;
            fModule.SpectralExponent = 1;

            NoiseMap heightMap = new NoiseMap();

            heightMap.SetSize(width, height);
            float bound = 2f;
            //NoiseMapBuilderPlane heightMapBuilder = new NoiseMapBuilderPlane(bound, bound * 2, 0.0f, 100.0f, true);
            bool seemless = random.Next(0, 1) == 1;
            NoiseMapBuilderPlane heightMapBuilder = new NoiseMapBuilderPlane(bound, bound * 2, bound, bound * 2, seemless);

            heightMapBuilder.SourceModule = (IModule3D)fModule;
            heightMapBuilder.NoiseMap     = heightMap;
            heightMapBuilder.SetSize(width, height);
            heightMapBuilder.Build();
            return(heightMap);
        }