From 2e1a69c3b1154c189816c8072ce3a4dbcc9fa163 Mon Sep 17 00:00:00 2001 From: Ciaran Gultnieks Date: Mon, 9 May 2011 19:22:07 +0100 Subject: [PATCH] Added glass, with rendering and furnace support. --- src/inventory.cpp | 8 +++++ src/mapblock.cpp | 77 +++++++++++++++++++++++++++++++++++++++++++++++ src/mapnode.cpp | 12 +++++++- src/mapnode.h | 1 + src/materials.cpp | 1 + src/server.cpp | 1 + src/tile.cpp | 1 + 7 files changed, 100 insertions(+), 1 deletion(-) diff --git a/src/inventory.cpp b/src/inventory.cpp index f91e2e0b..47a8d4de 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 67e7e257..58b23bd1 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; zm_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 6deebd56..c27f4848 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 d456cf88..9ab88538 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 2e33abeb..e5f0c3b9 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 d47dcb9c..b5a38aa0 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 e65e92b7..5b89c693 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");