本文整理汇总了C++中Perlin::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ Perlin::Get方法的具体用法?C++ Perlin::Get怎么用?C++ Perlin::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Perlin
的用法示例。
在下文中一共展示了Perlin::Get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateTexture3D
int generateTexture3D(char *framebuffer, int width, int height, char *imagePx) {
GzColor textureColor = { 0, 0, 0 };
int finalColor[] = { 0, 0, 0 };
char *copybuffer = framebuffer;
Perlin *per = new Perlin(4, 0.5, 2.0, 10);
for (float x = 0; x < width; x += 1) {
for (float y = 0; y < height; y += 1) {
float noise = 0.0f;
for (float z = 0; z < 256; z += 10){
noise += noise3d[(int)x][(int)y][(int)z] = per->Get(x, y, z);
//noise += noise3d[(int)x][(int)y][(int)z] = ken_perlin_3D(x, y, z);
}
noise /= 25;
textureColor[RED] = finddensity3D(y, x, 256, 256, noise, 45);
textureColor[GREEN] = finddensity3D(y, x, 256, 256, noise, 45);
//textureColor[RED] = noise;
//textureColor[GREEN] = noise;
textureColor[BLUE] = 0.8;
finalColor[RED] = (int)(textureColor[RED] * 255);
finalColor[GREEN] = (int)(textureColor[GREEN] * 255);
finalColor[BLUE] = (int)(textureColor[BLUE] * 255);
if (finalColor[RED] > 255)
finalColor[RED] = 255;
if (finalColor[RED] < 0)
finalColor[RED] = 0;
if (finalColor[GREEN] > 255)
finalColor[GREEN] = 255;
if (finalColor[GREEN] < 0)
finalColor[GREEN] = 0;
if (finalColor[BLUE] > 255)
finalColor[BLUE] = 255;
if (finalColor[BLUE] < 0)
finalColor[BLUE] = 0;
*(framebuffer++) = (char)(finalColor[RED]);
*(framebuffer++) = (char)(finalColor[GREEN]);
*(framebuffer++) = (char)(finalColor[BLUE]);
}
}
return 0;
}
示例2: perlin
bool Noise::perlin(Map& map, int octaves = 8, float frequency = 10.0f, float amplitude = 0.5f)
{
Perlin* noise = new Perlin(octaves, frequency, amplitude, rand());
for (int x = 0; x < map.getSize(); x++)
{
for (int y = 0; y < map.getSize(); y++)
{
map.map[x][y] = noise->Get((float)x / (float)map.getSize(), (float)y / (float)map.getSize());
}
}
return true;
}
示例3: perlinNoise
void Image::perlinNoise(int seed, bool alpha) {
Perlin *perlin = new Perlin(12,33,1,seed);
unsigned int *imageData32 = (unsigned int*)imageData;
Color pixelColor;
Number noiseVal;
for(int i=0; i < width*height;i++) {
noiseVal = fabs(1.0f/perlin->Get( 0.1+(0.9f/((Number)width)) * (i%width), (1.0f/((Number)height)) * (i - (i%width))));
if(alpha)
pixelColor.setColor(noiseVal, noiseVal, noiseVal, noiseVal);
else
pixelColor.setColor(noiseVal, noiseVal, noiseVal, 1.0f);
imageData32[i] = pixelColor.getUint();
}
}
示例4: generateTexture2D
int generateTexture2D(char *framebuffer, int width, int height, char* imagePx) {
GzColor textureColor = { 0, 0, 0 };
int finalColor[] = { 0, 0, 0 };
char *copybuffer = framebuffer;
Perlin *per = new Perlin(4, 6.5, 0.5, 10);
for (float x = 0; x < 256; x += 1) {
for (float y = 0; y < 256; y += 1) {
float noise = per->Get(x, y);
//float noise = perlin_type1_2D(x, y);
textureColor[RED] = finddensity(y, x, 256, 256, noise, 145);
textureColor[GREEN] = finddensity(y, x, 256, 256, noise, 145);
//textureColor[RED] = noise;
//textureColor[GREEN] = noise;
textureColor[BLUE] = 0.8;
finalColor[RED] = (int)(textureColor[RED] * 255);
finalColor[GREEN] = (int)(textureColor[GREEN] * 255);
finalColor[BLUE] = (int)(textureColor[BLUE] * 255);
if (finalColor[RED] > 255)
finalColor[RED] = 255;
if (finalColor[RED] < 0)
finalColor[RED] = 0;
if (finalColor[GREEN] > 255)
finalColor[GREEN] = 255;
if (finalColor[GREEN] < 0)
finalColor[GREEN] = 0;
if (finalColor[BLUE] > 255)
finalColor[BLUE] = 255;
if (finalColor[BLUE] < 0)
finalColor[BLUE] = 0;
*(framebuffer++) = (char)(finalColor[RED]);
*(framebuffer++) = (char)(finalColor[GREEN]);
*(framebuffer++) = (char)(finalColor[BLUE]);
}
}
return 0;
}
示例5: copyNoiseToHeightmap
void copyNoiseToHeightmap(Perlin& pn, RECT rc, HeightMap<T>* pHMap, int tMax)
{
int x,y;
float xStep = 1.0f/(rc.right-rc.left);
float yStep = 1.0f/(rc.bottom-rc.top);
//Perlin产生的值域在[-振幅,+振幅]之间
//--缩放到0-255的区间
float offset = pn.GetAmplitude();
float range = pn.GetAmplitude()*2;
for(y=rc.top; y<rc.bottom; y++)
{
for(x=rc.left; x<rc.right; x++)
{
float n = pn.Get(x*xStep, y*yStep);
T tn = T((n+offset)/range*tMax);
pHMap->setValue(x, y, tn);
}
}//endof for
}
示例6: StdPerlin
inline float StdPerlin( Perlin& obj, float x, float y, float w, float h ) { return obj.Get(x,y); }
示例7: fx1
float fx1(float a) {
return gMediumPerlinNoise.Get(a/(CK_MAX_WIDTH/50), 0.22) * 800;
// return gPerlinNoise.Get(a/(CK_MAX_WIDTH/5), 0.22) * 800 + gMediumPerlinNoise.Get(a/(CK_MAX_WIDTH/50), 0.22) * 800;
}
示例8: fz1
float fz1(float a) {
return gMediumPerlinNoise.Get(a/(CK_MAX_WIDTH/20), 0.22) * 800;
}