本文整理汇总了C++中NoisePerlin2D函数的典型用法代码示例。如果您正苦于以下问题:C++ NoisePerlin2D函数的具体用法?C++ NoisePerlin2D怎么用?C++ NoisePerlin2D使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NoisePerlin2D函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NoisePerlin2D
int MapgenV5::getSpawnLevelAtPoint(v2s16 p)
{
float f = 0.55 + NoisePerlin2D(&noise_factor->np, p.X, p.Y, seed);
if (f < 0.01)
f = 0.01;
else if (f >= 1.0)
f *= 1.6;
float h = NoisePerlin2D(&noise_height->np, p.X, p.Y, seed);
// noise_height 'offset' is the average level of terrain. At least 50% of
// terrain will be below this.
// Raising the maximum spawn level above 'water_level + 16' is necessary
// for when noise_height 'offset' is set much higher than water_level.
s16 max_spawn_y = MYMAX(noise_height->np.offset, water_level + 16);
// Starting spawn search at max_spawn_y + 128 ensures 128 nodes of open
// space above spawn position. Avoids spawning in possibly sealed voids.
for (s16 y = max_spawn_y + 128; y >= water_level; y--) {
float n_ground = NoisePerlin3D(&noise_ground->np, p.X, y, p.Y, seed);
if (n_ground * f > y - h) { // If solid
if (y < water_level || y > max_spawn_y)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
// y + 2 because y is surface and due to biome 'dust' nodes.
return y + 2;
}
}
// Unsuitable spawn position, no ground found
return MAX_MAP_GENERATION_LIMIT;
}
开发者ID:yzziizzy,项目名称:minetest,代码行数:32,代码来源:mapgen_v5.cpp
示例2: NoisePerlin2D
// For BiomeGen type 'BiomeGenOriginal'
float BiomeManager::getHeatAtPosOriginal(v3s16 pos, NoiseParams &np_heat,
NoiseParams &np_heat_blend, u64 seed)
{
return
NoisePerlin2D(&np_heat, pos.X, pos.Z, seed) +
NoisePerlin2D(&np_heat_blend, pos.X, pos.Z, seed);
}
开发者ID:Sokomine,项目名称:minetest,代码行数:8,代码来源:mg_biome.cpp
示例3: NoisePerlin2D
int MapgenV5::getSpawnLevelAtPoint(v2s16 p)
{
//TimeTaker t("getGroundLevelAtPoint", NULL, PRECISION_MICRO);
float f = 0.55 + NoisePerlin2D(&noise_factor->np, p.X, p.Y, seed);
if (f < 0.01)
f = 0.01;
else if (f >= 1.0)
f *= 1.6;
float h = NoisePerlin2D(&noise_height->np, p.X, p.Y, seed);
for (s16 y = 128; y >= -128; y--) {
float n_ground = NoisePerlin3D(&noise_ground->np, p.X, y, p.Y, seed);
if (n_ground * f > y - h) { // If solid
// If either top 2 nodes of search are solid this is inside a
// mountain or floatland with possibly no space for the player to spawn.
if (y >= 127) {
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
} else { // Ground below at least 2 nodes of empty space
if (y <= water_level || y > water_level + 16)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
else
return y;
}
}
}
//printf("getGroundLevelAtPoint: %dus\n", t.stop());
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn position, no ground found
}
开发者ID:Mab879,项目名称:freeminer,代码行数:31,代码来源:mapgen_v5.cpp
示例4: NoisePerlin2D
float MapgenV7P::mountainLevelAtPoint(s16 x, s16 z)
{
float mnt_h_n = NoisePerlin2D(&noise_mount_height->np, x, z, seed);
float mnt_n = NoisePerlin2D(&noise_mountain->np, x, z, seed);
return mnt_n * mnt_h_n;
}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:7,代码来源:mapgen_v7p.cpp
示例5: NoisePerlin2D
int MapgenV5::getGroundLevelAtPoint(v2s16 p)
{
//TimeTaker t("getGroundLevelAtPoint", NULL, PRECISION_MICRO);
float f = 0.55 + NoisePerlin2D(&noise_factor->np, p.X, p.Y, seed);
if (f < 0.01)
f = 0.01;
else if (f >= 1.0)
f *= 1.6;
float h = NoisePerlin2D(&noise_height->np, p.X, p.Y, seed);
s16 search_start = 128; // Only bother searching this range, actual
s16 search_end = -128; // ground level is rarely higher or lower.
for (s16 y = search_start; y >= search_end; y--) {
float n_ground = NoisePerlin3D(&noise_ground->np, p.X, y, p.Y, seed);
// If solid
if (n_ground * f > y - h) {
// If either top 2 nodes of search are solid this is inside a
// mountain or floatland with no space for the player to spawn.
if (y >= search_start - 1)
return MAX_MAP_GENERATION_LIMIT;
else
return y; // Ground below at least 2 nodes of space
}
}
//printf("getGroundLevelAtPoint: %dus\n", t.stop());
return -MAX_MAP_GENERATION_LIMIT;
}
开发者ID:hondalyfe88,项目名称:MultiCraft,代码行数:30,代码来源:mapgen_v5.cpp
示例6: NoisePerlin2D
int MapgenV5::getGroundLevelAtPoint(v2s16 p)
{
//TimeTaker t("getGroundLevelAtPoint", NULL, PRECISION_MICRO);
float f = 0.55 + NoisePerlin2D(&noise_factor->np, p.X, p.Y, seed);
if (f < 0.01)
f = 0.01;
else if (f >= 1.0)
f *= 1.6;
float h = NoisePerlin2D(&noise_height->np, p.X, p.Y, seed);
s16 search_top = water_level + 15;
s16 search_base = water_level;
s16 level = -31000;
for (s16 y = search_top; y >= search_base; y--) {
float n_ground = NoisePerlin3D(&noise_ground->np, p.X, y, p.Y, seed);
if (n_ground * f > y - h) {
if (y >= search_top - 7)
break;
else
level = y;
break;
}
}
//printf("getGroundLevelAtPoint: %dus\n", t.stop());
return level;
}
开发者ID:MirceaKitsune,项目名称:minetest,代码行数:29,代码来源:mapgen_v5.cpp
示例7: NoisePerlin2D
Biome *MapgenV7::getBiomeAtPoint(v3s16 p) {
float heat = NoisePerlin2D(&noise_heat->np, p.X, p.Z, seed);
float humidity = NoisePerlin2D(&noise_humidity->np, p.X, p.Z, seed);
s16 groundlevel = baseTerrainLevelAtPoint(p.X, p.Z);
return bmgr->getBiome(heat, humidity, groundlevel);
}
开发者ID:FunKetApp,项目名称:minetest,代码行数:7,代码来源:mapgen_v7.cpp
示例8: NoisePerlin2D
float MapgenValleys::terrainLevelAtPoint(s16 x, s16 z)
{
TerrainNoise tn;
float rivers = NoisePerlin2D(&noise_rivers->np, x, z, seed);
float valley = NoisePerlin2D(&noise_valley_depth->np, x, z, seed);
float inter_valley_slope = NoisePerlin2D(&noise_inter_valley_slope->np, x, z, seed);
tn.x = x;
tn.z = z;
tn.terrain_height = NoisePerlin2D(&noise_terrain_height->np, x, z, seed);
tn.rivers = &rivers;
tn.valley = &valley;
tn.valley_profile = NoisePerlin2D(&noise_valley_profile->np, x, z, seed);
tn.slope = &inter_valley_slope;
tn.inter_valley_fill = 0.f;
tn.cliffs = 0.f;
tn.corr = 0.f;
if (fast_terrain) {
tn.inter_valley_fill = NoisePerlin2D(&noise_inter_valley_fill->np, x, z, seed);
if (cliff_terrain)
tn.cliffs = NoisePerlin2D(&noise_cliffs->np, x, z, seed);
if (rugged_terrain)
tn.corr = NoisePerlin2D(&noise_corr->np, x, z, seed);
}
return adjustedTerrainLevelFromNoise(&tn);
}
开发者ID:joshburt,项目名称:minetestbot,代码行数:30,代码来源:mapgen_valleys.cpp
示例9: NoisePerlin2DNoTxfm
float MapgenV7::baseTerrainLevelAtPoint(int x, int z) {
float terrain_mod = NoisePerlin2DNoTxfm(noise_terrain_mod->np, x, z, seed);
float hselect = NoisePerlin2D(noise_height_select->np, x, z, seed);
float persist = abs(NoisePerlin2DNoTxfm(noise_terrain_persist->np, x, z, seed));
noise_terrain_base->np->persist = persist;
float terrain_base = NoisePerlin2D(noise_terrain_base->np, x, z, seed);
float height_base = terrain_base * terrain_mod;
noise_terrain_alt->np->persist = persist;
float height_alt = NoisePerlin2D(noise_terrain_alt->np, x, z, seed);
return (height_base * hselect) + (height_alt * (1.0 - hselect));
}
开发者ID:0gb-us,项目名称:minetest,代码行数:14,代码来源:mapgen_v7.cpp
示例10: NoisePerlin2D
s16 BiomeDefManager::calcBlockHeat(v3s16 p, u64 seed, float timeofday, float totaltime) {
//variant 1: full random
//f32 heat = NoisePerlin3D(np_heat, p.X, env->getGameTime()/100, p.Z, seed);
//variant 2: season change based on default heat map
const f32 offset = 20; // = np_heat->offset
const f32 scale = 20; // = np_heat->scale
const f32 range = 20;
f32 heat = NoisePerlin2D(np_heat, p.X, p.Z, seed); // 0..50..100
heat -= np_heat->offset; // -50..0..+50
// normalizing - todo REMOVE after fixed NoiseParams nparams_biome_def_heat = {50, 50, -> 20, 50,
if (np_heat->scale)
heat /= np_heat->scale / scale; // -20..0..+20
f32 seasonv = totaltime;
seasonv /= 86400 * g_settings->getS16("year_days"); // season change speed
seasonv += (f32)p.X / 3000; // you can walk to area with other season
seasonv = sin(seasonv * M_PI);
heat += (range * (heat < 0 ? 2 : 0.5)) * seasonv; // -60..0..30
heat += offset; // -40..0..50
heat += p.Y / -333; // upper=colder, lower=hotter, 3c per 1000
// daily change, hotter at sun +4, colder at night -4
heat += 8 * (sin(cycle_shift(timeofday, -0.25) * M_PI) - 0.5); //-44..20..54
return heat;
}
开发者ID:BpTsTG,项目名称:minetest,代码行数:30,代码来源:biome.cpp
示例11: NoisePerlin2D
void MapgenV6::generateCaves(int max_stone_y)
{
float cave_amount = NoisePerlin2D(np_cave, node_min.X, node_min.Y, seed);
int volume_nodes = (node_max.X - node_min.X + 1) *
(node_max.Y - node_min.Y + 1) * MAP_BLOCKSIZE;
cave_amount = MYMAX(0.0, cave_amount);
u32 caves_count = cave_amount * volume_nodes / 50000;
u32 bruises_count = 1;
PseudoRandom ps(blockseed + 21343);
PseudoRandom ps2(blockseed + 1032);
if (ps.range(1, 6) == 1)
bruises_count = ps.range(0, ps.range(0, 2));
if (getBiome(v2s16(node_min.X, node_min.Z)) == BT_DESERT) {
caves_count /= 3;
bruises_count /= 3;
}
for (u32 i = 0; i < caves_count + bruises_count; i++) {
CavesV6 cave(ndef, &gennotify, water_level, c_water_source, c_lava_source);
bool large_cave = (i >= caves_count);
cave.makeCave(vm, node_min, node_max, &ps, &ps2,
large_cave, max_stone_y, heightmap);
}
}
开发者ID:ERIIX,项目名称:minetest,代码行数:27,代码来源:mapgen_v6.cpp
示例12: baseTerrainLevelAtPoint
int MapgenV7::getSpawnLevelAtPoint(v2s16 p)
{
// Base terrain calculation
s16 y = baseTerrainLevelAtPoint(p.X, p.Y);
// Ridge/river terrain calculation
float width = 0.2;
float uwatern = NoisePerlin2D(&noise_ridge_uwater->np, p.X, p.Y, seed) * 2;
// if inside a river this is an unsuitable spawn point
if (fabs(uwatern) <= width)
return MAX_MAP_GENERATION_LIMIT;
// Mountain terrain calculation
int iters = 128;
while (iters--) {
if (!getMountainTerrainAtPoint(p.X, y + 1, p.Y)) { // Air, y is ground level
if (y <= water_level || y > water_level + 16)
return MAX_MAP_GENERATION_LIMIT; // Unsuitable spawn point
else
return y;
}
y++;
}
// Unsuitable spawn point, no ground surface found
return MAX_MAP_GENERATION_LIMIT;
}
开发者ID:grigoriis,项目名称:MultiCraft,代码行数:27,代码来源:mapgen_v7.cpp
示例13: NoisePerlin2D
s16 BiomeManager::calcBlockHeat(v3POS p, uint64_t seed, float timeofday, float totaltime, bool use_weather) {
//variant 1: full random
//f32 heat = NoisePerlin3D(np_heat, p.X, env->getGameTime()/100, p.Z, seed);
//variant 2: season change based on default heat map
auto heat = NoisePerlin2D(&(mapgen_params->np_biome_heat), p.X, p.Z, seed); // -30..20..70
if (use_weather) {
f32 seasonv = totaltime;
seasonv /= 86400 * year_days; // season change speed
seasonv += (f32)p.X / weather_heat_width; // you can walk to area with other season
seasonv = sin(seasonv * M_PI);
//heat += (weather_heat_season * (heat < offset ? 2 : 0.5)) * seasonv; // -60..0..30
heat += (weather_heat_season) * seasonv; // -60..0..30
// daily change, hotter at sun +4, colder at night -4
heat += weather_heat_daily * (sin(cycle_shift(timeofday, -0.25) * M_PI) - 0.5); //-64..0..34
}
heat += p.Y / weather_heat_height; // upper=colder, lower=hotter, 3c per 1000
if (weather_hot_core && p.Y < -(MAX_MAP_GENERATION_LIMIT-weather_hot_core))
heat += 6000 * (1.0-((float)(p.Y - -MAX_MAP_GENERATION_LIMIT)/weather_hot_core)); //hot core, later via realms
return heat;
}
开发者ID:proller,项目名称:freeminer,代码行数:25,代码来源:mg_biome.cpp
示例14: NoisePerlin2D
void MapgenV6::generateCaves(int max_stone_y)
{
float cave_amount = NoisePerlin2D(np_cave, node_min.X, node_min.Y, seed);
int volume_nodes = (node_max.X - node_min.X + 1) *
(node_max.Y - node_min.Y + 1) * MAP_BLOCKSIZE;
cave_amount = MYMAX(0.0, cave_amount);
u32 caves_count = cave_amount * volume_nodes / 50000;
u32 bruises_count = 1;
PseudoRandom ps(blockseed + 21343);
PseudoRandom ps2(blockseed + 1032);
if (ps.range(1, 6) == 1)
bruises_count = ps.range(0, ps.range(0, 2));
if (getBiome(node_min) == BT_DESERT) {
caves_count /= 3;
bruises_count /= 3;
}
for (u32 i = 0; i < caves_count + bruises_count; i++) {
bool large_cave = (i >= caves_count);
CaveV6 cave(this, &ps, &ps2, large_cave);
cave.makeCave(node_min, node_max, max_stone_y);
}
}
开发者ID:Wayward1,项目名称:freeminer,代码行数:26,代码来源:mapgen_v6.cpp
示例15: baseTerrainLevelAtPoint
int MapgenV7::getGroundLevelAtPoint(v2s16 p)
{
// Base terrain calculation
s16 y = baseTerrainLevelAtPoint(p.X, p.Y);
// Ridge/river terrain calculation
float width = 0.2;
float uwatern = NoisePerlin2D(&noise_ridge_uwater->np, p.X, p.Y, seed) * 2;
// actually computing the depth of the ridge is much more expensive;
// if inside a river, simply guess
if (fabs(uwatern) <= width)
return water_level - 10;
// Mountain terrain calculation
int iters = 128; // don't even bother iterating more than 128 times..
while (iters--) {
//current point would have been air
if (!getMountainTerrainAtPoint(p.X, y, p.Y))
return y;
y++;
}
return y;
}
开发者ID:nathanlol5,项目名称:minetest,代码行数:25,代码来源:mapgen_v7.cpp
示例16: NoisePerlin2D
bool MapgenV7::getMountainTerrainAtPoint(s16 x, s16 y, s16 z)
{
float mnt_h_n = NoisePerlin2D(&noise_mount_height->np, x, z, seed);
float density_gradient = -((float)y / mnt_h_n);
float mnt_n = NoisePerlin3D(&noise_mountain->np, x, y, z, seed);
return mnt_n + density_gradient >= 0.0;
}
开发者ID:nathanlol5,项目名称:minetest,代码行数:8,代码来源:mapgen_v7.cpp
示例17: checkobject
int LuaPerlinNoise::l_get2d(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
LuaPerlinNoise *o = checkobject(L, 1);
v2f p = check_v2f(L, 2);
lua_Number val = NoisePerlin2D(&o->np, p.X, p.Y, 0);
lua_pushnumber(L, val);
return 1;
}
开发者ID:rwmpelstilzchen,项目名称:minetest,代码行数:9,代码来源:l_noise.cpp
示例18: baseTerrainLevelAtPoint
int MapgenV7::getGroundLevelAtPoint(v2s16 p) {
s16 groundlevel = baseTerrainLevelAtPoint(p.X, p.Y);
float heat = NoisePerlin2D(bmgr->np_heat, p.X, p.Y, seed);
float humidity = NoisePerlin2D(bmgr->np_humidity, p.X, p.Y, seed);
Biome *b = bmgr->getBiome(heat, humidity, groundlevel);
s16 y = groundlevel;
if (y > water_level) {
int iters = 1024; // don't even bother iterating more than 1024 times..
while (iters--) {
float ridgenoise = NoisePerlin3D(noise_ridge->np, p.X, y, p.Y, seed);
if (ridgenoise * (float)(y * y) < 15.0)
break;
y--;
}
}
return y + b->top_depth;
}
开发者ID:0gb-us,项目名称:minetest,代码行数:19,代码来源:mapgen_v7.cpp
示例19: np_normal
void TestNoise::testNoise2dPoint()
{
NoiseParams np_normal(20, 40, v3f(50, 50, 50), 9, 5, 0.6, 2.0);
u32 i = 0;
for (u32 y = 0; y != 10; y++)
for (u32 x = 0; x != 10; x++, i++) {
float actual = NoisePerlin2D(&np_normal, x, y, 1337);
float expected = expected_2d_results[i];
UASSERT(fabs(actual - expected) <= 0.00001);
}
}
开发者ID:00c,项目名称:minetest,代码行数:12,代码来源:test_noise.cpp
示例20: NoisePerlin2D
int MapgenFlat::getGroundLevelAtPoint(v2s16 p)
{
float n_terrain = NoisePerlin2D(&noise_terrain->np, p.X, p.Y, seed);
if ((spflags & MGFLAT_LAKES) && n_terrain < lake_threshold) {
s16 depress = (lake_threshold - n_terrain) * lake_steepness;
return ground_level - depress;
} else if ((spflags & MGFLAT_HILLS) && n_terrain > hill_threshold) {
s16 rise = (n_terrain - hill_threshold) * hill_steepness;
return ground_level + rise;
} else {
return ground_level;
}
}
开发者ID:johnnyjoy,项目名称:minetest,代码行数:13,代码来源:mapgen_flat.cpp
注:本文中的NoisePerlin2D函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论