本文整理汇总了C++中Simplex::Turbulence方法的典型用法代码示例。如果您正苦于以下问题:C++ Simplex::Turbulence方法的具体用法?C++ Simplex::Turbulence怎么用?C++ Simplex::Turbulence使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simplex
的用法示例。
在下文中一共展示了Simplex::Turbulence方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateWoodSide
Image* GenerateWoodSide(int width, int height){
// Initialize Variables:
Image *terrain = new Image(width, height); // Output Map
double xValue, yValue, turb, distValue, sineValue;
int value;
const double PI = 3.141592653589793238463;
double xyFactor = 2.0; //Rings
double turbFactor = 1.0 / 800.0;
double turbPower = 0.05;
int octaves = 10;
// Initialize Simplex Generator:
srand(time(0) ^ rand()); // Initialize Random Seed
Simplex generator = Simplex();
// Loops through all the pixels
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
xValue = (x + width) / ((double)width);
yValue = (y - height / 2) / ((double)height);
turb = turbPower*generator.Turbulence(x*turbFactor, y*turbFactor, octaves);
distValue = (sqrt(xValue * xValue + yValue * yValue) + turb);
sineValue = 128 * fabs(sin(2 * distValue*PI*xyFactor));
// Convert the 0.0 to 1.0 noise value to a 0 to 255 RGB value:
value = int(sineValue);
if (value > 128)
value = 128;
else if (value < 0)
value = 0;
// Output heightmap to image:
(*terrain)[y][x].red = 80 + value;
(*terrain)[y][x].green = 30 + value;
(*terrain)[y][x].blue = 30;
}
}
return terrain;
}