make some 3d things 3d, and tweak nodebox lighiting a little

This commit is contained in:
darkrose 2013-10-06 19:28:41 +10:00
parent c1489ce443
commit 289c313fc3
13 changed files with 400 additions and 77 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 610 B

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 580 B

View File

Before

Width:  |  Height:  |  Size: 469 B

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 B

View File

@ -164,6 +164,17 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
g_texturesource->getTextureId("wood.png")); g_texturesource->getTextureId("wood.png"));
material_wood.setTexture(0, pa_wood.atlas); material_wood.setTexture(0, pa_wood.atlas);
// Sign material
video::SMaterial material_sign;
material_sign.setFlag(video::EMF_LIGHTING, false);
material_sign.setFlag(video::EMF_BILINEAR_FILTER, false);
material_sign.setFlag(video::EMF_BACK_FACE_CULLING, false);
material_sign.setFlag(video::EMF_FOG_ENABLE, true);
material_sign.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
AtlasPointer pa_sign = g_texturesource->getTexture(
g_texturesource->getTextureId("sign.png"));
material_sign.setTexture(0, pa_sign.atlas);
// Junglewood material // Junglewood material
video::SMaterial material_junglewood; video::SMaterial material_junglewood;
material_junglewood.setFlag(video::EMF_LIGHTING, false); material_junglewood.setFlag(video::EMF_LIGHTING, false);
@ -236,6 +247,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
// Papyrus material // Papyrus material
video::SMaterial material_papyrus; video::SMaterial material_papyrus;
material_papyrus.setFlag(video::EMF_LIGHTING, false); material_papyrus.setFlag(video::EMF_LIGHTING, false);
material_papyrus.setFlag(video::EMF_BACK_FACE_CULLING, false);
material_papyrus.setFlag(video::EMF_BILINEAR_FILTER, false); material_papyrus.setFlag(video::EMF_BILINEAR_FILTER, false);
material_papyrus.setFlag(video::EMF_FOG_ENABLE, true); material_papyrus.setFlag(video::EMF_FOG_ENABLE, true);
material_papyrus.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; material_papyrus.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
@ -247,6 +259,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
video::SMaterial material_apple; video::SMaterial material_apple;
material_apple.setFlag(video::EMF_LIGHTING, false); material_apple.setFlag(video::EMF_LIGHTING, false);
material_apple.setFlag(video::EMF_BILINEAR_FILTER, false); material_apple.setFlag(video::EMF_BILINEAR_FILTER, false);
material_apple.setFlag(video::EMF_BACK_FACE_CULLING, false);
material_apple.setFlag(video::EMF_FOG_ENABLE, true); material_apple.setFlag(video::EMF_FOG_ENABLE, true);
material_apple.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; material_apple.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
AtlasPointer pa_apple = g_texturesource->getTexture( AtlasPointer pa_apple = g_texturesource->getTexture(
@ -258,6 +271,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
video::SMaterial material_sapling; video::SMaterial material_sapling;
material_sapling.setFlag(video::EMF_LIGHTING, false); material_sapling.setFlag(video::EMF_LIGHTING, false);
material_sapling.setFlag(video::EMF_BILINEAR_FILTER, false); material_sapling.setFlag(video::EMF_BILINEAR_FILTER, false);
material_sapling.setFlag(video::EMF_BACK_FACE_CULLING, false);
material_sapling.setFlag(video::EMF_FOG_ENABLE, true); material_sapling.setFlag(video::EMF_FOG_ENABLE, true);
material_sapling.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; material_sapling.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
AtlasPointer pa_sapling = g_texturesource->getTexture( AtlasPointer pa_sapling = g_texturesource->getTexture(
@ -269,6 +283,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
video::SMaterial material_junglegrass; video::SMaterial material_junglegrass;
material_junglegrass.setFlag(video::EMF_LIGHTING, false); material_junglegrass.setFlag(video::EMF_LIGHTING, false);
material_junglegrass.setFlag(video::EMF_BILINEAR_FILTER, false); material_junglegrass.setFlag(video::EMF_BILINEAR_FILTER, false);
material_junglegrass.setFlag(video::EMF_BACK_FACE_CULLING, false);
material_junglegrass.setFlag(video::EMF_FOG_ENABLE, true); material_junglegrass.setFlag(video::EMF_FOG_ENABLE, true);
material_junglegrass.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; material_junglegrass.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
AtlasPointer pa_junglegrass = g_texturesource->getTexture( AtlasPointer pa_junglegrass = g_texturesource->getTexture(
@ -628,26 +643,21 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
break; break;
case CDT_TORCHLIKE: case CDT_TORCHLIKE:
{ {
v3s16 dir = unpackDir(n.param2);
const char *texturename = "torch.png"; AtlasPointer ap = g_texturesource->getTexture("torch.png");
if(dir == v3s16(0,-1,0)){ static const f32 txc[24] = {
texturename = "torch_on_floor.png"; 0,0,0.05,0.05,
} else if(dir == v3s16(0,1,0)){ 0.8,0.8,0.9,0.9,
texturename = "torch_on_ceiling.png"; 0,0,1,1,
// For backwards compatibility 0,0,1,1,
} else if(dir == v3s16(0,0,0)){ 0,0,1,1,
texturename = "torch_on_floor.png"; 0,0,1,1
} else { };
texturename = "torch.png"; video::S3DVertex *v;
}
AtlasPointer ap = g_texturesource->getTexture(texturename);
// Set material // Set material
video::SMaterial material; video::SMaterial material;
material.setFlag(video::EMF_LIGHTING, false); 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_BILINEAR_FILTER, false);
material.setFlag(video::EMF_FOG_ENABLE, true); material.setFlag(video::EMF_FOG_ENABLE, true);
//material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; //material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
@ -656,41 +666,147 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
material.setTexture(0, ap.atlas); material.setTexture(0, ap.atlas);
video::SColor c(255,255,255,255); video::SColor c(255,255,255,255);
v3f pos = intToFloat(p+blockpos_nodes, BS);
// Wall at X+ of node v3s16 dir = unpackDir(n.param2);
video::S3DVertex vertices[4] = if (dir.Y == 1) { // roof
{ video::S3DVertex vertices[24] = {
video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, // up
ap.x0(), ap.y1()), video::S3DVertex(-0.1*BS, 0.5*BS,0., 0,1,0, c, txc[4],txc[5]),
video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, video::S3DVertex(0.,0.5*BS,0., 0,1,0, c, txc[6],txc[5]),
ap.x1(), ap.y1()), video::S3DVertex(0.,0.5*BS,-0.1*BS, 0,1,0, c, txc[6],txc[7]),
video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, video::S3DVertex(-0.1*BS, 0.5*BS,-0.1*BS, 0,1,0, c, txc[4],txc[7]),
ap.x1(), ap.y0()), // down
video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c, video::S3DVertex(0.,-0.1*BS,0., 0,-1,0, c, txc[0],txc[1]),
ap.x0(), ap.y0()), video::S3DVertex(0.1*BS,-0.1*BS,0., 0,-1,0, c, txc[2],txc[1]),
video::S3DVertex(0.1*BS,-0.1*BS,0.1*BS, 0,-1,0, c, txc[2],txc[3]),
video::S3DVertex(0.,-0.1*BS,0.1*BS, 0,-1,0, c, txc[0],txc[3]),
// right
video::S3DVertex(0.,0.5*BS,-0.1*BS, 1,0,0, c, txc[ 8],txc[11]),
video::S3DVertex(0.,0.5*BS,0., 1,0,0, c, txc[10],txc[11]),
video::S3DVertex(0.1*BS,-0.1*BS,0.1*BS, 1,0,0, c, txc[10],txc[9]),
video::S3DVertex(0.1*BS,-0.1*BS,0., 1,0,0, c, txc[ 8],txc[9]),
// left
video::S3DVertex(-0.1*BS,0.5*BS,0., -1,0,0, c, txc[12],txc[15]),
video::S3DVertex(-0.1*BS,0.5*BS,-0.1*BS, -1,0,0, c, txc[14],txc[15]),
video::S3DVertex(0.,-0.1*BS,0., -1,0,0, c, txc[14],txc[13]),
video::S3DVertex(0.,-0.1*BS,0.1*BS, -1,0,0, c, txc[12],txc[13]),
// back
video::S3DVertex(0.,0.5*BS,0., 0,0,1, c, txc[16],txc[19]),
video::S3DVertex(-0.1*BS,0.5*BS,0., 0,0,1, c, txc[18],txc[19]),
video::S3DVertex(0.,-0.1*BS,0.1*BS, 0,0,1, c, txc[18],txc[17]),
video::S3DVertex(0.1*BS,-0.1*BS,0.1*BS, 0,0,1, c, txc[16],txc[17]),
// front
video::S3DVertex(-0.1*BS,0.5*BS,-0.1*BS, 0,0,-1, c, txc[20],txc[23]),
video::S3DVertex(0.,0.5*BS,-0.1*BS, 0,0,-1, c, txc[22],txc[23]),
video::S3DVertex(0.1*BS,-0.1*BS,0., 0,0,-1, c, txc[22],txc[21]),
video::S3DVertex(0.,-0.1*BS,0., 0,0,-1, c, txc[20],txc[21]),
};
for(s32 i=0; i<24; i++) {
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
}
v = vertices;
}else if (dir.Y == -1) { // floor
video::S3DVertex vertices[24] = {
// up
//video::S3DVertex(min.X,max.Y,max.Z, 0,1,0, c, txc[0],txc[1]),
video::S3DVertex(-0.05*BS,0.1*BS,0.05*BS, 0,1,0, c, txc[0],txc[1]),
video::S3DVertex(0.05*BS,0.1*BS,0.05*BS, 0,1,0, c, txc[2],txc[1]),
video::S3DVertex(0.05*BS,0.1*BS,-0.05*BS, 0,1,0, c, txc[2],txc[3]),
video::S3DVertex(-0.05*BS,0.1*BS,-0.05*BS, 0,1,0, c, txc[0],txc[3]),
// down
video::S3DVertex(-0.05*BS,-0.5*BS,-0.05*BS, 0,-1,0, c, txc[4],txc[5]),
video::S3DVertex(0.05*BS,-0.5*BS,-0.05*BS, 0,-1,0, c, txc[6],txc[5]),
video::S3DVertex(0.05*BS,-0.5*BS,0.05*BS, 0,-1,0, c, txc[6],txc[7]),
video::S3DVertex(-0.05*BS,-0.5*BS,0.05*BS, 0,-1,0, c, txc[4],txc[7]),
// right
video::S3DVertex(0.05*BS,0.1*BS,-0.05*BS, 1,0,0, c, txc[ 8],txc[9]),
video::S3DVertex(0.05*BS,0.1*BS,0.05*BS, 1,0,0, c, txc[10],txc[9]),
video::S3DVertex(0.05*BS,-0.5*BS,0.05*BS, 1,0,0, c, txc[10],txc[11]),
video::S3DVertex(0.05*BS,-0.5*BS,-0.05*BS, 1,0,0, c, txc[ 8],txc[11]),
// left
video::S3DVertex(-0.05*BS,0.1*BS,0.05*BS, -1,0,0, c, txc[12],txc[13]),
video::S3DVertex(-0.05*BS,0.1*BS,-0.05*BS, -1,0,0, c, txc[14],txc[13]),
video::S3DVertex(-0.05*BS,-0.5*BS,-0.05*BS, -1,0,0, c, txc[14],txc[15]),
video::S3DVertex(-0.05*BS,-0.5*BS,0.05*BS, -1,0,0, c, txc[12],txc[15]),
// back
video::S3DVertex(0.05*BS,0.1*BS,0.05*BS, 0,0,1, c, txc[16],txc[17]),
video::S3DVertex(-0.05*BS,0.1*BS,0.05*BS, 0,0,1, c, txc[18],txc[17]),
video::S3DVertex(-0.05*BS,-0.5*BS,0.05*BS, 0,0,1, c, txc[18],txc[19]),
video::S3DVertex(0.05*BS,-0.5*BS,0.05*BS, 0,0,1, c, txc[16],txc[19]),
// front
video::S3DVertex(-0.05*BS,0.1*BS,-0.05*BS, 0,0,-1, c, txc[20],txc[21]),
video::S3DVertex(0.05*BS,0.1*BS,-0.05*BS, 0,0,-1, c, txc[22],txc[21]),
video::S3DVertex(0.05*BS,-0.5*BS,-0.05*BS, 0,0,-1, c, txc[22],txc[23]),
video::S3DVertex(-0.05*BS,-0.5*BS,-0.05*BS, 0,0,-1, c, txc[20],txc[23]),
};
for(s32 i=0; i<24; i++) {
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
}
v = vertices;
}else{ // wall
video::S3DVertex vertices[24] = {
// up
//video::S3DVertex(min.X,max.Y,max.Z, 0,1,0, c, txc[0],txc[1]),
video::S3DVertex(-0.05*BS,0.3*BS,0.4*BS, 0,1,0, c, txc[0],txc[1]),
video::S3DVertex(0.05*BS,0.3*BS,0.4*BS, 0,1,0, c, txc[2],txc[1]),
video::S3DVertex(0.05*BS,0.3*BS,0.3*BS, 0,1,0, c, txc[2],txc[3]),
video::S3DVertex(-0.05*BS,0.3*BS,0.3*BS, 0,1,0, c, txc[0],txc[3]),
// down
video::S3DVertex(-0.05*BS,-0.3*BS,0.4*BS, 0,-1,0, c, txc[4],txc[5]),
video::S3DVertex(0.05*BS,-0.3*BS,0.4*BS, 0,-1,0, c, txc[6],txc[5]),
video::S3DVertex(0.05*BS,-0.3*BS,0.5*BS, 0,-1,0, c, txc[6],txc[7]),
video::S3DVertex(-0.05*BS,-0.3*BS,0.5*BS, 0,-1,0, c, txc[4],txc[7]),
// right
video::S3DVertex(0.05*BS,0.3*BS,0.3*BS, 1,0,0, c, txc[ 8],txc[9]),
video::S3DVertex(0.05*BS,0.3*BS,0.4*BS, 1,0,0, c, txc[10],txc[9]),
video::S3DVertex(0.05*BS,-0.3*BS,0.5*BS, 1,0,0, c, txc[10],txc[11]),
video::S3DVertex(0.05*BS,-0.3*BS,0.4*BS, 1,0,0, c, txc[ 8],txc[11]),
// left
video::S3DVertex(-0.05*BS,0.3*BS,0.4*BS, -1,0,0, c, txc[12],txc[13]),
video::S3DVertex(-0.05*BS,0.3*BS,0.3*BS, -1,0,0, c, txc[14],txc[13]),
video::S3DVertex(-0.05*BS,-0.3*BS,0.4*BS, -1,0,0, c, txc[14],txc[15]),
video::S3DVertex(-0.05*BS,-0.3*BS,0.5*BS, -1,0,0, c, txc[12],txc[15]),
// back
video::S3DVertex(0.05*BS,0.3*BS,0.4*BS, 0,0,1, c, txc[16],txc[17]),
video::S3DVertex(-0.05*BS,0.3*BS,0.4*BS, 0,0,1, c, txc[18],txc[17]),
video::S3DVertex(-0.05*BS,-0.3*BS,0.5*BS, 0,0,1, c, txc[18],txc[19]),
video::S3DVertex(0.05*BS,-0.3*BS,0.5*BS, 0,0,1, c, txc[16],txc[19]),
// front
video::S3DVertex(-0.05*BS,0.3*BS,0.3*BS, 0,0,-1, c, txc[20],txc[21]),
video::S3DVertex(0.05*BS,0.3*BS,0.3*BS, 0,0,-1, c, txc[22],txc[21]),
video::S3DVertex(0.05*BS,-0.3*BS,0.4*BS, 0,0,-1, c, txc[22],txc[23]),
video::S3DVertex(-0.05*BS,-0.3*BS,0.4*BS, 0,0,-1, c, txc[20],txc[23]),
}; };
for(s32 i=0; i<4; i++) for(s32 i=0; i<24; i++) {
{
if(dir == v3s16(1,0,0)) if(dir == v3s16(1,0,0))
vertices[i].Pos.rotateXZBy(0);
if(dir == v3s16(-1,0,0))
vertices[i].Pos.rotateXZBy(180);
if(dir == v3s16(0,0,1))
vertices[i].Pos.rotateXZBy(90);
if(dir == v3s16(0,0,-1))
vertices[i].Pos.rotateXZBy(-90); vertices[i].Pos.rotateXZBy(-90);
if(dir == v3s16(0,-1,0)) if(dir == v3s16(-1,0,0))
vertices[i].Pos.rotateXZBy(45); vertices[i].Pos.rotateXZBy(90);
if(dir == v3s16(0,1,0)) if(dir == v3s16(0,0,1))
vertices[i].Pos.rotateXZBy(-45); vertices[i].Pos.rotateXZBy(0);
if(dir == v3s16(0,0,-1))
vertices[i].Pos.rotateXZBy(180);
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
} }
v = vertices;
}
f32 sx = ap.x1()-ap.x0();
f32 sy = ap.y1()-ap.y0();
for (s32 j=0; j<24; j++) {
v[j].TCoords *= v2f(sx,sy);
v[j].TCoords += v2f(ap.x0(),ap.y0());
}
u16 indices[] = {0,1,2,2,3,0}; u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector // Add to mesh collector
collector.append(material, vertices, 4, indices, 6); for (s32 j=0; j<24; j+=4) {
collector.append(material, &v[j], 4, indices, 6);
}
} }
/* /*
Signs on walls Signs on walls
@ -700,13 +816,102 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
{ {
switch (n.getContent()) { switch (n.getContent()) {
case CONTENT_SIGN_WALL: case CONTENT_SIGN_WALL:
pa_current = &ap_sign_wall; material_current = &material_sign;
pa_current = &pa_sign;
break; break;
default:
material_current = &material_sign;
pa_current = &pa_sign;
break;
}
u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio));
video::SColor c = MapBlock_LightColor(255, l);
static const f32 txc[24] = {
0.1,0,0.9,0.1,
0.1,0,0.9,0.1,
0.1,0.3,0.9,0.7,
0.1,0.3,0.9,0.7,
0.1,0.3,0.9,0.7,
0.1,0.3,0.9,0.7
};
video::S3DVertex vertices[24] = {
// up
video::S3DVertex(-0.4*BS,0.2*BS,0.5*BS, 0,1,0, c, txc[0],txc[1]),
video::S3DVertex(0.4*BS,0.2*BS,0.5*BS, 0,1,0, c, txc[2],txc[1]),
video::S3DVertex(0.4*BS,0.2*BS,0.45*BS, 0,1,0, c, txc[2],txc[3]),
video::S3DVertex(-0.4*BS,0.2*BS,0.45*BS, 0,1,0, c, txc[0],txc[3]),
// down
video::S3DVertex(-0.4*BS,-0.2*BS,0.45*BS, 0,-1,0, c, txc[4],txc[5]),
video::S3DVertex(0.4*BS,-0.2*BS,0.45*BS, 0,-1,0, c, txc[6],txc[5]),
video::S3DVertex(0.4*BS,-0.2*BS,0.5*BS, 0,-1,0, c, txc[6],txc[7]),
video::S3DVertex(-0.4*BS,-0.2*BS,0.5*BS, 0,-1,0, c, txc[4],txc[7]),
// right
video::S3DVertex(0.4*BS,0.2*BS,0.45*BS, 1,0,0, c, txc[ 8],txc[9]),
video::S3DVertex(0.4*BS,0.2*BS,0.5*BS, 1,0,0, c, txc[10],txc[9]),
video::S3DVertex(0.4*BS,-0.2*BS,0.5*BS, 1,0,0, c, txc[10],txc[11]),
video::S3DVertex(0.4*BS,-0.2*BS,0.45*BS, 1,0,0, c, txc[ 8],txc[11]),
// left
video::S3DVertex(-0.4*BS,0.2*BS,0.5*BS, -1,0,0, c, txc[12],txc[13]),
video::S3DVertex(-0.4*BS,0.2*BS,0.45*BS, -1,0,0, c, txc[14],txc[13]),
video::S3DVertex(-0.4*BS,-0.2*BS,0.45*BS, -1,0,0, c, txc[14],txc[15]),
video::S3DVertex(-0.4*BS,-0.2*BS,0.5*BS, -1,0,0, c, txc[12],txc[15]),
// back
video::S3DVertex(0.4*BS,0.2*BS,0.5*BS, 0,0,1, c, txc[16],txc[17]),
video::S3DVertex(-0.4*BS,0.2*BS,0.5*BS, 0,0,1, c, txc[18],txc[17]),
video::S3DVertex(-0.4*BS,-0.2*BS,0.5*BS, 0,0,1, c, txc[18],txc[19]),
video::S3DVertex(0.4*BS,-0.2*BS,0.5*BS, 0,0,1, c, txc[16],txc[19]),
// front
video::S3DVertex(-0.4*BS,0.2*BS,0.45*BS, 0,0,-1, c, txc[20],txc[21]),
video::S3DVertex(0.4*BS,0.2*BS,0.45*BS, 0,0,-1, c, txc[22],txc[21]),
video::S3DVertex(0.4*BS,-0.2*BS,0.45*BS, 0,0,-1, c, txc[22],txc[23]),
video::S3DVertex(-0.4*BS,-0.2*BS,0.45*BS, 0,0,-1, c, txc[20],txc[23]),
};
f32 sx = pa_current->x1()-pa_current->x0();
f32 sy = pa_current->y1()-pa_current->y0();
for (s32 j=0; j<24; j++) {
vertices[j].TCoords *= v2f(sx,sy);
vertices[j].TCoords += v2f(pa_current->x0(),pa_current->y0());
}
v3s16 dir = unpackDir(n.param2);
for (s32 i=0; i<24; i++) {
if(dir == v3s16(1,0,0))
vertices[i].Pos.rotateXZBy(-90);
if(dir == v3s16(-1,0,0))
vertices[i].Pos.rotateXZBy(90);
if(dir == v3s16(0,0,1))
vertices[i].Pos.rotateXZBy(0);
if(dir == v3s16(0,0,-1))
vertices[i].Pos.rotateXZBy(180);
if(dir == v3s16(0,-1,0))
vertices[i].Pos.rotateYZBy(90);
if(dir == v3s16(0,1,0))
vertices[i].Pos.rotateYZBy(-90);
vertices[i].Pos += intToFloat(p + blockpos_nodes, BS);
}
u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector
for (s32 j=0; j<24; j+=4) {
collector.append(*material_current, &vertices[j], 4, indices, 6);
}
}
/*
Signs on walls
*/
break;
case CDT_WALLMOUNT:
{
switch (n.getContent()) {
case CONTENT_LADDER: case CONTENT_LADDER:
pa_current = &ap_ladder; pa_current = &ap_ladder;
break; break;
default: default:
pa_current = &ap_sign_wall; pa_current = &ap_ladder;
break; break;
} }
@ -876,13 +1081,13 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
post.MinEdge += pos; post.MinEdge += pos;
post.MaxEdge += pos; post.MaxEdge += pos;
f32 postuv[24]={ f32 postuv[24]={
0.4,0.4,0.6,0.6,
0.4,0.4,0.6,0.6, 0.4,0.4,0.6,0.6,
0.35,0,0.65,1, 0.35,0,0.65,1,
0.35,0,0.65,1, 0.35,0,0.65,1,
0.35,0,0.65,1, 0.35,0,0.65,1,
0.35,0,0.65,1, 0.35,0,0.65,1
0.4,0.4,0.6,0.6}; };
makeCuboid(material_wood, &pa_wood, &collector, c, post, postuv); makeCuboid(material_wood, &pa_wood, &collector, c, post, postuv);
// Now a section of fence, +X, if there's a post there // Now a section of fence, +X, if there's a post there
@ -902,7 +1107,8 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
0,0.4,1,0.6, 0,0.4,1,0.6,
0,0.4,1,0.6, 0,0.4,1,0.6,
0,0.4,1,0.6, 0,0.4,1,0.6,
0,0.4,1,0.6}; 0,0.4,1,0.6
};
makeCuboid(material_wood, &pa_wood, &collector, c, bar, xrailuv); makeCuboid(material_wood, &pa_wood, &collector, c, bar, xrailuv);
bar.MinEdge.Y -= BS/2; bar.MinEdge.Y -= BS/2;
bar.MaxEdge.Y -= BS/2; bar.MaxEdge.Y -= BS/2;
@ -1050,7 +1256,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio))); u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio)));
video::SColor c = MapBlock_LightColor(255, l); video::SColor c = MapBlock_LightColor(255, l);
for(u32 j=0; j<4; j++) for(u32 j=0; j<2; j++)
{ {
video::S3DVertex vertices[4] = video::S3DVertex vertices[4] =
{ {
@ -1113,7 +1319,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio))); u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio)));
video::SColor c = MapBlock_LightColor(255, l); video::SColor c = MapBlock_LightColor(255, l);
for(u32 j=0; j<4; j++) for(u32 j=0; j<2; j++)
{ {
video::S3DVertex vertices[4] = video::S3DVertex vertices[4] =
{ {
@ -1171,7 +1377,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio))); u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio)));
video::SColor c = MapBlock_LightColor(255, l); video::SColor c = MapBlock_LightColor(255, l);
for(u32 j=0; j<4; j++) for(u32 j=0; j<2; j++)
{ {
video::S3DVertex vertices[4] = video::S3DVertex vertices[4] =
{ {
@ -1263,12 +1469,18 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
material_current = &material_sandstone; material_current = &material_sandstone;
pa_current = &pa_sandstone; pa_current = &pa_sandstone;
break; break;
case CONTENT_SIGN:
case CONTENT_SIGN_UD:
material_current = &material_sign;
pa_current = &pa_sign;
break;
default: default:
material_current = &material_cobble; material_current = &material_cobble;
pa_current = &pa_cobble; pa_current = &pa_cobble;
} }
u32 lt = 0; u32 lt = 0;
u32 ltp;
u8 ld = 0; u8 ld = 0;
for (s16 tx=-1; tx<2; tx++) { for (s16 tx=-1; tx<2; tx++) {
for (s16 ty=-1; ty<2; ty++) { for (s16 ty=-1; ty<2; ty++) {
@ -1278,7 +1490,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x+tx,y+ty,z+tz)); MapNode n = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x+tx,y+ty,z+tz));
if (ty<1 && n.getContent() != CONTENT_AIR) if (ty<1 && n.getContent() != CONTENT_AIR)
continue; continue;
lt += decode_light(n.getLightBlend(data->m_daynight_ratio)); ltp = decode_light(n.getLightBlend(data->m_daynight_ratio));
if (!ltp)
continue;
lt += ltp;
ld++; ld++;
} }
} }

