GetNoise() публичный Метод

public GetNoise ( double x, double y ) : double
x double
y double
Результат double
Пример #1
0
        // create the base heightmap
        void Raise()
        {
            Random        raiseRand   = new Random(random.Next());
            FilteredNoise raiseNoise1 = new FilteredNoise(new PerlinNoise(raiseRand, genParams.TerrainDetailOctaves),
                                                          new PerlinNoise(raiseRand, genParams.TerrainDetailOctaves));
            FilteredNoise raiseNoise2 = new FilteredNoise(new PerlinNoise(raiseRand, genParams.TerrainDetailOctaves),
                                                          new PerlinNoise(raiseRand, genParams.TerrainDetailOctaves));
            PerlinNoise raiseNoise3 = new PerlinNoise(raiseRand, genParams.TerrainFeatureOctaves);

            const double scale = 1.3;

            for (int x = 0; x < genParams.MapWidth; x++)
            {
                for (int y = 0; y < genParams.MapLength; y++)
                {
                    double d2 = raiseNoise1.GetNoise(x * scale, y * scale) / 6 - 4;
                    double d3 = raiseNoise2.GetNoise(x * scale, y * scale) / 5 + 10 - 4;
                    double d4 = raiseNoise3.GetNoise(x, y) / 8;
                    if (d4 > 0)
                    {
                        d3 = d2;
                    }
                    double elevation = Math.Max(d2, d3) / 2;
                    if (elevation < 0)
                    {
                        elevation *= 0.8;
                    }
                    heightmap[(x + y * genParams.MapWidth)] = (int)elevation;
                }
            }
        }
Пример #2
0
        // apply erosion effect on the heightmap
        void Erode()
        {
            Random        erodeRand   = new Random(random.Next());
            FilteredNoise erodeNoise1 = new FilteredNoise(new PerlinNoise(erodeRand, genParams.TerrainDetailOctaves),
                                                          new PerlinNoise(erodeRand, genParams.TerrainDetailOctaves));
            FilteredNoise erodeNoise2 = new FilteredNoise(new PerlinNoise(erodeRand, genParams.TerrainDetailOctaves),
                                                          new PerlinNoise(erodeRand, genParams.TerrainDetailOctaves));

            for (int x = 0; x < genParams.MapWidth; x++)
            {
                for (int y = 0; y < genParams.MapLength; y++)
                {
                    double d1 = erodeNoise1.GetNoise(x * 2, y * 2) / 8;
                    int    i7 = erodeNoise2.GetNoise(x * 2, y * 2) > 0 ? 1 : 0;
                    if (d1 <= 2)
                    {
                        continue;
                    }
                    int i19 = ((heightmap[(x + y * genParams.MapWidth)] - i7) / 2 * 2) + i7;
                    heightmap[(x + y * genParams.MapWidth)] = i19;
                }
            }
        }
Пример #3
0
 // apply erosion effect on the heightmap
 void Erode() {
     Random erodeRand = new Random( random.Next() );
     FilteredNoise erodeNoise1 = new FilteredNoise( new PerlinNoise( erodeRand, genParams.TerrainDetailOctaves ),
                                                    new PerlinNoise( erodeRand, genParams.TerrainDetailOctaves ) );
     FilteredNoise erodeNoise2 = new FilteredNoise( new PerlinNoise( erodeRand, genParams.TerrainDetailOctaves ),
                                                    new PerlinNoise( erodeRand, genParams.TerrainDetailOctaves ) );
     for( int x = 0; x < genParams.MapWidth; x++ ) {
         for( int y = 0; y < genParams.MapLength; y++ ) {
             double d1 = erodeNoise1.GetNoise( x*2, y*2 )/8;
             int i7 = erodeNoise2.GetNoise( x*2, y*2 ) > 0 ? 1 : 0;
             if( d1 <= 2 )
                 continue;
             int i19 = ((heightmap[(x + y*genParams.MapWidth)] - i7)/2*2) + i7;
             heightmap[(x + y*genParams.MapWidth)] = i19;
         }
     }
 }
Пример #4
0
        // create the base heightmap
        void Raise() {
            Random raiseRand = new Random( random.Next() );
            FilteredNoise raiseNoise1 = new FilteredNoise( new PerlinNoise( raiseRand, genParams.TerrainDetailOctaves ),
                                                           new PerlinNoise( raiseRand, genParams.TerrainDetailOctaves ) );
            FilteredNoise raiseNoise2 = new FilteredNoise( new PerlinNoise( raiseRand, genParams.TerrainDetailOctaves ),
                                                           new PerlinNoise( raiseRand, genParams.TerrainDetailOctaves ) );
            PerlinNoise raiseNoise3 = new PerlinNoise( raiseRand, genParams.TerrainFeatureOctaves );

            const double scale = 1.3;
            for( int x = 0; x < genParams.MapWidth; x++ ) {
                for( int y = 0; y < genParams.MapLength; y++ ) {
                    double d2 = raiseNoise1.GetNoise( x*scale, y*scale )/6 - 4;
                    double d3 = raiseNoise2.GetNoise( x*scale, y*scale )/5 + 10 - 4;
                    double d4 = raiseNoise3.GetNoise( x, y )/8;
                    if( d4 > 0 )
                        d3 = d2;
                    double elevation = Math.Max( d2, d3 )/2;
                    if( elevation < 0 )
                        elevation *= 0.8;
                    heightmap[(x + y*genParams.MapWidth)] = (int)elevation;
                }
            }
        }