vertices[i].Pos.rotateXZBy(90);
}
else if(j == 4)
- else if(n.d == CONTENT_PAPYRUS)
+
+ 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_general, vertices, 4, indices, 6);
+ }
+ }
+ #endif
++ else if(n.getContent() == CONTENT_PAPYRUS)
+ {
+ u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio)));
+ video::SColor c(255,l,l,l);
+
+ for(u32 j=0; j<4; j++)
+ {
+ video::S3DVertex vertices[4] =
+ {
+ video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c,
+ pa_papyrus.x0(), pa_papyrus.y1()),
+ video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c,
+ pa_papyrus.x1(), pa_papyrus.y1()),
+ video::S3DVertex(BS/2,BS/2,0, 0,0,0, c,
+ pa_papyrus.x1(), pa_papyrus.y0()),
+ video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c,
+ pa_papyrus.x0(), pa_papyrus.y0()),
+ };
+
+ if(j == 0)
{
for(u16 i=0; i<4; i++)
- vertices[i].Pos.rotateYZBy(-90);
+ vertices[i].Pos.rotateXZBy(45);
}
- else if(j == 5)
+ else if(j == 1)
{
for(u16 i=0; i<4; i++)
- vertices[i].Pos.rotateYZBy(90);
+ 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++)
u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector
- collector.append(material_general, vertices, 4, indices, 6);
+ collector.append(material_papyrus, vertices, 4, indices, 6);
}
}
- #endif
- else if(n.d == CONTENT_RAIL)
++ else if(n.getContent() == CONTENT_RAIL)
+ {
+ u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
+ video::SColor c(255,l,l,l);
+
+ bool is_rail_x [] = { false, false }; /* x-1, x+1 */
+ bool is_rail_z [] = { false, false }; /* z-1, z+1 */
+
+ MapNode n_minus_x = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x-1,y,z));
+ MapNode n_plus_x = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x+1,y,z));
+ MapNode n_minus_z = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y,z-1));
+ MapNode n_plus_z = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y,z+1));
+
- if(n_minus_x.d == CONTENT_RAIL)
++ if(n_minus_x.getContent() == CONTENT_RAIL)
+ is_rail_x[0] = true;
- if(n_plus_x.d == CONTENT_RAIL)
++ if(n_plus_x.getContent() == CONTENT_RAIL)
+ is_rail_x[1] = true;
- if(n_minus_z.d == CONTENT_RAIL)
++ if(n_minus_z.getContent() == CONTENT_RAIL)
+ is_rail_z[0] = true;
- if(n_plus_z.d == CONTENT_RAIL)
++ 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
+ if(adjacencies < 2)
+ material_rail.setTexture(0, g_texturesource->getTextureRaw("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"));
+ else
+ material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_curved.png"));
+ }
+ else if(adjacencies == 3)
+ material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_t_junction.png"));
+ else if(adjacencies == 4)
+ material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_crossing.png"));
+ // Rotate textures
+ int angle = 0;
+
+ if(adjacencies == 1)
+ {
+ if(is_rail_x[0] || is_rail_x[1])
+ angle = 90;
+ }
+ else if(adjacencies == 2)
+ {
+ if(is_rail_x[0] && is_rail_x[1])
+ angle = 90;
+ else if(is_rail_x[0] && is_rail_z[0])
+ angle = 270;
+ else if(is_rail_x[0] && is_rail_z[1])
+ angle = 180;
+ else if(is_rail_x[1] && is_rail_z[1])
+ angle = 90;
+ }
+ else if(adjacencies == 3)
+ {
+ if(!is_rail_x[0])
+ angle=0;
+ if(!is_rail_x[1])
+ angle=180;
+ if(!is_rail_z[0])
+ angle=90;
+ if(!is_rail_z[1])
+ angle=270;
+ }
+
+ if(angle != 0) {
+ for(u16 i=0; i<4; i++)
+ vertices[i].Pos.rotateXZBy(angle);
+ }
+
+ for(s32 i=0; i<4; i++)
+ {
+ vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
+ }
+
+ u16 indices[] = {0,1,2,2,3,0};
+ collector.append(material_rail, vertices, 4, indices, 6);
+ }
}
}
#endif
void setDirtLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
void setWoodLikeDiggingProperties(DiggingPropertiesList &list, float toughness);
+content_t trans_table_19[][2] = {
+ {CONTENT_GRASS, 1},
+ {CONTENT_TREE, 4},
+ {CONTENT_LEAVES, 5},
+ {CONTENT_GRASS_FOOTSTEPS, 6},
+ {CONTENT_MESE, 7},
+ {CONTENT_MUD, 8},
+ {CONTENT_CLOUD, 10},
+ {CONTENT_COALSTONE, 11},
+ {CONTENT_WOOD, 12},
+ {CONTENT_SAND, 13},
+ {CONTENT_COBBLE, 18},
+ {CONTENT_STEEL, 19},
+ {CONTENT_GLASS, 20},
+ {CONTENT_MOSSYCOBBLE, 22},
+ {CONTENT_GRAVEL, 23},
++ {CONTENT_SANDSTONE, 24},
++ {CONTENT_CACTUS, 25},
++ {CONTENT_BRICK, 26},
++ {CONTENT_CLAY, 27},
++ {CONTENT_PAPYRUS, 28},
++ {CONTENT_BOOKSHELF, 29},
+};
+
+MapNode mapnode_translate_from_internal(MapNode n_from, u8 version)
+{
+ MapNode result = n_from;
+ if(version <= 19)
+ {
+ content_t c_from = n_from.getContent();
+ for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
+ {
+ if(trans_table_19[i][0] == c_from)
+ {
+ result.setContent(trans_table_19[i][1]);
+ break;
+ }
+ }
+ }
+ return result;
+}
+MapNode mapnode_translate_to_internal(MapNode n_from, u8 version)
+{
+ MapNode result = n_from;
+ if(version <= 19)
+ {
+ content_t c_from = n_from.getContent();
+ for(u32 i=0; i<sizeof(trans_table_19)/sizeof(trans_table_19[0]); i++)
+ {
+ if(trans_table_19[i][1] == c_from)
+ {
+ result.setContent(trans_table_19[i][0]);
+ break;
+ }
+ }
+ }
+ return result;
+}
+
void content_mapnode_init()
{
// Read some settings
#ifndef CONTENT_MAPNODE_HEADER
#define CONTENT_MAPNODE_HEADER
+#include "mapnode.h"
+
void content_mapnode_init();
+MapNode mapnode_translate_from_internal(MapNode n_from, u8 version);
+MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
+
/*
Node content type IDs
+ Ranges:
*/
- // Use these sparingly, only when the extra space in param2 is needed.
+
+// 0x000...0x07f (0...127): param2 is fully usable
+// 126 and 127 are reserved.
++// Use these sparingly, only when the extra space in param2 might be needed.
#define CONTENT_STONE 0
-#define CONTENT_GRASS 1
#define CONTENT_WATER 2
#define CONTENT_TORCH 3
-#define CONTENT_TREE 4
-#define CONTENT_LEAVES 5
-#define CONTENT_GRASS_FOOTSTEPS 6
-#define CONTENT_MESE 7
-#define CONTENT_MUD 8
#define CONTENT_WATERSOURCE 9
-// Pretty much useless, clouds won't be drawn this way
-#define CONTENT_CLOUD 10
-#define CONTENT_COALSTONE 11
-#define CONTENT_WOOD 12
-#define CONTENT_SAND 13
#define CONTENT_SIGN_WALL 14
#define CONTENT_CHEST 15
#define CONTENT_FURNACE 16
--//#define CONTENT_WORKBENCH 17
-#define CONTENT_COBBLE 18
-#define CONTENT_STEEL 19
-#define CONTENT_GLASS 20
#define CONTENT_FENCE 21
-#define CONTENT_MOSSYCOBBLE 22
-#define CONTENT_GRAVEL 23
-#define CONTENT_SANDSTONE 24
-#define CONTENT_CACTUS 25
-#define CONTENT_BRICK 26
-#define CONTENT_CLAY 27
-#define CONTENT_PAPYRUS 28
-#define CONTENT_BOOKSHELF 29
+ #define CONTENT_RAIL 30
- // 0x800...0xfff: param2 higher 4 bytes are not usable
++// 0x800...0xfff (2048...4095): higher 4 bytes of param2 are not usable
+#define CONTENT_GRASS 0x800 //1
+#define CONTENT_TREE 0x801 //4
+#define CONTENT_LEAVES 0x802 //5
+#define CONTENT_GRASS_FOOTSTEPS 0x803 //6
+#define CONTENT_MESE 0x804 //7
+#define CONTENT_MUD 0x805 //8
+// Pretty much useless, clouds won't be drawn this way
+#define CONTENT_CLOUD 0x806 //10
+#define CONTENT_COALSTONE 0x807 //11
+#define CONTENT_WOOD 0x808 //12
+#define CONTENT_SAND 0x809 //13
+#define CONTENT_COBBLE 0x80a //18
+#define CONTENT_STEEL 0x80b //19
+#define CONTENT_GLASS 0x80c //20
+#define CONTENT_MOSSYCOBBLE 0x80d //22
+#define CONTENT_GRAVEL 0x80e //23
++#define CONTENT_SANDSTONE 0x80f //24
++#define CONTENT_CACTUS 0x810 //25
++#define CONTENT_BRICK 0x811 //26
++#define CONTENT_CLAY 0x812 //27
++#define CONTENT_PAPYRUS 0x813 //28
++#define CONTENT_BOOKSHELF 0x814 //29
++
+
#endif
}
}
}
- else if(n.d == CONTENT_RAIL)
++ else if(n.getContent() == CONTENT_RAIL)
+ {
- v3s16 dir = unpackDir(n.dir);
++ v3s16 dir = unpackDir(n.param0);
+ v3f dir_f = v3f(dir.X, dir.Y, dir.Z);
+ dir_f *= BS/2 - BS/6 - BS/20;
+ v3f cpf = npf + dir_f;
+ f32 distance = (cpf - camera_position).getLength();
+
+ float d = (float)BS/16;
+ v3f vertices[4] =
+ {
+ v3f(BS/2, -BS/2+d, -BS/2),
+ v3f(-BS/2, -BS/2, BS/2),
+ };
+
+ for(s32 i=0; i<2; i++)
+ {
+ vertices[i] += npf;
+ }
+
+ core::aabbox3d<f32> box;
+
+ box = core::aabbox3d<f32>(vertices[0]);
+ box.addInternalPoint(vertices[1]);
+
+ if(distance < mindistance)
+ {
+ if(box.intersectsWithLine(shootline))
+ {
+ nodefound = true;
+ nodepos = np;
+ neighbourpos = np;
+ mindistance = distance;
+ nodehilightbox = box;
+ }
+ }
+ }
/*
Regular blocks
*/
\r
TODO: Merge bahamada's audio stuff (clean patch available)\r
\r
-TODO: Merge key configuration menu (no clean patch available)\r
+TODO: Move content_features to mapnode_content_features.{h,cpp} or so\r
\r
+ TODO: Add some kind of content range validation to mapnode serialization\r
+ \r
+ TODO: Make sure menu text position is fixed\r
+ \r
+ TODO: Fix sector over limits error\r
+ \r
Making it more portable:\r
------------------------\r
\r
{
u32 i = data->vmanip->m_area.index(p);
MapNode *n = &data->vmanip->m_data[i];
- if(n->getContent() != CONTENT_AIR && n->getContent() != CONTENT_IGNORE)
- if(n->d != CONTENT_AIR && n->d != CONTENT_WATERSOURCE && n->d != CONTENT_IGNORE)
++ if(n->getContent() != CONTENT_AIR && n->getContent() != CONTENT_WATERSOURCE && n->getContent() != CONTENT_IGNORE)
{
found = true;
break;
{
u32 i = data->vmanip->m_area.index(p);
MapNode *n = &data->vmanip->m_data[i];
- if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS)
- continue;
+
- if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND)
++ if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS && n->getContent() != CONTENT_SAND)
+ continue;
+
+ // Papyrus grows only on mud and in water
- if(n->d == CONTENT_MUD && y <= WATER_LEVEL)
++ if(n->getContent() == CONTENT_MUD && y <= WATER_LEVEL)
+ {
+ p.Y++;
+ make_papyrus(vmanip, p);
+ }
+ // Trees grow only on mud and grass, on land
- else if((n->d == CONTENT_MUD || n->d == CONTENT_GRASS) && y > WATER_LEVEL + 2)
++ else if((n->getContent() == CONTENT_MUD || n->getContent() == CONTENT_GRASS) && y > WATER_LEVEL + 2)
+ {
+ p.Y++;
+ make_tree(vmanip, p);
+ }
+ // Cactii grow only on sand, on land
- else if(n->d == CONTENT_SAND && y > WATER_LEVEL + 2)
++ else if(n->getContent() == CONTENT_SAND && y > WATER_LEVEL + 2)
+ {
+ p.Y++;
+ make_cactus(vmanip, p);
+ }
}
- // Tree will be placed one higher
- p.Y++;
- // Make a tree
- make_tree(vmanip, p);
}
#if 0
NodeMetadata *initial_metadata;
// If the content is liquid, this is the flowing version of the liquid.
- // If content is flowing liquid, this is the same content.
- u8 liquid_alternative_flowing;
+ // If content is liquid, this is the same content.
+ content_t liquid_alternative_flowing;
+ // If the content is liquid, this is the source version of the liquid.
- u8 liquid_alternative_source;
++ content_t liquid_alternative_source;
// Amount of light the node emits
u8 light_source;