diff options
Diffstat (limited to 'src/content_mapblock.cpp')
-rw-r--r-- | src/content_mapblock.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 482b9eb63..1cc37b969 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -188,6 +188,16 @@ void mapblock_mesh_generate_special(MeshMakeData *data, AtlasPointer pa_papyrus = g_texturesource->getTexture( g_texturesource->getTextureId("papyrus.png")); material_papyrus.setTexture(0, pa_papyrus.atlas); + + // Apple material + video::SMaterial material_apple; + material_apple.setFlag(video::EMF_LIGHTING, false); + material_apple.setFlag(video::EMF_BILINEAR_FILTER, false); + material_apple.setFlag(video::EMF_FOG_ENABLE, true); + material_apple.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + AtlasPointer pa_apple = g_texturesource->getTexture( + g_texturesource->getTextureId("apple.png")); + material_apple.setTexture(0, pa_apple.atlas); // junglegrass material video::SMaterial material_junglegrass; @@ -1203,6 +1213,56 @@ void mapblock_mesh_generate_special(MeshMakeData *data, // Add to mesh collector collector.append(material_ladder, vertices, 4, indices, 6); } + else if(n.getContent() == CONTENT_APPLE) + { + u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio))); + video::SColor c = MapBlock_LightColor(255, l); + + for(u32 j=0; j<4; j++) + { + video::S3DVertex vertices[4] = + { + video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, + pa_apple.x0(), pa_apple.y1()), + video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, + pa_apple.x1(), pa_apple.y1()), + video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, + pa_apple.x1(), pa_apple.y0()), + video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c, + pa_apple.x0(), pa_apple.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_apple, vertices, 4, indices, 6); + } + } } } #endif |