+ papyrus
authorNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>
Thu, 2 Jun 2011 22:55:28 +0000 (00:55 +0200)
committerNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>
Thu, 2 Jun 2011 22:55:28 +0000 (00:55 +0200)
data/papyrus.png [new file with mode: 0644]
src/map.cpp
src/mapblock.cpp
src/mapnode.cpp
src/mapnode.h
src/materials.cpp
src/server.cpp
src/tile.cpp

diff --git a/data/papyrus.png b/data/papyrus.png
new file mode 100644 (file)
index 0000000..bf0dec7
Binary files /dev/null and b/data/papyrus.png differ
index ac5bd7d14e49bf32b06aa8c56ee06d51bec736ea..fc674d263642bf05e2627cd6f5e13e2cedbf5e9e 100644 (file)
@@ -2045,6 +2045,20 @@ void make_tree(VoxelManipulator &vmanip, v3s16 p0)
        }
 }
 
+void make_papyrus(VoxelManipulator &vmanip, v3s16 p0)
+{
+       MapNode papyrusnode(CONTENT_PAPYRUS);
+
+       s16 trunk_h = myrand_range(2, 3);
+       v3s16 p1 = p0;
+       for(s16 ii=0; ii<trunk_h; ii++)
+       {
+               if(vmanip.m_area.contains(p1))
+                       vmanip.m_data[vmanip.m_area.index(p1)] = papyrusnode;
+               p1.Y++;
+       }
+}
+
 void make_cactus(VoxelManipulator &vmanip, v3s16 p0)
 {
        MapNode cactusnode(CONTENT_CACTUS);
@@ -3225,7 +3239,7 @@ void makeChunk(ChunkMakeData *data)
                                s16 z = myrand_range(p2d_min.Y, p2d_max.Y);
                                s16 y = find_ground_level(data->vmanip, v2s16(x,z));
                                // Don't make a tree under water level
-                               if(y < WATER_LEVEL)
+                               if(y < WATER_LEVEL - 1)
                                        continue;
                                // Don't make a tree so high that it doesn't fit
                                if(y > y_nodes_max - 6)
@@ -3236,6 +3250,15 @@ void makeChunk(ChunkMakeData *data)
                                        MapNode *n = &data->vmanip.m_data[i];
                                        if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND)
                                                continue;
+                                       // Papyrus grows only on mud and in water
+                                       if(n->d == CONTENT_MUD && y == WATER_LEVEL - 1)
+                                       {
+                                               p.Y++;
+                                               make_papyrus(data->vmanip, p);
+                                       }
+                                       // Don't make a tree under water level
+                                       if(y < WATER_LEVEL)
+                                               continue;
                                        // Trees grow only on mud and grass
                                        if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS)
                                        {
@@ -3243,7 +3266,7 @@ void makeChunk(ChunkMakeData *data)
                                                make_tree(data->vmanip, p);
                                        }
                                        // Cactii grow only on sand
-                                       if(n->d == CONTENT_SAND)
+                                       else if(n->d == CONTENT_SAND)
                                        {
                                                p.Y++;
                                                make_cactus(data->vmanip, p);
index d98bfaf1ee46fd8e024a41db15d86a4e2bda26cb..c6b82634db21bf6bafc464ccd64dd920c944e585 100644 (file)
@@ -987,6 +987,16 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
                        g_texturesource->getTextureId("wood.png"));
        material_wood.setTexture(0, pa_wood.atlas);
 
+       // Papyrus material
+       video::SMaterial material_papyrus;
+       material_papyrus.setFlag(video::EMF_LIGHTING, false);
+       material_papyrus.setFlag(video::EMF_BILINEAR_FILTER, false);
+       material_papyrus.setFlag(video::EMF_FOG_ENABLE, true);
+       material_papyrus.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+       AtlasPointer pa_papyrus = g_texturesource->getTexture(
+                       g_texturesource->getTextureId("papyrus.png"));
+       material_papyrus.setTexture(0, pa_papyrus.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++)
@@ -1612,8 +1622,56 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data)
                        }
 
                }
