示例#1
0
void PerlinNoiseCache::Cache(int cx, int cy)
{
	ASSERT(cx >= 1 && cy >= 1);
	Clear();
	sz = Size(cx, cy);
	InitNoise();
	int xycnt = cx *cy;
	cache.Alloc(xycnt);	
	float *q = ~cache;
	for (int y = 0; y < sz.cy; y++)
		for (int x = 0; x < sz.cx; x++, q++)
			*q = PerlinNoise2D(x, y);
	DeinitNoise();		
}
示例#2
0
void perlin(int low, int high, int type)
{
  int x, y, z, i;
  int level = (high + low)/2;
  int scale = level - low;

  for(x = 0; x <= WORLDX; x++)
  {
    for(z = 0; z < WORLDZ; z++)
    {
      /* Give it small x/z values to increase smoothness; 2 octaves is enough */
      y = level + (scale * PerlinNoise2D(x/47.0, z/47.0, 2, 2, 2));

      /* Have to keep the result safely inside the boundaries of the earth. */		
      y = bounds(y, 0, WORLDY-1); 

      for(i = y; world[x][i][z] == EMPTY; i--)
      {
        world[x][i][z] = type;
      }
    }
  }
}
示例#3
0
	int getSandHeight(int x, int y){
		float NoiseHeight = PerlinNoise2D(x / NoiseScaleX * 3 + 1222, y / NoiseScaleZ * 3 + 1222) / 4.0f - 2;
		return int(NoiseHeight);
	}
示例#4
0
	int getHeight(int x, int y){
		float NoiseHeight = PerlinNoise2D(x / NoiseScaleX, y / NoiseScaleZ) / 4.0f;
		return int(NoiseHeight);
	}
示例#5
0
文件: perlin.cpp 项目: sdp0et/gtp
real PerlinGenerator::mountainHeight( real u, real v )
{
  //return PerlinNoise2D( u, v, persistence, lacunarity, octaves ) ;
  return PerlinNoise2D( u, v, 2, 2, 4 ) ;
}
示例#6
0
//======================================================================================
//======================================================================================
double PNoise::PNoise2D(double x, double y)
{
  return PerlinNoise2D(x, y, _n, _alpha, _beta);
}