From 3b0bff2f743a3abf100368f94efafa7c2843a9b7 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 21 Dec 2010 02:25:47 +0200 Subject: Cracking blocks while digging --- src/mapblock.cpp | 50 ++++++++++++++++++++++---------------------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'src/mapblock.cpp') diff --git a/src/mapblock.cpp b/src/mapblock.cpp index af08cadaa..e2262544c 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -300,6 +300,8 @@ TileSpec MapBlock::getNodeTile(MapNode mn, v3s16 p, v3s16 face_dir) } if(mod.type == NODEMOD_CRACK) { + spec.feature = TILEFEAT_CRACK; + spec.param.crack.progression = mod.param; } } @@ -646,14 +648,31 @@ void MapBlock::updateMesh(u32 daynight_ratio) if(f.tile.feature == TILEFEAT_NONE) { - /*collector.append(g_tile_materials[f.tile.id], f.vertices, 4, - indices, 6);*/ collector.append(tile_material_get(f.tile.id), f.vertices, 4, indices, 6); } + else if(f.tile.feature == TILEFEAT_CRACK) + { + const char *path = tile_texture_path_get(f.tile.id); + + u16 progression = f.tile.param.crack.progression; + + std::string name = (std::string)path + "_cracked_" + + (char)('0' + progression); + + TextureMod *mod = new CrackTextureMod(progression); + + video::ITexture *texture = g_irrlicht->getTexture( + TextureSpec(name, path, mod)); + + video::SMaterial material = tile_material_get(f.tile.id); + material.setTexture(0, texture); + + collector.append(material, f.vertices, 4, indices, 6); + } else { - // Not implemented + // No such feature assert(0); } } @@ -668,19 +687,6 @@ void MapBlock::updateMesh(u32 daynight_ratio) <<" materials (meshbuffers)"<::Iterator i; - i = fastfaces_new->begin(); - for(; i != fastfaces_new->end(); i++) - { - delete *i; - } - fastfaces_new->clear(); - delete fastfaces_new;*/ - /* Add special graphics: - torches @@ -688,14 +694,6 @@ void MapBlock::updateMesh(u32 daynight_ratio) TODO: Optimize by using same meshbuffer for same textures */ - /*scene::ISceneManager *smgr = NULL; - video::IVideoDriver* driver = NULL; - if(g_device) - { - smgr = g_device->getSceneManager(); - driver = smgr->getVideoDriver(); - }*/ - for(s16 z=0; zgetMaterial().setTexture(0, g_irrlicht->getTexture("../data/torch_on_floor.png")); - //g_texturecache.get("torch_on_floor")); else if(dir == v3s16(0,1,0)) buf->getMaterial().setTexture(0, g_irrlicht->getTexture("../data/torch_on_ceiling.png")); - //g_texturecache.get("torch_on_ceiling")); // For backwards compatibility else if(dir == v3s16(0,0,0)) buf->getMaterial().setTexture(0, g_irrlicht->getTexture("../data/torch_on_floor.png")); - //g_texturecache.get("torch_on_floor")); else buf->getMaterial().setTexture(0, g_irrlicht->getTexture("../data/torch.png")); - //buf->getMaterial().setTexture(0, g_texturecache.get("torch")); // Add to mesh mesh_new->addMeshBuffer(buf); -- cgit v1.2.3