makeFastFace(tile, lights[0], lights[1], lights[2], lights[3],
sp, face_dir_corrected, scale,
posRelative_f, dest);
-
- #if 0
- // First node
- v3s16 p_first = p_corrected - (continuous_tiles_count-1)
- * translate_dir;
-
- v3s16 p_map_leftmost;
- v3s16 p_map_rightmost;
- p_map_leftmost = p_corrected + blockpos_nodes;
- p_map_rightmost = p_first + blockpos_nodes;
-
- /*if(p != p_corrected)
- {
- if(face_dir == v3s16(0,0,1))
- {
- v3s16 orig_leftmost = p_map_leftmost;
- v3s16 orig_rightmost = p_map_leftmost;
- p_map_leftmost = orig_rightmost;
- p_map_rightmost = orig_leftmost;
- }
- }*/
-
- if(smooth_lighting == false)
- {
- li0 = li1 = li2 = li3 = decode_light(light);
- }
- else
- {
- v3s16 vertex_dirs[4];
- getNodeVertexDirs(face_dir_corrected, vertex_dirs);
-
- li0 = getSmoothLight(p_map_rightmost, vertex_dirs[0],
- vmanip, daynight_ratio);
- li1 = getSmoothLight(p_map_leftmost, vertex_dirs[1],
- vmanip, daynight_ratio);
- li2 = getSmoothLight(p_map_leftmost, vertex_dirs[2],
- vmanip, daynight_ratio);
- li3 = getSmoothLight(p_map_rightmost, vertex_dirs[3],
- vmanip, daynight_ratio);
- }
- makeFastFace(tile, li0, li1, li2, li3,
- sp, face_dir_corrected, scale,
- posRelative_f, dest);
- #endif
}
continuous_tiles_count = 0;
FastFace &f = fastfaces_new[i];
const u16 indices[] = {0,1,2,2,3,0};
+ const u16 indices_alternate[] = {0,1,3,2,3,1};
video::ITexture *texture = f.tile.texture.atlas;
if(texture == NULL)
material.setTexture(0, texture);
f.tile.applyMaterialOptions(material);
+
+ const u16 *indices_p = indices;
- collector.append(material, f.vertices, 4, indices, 6);
+ /*
+ Revert triangles for nicer looking gradient if vertices
+ 1 and 3 have same color or 0 and 2 have different color.
+ */
+ if(f.vertices[0].Color != f.vertices[2].Color
+ || f.vertices[1].Color == f.vertices[3].Color)
+ indices_p = indices_alternate;
+
+ collector.append(material, f.vertices, 4, indices_p, 6);
}
}
g_texturesource->getTextureId("leaves.png"));
material_leaves1.setTexture(0, pa_leaves1.atlas);
+ // Glass material
+ video::SMaterial material_glass;
+ material_glass.setFlag(video::EMF_LIGHTING, false);
+ material_glass.setFlag(video::EMF_BILINEAR_FILTER, false);
+ material_glass.setFlag(video::EMF_FOG_ENABLE, true);
+ material_glass.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
+ AtlasPointer pa_glass = g_texturesource->getTexture(
+ g_texturesource->getTextureId("glass.png"));
+ material_glass.setTexture(0, pa_glass.atlas);
+
+
for(s16 z=0; z<MAP_BLOCKSIZE; z++)
for(s16 y=0; y<MAP_BLOCKSIZE; y++)
for(s16 x=0; x<MAP_BLOCKSIZE; x++)
collector.append(material_leaves1, vertices, 4, indices, 6);
}
}
+ /*
+ Add glass
+ */
+ else if(n.d == CONTENT_GLASS)
+ {
+ u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio)));
+ video::SColor c(255,l,l,l);
+
+ for(u32 j=0; j<6; j++)
+ {
+ video::S3DVertex vertices[4] =
+ {
+ video::S3DVertex(-BS/2,-BS/2,BS/2, 0,0,0, c,
+ pa_glass.x0(), pa_glass.y1()),
+ video::S3DVertex(BS/2,-BS/2,BS/2, 0,0,0, c,
+ pa_glass.x1(), pa_glass.y1()),
+ video::S3DVertex(BS/2,BS/2,BS/2, 0,0,0, c,
+ pa_glass.x1(), pa_glass.y0()),
+ video::S3DVertex(-BS/2,BS/2,BS/2, 0,0,0, c,
+ pa_glass.x0(), pa_glass.y0()),
+ };
+
+ if(j == 0)
+ {
+ for(u16 i=0; i<4; i++)
+ vertices[i].Pos.rotateXZBy(0);
+ }
+ else if(j == 1)
+ {
+ for(u16 i=0; i<4; i++)
+ vertices[i].Pos.rotateXZBy(180);
+ }
+ else if(j == 2)
+ {
+ for(u16 i=0; i<4; i++)
+ vertices[i].Pos.rotateXZBy(-90);
+ }
+ else if(j == 3)
+ {
+ for(u16 i=0; i<4; i++)
+ vertices[i].Pos.rotateXZBy(90);
+ }
+ else if(j == 4)
+ {
+ for(u16 i=0; i<4; i++)
+ vertices[i].Pos.rotateYZBy(-90);
+ }
+ else if(j == 5)
+ {
+ for(u16 i=0; i<4; i++)
+ vertices[i].Pos.rotateYZBy(90);
+ }
+
+ 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_glass, vertices, 4, indices, 6);
+ }
+ }
+
+
+
}
/*
{
if(version <= 15)
{
- std::ostringstream oss(std::ios_base::binary);
- m_node_metadata.serialize(oss);
- os<<serializeString(oss.str());
+ try{
+ std::ostringstream oss(std::ios_base::binary);
+ m_node_metadata.serialize(oss);
+ os<<serializeString(oss.str());
+ }
+ // This will happen if the string is longer than 65535
+ catch(SerializationError &e)
+ {
+ // Use an empty string
+ os<<serializeString("");
+ }
}
else
{