*/
else if(nodedef->get(n).liquid_type == LIQUID_FLOWING)
{
- assert(nodedef->get(n).special_material);
+ assert(nodedef->get(n).special_materials[0]);
+ assert(nodedef->get(n).special_materials[1]);
+ assert(nodedef->get(n).special_aps[0]);
+
video::SMaterial &liquid_material =
- *nodedef->get(n).special_material;
+ *nodedef->get(n).special_materials[0];
video::SMaterial &liquid_material_bfculled =
- *nodedef->get(n).special_material2;
-
- assert(nodedef->get(n).special_atlas);
+ *nodedef->get(n).special_materials[1];
AtlasPointer &pa_liquid1 =
- *nodedef->get(n).special_atlas;
+ *nodedef->get(n).special_aps[0];
bool top_is_same_liquid = false;
MapNode ntop = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y+1,z));
else if(nodedef->get(n).liquid_type == LIQUID_SOURCE
&& new_style_water)
{
- assert(nodedef->get(n).special_material);
+ assert(nodedef->get(n).special_materials[0]);
+ //assert(nodedef->get(n).special_materials[1]);
+ assert(nodedef->get(n).special_aps[0]);
+
video::SMaterial &liquid_material =
- *nodedef->get(n).special_material;
- assert(nodedef->get(n).special_atlas);
+ *nodedef->get(n).special_materials[0];
+ /*video::SMaterial &liquid_material_bfculled =
+ *nodedef->get(n).special_materials[1];*/
AtlasPointer &pa_liquid1 =
- *nodedef->get(n).special_atlas;
+ *nodedef->get(n).special_aps[0];
bool top_is_air = false;
MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y+1,z));
f->liquid_alternative_flowing = CONTENT_WATER;
f->liquid_alternative_source = CONTENT_WATERSOURCE;
f->liquid_viscosity = WATER_VISC;
-#ifndef SERVER
if(!opaque_water)
f->alpha = WATER_ALPHA;
f->post_effect_color = video::SColor(64, 100, 100, 200);
+ // Flowing water material
+ f->mspec_special[0].tname = "water.png";
+ f->mspec_special[0].backface_culling = false;
+ f->mspec_special[1].tname = "water.png";
+ f->mspec_special[1].backface_culling = true;
+
+/*#ifndef SERVER
if(f->special_material == NULL && tsrc)
{
- // Flowing water material
f->special_material = new video::SMaterial;
f->special_material->setFlag(video::EMF_LIGHTING, false);
f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
f->special_atlas = pa_water1;
}
-#endif
+#endif*/
i = CONTENT_WATERSOURCE;
f = nodemgr->getModifiable(i);
f->liquid_alternative_flowing = CONTENT_WATER;
f->liquid_alternative_source = CONTENT_WATERSOURCE;
f->liquid_viscosity = WATER_VISC;
-#ifndef SERVER
if(!opaque_water)
f->alpha = WATER_ALPHA;
f->post_effect_color = video::SColor(64, 100, 100, 200);
+ // New-style water source material (mostly unused)
+ f->mspec_special[0].tname = "water.png";
+ f->mspec_special[0].backface_culling = false;
+/*#ifndef SERVER
if(f->special_material == NULL && tsrc)
{
- // New-style water source material (mostly unused)
f->special_material = new video::SMaterial;
f->special_material->setFlag(video::EMF_LIGHTING, false);
f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
f->special_material->setTexture(0, pa_water1->atlas);
f->special_atlas = pa_water1;
}
-#endif
+#endif*/
i = CONTENT_LAVA;
f = nodemgr->getModifiable(i);
f->liquid_alternative_source = CONTENT_LAVASOURCE;
f->liquid_viscosity = LAVA_VISC;
f->damage_per_second = 4*2;
-#ifndef SERVER
f->post_effect_color = video::SColor(192, 255, 64, 0);
+ // Flowing lava material
+ f->mspec_special[0].tname = "lava.png";
+ f->mspec_special[0].backface_culling = false;
+ f->mspec_special[1].tname = "lava.png";
+ f->mspec_special[1].backface_culling = true;
+/*#ifndef SERVER
if(f->special_material == NULL && tsrc)
{
- // Flowing lava material
- f->special_material = new video::SMaterial;
- f->special_material->setFlag(video::EMF_LIGHTING, false);
- f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
- f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
- f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
- f->special_material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
-
- AtlasPointer *pa_lava1 = new AtlasPointer(
- tsrc->getTexture(
- tsrc->getTextureId("lava.png")));
- f->special_material->setTexture(0, pa_lava1->atlas);
-
- // Flowing lava material, backface culled
- f->special_material2 = new video::SMaterial;
- *f->special_material2 = *f->special_material;
- f->special_material2->setFlag(video::EMF_BACK_FACE_CULLING, true);
-
- f->special_atlas = pa_lava1;
}
-#endif
+#endif*/
i = CONTENT_LAVASOURCE;
f = nodemgr->getModifiable(i);
f->liquid_alternative_source = CONTENT_LAVASOURCE;
f->liquid_viscosity = LAVA_VISC;
f->damage_per_second = 4*2;
-#ifndef SERVER
f->post_effect_color = video::SColor(192, 255, 64, 0);
+ // New-style lava source material (mostly unused)
+ f->mspec_special[0].tname = "lava.png";
+ f->mspec_special[0].backface_culling = false;
+/*#ifndef SERVER
if(f->special_material == NULL && tsrc)
{
- // New-style lava source material (mostly unused)
- f->special_material = new video::SMaterial;
- f->special_material->setFlag(video::EMF_LIGHTING, false);
- f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
- f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
- f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
- f->special_material->MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
- AtlasPointer *pa_lava1 = new AtlasPointer(
- tsrc->getTexture(
- tsrc->getTextureId("lava.png")));
- f->special_material->setTexture(0, pa_lava1->atlas);
-
- f->special_atlas = pa_lava1;
}
-#endif
+#endif*/
i = CONTENT_TORCH;
f = nodemgr->getModifiable(i);
{
delete initial_metadata;
#ifndef SERVER
- delete special_material;
- delete special_atlas;
+ for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
+ delete special_materials[j];
+ delete special_aps[j];
+ }
#endif
}
else
f->tiles[j].material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
}
- // Special texture
- if(f->tname_special != ""){
- if(!f->special_atlas)
- f->special_atlas = new AtlasPointer(
- tsrc->getTexture(f->tname_special));
- else
- *(f->special_atlas) =
- tsrc->getTexture(f->tname_special);
- // Special material textures
- if(f->special_material)
- f->special_material->setTexture(0, f->special_atlas->atlas);
- if(f->special_material2)
- f->special_material2->setTexture(0, f->special_atlas->atlas);
+ // Special textures
+ for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
+ // Remove all stuff
+ if(f->special_aps[j]){
+ delete f->special_aps[j];
+ f->special_aps[j] = NULL;
+ }
+ if(f->special_materials[j]){
+ delete f->special_materials[j];
+ f->special_materials[j] = NULL;
+ }
+ // Skip if should not exist
+ if(f->mspec_special[j].tname == "")
+ continue;
+ // Create all stuff
+ f->special_aps[j] = new AtlasPointer(
+ tsrc->getTexture(f->mspec_special[j].tname));
+ f->special_materials[j] = new video::SMaterial;
+ f->special_materials[j]->setFlag(video::EMF_LIGHTING, false);
+ f->special_materials[j]->setFlag(video::EMF_BACK_FACE_CULLING,
+ f->mspec_special[j].backface_culling);
+ f->special_materials[j]->setFlag(video::EMF_BILINEAR_FILTER, false);
+ f->special_materials[j]->setFlag(video::EMF_FOG_ENABLE, true);
+ f->special_materials[j]->setTexture(0, f->special_aps[j]->atlas);
}
}
#endif
struct MapNode;
class NodeMetadata;
+struct MaterialSpec
+{
+ std::string tname;
+ bool backface_culling;
+
+ MaterialSpec(const std::string &tname_="", bool backface_culling_=true):
+ tname(tname_),
+ backface_culling(backface_culling_)
+ {}
+};
+
+#define CF_SPECIAL_COUNT 2
+
struct ContentFeatures
{
#ifndef SERVER
// Special material/texture
// - Currently used for flowing liquids
- video::SMaterial *special_material;
- video::SMaterial *special_material2;
- AtlasPointer *special_atlas;
+ video::SMaterial *special_materials[CF_SPECIAL_COUNT];
+ AtlasPointer *special_aps[CF_SPECIAL_COUNT];
#endif
- // Texture names
+ // Visual definition
std::string tname_tiles[6];
std::string tname_inventory;
- std::string tname_special;
+ MaterialSpec mspec_special[CF_SPECIAL_COUNT];
u8 alpha;
bool backface_culling;
inventory_texture = NULL;
post_effect_color = video::SColor(0, 0, 0, 0);
- special_material = NULL;
- special_material2 = NULL;
- special_atlas = NULL;
+ for(u16 j=0; j<CF_SPECIAL_COUNT; j++){
+ special_materials[j] = NULL;
+ special_aps[j] = NULL;
+ }
#endif
for(u32 i=0; i<6; i++)
tname_tiles[i] = "";
+ for(u16 j=0; j<CF_SPECIAL_COUNT; j++)
+ mspec_special[j] = MaterialSpec();
tname_inventory = "";
- tname_special = "";
alpha = 255;
backface_culling = true;
used_texturenames.clear();
void setInventoryTextureCube(std::string top,
std::string left, std::string right);
-#if 0
-#ifndef SERVER
- void setTile(u16 i, const TileSpec &tile)
- { tiles[i] = tile; }
- void setAllTiles(const TileSpec &tile)
- { for(u16 i=0; i<6; i++) setTile(i, tile); }
-#endif
-#endif
-
/*
Some handy methods
*/