diff --git a/src/camera.cpp b/src/camera.cpp index ab7d4ff..3d05237 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -424,6 +424,8 @@ void Camera::wield(const InventoryItem* item) || content_features(content).draw_type == CDT_NODEBOX_META || content_features(content).draw_type == CDT_FENCELIKE || content_features(content).draw_type == CDT_WALLLIKE + || content_features(content).draw_type == CDT_STAIRLIKE + || content_features(content).draw_type == CDT_SLABLIKE ) && content_features(content).wield_nodebox == true ) { diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index bf0c143..4446bc6 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -3456,6 +3456,179 @@ void mapblock_mesh_generate_special(MeshMakeData *data, } } break; + case CDT_STAIRLIKE: + { + static const v3s16 tile_dirs[6] = { + v3s16(0, 1, 0), + v3s16(0, -1, 0), + v3s16(1, 0, 0), + v3s16(-1, 0, 0), + v3s16(0, 0, 1), + v3s16(0, 0, -1) + }; + + TileSpec tiles[6]; + NodeMetadata *meta = data->m_env->getMap().getNodeMetadata(p+blockpos_nodes); + for (int i=0; i<6; i++) { + // Handles facedir rotation for textures + tiles[i] = getNodeTile(n,p,tile_dirs[i],data->m_temp_mods,meta); + } + video::SColor c[8]; + getLights(blockpos_nodes+p,c,data,smooth_lighting); + + std::vector boxes; + boxes.push_back(NodeBox( + -0.5*BS, + -0.5*BS, + -0.25*BS, + 0.5*BS, + 0., + 0.5*BS + )); + boxes.push_back(NodeBox( + -0.5*BS, + 0., + 0., + 0.5*BS, + 0.25*BS, + 0.5*BS + )); + boxes.push_back(NodeBox( + -0.5*BS, + 0.25*BS, + 0.25*BS, + 0.5*BS, + 0.5*BS, + 0.5*BS + )); + v3f pos = intToFloat(p, BS); + s16 rot = n.getRotationAngle(); + v3s16 front(0,0,-1); + v3s16 left(-1,0,0); + v3s16 right(1,0,0); + front.rotateXZBy(rot); + left.rotateXZBy(rot); + right.rotateXZBy(rot); + MapNode nf = data->m_vmanip.getNodeRO(blockpos_nodes + p + front); + MapNode nl = data->m_vmanip.getNodeRO(blockpos_nodes + p + left); + MapNode nr = data->m_vmanip.getNodeRO(blockpos_nodes + p + right); + if ( + content_features(nf).draw_type == CDT_SLABLIKE + || ( + content_features(nf).draw_type == CDT_STAIRLIKE + && ( + content_features(nl).draw_type == CDT_SLABLIKE + || content_features(nl).draw_type == CDT_STAIRLIKE + ) && ( + content_features(nr).draw_type == CDT_SLABLIKE + || content_features(nr).draw_type == CDT_STAIRLIKE + ) + ) + ) { + boxes.push_back(NodeBox( + -0.5*BS, + -0.5*BS, + -0.5*BS, + 0.5*BS, + 0., + -0.25*BS + )); + }else{ + boxes.push_back(NodeBox( + -0.5*BS, + -0.5*BS, + -0.5*BS, + 0.5*BS, + -0.25*BS, + -0.25*BS + )); + } + + for (std::vector::iterator i = boxes.begin(); i != boxes.end(); i++) { + NodeBox box = *i; + if (rot) { + box.m_box.MinEdge.rotateXZBy(rot); + box.m_box.MaxEdge.rotateXZBy(rot); + box.m_box.repair(); + } + // Compute texture coords + f32 tx1 = (box.m_box.MinEdge.X/BS)+0.5; + f32 ty1 = (box.m_box.MinEdge.Y/BS)+0.5; + f32 tz1 = (box.m_box.MinEdge.Z/BS)+0.5; + f32 tx2 = (box.m_box.MaxEdge.X/BS)+0.5; + f32 ty2 = (box.m_box.MaxEdge.Y/BS)+0.5; + f32 tz2 = (box.m_box.MaxEdge.Z/BS)+0.5; + f32 txc[24] = { + // up + tx1, 1-tz2, tx2, 1-tz1, + // down + tx1, tz1, tx2, tz2, + // right + tz1, 1-ty2, tz2, 1-ty1, + // left + 1-tz2, 1-ty2, 1-tz1, 1-ty1, + // back + 1-tx2, 1-ty2, 1-tx1, 1-ty1, + // front + tx1, 1-ty2, tx2, 1-ty1, + }; + makeRotatedCuboid(&collector, pos, box.m_box, tiles, 6, c, txc, box.m_angle, box.m_centre); + } + } + break; + case CDT_SLABLIKE: + { + static const v3s16 tile_dirs[6] = { + v3s16(0, 1, 0), + v3s16(0, -1, 0), + v3s16(1, 0, 0), + v3s16(-1, 0, 0), + v3s16(0, 0, 1), + v3s16(0, 0, -1) + }; + + TileSpec tiles[6]; + NodeMetadata *meta = data->m_env->getMap().getNodeMetadata(p+blockpos_nodes); + for (int i = 0; i < 6; i++) { + // Handles facedir rotation for textures + tiles[i] = getNodeTile(n,p,tile_dirs[i],data->m_temp_mods,meta); + } + video::SColor c[8]; + getLights(blockpos_nodes+p,c,data,smooth_lighting); + + NodeBox boxes[2] = { + NodeBox(-0.5*BS,-0.5*BS,-0.5*BS,0.5*BS,-0.0625*BS,0.5*BS), + NodeBox(-0.375*BS,-0.0625*BS,-0.375*BS,0.375*BS,0,0.375*BS) + }; + v3f pos = intToFloat(p, BS); + + for (u16 i=0; i<2; i++) { + NodeBox box = boxes[i]; + // Compute texture coords + f32 tx1 = (box.m_box.MinEdge.X/BS)+0.5; + f32 ty1 = (box.m_box.MinEdge.Y/BS)+0.5; + f32 tz1 = (box.m_box.MinEdge.Z/BS)+0.5; + f32 tx2 = (box.m_box.MaxEdge.X/BS)+0.5; + f32 ty2 = (box.m_box.MaxEdge.Y/BS)+0.5; + f32 tz2 = (box.m_box.MaxEdge.Z/BS)+0.5; + f32 txc[24] = { + // up + tx1, 1-tz2, tx2, 1-tz1, + // down + tx1, tz1, tx2, tz2, + // right + tz1, 1-ty2, tz2, 1-ty1, + // left + 1-tz2, 1-ty2, 1-tz1, 1-ty1, + // back + 1-tx2, 1-ty2, 1-tx1, 1-ty1, + // front + tx1, 1-ty2, tx2, 1-ty1, + }; + makeRotatedCuboid(&collector, pos, box.m_box, tiles, 6, c, txc, box.m_angle, box.m_centre); + } + } + break; case CDT_NODEBOX: case CDT_NODEBOX_META: { diff --git a/src/content_mapnode_slab.cpp b/src/content_mapnode_slab.cpp index 68a7f75..447333e 100644 --- a/src/content_mapnode_slab.cpp +++ b/src/content_mapnode_slab.cpp @@ -37,7 +37,7 @@ void content_mapnode_slab(bool repeat) f->description = wgettext("Rough Stone Slab"); f->setAllTextures("roughstone.png"); f->param_type = CPT_NONE; - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_SLABLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -56,7 +56,7 @@ void content_mapnode_slab(bool repeat) f->description = wgettext("Cobble Stone Slab"); f->setAllTextures("cobble.png"); f->param_type = CPT_NONE; - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_SLABLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -75,7 +75,7 @@ void content_mapnode_slab(bool repeat) f->description = wgettext("Mossy Cobble Stone Slab"); f->setAllTextures("mossycobble.png"); f->param_type = CPT_NONE; - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_SLABLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -93,7 +93,7 @@ void content_mapnode_slab(bool repeat) f = &content_features(i); f->description = wgettext("Stone Slab"); f->setAllTextures("stone.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_SLABLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -169,7 +169,7 @@ void content_mapnode_slab(bool repeat) f = &content_features(i); f->description = wgettext("Sand Stone Slab"); f->setAllTextures("sandstone.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_SLABLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAND)+" 4"; diff --git a/src/content_mapnode_stair.cpp b/src/content_mapnode_stair.cpp index acc8799..7296c1f 100644 --- a/src/content_mapnode_stair.cpp +++ b/src/content_mapnode_stair.cpp @@ -38,7 +38,7 @@ void content_mapnode_stair(bool repeat) f->description = wgettext("Rough Stone Stair"); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("roughstone.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -55,7 +55,7 @@ void content_mapnode_stair(bool repeat) f->description = wgettext("Cobble Stone Stair"); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("cobble.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -72,7 +72,7 @@ void content_mapnode_stair(bool repeat) f->description = wgettext("Mossy Cobble Stone Stair"); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("mossycobble.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -89,7 +89,7 @@ void content_mapnode_stair(bool repeat) f->description = wgettext("Stone Stair"); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("stone.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->often_contains_mineral = true; @@ -106,7 +106,7 @@ void content_mapnode_stair(bool repeat) f = &content_features(i); f->description = wgettext("Wood Stair"); f->param_type = CPT_FACEDIR_SIMPLE; - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->setAllTextures("wood.png"); f->is_ground_content = true; @@ -126,7 +126,7 @@ void content_mapnode_stair(bool repeat) f->description = wgettext("Jungle Wood Stair"); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("junglewood.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces //f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1"; @@ -145,7 +145,7 @@ void content_mapnode_stair(bool repeat) f->description = wgettext("Brick Stair"); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("brick.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("CraftItem clay_brick 4"); @@ -162,7 +162,7 @@ void content_mapnode_stair(bool repeat) f->description = wgettext("Sand Stone Stair"); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("sandstone.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAND)+" 4"; @@ -179,7 +179,7 @@ void content_mapnode_stair(bool repeat) f = &content_features(i); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("roughstone.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_ROUGHSTONE_STAIR)+" 1"; @@ -193,7 +193,7 @@ void content_mapnode_stair(bool repeat) f = &content_features(i); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("cobble.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_ROUGHSTONE_STAIR)+" 1"; @@ -207,7 +207,7 @@ void content_mapnode_stair(bool repeat) f = &content_features(i); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("mossycobble.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MOSSYCOBBLE_STAIR)+" 1"; @@ -221,7 +221,7 @@ void content_mapnode_stair(bool repeat) f = &content_features(i); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("stone.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_STONE_STAIR)+" 1"; @@ -235,7 +235,7 @@ void content_mapnode_stair(bool repeat) f = &content_features(i); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("wood.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_WOOD_STAIR)+" 1"; @@ -251,7 +251,7 @@ void content_mapnode_stair(bool repeat) f = &content_features(i); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("junglewood.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces //f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_JUNGLE_STAIR)+" 1"; @@ -267,7 +267,7 @@ void content_mapnode_stair(bool repeat) f = &content_features(i); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("brick.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("CraftItem clay_brick 4"); @@ -281,7 +281,7 @@ void content_mapnode_stair(bool repeat) f = &content_features(i); f->param_type = CPT_FACEDIR_SIMPLE; f->setAllTextures("sandstone.png"); - f->draw_type = CDT_NODEBOX; + f->draw_type = CDT_STAIRLIKE; f->solidness = 0; // drawn separately, makes no faces f->is_ground_content = true; f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_SAND)+" 4"; diff --git a/src/content_nodebox.cpp b/src/content_nodebox.cpp index 2ed4c95..5102b1d 100644 --- a/src/content_nodebox.cpp +++ b/src/content_nodebox.cpp @@ -27,9 +27,9 @@ void content_nodebox_stair(ContentFeatures *f) f->setNodeBox(NodeBox( -0.5*BS, -0.5*BS, - -0.5*BS, + -0.25*BS, 0.5*BS, - 0, + 0., 0.5*BS )); f->addNodeBox(NodeBox( @@ -37,9 +37,25 @@ void content_nodebox_stair(ContentFeatures *f) 0., 0., 0.5*BS, + 0.25*BS, + 0.5*BS + )); + f->addNodeBox(NodeBox( + -0.5*BS, + 0.25*BS, + 0.25*BS, + 0.5*BS, 0.5*BS, 0.5*BS )); + f->addNodeBox(NodeBox( + -0.5*BS, + -0.5*BS, + -0.5*BS, + 0.5*BS, + -0.25*BS, + -0.25*BS + )); } void content_nodebox_stairud(ContentFeatures *f) diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 459925e..b295a0f 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -399,6 +399,36 @@ v3s16 MapNode::getRotation(v3s16 dir) return dir; } +s16 MapNode::getRotationAngle() +{ + int facedir = 0; + ContentFeatures &f = content_features(*this); + if ( + f.param2_type == CPT_FACEDIR_SIMPLE + || f.param2_type == CPT_FACEDIR_WALLMOUNT + ) { + facedir = param2&0x0F; + }else if ( + f.param_type == CPT_FACEDIR_SIMPLE + || f.param_type == CPT_FACEDIR_WALLMOUNT + ) { + facedir = param1; + } + switch (facedir) { + case 1: + return -90; + break; + case 2: + return 180; + break; + case 3: + return 90; + break; + default:; + } + return 0; +} + #ifndef SERVER TileSpec MapNode::getTileFrom(v3s16 dir, TileSpec raw_spec[6]) { diff --git a/src/mapnode.h b/src/mapnode.h index 9fb272c..078f98b 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -117,7 +117,9 @@ enum ContentDrawType CDT_ROOFLIKE, CDT_NODEBOX_META, CDT_WIRELIKE, - CDT_3DWIRELIKE + CDT_3DWIRELIKE, + CDT_STAIRLIKE, + CDT_SLABLIKE }; /* @@ -962,6 +964,7 @@ struct MapNode assert(0); } v3s16 getRotation(v3s16 dir = v3s16(1,1,1)); + s16 getRotationAngle(); // In mapnode.cpp #ifndef SERVER