View File

@ -409,7 +409,7 @@ void content_mapnode_init()
f->used_texturenames["ladder.png"] = true; f->used_texturenames["ladder.png"] = true;
f->light_propagates = true; f->light_propagates = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->draw_type = CDT_SIGNLIKE; f->draw_type = CDT_WALLMOUNT;
f->is_ground_content = true; f->is_ground_content = true;
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
f->wall_mounted = true; f->wall_mounted = true;
@ -693,10 +693,8 @@ void content_mapnode_init()
i = CONTENT_TORCH; i = CONTENT_TORCH;
f = &content_features(i); f = &content_features(i);
f->description = std::string("Torch"); f->description = std::string("Torch");
f->setInventoryTexture("torch_on_floor.png"); f->setInventoryTexture("torch_inventory.png");
f->used_texturenames["torch_on_floor.png"] = true; f->used_texturenames["torch_inventory.png"] = true;
f->used_texturenames["torch_on_ceiling.png"] = true;
f->used_texturenames["torch_on_floor.png"] = true;
f->used_texturenames["torch.png"] = true; f->used_texturenames["torch.png"] = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->draw_type = CDT_TORCHLIKE; f->draw_type = CDT_TORCHLIKE;
@ -713,8 +711,9 @@ void content_mapnode_init()
i = CONTENT_SIGN_WALL; i = CONTENT_SIGN_WALL;
f = &content_features(i); f = &content_features(i);
f->description = std::string("Sign"); f->description = std::string("Sign");
f->setInventoryTexture("sign_wall.png"); f->setInventoryTexture("sign_inventory.png");
f->used_texturenames["sign_wall.png"] = true; f->used_texturenames["sign_inventory.png"] = true;
f->used_texturenames["sign.png"] = true;
f->param_type = CPT_LIGHT; f->param_type = CPT_LIGHT;
f->draw_type = CDT_SIGNLIKE; f->draw_type = CDT_SIGNLIKE;
f->light_propagates = true; f->light_propagates = true;
@ -728,6 +727,66 @@ void content_mapnode_init()
f->initial_metadata = new SignNodeMetadata("Some sign"); f->initial_metadata = new SignNodeMetadata("Some sign");
f->digging_properties.set("", DiggingProperties(true, 0.5, 0)); f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
i = CONTENT_SIGN;
f = &content_features(i);
f->description = std::string("Sign");
f->setInventoryTexture("sign_inventory.png");
f->used_texturenames["sign_inventory.png"] = true;
f->used_texturenames["sign.png"] = true;
f->param_type = CPT_FACEDIR_SIMPLE;
f->draw_type = CDT_NODEBOX;
f->solidness = 0; // drawn separately, makes no faces
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SIGN_WALL)+" 1";
if(f->initial_metadata == NULL)
f->initial_metadata = new SignNodeMetadata("Some sign");
f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
f->setNodeBox(core::aabbox3d<f32>(
-0.05*BS,
-0.5*BS,
-0.05*BS,
0.05*BS,
0.5*BS,
0.05*BS
));
f->addNodeBox(core::aabbox3d<f32>(
-0.4*BS,
0.,
-0.1*BS,
0.4*BS,
0.4*BS,
-0.05*BS
));
i = CONTENT_SIGN_UD;
f = &content_features(i);
f->description = std::string("Sign");
f->setInventoryTexture("sign_inventory.png");
f->used_texturenames["sign_inventory.png"] = true;
f->used_texturenames["sign.png"] = true;
f->param_type = CPT_FACEDIR_SIMPLE;
f->draw_type = CDT_NODEBOX;
f->solidness = 0; // drawn separately, makes no faces
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SIGN_WALL)+" 1";
if(f->initial_metadata == NULL)
f->initial_metadata = new SignNodeMetadata("Some sign");
f->digging_properties.set("", DiggingProperties(true, 0.5, 0));
f->setNodeBox(core::aabbox3d<f32>(
-0.05*BS,
-0.5*BS,
-0.05*BS,
0.05*BS,
0.5*BS,
0.05*BS
));
f->addNodeBox(core::aabbox3d<f32>(
-0.4*BS,
-0.4*BS,
-0.1*BS,
0.4*BS,
0.,
-0.05*BS
));
i = CONTENT_CHEST; i = CONTENT_CHEST;
f = &content_features(i); f = &content_features(i);
f->description = std::string("Chest"); f->description = std::string("Chest");

