diff options
author | Perttu Ahola <celeron55@gmail.com> | 2011-05-09 21:41:16 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2011-05-09 21:41:16 +0300 |
commit | 0674db4a6b687a73637844fa354d2ac662e42820 (patch) | |
tree | 0fd303ffdbca9d1a7c60c13c3ca4aeddd28c7c57 | |
parent | 8c3b4fed10ce5bad422436b8b804fd1fd71b0e65 (diff) | |
parent | 2c4eb198c37a3b6cc63a277916139c94922e442f (diff) | |
download | minetest-0674db4a6b687a73637844fa354d2ac662e42820.tar.gz minetest-0674db4a6b687a73637844fa354d2ac662e42820.tar.bz2 minetest-0674db4a6b687a73637844fa354d2ac662e42820.zip |
merged CiaranG's changes: the glass block
-rw-r--r-- | .hgignore | 18 | ||||
-rw-r--r-- | data/glass.png | bin | 0 -> 1309 bytes | |||
-rw-r--r-- | src/inventory.cpp | 8 | ||||
-rw-r--r-- | src/mapblock.cpp | 77 | ||||
-rw-r--r-- | src/mapnode.cpp | 12 | ||||
-rw-r--r-- | src/mapnode.h | 1 | ||||
-rw-r--r-- | src/materials.cpp | 1 | ||||
-rw-r--r-- | src/server.cpp | 1 | ||||
-rw-r--r-- | src/tile.cpp | 1 |
9 files changed, 118 insertions, 1 deletions
diff --git a/.hgignore b/.hgignore new file mode 100644 index 000000000..58a32bafb --- /dev/null +++ b/.hgignore @@ -0,0 +1,18 @@ +map/* +CMakeFiles/* +src/CMakeFiles/* +src/Makefile +src/cmake_config.h +src/cmake_install.cmake +src/jthread/CMakeFiles/* +src/jthread/Makefile +src/jthread/cmake_config.h +src/jthread/cmake_install.cmake +minetest.conf +bin/ +CMakeCache.txt +CPackConfig.cmake +CPackSourceConfig.cmake +Makefile +cmake_install.cmake +src/jthread/libjthread.a diff --git a/data/glass.png b/data/glass.png Binary files differnew file mode 100644 index 000000000..8598ce670 --- /dev/null +++ b/data/glass.png diff --git a/src/inventory.cpp b/src/inventory.cpp index f91e2e0b6..47a8d4de9 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -118,6 +118,10 @@ bool MaterialItem::isCookable() { return true; } + else if(m_content == CONTENT_SAND) + { + return true; + } return false; } @@ -131,6 +135,10 @@ InventoryItem *MaterialItem::createCookResult() { return new MaterialItem(CONTENT_STONE, 1); } + else if(m_content == CONTENT_SAND) + { + return new MaterialItem(CONTENT_GLASS, 1); + } return NULL; } diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 67e7e2574..58b23bd14 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -901,6 +901,17 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) g_texturesource->getTextureId("leaves.png")); material_leaves1.setTexture(0, pa_leaves1.atlas); + // Glass material + video::SMaterial material_glass; + material_glass.setFlag(video::EMF_LIGHTING, false); + material_glass.setFlag(video::EMF_BILINEAR_FILTER, false); + material_glass.setFlag(video::EMF_FOG_ENABLE, true); + material_glass.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + AtlasPointer pa_glass = g_texturesource->getTexture( + g_texturesource->getTextureId("glass.png")); + material_glass.setTexture(0, pa_glass.atlas); + + for(s16 z=0; z<MAP_BLOCKSIZE; z++) for(s16 y=0; y<MAP_BLOCKSIZE; y++) for(s16 x=0; x<MAP_BLOCKSIZE; x++) @@ -1406,6 +1417,72 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) collector.append(material_leaves1, vertices, 4, indices, 6); } } + /* + Add glass + */ + else if(n.d == CONTENT_GLASS) + { + u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio))); + video::SColor c(255,l,l,l); + + for(u32 j=0; j<6; j++) + { + video::S3DVertex vertices[4] = + { + video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, + pa_glass.x0(), pa_glass.y1()), + video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, + pa_glass.x1(), pa_glass.y1()), + video::S3DVertex(BS/2,BS/2,BS/2, 0,0,0, c, + pa_glass.x1(), pa_glass.y0()), + video::S3DVertex(-BS/2,BS/2,BS/2, 0,0,0, c, + pa_glass.x0(), pa_glass.y0()), + }; + + if(j == 0) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(0); + } + else if(j == 1) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(180); + } + else if(j == 2) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(-90); + } + else if(j == 3) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(90); + } + else if(j == 4) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateYZBy(-90); + } + else if(j == 5) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateYZBy(90); + } + + for(u16 i=0; i<4; i++) + { + vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); + } + + u16 indices[] = {0,1,2,2,3,0}; + // Add to mesh collector + collector.append(material_glass, vertices, 4, indices, 6); + } + } + + + } /* diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 6deebd56d..c27f4848b 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -204,7 +204,17 @@ void init_mapnode() f->setAllTextures("[noalpha:leaves.png"); } f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; - + + i = CONTENT_GLASS; + f = &g_content_features[i]; + f->light_propagates = true; + f->param_type = CPT_LIGHT; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + f->solidness = 0; // drawn separately, makes no faces + f->setInventoryTextureCube("glass.png", "glass.png", "glass.png"); + + // Deprecated i = CONTENT_COALSTONE; f = &g_content_features[i]; diff --git a/src/mapnode.h b/src/mapnode.h index d456cf883..9ab885386 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -99,6 +99,7 @@ void init_content_inventory_texture_paths(); //#define CONTENT_WORKBENCH 17 #define CONTENT_COBBLE 18 #define CONTENT_STEEL 19 +#define CONTENT_GLASS 20 /* Content feature list diff --git a/src/materials.cpp b/src/materials.cpp index 2e33abeba..e5f0c3b9e 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -72,6 +72,7 @@ void initializeMaterialProperties() setWoodLikeDiggingProperties(CONTENT_TREE, 1.0); setWoodLikeDiggingProperties(CONTENT_LEAVES, 0.15); + setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15); setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75); setWoodLikeDiggingProperties(CONTENT_CHEST, 1.0); diff --git a/src/server.cpp b/src/server.cpp index d47dcb9ce..b5a38aa06 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3984,6 +3984,7 @@ void setCreativeInventory(Player *player) CONTENT_SAND, CONTENT_TREE, CONTENT_LEAVES, + CONTENT_GLASS, CONTENT_MESE, CONTENT_WATERSOURCE, CONTENT_CLOUD, diff --git a/src/tile.cpp b/src/tile.cpp index e65e92b7e..5b89c6932 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -476,6 +476,7 @@ void TextureSource::buildMainAtlas() sourcelist.push_back("tree_top.png"); sourcelist.push_back("water.png"); sourcelist.push_back("leaves.png"); + sourcelist.push_back("glass.png"); sourcelist.push_back("mud.png^grass_side.png"); sourcelist.push_back("cobble.png"); |