aboutsummaryrefslogtreecommitdiff
path: root/src/content_mapblock.cpp
diff options
context:
space:
mode:
authorMark Holmquist <marktraceur@gmail.com>2011-08-16 02:14:49 -0700
committerMark Holmquist <marktraceur@gmail.com>2011-09-23 18:13:53 -0700
commit85f119e1e6cc958a54eaf8468f2a302aa8c60dbe (patch)
tree289ee051ee5eeba1174147229f111ce109ac9e68 /src/content_mapblock.cpp
parent789c88509c1eab8407d3451d55eb31f65150e54a (diff)
downloadminetest-85f119e1e6cc958a54eaf8468f2a302aa8c60dbe.tar.gz
minetest-85f119e1e6cc958a54eaf8468f2a302aa8c60dbe.tar.bz2
minetest-85f119e1e6cc958a54eaf8468f2a302aa8c60dbe.zip
Adding (most) of the sapling functionality. It has yet to work, since MEET_OTHER was not implemented at the time of this commit. Hopefully it will work when merged with celeron's latest.
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