View File

@ -50,6 +50,8 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
#define CONTENT_CHEST 15 #define CONTENT_CHEST 15
#define CONTENT_FURNACE 16 #define CONTENT_FURNACE 16
#define CONTENT_LOCKABLE_CHEST 17 #define CONTENT_LOCKABLE_CHEST 17
#define CONTENT_SIGN 18
#define CONTENT_SIGN_UD 19
#define CONTENT_FENCE 21 #define CONTENT_FENCE 21

View File

@ -1084,7 +1084,7 @@ void ServerEnvironment::step(float dtime)
{ {
MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0)); MapNode n_top = m_map->getNodeNoEx(p+v3s16(0,1,0));
if(content_features(n_top).air_equivalent == false if(content_features(n_top).air_equivalent == false
&& n_top.getContent() != CONTENT_IGNORE) && n_top.getContent() != CONTENT_IGNORE && content_features(n_top).draw_type != CDT_PLANTLIKE && n_top.getContent() != CONTENT_SIGN)
{ {
n.setContent(CONTENT_MUD); n.setContent(CONTENT_MUD);
m_map->addNodeWithEvent(p, n); m_map->addNodeWithEvent(p, n);
@ -1203,6 +1203,27 @@ void ServerEnvironment::step(float dtime)
} }
} }
} }
if (grow) {
for (s16 z=-max_o; grow && z < max_o; z++) {
for (s16 x=-max_o; grow && x < max_o; x++) {
v3s16 test_p = p + v3s16(x,-1,z);
if (test_p != p) {
content_t tcon = m_map->getNodeNoEx(test_p).getContent();
if (
tcon != CONTENT_AIR
&& tcon != CONTENT_TREE
&& tcon != CONTENT_JUNGLETREE
&& tcon != CONTENT_LEAVES
&& tcon != CONTENT_APPLE
&& tcon != CONTENT_IGNORE
&& tcon != CONTENT_MUD
&& tcon != CONTENT_GRASS
)
grow = 0;
}
}
}
}
}else if (below == CONTENT_MUD || below == CONTENT_GRASS) { }else if (below == CONTENT_MUD || below == CONTENT_GRASS) {
for (s16 z=-max_o; grow && z < max_o; z++) { for (s16 z=-max_o; grow && z < max_o; z++) {
for (s16 y=2; grow && y < max_y; y++) { for (s16 y=2; grow && y < max_y; y++) {

View File

@ -91,6 +91,7 @@ enum ContentDrawType
CDT_LIQUID, CDT_LIQUID,
CDT_LIQUID_SOURCE, CDT_LIQUID_SOURCE,
CDT_SIGNLIKE, CDT_SIGNLIKE,
CDT_WALLMOUNT,
CDT_NODEBOX, CDT_NODEBOX,
CDT_GLASSLIKE, CDT_GLASSLIKE,
CDT_TORCHLIKE, CDT_TORCHLIKE,

View File

@ -2853,6 +2853,15 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
} }
} }
// Signs?
if (n.getContent() == CONTENT_SIGN_WALL) {
if (p_dir.Y == 1) {
n.setContent(CONTENT_SIGN_UD);
}else if (p_dir.Y == -1) {
n.setContent(CONTENT_SIGN);
}
}
// Calculate the direction for furnaces and chests and stuff // Calculate the direction for furnaces and chests and stuff
if(content_features(n).param_type == CPT_FACEDIR_SIMPLE) if(content_features(n).param_type == CPT_FACEDIR_SIMPLE)
{ {

View File

@ -1602,18 +1602,34 @@ inline std::string deSerializeLongString(std::istream &is)
inline u32 time_to_daynight_ratio(u32 time_of_day) inline u32 time_to_daynight_ratio(u32 time_of_day)
{ {
const s32 daylength = 16; float t = time_of_day;
const s32 nightlength = 6; if(t < 0)
const s32 daytimelength = 8; t += ((int)(-t)/24000)*24000;
s32 d = daylength; if(t >= 24000)
s32 t = (((time_of_day)%24000)/(24000/d)); t -= ((int)(t)/24000)*24000;
if(t < nightlength/2 || t >= d - nightlength/2) if(t > 12000)
//return 300; t = 24000 - t;
return 350; float values[][2] = {
else if(t >= d/2 - daytimelength/2 && t < d/2 + daytimelength/2) {4250+125, 150},
{4500+125, 150},
{4750+125, 250},
{5000+125, 350},
{5250+125, 500},
{5500+125, 675},
{5750+125, 875},
{6000+125, 1000},
{6250+125, 1000},
};
for (u32 i=0; i<sizeof(values)/sizeof(*values); i++) {
if (values[i][0] <= t)
continue;
if (i == 0)
return values[i][1];
float td0 = values[i][0] - values[i-1][0];
float f = (t - values[i-1][0]) / td0;
return f * values[i][1] + (1.0 - f) * values[i-1][1];
}
return 1000; return 1000;
else
return 750;
} }
// Random helper. Usually d=BS // Random helper. Usually d=BS