// New-style leaves material
video::SMaterial material_leaves1;
material_leaves1.setFlag(video::EMF_LIGHTING, false);
- //material_leaves1.setFlag(video::EMF_BACK_FACE_CULLING, false);
material_leaves1.setFlag(video::EMF_BILINEAR_FILTER, false);
material_leaves1.setFlag(video::EMF_FOG_ENABLE, true);
material_leaves1.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
v3s16 p(x,y,z);
MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes+p);
-
+
/*
Add torches to mesh
*/
if(n.getContent() == CONTENT_TORCH)
{
+ v3s16 dir = unpackDir(n.param2);
+
+ const char *texturename = "torch.png";
+ if(dir == v3s16(0,-1,0)){
+ texturename = "torch_on_floor.png";
+ } else if(dir == v3s16(0,1,0)){
+ texturename = "torch_on_ceiling.png";
+ // For backwards compatibility
+ } else if(dir == v3s16(0,0,0)){
+ texturename = "torch_on_floor.png";
+ } else {
+ texturename = "torch.png";
+ }
+
+ AtlasPointer ap = g_texturesource->getTexture(texturename);
+
+ // Set material
+ video::SMaterial material;
+ material.setFlag(video::EMF_LIGHTING, false);
+ material.setFlag(video::EMF_BACK_FACE_CULLING, true);
+ material.setFlag(video::EMF_BILINEAR_FILTER, false);
+ material.setFlag(video::EMF_FOG_ENABLE, true);
+ //material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
+ material.MaterialType
+ = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ material.setTexture(0, ap.atlas);
+
video::SColor c(255,255,255,255);
// Wall at X+ of node
video::S3DVertex vertices[4] =
{
- video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, 0,1),
- video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, 1,1),
- video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, 1,0),
- video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c, 0,0),
+ video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c,
+ ap.x0(), ap.y1()),
+ video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c,
+ ap.x1(), ap.y1()),
+ video::S3DVertex(BS/2,BS/2,0, 0,0,0, c,
+ ap.x1(), ap.y0()),
+ video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c,
+ ap.x0(), ap.y0()),
};
- v3s16 dir = unpackDir(n.param2);
-
for(s32 i=0; i<4; i++)
{
if(dir == v3s16(1,0,0))
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
}
- // Set material
- video::SMaterial material;
- material.setFlag(video::EMF_LIGHTING, false);
- material.setFlag(video::EMF_BACK_FACE_CULLING, false);
- material.setFlag(video::EMF_BILINEAR_FILTER, false);
- //material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
- material.MaterialType
- = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
-
- if(dir == v3s16(0,-1,0))
- material.setTexture(0,
- g_texturesource->getTextureRaw("torch_on_floor.png"));
- else if(dir == v3s16(0,1,0))
- material.setTexture(0,
- g_texturesource->getTextureRaw("torch_on_ceiling.png"));
- // For backwards compatibility
- else if(dir == v3s16(0,0,0))
- material.setTexture(0,
- g_texturesource->getTextureRaw("torch_on_floor.png"));
- else
- material.setTexture(0,
- g_texturesource->getTextureRaw("torch.png"));
-
u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector
collector.append(material, vertices, 4, indices, 6);
*/
else if(n.getContent() == CONTENT_SIGN_WALL)
{
+ AtlasPointer ap = g_texturesource->getTexture("sign_wall.png");
+
+ // Set material
+ video::SMaterial material;
+ material.setFlag(video::EMF_LIGHTING, false);
+ material.setFlag(video::EMF_BACK_FACE_CULLING, true);
+ material.setFlag(video::EMF_BILINEAR_FILTER, false);
+ material.setFlag(video::EMF_FOG_ENABLE, true);
+ material.MaterialType
+ = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ material.setTexture(0, ap.atlas);
+
u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
video::SColor c = MapBlock_LightColor(255, l);
// Wall at X+ of node
video::S3DVertex vertices[4] =
{
- video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, 0,1),
- video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 1,1),
- video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, 1,0),
- video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0),
+ video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c,
+ ap.x0(), ap.y1()),
+ video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c,
+ ap.x1(), ap.y1()),
+ video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c,
+ ap.x1(), ap.y0()),
+ video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c,
+ ap.x0(), ap.y0()),
};
v3s16 dir = unpackDir(n.param2);
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
}
- // Set material
- video::SMaterial material;
- material.setFlag(video::EMF_LIGHTING, false);
- material.setFlag(video::EMF_BACK_FACE_CULLING, false);
- material.setFlag(video::EMF_BILINEAR_FILTER, false);
- material.setFlag(video::EMF_FOG_ENABLE, true);
- //material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
- material.MaterialType
- = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
-
- material.setTexture(0,
- g_texturesource->getTextureRaw("sign_wall.png"));
-
u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector
collector.append(material, vertices, 4, indices, 6);
video::S3DVertex vertices[4] =
{
- /*video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, 0,1),
- video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 1,1),
- video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 1,0),
- video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, 0,0),*/
video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c,
pa_liquid1.x0(), pa_liquid1.y1()),
video::S3DVertex(BS/2,0,BS/2, 0,0,0, c,
{
video::S3DVertex vertices[4] =
{
- /*video::S3DVertex(-BS/2,0,-BS/2, 0,0,0, c, 0,1),
- video::S3DVertex(BS/2,0,-BS/2, 0,0,0, c, 1,1),
- video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 1,0),
- video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, 0,0),*/
video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c,
pa_liquid1.x0(), pa_liquid1.y1()),
video::S3DVertex(BS/2,0,BS/2, 0,0,0, c,
video::S3DVertex vertices[4] =
{
- /*video::S3DVertex(-BS/2,0,-BS/2, 0,0,0, c, 0,1),
- video::S3DVertex(BS/2,0,-BS/2, 0,0,0, c, 1,1),
- video::S3DVertex(BS/2,0,BS/2, 0,0,0, c, 1,0),
- video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c, 0,0),*/
video::S3DVertex(-BS/2,0,BS/2, 0,0,0, c,
pa_liquid1.x0(), pa_liquid1.y1()),
video::S3DVertex(BS/2,0,BS/2, 0,0,0, c,
{
video::S3DVertex vertices[4] =
{
- /*video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, 0,1),
- video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, 1,1),
- video::S3DVertex(BS/2,BS/2,BS/2, 0,0,0, c, 1,0),
- video::S3DVertex(-BS/2,BS/2,BS/2, 0,0,0, c, 0,0),*/
video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c,
pa_leaves1.x0(), pa_leaves1.y1()),
video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c,
video::S3DVertex vertices[4] =
{
- /*video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c, 0,1),
- video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c, 1,1),
- video::S3DVertex(BS/2,BS/2,BS/2, 0,0,0, c, 1,0),
- video::S3DVertex(-BS/2,BS/2,BS/2, 0,0,0, c, 0,0),*/
video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c,
ap.x0(), ap.y1()),
video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c,
video::S3DVertex vertices[4] =
{
video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c,
- pa_papyrus.x0(), pa_papyrus.y1()),
+ pa_junglegrass.x0(), pa_junglegrass.y1()),
video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c,
- pa_papyrus.x1(), pa_papyrus.y1()),
+ pa_junglegrass.x1(), pa_junglegrass.y1()),
video::S3DVertex(BS/2,BS/1,0, 0,0,0, c,
- pa_papyrus.x1(), pa_papyrus.y0()),
+ pa_junglegrass.x1(), pa_junglegrass.y0()),
video::S3DVertex(-BS/2,BS/1,0, 0,0,0, c,
- pa_papyrus.x0(), pa_papyrus.y0()),
+ pa_junglegrass.x0(), pa_junglegrass.y0()),
};
if(j == 0)
}
else if(n.getContent() == CONTENT_RAIL)
{
- u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
- video::SColor c = MapBlock_LightColor(255, l);
-
bool is_rail_x [] = { false, false }; /* x-1, x+1 */
bool is_rail_z [] = { false, false }; /* z-1, z+1 */
if(n_plus_z.getContent() == CONTENT_RAIL)
is_rail_z[1] = true;
- float d = (float)BS/16;
- video::S3DVertex vertices[4] =
- {
- video::S3DVertex(-BS/2,-BS/2+d,-BS/2, 0,0,0, c,
- 0, 1),
- video::S3DVertex(BS/2,-BS/2+d,-BS/2, 0,0,0, c,
- 1, 1),
- video::S3DVertex(BS/2,-BS/2+d,BS/2, 0,0,0, c,
- 1, 0),
- video::S3DVertex(-BS/2,-BS/2+d,BS/2, 0,0,0, c,
- 0, 0),
- };
-
- video::SMaterial material_rail;
- material_rail.setFlag(video::EMF_LIGHTING, false);
- material_rail.setFlag(video::EMF_BACK_FACE_CULLING, false);
- material_rail.setFlag(video::EMF_BILINEAR_FILTER, false);
- material_rail.setFlag(video::EMF_FOG_ENABLE, true);
- material_rail.MaterialType
- = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
-
int adjacencies = is_rail_x[0] + is_rail_x[1] + is_rail_z[0] + is_rail_z[1];
// Assign textures
+ const char *texturename = "rail.png";
if(adjacencies < 2)
- material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png"));
+ texturename = "rail.png";
else if(adjacencies == 2)
{
if((is_rail_x[0] && is_rail_x[1]) || (is_rail_z[0] && is_rail_z[1]))
- material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png"));
+ texturename = "rail.png";
else
- material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_curved.png"));
+ texturename = "rail_curved.png";
}
else if(adjacencies == 3)
- material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_t_junction.png"));
+ texturename = "rail_t_junction.png";
else if(adjacencies == 4)
- material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_crossing.png"));
+ texturename = "rail_crossing.png";
+
+ AtlasPointer ap = g_texturesource->getTexture(texturename);
+
+ video::SMaterial material_rail;
+ material_rail.setFlag(video::EMF_LIGHTING, false);
+ material_rail.setFlag(video::EMF_BACK_FACE_CULLING, true);
+ material_rail.setFlag(video::EMF_BILINEAR_FILTER, false);
+ material_rail.setFlag(video::EMF_FOG_ENABLE, true);
+ material_rail.MaterialType
+ = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ material_rail.setTexture(0, ap.atlas);
+
+ u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
+ video::SColor c = MapBlock_LightColor(255, l);
+
+ float d = (float)BS/16;
+ video::S3DVertex vertices[4] =
+ {
+ video::S3DVertex(-BS/2,-BS/2+d,-BS/2, 0,0,0, c,
+ ap.x0(), ap.y1()),
+ video::S3DVertex(BS/2,-BS/2+d,-BS/2, 0,0,0, c,
+ ap.x1(), ap.y1()),
+ video::S3DVertex(BS/2,-BS/2+d,BS/2, 0,0,0, c,
+ ap.x1(), ap.y0()),
+ video::S3DVertex(-BS/2,-BS/2+d,BS/2, 0,0,0, c,
+ ap.x0(), ap.y0()),
+ };
// Rotate textures
int angle = 0;
collector.append(material_rail, vertices, 4, indices, 6);
}
else if (n.getContent() == CONTENT_LADDER) {
+ AtlasPointer ap = g_texturesource->getTexture("ladder.png");
+
+ // Set material
+ video::SMaterial material_ladder;
+ material_ladder.setFlag(video::EMF_LIGHTING, false);
+ material_ladder.setFlag(video::EMF_BACK_FACE_CULLING, true);
+ material_ladder.setFlag(video::EMF_BILINEAR_FILTER, false);
+ material_ladder.setFlag(video::EMF_FOG_ENABLE, true);
+ material_ladder.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ material_ladder.setTexture(0, ap.atlas);
+
u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
video::SColor c(255,l,l,l);
// Assume wall is at X+
video::S3DVertex vertices[4] =
{
- video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, 0,1),
- video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 1,1),
- video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, 1,0),
- video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0),
+ video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c,
+ ap.x0(), ap.y1()),
+ video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c,
+ ap.x1(), ap.y1()),
+ video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c,
+ ap.x1(), ap.y0()),
+ video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c,
+ ap.x0(), ap.y0()),
};
v3s16 dir = unpackDir(n.param2);
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
}
- video::SMaterial material_ladder;
- material_ladder.setFlag(video::EMF_LIGHTING, false);
- material_ladder.setFlag(video::EMF_BACK_FACE_CULLING, false);
- material_ladder.setFlag(video::EMF_BILINEAR_FILTER, false);
- material_ladder.setFlag(video::EMF_FOG_ENABLE, true);
- material_ladder.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
- material_ladder.setTexture(0, g_texturesource->getTextureRaw("ladder.png"));
-
u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector
collector.append(material_ladder, vertices, 4, indices, 6);