本文整理汇总了C++中MapNode函数的典型用法代码示例。如果您正苦于以下问题:C++ MapNode函数的具体用法?C++ MapNode怎么用?C++ MapNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MapNode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: p
void TestVoxelAlgorithms::testClearLightAndCollectSources(INodeDefManager *ndef)
{
VoxelManipulator v;
for (u16 z = 0; z < 3; z++)
for (u16 y = 0; y < 3; y++)
for (u16 x = 0; x < 3; x++) {
v3s16 p(x,y,z);
v.setNode(p, MapNode(CONTENT_AIR));
}
VoxelArea a(v3s16(0,0,0), v3s16(2,2,2));
v.setNodeNoRef(v3s16(0,0,0), MapNode(t_CONTENT_STONE));
v.setNodeNoRef(v3s16(1,1,1), MapNode(t_CONTENT_TORCH));
{
MapNode n(CONTENT_AIR);
n.setLight(LIGHTBANK_DAY, 1, ndef);
v.setNode(v3s16(1,1,2), n);
}
{
std::set<v3s16> light_sources;
std::map<v3s16, u8> unlight_from;
voxalgo::clearLightAndCollectSources(v, a, LIGHTBANK_DAY,
ndef, light_sources, unlight_from);
//v.print(dstream, ndef, VOXELPRINT_LIGHT_DAY);
UASSERT(v.getNode(v3s16(0,1,1)).getLight(LIGHTBANK_DAY, ndef) == 0);
UASSERT(light_sources.find(v3s16(1,1,1)) != light_sources.end());
UASSERT(light_sources.size() == 1);
UASSERT(unlight_from.find(v3s16(1,1,2)) != unlight_from.end());
UASSERT(unlight_from.size() == 1);
}
}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:34,代码来源:test_voxelalgorithms.cpp
示例2: contour
void MapgenFractal::generateCaves(s16 max_stone_y)
{
if (max_stone_y < node_min.Y)
return;
noise_cave1->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
noise_cave2->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
v3s16 em = vm->m_area.getExtent();
u32 index2d = 0;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index2d++) {
bool column_is_open = false; // Is column open to overground
u32 vi = vm->m_area.index(x, node_max.Y + 1, z);
u32 index3d = (z - node_min.Z) * zstride + (csize.Y + 1) * ystride +
(x - node_min.X);
// Biome of column
Biome *biome = (Biome *)bmgr->getRaw(biomemap[index2d]);
for (s16 y = node_max.Y + 1; y >= node_min.Y - 1;
y--, index3d -= ystride, vm->m_area.add_y(em, vi, -1)) {
content_t c = vm->m_data[vi].getContent();
if (c == CONTENT_AIR || c == biome->c_water_top ||
c == biome->c_water) {
column_is_open = true;
continue;
}
// Ground
float d1 = contour(noise_cave1->result[index3d]);
float d2 = contour(noise_cave2->result[index3d]);
if (d1 * d2 > 0.3f && ndef->get(c).is_ground_content) {
// In tunnel and ground content, excavate
vm->m_data[vi] = MapNode(CONTENT_AIR);
} else if (column_is_open &&
(c == biome->c_filler || c == biome->c_stone)) {
// Tunnel entrance floor
vm->m_data[vi] = MapNode(biome->c_top);
column_is_open = false;
} else {
column_is_open = false;
}
}
}
if (node_max.Y > MGFRACTAL_LARGE_CAVE_DEPTH)
return;
PseudoRandom ps(blockseed + 21343);
u32 bruises_count = ps.range(0, 2);
for (u32 i = 0; i < bruises_count; i++) {
CaveV5 cave(this, &ps);
cave.makeCave(node_min, node_max, max_stone_y);
}
}
开发者ID:voronaam,项目名称:freeminer,代码行数:55,代码来源:mapgen_fractal.cpp
示例3: n_air
void MapgenV7::generateTerrain() {
MapNode n_air(CONTENT_AIR), n_water_source(c_water_source);
MapNode n_stone(c_stone);
v3s16 em = vm->m_area.getExtent();
u32 index = 0;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
s16 surface_y = heightmap[index];
Biome *biome = bmgr->biomes[biomemap[index]];
u32 i = vm->m_area.index(x, node_min.Y, z);
for (s16 y = node_min.Y; y <= node_max.Y; y++) {
if (vm->m_data[i].getContent() == CONTENT_IGNORE) {
if (y <= surface_y) {
vm->m_data[i] = (y > water_level + biome->filler_height) ?
MapNode(biome->c_filler) : n_stone;
} else if (y <= water_level) {
vm->m_data[i] = n_water_source;
} else {
vm->m_data[i] = n_air;
}
}
vm->m_area.add_y(em, i, 1);
}
}
}
开发者ID:0gb-us,项目名称:minetest,代码行数:28,代码来源:mapgen_v7.cpp
示例4: v3s16
void MeshMakeData::fillSingleNode(MapNode *node)
{
m_blockpos = v3s16(0,0,0);
#if !defined(MESH_ZEROCOPY)
v3s16 blockpos_nodes = v3s16(0,0,0);
VoxelArea area(blockpos_nodes-v3s16(1,1,1)*MAP_BLOCKSIZE,
blockpos_nodes+v3s16(1,1,1)*MAP_BLOCKSIZE*2-v3s16(1,1,1));
s32 volume = area.getVolume();
s32 our_node_index = area.index(1,1,1);
// Allocate this block + neighbors
m_vmanip.clear();
m_vmanip.addArea(area);
// Fill in data
MapNode *data = reinterpret_cast<MapNode*>( ::operator new(volume * sizeof(MapNode)));
for(s32 i = 0; i < volume; i++)
{
if(i == our_node_index)
{
data[i] = *node;
}
else
{
data[i] = MapNode(CONTENT_AIR, LIGHT_MAX, 0);
}
}
m_vmanip.copyFrom(data, area, area.MinEdge, area.MinEdge, area.getExtent());
delete[] data;
#endif
}
开发者ID:gourytch,项目名称:freeminer,代码行数:32,代码来源:mapblock_mesh.cpp
示例5: MapNode
void MapgenV7::dustTopNodes()
{
v3s16 em = vm->m_area.getExtent();
u32 index = 0;
if (water_level > node_max.Y)
return;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 x = node_min.X; x <= node_max.X; x++, index++) {
Biome *biome = (Biome *)bmgr->get(biomemap[index]);
if (biome->c_dust == CONTENT_IGNORE)
continue;
s16 y = node_max.Y;
u32 vi = vm->m_area.index(x, y, z);
for (; y >= node_min.Y; y--) {
if (vm->m_data[vi].getContent() != CONTENT_AIR)
break;
vm->m_area.add_y(em, vi, -1);
}
content_t c = vm->m_data[vi].getContent();
if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE) {
if (y == node_max.Y)
continue;
vm->m_area.add_y(em, vi, 1);
vm->m_data[vi] = MapNode(biome->c_dust);
}
}
}
开发者ID:KodexKy,项目名称:minetest,代码行数:34,代码来源:mapgen_v7.cpp
示例6: MapNode
void Mapgen_features::layers_init(EmergeManager *emerge, const Json::Value & paramsj) {
const auto & layersj = paramsj["layers"];
INodeDefManager *ndef = emerge->ndef;
auto layer_default_thickness = paramsj.get("layer_default_thickness", 1).asInt();
auto layer_thickness_multiplier = paramsj.get("layer_thickness_multiplier", 1).asInt();
if (!layersj.empty())
for (unsigned int i = 0; i < layersj.size(); ++i) {
if (layersj[i].empty())
continue;
const auto & layerj = layersj[i];
const auto & name = layerj["name"].asString();
if (name.empty())
continue;
auto content = ndef->getId(name);
if (content == CONTENT_IGNORE)
continue;
auto layer = layer_data{ content, MapNode(content, layerj["param1"].asInt(), layerj["param2"].asInt()) };
layer.height_min = layerj.get("y_min", layerj.get("height_min", -MAX_MAP_GENERATION_LIMIT).asInt()).asInt();
layer.height_max = layerj.get("y_max", layerj.get("height_max", +MAX_MAP_GENERATION_LIMIT).asInt()).asInt();
layer.thickness = layerj.get("thickness", layer_default_thickness).asInt() * layer_thickness_multiplier;
//layer.name = name; //dev
layers.emplace_back(layer);
}
if (layers.empty())
infostream << "layers empty, using only default:stone mg_params="<<paramsj<<std::endl;
else
verbosestream << "layers size=" << layers.size() << std::endl;
}
开发者ID:ChunHungLiu,项目名称:freeminer,代码行数:30,代码来源:mapgen_indev.cpp
示例7: Setting
void TestVoxelManipulator::testVoxelManipulator(INodeDefManager *nodedef)
{
VoxelManipulator v;
v.print(infostream, nodedef);
infostream << "*** Setting (-1,0,-1)=2 ***" << std::endl;
v.setNodeNoRef(v3s16(-1,0,-1), MapNode(t_CONTENT_GRASS));
v.print(infostream, nodedef);
UASSERT(v.getNode(v3s16(-1,0,-1)).getContent() == t_CONTENT_GRASS);
infostream << "*** Reading from inexistent (0,0,-1) ***" << std::endl;
EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,0,-1)));
v.print(infostream, nodedef);
infostream << "*** Adding area ***" << std::endl;
VoxelArea a(v3s16(-1,-1,-1), v3s16(1,1,1));
v.addArea(a);
v.print(infostream, nodedef);
UASSERT(v.getNode(v3s16(-1,0,-1)).getContent() == t_CONTENT_GRASS);
EXCEPTION_CHECK(InvalidPositionException, v.getNode(v3s16(0,1,1)));
}
开发者ID:00c,项目名称:minetest,代码行数:26,代码来源:test_voxelmanipulator.cpp
示例8: contour
void MapgenV7::generateCaves(s16 max_stone_y)
{
if (max_stone_y >= node_min.Y) {
u32 index = 0;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 y = node_min.Y - 1; y <= node_max.Y + 1; y++) {
u32 i = vm->m_area.index(node_min.X, y, z);
for (s16 x = node_min.X; x <= node_max.X; x++, i++, index++) {
float d1 = contour(noise_cave1->result[index]);
float d2 = contour(noise_cave2->result[index]);
if (d1 * d2 > 0.3) {
content_t c = vm->m_data[i].getContent();
if (!ndef->get(c).is_ground_content || c == CONTENT_AIR)
continue;
vm->m_data[i] = MapNode(CONTENT_AIR);
}
}
}
}
PseudoRandom ps(blockseed + 21343);
u32 bruises_count = (ps.range(1, 4) == 1) ? ps.range(1, 2) : 0;
for (u32 i = 0; i < bruises_count; i++) {
CaveV7 cave(this, &ps);
cave.makeCave(node_min, node_max, max_stone_y);
}
}
开发者ID:nathanlol5,项目名称:minetest,代码行数:29,代码来源:mapgen_v7.cpp
示例9: size
void TestSchematic::testLuaTableSerialize(INodeDefManager *ndef)
{
static const v3s16 size(3, 3, 3);
static const u32 volume = size.X * size.Y * size.Z;
Schematic schem;
schem.flags = 0;
schem.size = size;
schem.schemdata = new MapNode[volume];
schem.slice_probs = new u8[size.Y];
for (size_t i = 0; i != volume; i++)
schem.schemdata[i] = MapNode(test_schem2_data[i], test_schem2_prob[i], 0);
for (s16 y = 0; y != size.Y; y++)
schem.slice_probs[y] = MTSCHEM_PROB_ALWAYS;
std::vector<std::string> names;
names.push_back("air");
names.push_back("default:lava_source");
names.push_back("default:glass");
std::ostringstream ss(std::ios_base::binary);
UASSERT(schem.serializeToLua(&ss, names, false, 0));
UASSERTEQ(std::string, ss.str(), expected_lua_output);
}
开发者ID:MultiCraftProject,项目名称:MultiCraft,代码行数:26,代码来源:test_schematic.cpp
示例10: MYMIN
void DecoSimple::generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p)
{
ManualMapVoxelManipulator *vm = mg->vm;
if (!canPlaceDecoration(vm, p))
return;
content_t c_place = c_decos[pr->range(0, c_decos.size() - 1)];
s16 height = (deco_height_max > 0) ?
pr->range(deco_height, deco_height_max) : deco_height;
height = MYMIN(height, max_y - p.Y);
v3s16 em = vm->m_area.getExtent();
u32 vi = vm->m_area.index(p);
for (int i = 0; i < height; i++) {
vm->m_area.add_y(em, vi, 1);
content_t c = vm->m_data[vi].getContent();
if (c != CONTENT_AIR && c != CONTENT_IGNORE)
break;
vm->m_data[vi] = MapNode(c_place);
}
}
开发者ID:1CoreyDev1,项目名称:minetest,代码行数:26,代码来源:mg_decoration.cpp
示例11: v3s16
void MeshMakeData::fillSingleNode(MapNode *node)
{
m_blockpos = v3s16(0,0,0);
v3s16 blockpos_nodes = v3s16(0,0,0);
VoxelArea area(blockpos_nodes-v3s16(1,1,1)*MAP_BLOCKSIZE,
blockpos_nodes+v3s16(1,1,1)*MAP_BLOCKSIZE*2-v3s16(1,1,1));
s32 volume = area.getVolume();
s32 our_node_index = area.index(1,1,1);
// Allocate this block + neighbors
m_vmanip.clear();
m_vmanip.addArea(area);
// Fill in data
MapNode *data = new MapNode[volume];
for(s32 i = 0; i < volume; i++)
{
if(i == our_node_index)
{
data[i] = *node;
}
else
{
data[i] = MapNode(CONTENT_AIR, LIGHT_MAX, 0);
}
}
m_vmanip.copyFrom(data, area, area.MinEdge, area.MinEdge, area.getExtent());
delete[] data;
}
开发者ID:andrew889,项目名称:minetest-1,代码行数:30,代码来源:mapblock_mesh.cpp
示例12: if
int MapgenV5::generateBaseTerrain()
{
u32 index = 0;
u32 index2d = 0;
int stone_surface_max_y = -MAX_MAP_GENERATION_LIMIT;
noise_factor->perlinMap2D(node_min.X, node_min.Z);
noise_height->perlinMap2D(node_min.X, node_min.Z);
noise_ground->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z);
for (s16 z=node_min.Z; z<=node_max.Z; z++) {
for (s16 y=node_min.Y - 1; y<=node_max.Y + 1; y++) {
u32 vi = vm->m_area.index(node_min.X, y, z);
for (s16 x=node_min.X; x<=node_max.X; x++, vi++, index++, index2d++) {
if (vm->m_data[vi].getContent() != CONTENT_IGNORE)
continue;
float f = 0.55 + noise_factor->result[index2d];
if (f < 0.01)
f = 0.01;
else if (f >= 1.0)
f *= 1.6;
float h = noise_height->result[index2d];
if (noise_ground->result[index] * f < y - h) {
if (y <= water_level) {
vm->m_data[vi] = MapNode(c_water_source);
if (liquid_pressure && y <= 0)
vm->m_data[vi].addLevel(m_emerge->ndef, water_level - y, 1);
}
else
vm->m_data[vi] = MapNode(CONTENT_AIR);
} else {
vm->m_data[vi] = layers_get(index);
if (y > stone_surface_max_y)
stone_surface_max_y = y;
}
}
index2d -= ystride;
}
index2d += ystride;
}
return stone_surface_max_y;
}
开发者ID:yzziizzy,项目名称:freeminer,代码行数:45,代码来源:mapgen_v5.cpp
示例13: makeHole
void DungeonGen::makeDoor(v3s16 doorplace, v3s16 doordir)
{
makeHole(doorplace);
#ifdef DGEN_USE_TORCHES
// Place torch (for testing)
vm->m_data[vm->m_area.index(doorplace)] = MapNode(c_torch);
#endif
}
开发者ID:t0suj4,项目名称:minetest,代码行数:9,代码来源:dungeongen.cpp
示例14: sp
MapNode Map::getNodeTry(v3POS p) {
#ifndef NDEBUG
ScopeProfiler sp(g_profiler, "Map: getNodeTry");
#endif
auto blockpos = getNodeBlockPos(p);
auto block = getBlockNoCreateNoEx(blockpos, true);
if(!block)
return MapNode(CONTENT_IGNORE);
auto relpos = p - blockpos * MAP_BLOCKSIZE;
return block->getNodeTry(relpos);
}
开发者ID:Selat,项目名称:freeminer,代码行数:11,代码来源:fm_map.cpp
示例15: floatToInt
/**
* Helper function for Client Side Modding
* Flavour is applied there, this should not be used for core engine
* @param p
* @param is_valid_position
* @return
*/
MapNode Client::getNode(v3s16 p, bool *is_valid_position)
{
if (checkCSMFlavourLimit(CSMFlavourLimit::CSM_FL_LOOKUP_NODES)) {
v3s16 ppos = floatToInt(m_env.getLocalPlayer()->getPosition(), BS);
if ((u32) ppos.getDistanceFrom(p) > m_csm_noderange_limit) {
*is_valid_position = false;
return MapNode();
}
}
return m_env.getMap().getNodeNoEx(p, is_valid_position);
}
开发者ID:TeTpaAka,项目名称:minetest,代码行数:18,代码来源:client.cpp
示例16: MapNode
MapNode MapBlock::getNodeParent(v3s16 p, bool *is_valid_position)
{
if (isValidPosition(p) == false)
return m_parent->getNodeTry(getPosRelative() + p);
if (data == NULL) {
if (is_valid_position)
*is_valid_position = false;
return MapNode(CONTENT_IGNORE);
}
auto lock = try_lock_shared_rec();
if (!lock->owns_lock()) {
if (is_valid_position)
*is_valid_position = false;
return MapNode(CONTENT_IGNORE);
}
if (is_valid_position)
*is_valid_position = true;
return data[p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X];
}
开发者ID:daniel-santos,项目名称:freeminer,代码行数:21,代码来源:mapblock.cpp
示例17: catch
MapNode MapBlock::getNodeParentNoEx(v3s16 p)
{
if(isValidPosition(p) == false)
{
try{
return m_parent->getNode(getPosRelative() + p);
}
catch(InvalidPositionException &e)
{
return MapNode(CONTENT_IGNORE);
}
}
else
{
if(data == NULL)
{
return MapNode(CONTENT_IGNORE);
}
return data[p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X];
}
}
开发者ID:wowiamdiamonds,项目名称:minetest,代码行数:21,代码来源:mapblock.cpp
示例18: v3s16
void DecoSimple::generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, v3s16 p) {
ManualMapVoxelManipulator *vm = mg->vm;
u32 vi = vm->m_area.index(p);
if (vm->m_data[vi].getContent() != c_place_on &&
c_place_on != CONTENT_IGNORE)
return;
if (nspawnby != -1) {
int nneighs = 0;
v3s16 dirs[8] = { // a Moore neighborhood
v3s16( 0, 0, 1),
v3s16( 0, 0, -1),
v3s16( 1, 0, 0),
v3s16(-1, 0, 0),
v3s16( 1, 0, 1),
v3s16(-1, 0, 1),
v3s16(-1, 0, -1),
v3s16( 1, 0, -1)
};
for (int i = 0; i != 8; i++) {
u32 index = vm->m_area.index(p + dirs[i]);
if (vm->m_area.contains(index) &&
vm->m_data[index].getContent() == c_spawnby)
nneighs++;
}
if (nneighs < nspawnby)
return;
}
size_t ndecos = c_decolist.size();
content_t c_place = ndecos ? c_decolist[pr->range(0, ndecos - 1)] : c_deco;
s16 height = (deco_height_max > 0) ?
pr->range(deco_height, deco_height_max) : deco_height;
height = MYMIN(height, max_y - p.Y);
v3s16 em = vm->m_area.getExtent();
for (int i = 0; i < height; i++) {
vm->m_area.add_y(em, vi, 1);
content_t c = vm->m_data[vi].getContent();
if (c != CONTENT_AIR && c != CONTENT_IGNORE)
break;
vm->m_data[vi] = MapNode(c_place);
}
}
开发者ID:Nate-Devv,项目名称:freeminer,代码行数:51,代码来源:mapgen.cpp
示例19: if
int MapgenV5::generateBaseTerrain()
{
u32 index = 0;
u32 index2d = 0;
int stone_surface_max_y = -MAP_GENERATION_LIMIT;
for (s16 z=node_min.Z; z<=node_max.Z; z++) {
for (s16 y=node_min.Y - 1; y<=node_max.Y + 1; y++) {
u32 i = vm->m_area.index(node_min.X, y, z);
for (s16 x=node_min.X; x<=node_max.X; x++, i++, index++, index2d++) {
if (vm->m_data[i].getContent() != CONTENT_IGNORE)
continue;
float f = 0.55 + noise_factor->result[index2d];
if (f < 0.01)
f = 0.01;
else if (f >= 1.0)
f *= 1.6;
float h = noise_height->result[index2d];
if (noise_ground->result[index] * f < y - h) {
if (y <= water_level)
vm->m_data[i] = MapNode(c_water_source);
else
vm->m_data[i] = MapNode(CONTENT_AIR);
} else {
vm->m_data[i] = MapNode(c_stone);
if (y > stone_surface_max_y)
stone_surface_max_y = y;
}
}
index2d -= ystride;
}
index2d += ystride;
}
return stone_surface_max_y;
}
开发者ID:MirceaKitsune,项目名称:minetest,代码行数:38,代码来源:mapgen_v5.cpp
示例20: MapNode
MapNode MapBlock::getNodeParent(v3s16 p, bool *is_valid_position)
{
if (isValidPosition(p) == false)
return m_parent->getNodeNoEx(getPosRelative() + p, is_valid_position);
if (data == NULL) {
if (is_valid_position)
*is_valid_position = false;
return MapNode(CONTENT_IGNORE);
}
if (is_valid_position)
*is_valid_position = true;
return data[p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X];
}
开发者ID:TriBlade9,项目名称:minetest,代码行数:14,代码来源:mapblock.cpp
注:本文中的MapNode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论