summaryrefslogtreecommitdiff
path: root/src/content_mapblock.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-09-26 22:41:06 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-09-26 22:41:06 +0300
commita7833cca22bbb923efbc01fd0f820318a613eca6 (patch)
treeb8da72d3e36b70f1cd018615ed38de5d009cfe57 /src/content_mapblock.cpp
parent08ac3454ccb473156d39ebf543d617c1541588ca (diff)
parentbc01ae4cbd6e9ba2bcc0b75bab8ba5d99fcc4e34 (diff)
downloadminetest-a7833cca22bbb923efbc01fd0f820318a613eca6.tar.gz
minetest-a7833cca22bbb923efbc01fd0f820318a613eca6.tar.bz2
minetest-a7833cca22bbb923efbc01fd0f820318a613eca6.zip
Merge remote-tracking branch 'marktraceur/master'
Diffstat (limited to 'src/content_mapblock.cpp')
-rw-r--r--src/content_mapblock.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp
index 1cc37b969..9a156cb55 100644
--- a/src/content_mapblock.cpp
+++ b/src/content_mapblock.cpp
@@ -199,6 +199,18 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
g_texturesource->getTextureId("apple.png"));
material_apple.setTexture(0, pa_apple.atlas);
+
+ // Sapling material
+ video::SMaterial material_sapling;
+ material_sapling.setFlag(video::EMF_LIGHTING, false);
+ material_sapling.setFlag(video::EMF_BILINEAR_FILTER, false);
+ material_sapling.setFlag(video::EMF_FOG_ENABLE, true);
+ material_sapling.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ AtlasPointer pa_sapling = g_texturesource->getTexture(
+ g_texturesource->getTextureId("sapling.png"));
+ material_sapling.setTexture(0, pa_sapling.atlas);
+
+
// junglegrass material
video::SMaterial material_junglegrass;
material_junglegrass.setFlag(video::EMF_LIGHTING, false);
@@ -1263,6 +1275,55 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
collector.append(material_apple, vertices, 4, indices, 6);
}
}
+ else if(n.getContent() == CONTENT_SAPLING) {
+ 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_sapling.x0(), pa_sapling.y1()),
+ video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c,
+ pa_sapling.x1(), pa_sapling.y1()),
+ video::S3DVertex(BS/2,BS/1,0, 0,0,0, c,
+ pa_sapling.x1(), pa_sapling.y0()),
+ video::S3DVertex(-BS/2,BS/1,0, 0,0,0, c,
+ pa_sapling.x0(), pa_sapling.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_sapling, vertices, 4, indices, 6);
+ }
+ }
}
}
#endif