aboutsummaryrefslogtreecommitdiff
path: root/src/content_mapblock.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-09-16 19:09:13 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-09-16 19:09:13 +0300
commitb22cb69a155d586791341d4df90060b8220361e1 (patch)
tree9ba2ec3a1f675271f05509bfe1384514a83c1772 /src/content_mapblock.cpp
parent40707e3c5bc730ebc5780b1c545c5daeb3353a42 (diff)
parent88dc8c694ed0e182b4d5ace4fcd94a0a82946c31 (diff)
downloadminetest-b22cb69a155d586791341d4df90060b8220361e1.tar.gz
minetest-b22cb69a155d586791341d4df90060b8220361e1.tar.bz2
minetest-b22cb69a155d586791341d4df90060b8220361e1.zip
Merge remote-tracking branch 'sfan5/apple-trees'
Diffstat (limited to 'src/content_mapblock.cpp')
-rw-r--r--src/content_mapblock.cpp60
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