+               else if(n.d == CONTENT_PAPYRUS)
+               {
+                       u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio)));
+                       video::SColor c(255,l,l,l);
+
+                       for(u32 j=0; j<4; j++)
+                       {
+                               video::S3DVertex vertices[4] =
+                               {
+                                       video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c,
+                                               pa_papyrus.x0(), pa_papyrus.y1()),
+                                       video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c,
+                                               pa_papyrus.x1(), pa_papyrus.y1()),
+                                       video::S3DVertex(BS/2,BS/2,0, 0,0,0, c,
+                                               pa_papyrus.x1(), pa_papyrus.y0()),
+                                       video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c,
+                                               pa_papyrus.x0(), pa_papyrus.y0()),
+                               };
+
+                               if(j == 0)
+                               {
+                                       for(u16 i=0; i<4; i++)
+                                               vertices[i].Pos.rotateXZBy(45);
+                               }
+                               else if(j == 1)
+                               {
+                                       for(u16 i=0; i<4; i++)
+                                               vertices[i].Pos.rotateXZBy(-45);
+                               }
+                               else if(j == 2)
+                               {
+                                       for(u16 i=0; i<4; i++)
+                                               vertices[i].Pos.rotateXZBy(135);
+                               }
+                               else if(j == 3)
+                               {
+                                       for(u16 i=0; i<4; i++)
+                                               vertices[i].Pos.rotateXZBy(-135);
+                               }
 
+                               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_papyrus, vertices, 4, indices, 6);
+                       }
+               }
 
        }
 
index cef9bbf03674481dbb64d60e770cff7334187c24..954c85f2f7d9e75319ed9249a214525524f7bc9f 100644 (file)
@@ -241,6 +241,16 @@ void init_mapnode()
        f->is_ground_content = true;
        f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
 
+       i = CONTENT_PAPYRUS;
+       f = &g_content_features[i];
+       f->setInventoryTexture("papyrus.png");
+       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->walkable = false;
+
        i = CONTENT_GLASS;
        f = &g_content_features[i];
        f->light_propagates = true;
index e8cc0ab513fcdb0d47699f76b6b582e6eb558b2d..52d0199c4de760ab372b409a46d00cd76674b29e 100644 (file)
@@ -105,6 +105,7 @@ void init_content_inventory_texture_paths();
 #define CONTENT_CACTUS 23
 #define CONTENT_BRICK 24
 #define CONTENT_CLAY 25
+#define CONTENT_PAPYRUS 26
 
 /*
        Content feature list
index 8c23056f241a2cb6d518defbd981659e719ef9f0..e95ca7ba9c66c643c11ae4df88a8665053b9ceea 100644 (file)
@@ -76,6 +76,7 @@ void initializeMaterialProperties()
        setWoodLikeDiggingProperties(CONTENT_TREE, 1.0);
        setWoodLikeDiggingProperties(CONTENT_LEAVES, 0.15);
        setWoodLikeDiggingProperties(CONTENT_CACTUS, 0.75);
+       setWoodLikeDiggingProperties(CONTENT_PAPYRUS, 0.25);
        setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15);
        setWoodLikeDiggingProperties(CONTENT_FENCE, 0.75);
        setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75);
index 17850c5fad65cad1b14bc9ca2d2a9bd335674134..e9875456cfc8b6835dd7d4003b8a7746af5469a4 100644 (file)
@@ -4111,6 +4111,7 @@ void setCreativeInventory(Player *player)
                CONTENT_TREE,
                CONTENT_LEAVES,
                CONTENT_CACTUS,
+               CONTENT_PAPYRUS,
                CONTENT_GLASS,
                CONTENT_FENCE,
                CONTENT_MESE,
index 71e0c9638a15b9778206a587601cfeed0de6ab21..c77262c49ee7bf4185834b7cb10e37c60697233d 100644 (file)
@@ -517,6 +517,7 @@ void TextureSource::buildMainAtlas()
        sourcelist.push_back("leaves.png");
        sourcelist.push_back("cactus_side.png");
        sourcelist.push_back("cactus_top.png");
+       sourcelist.push_back("papyrus.png");
        sourcelist.push_back("glass.png");
        sourcelist.push_back("mud.png^grass_side.png");
        sourcelist.push_back("cobble.png");