From bc2819cab2978c61b2ca1d7b68a5d1f223e8647a Mon Sep 17 00:00:00 2001 From: Mark Holmquist Date: Wed, 27 Jul 2011 10:18:09 -0700 Subject: Added ladders--they don't have any use yet, though --- src/content_mapblock.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/content_mapblock.cpp') diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 3044c8b35..ceb673606 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -1134,6 +1134,53 @@ void mapblock_mesh_generate_special(MeshMakeData *data, u16 indices[] = {0,1,2,2,3,0}; collector.append(material_rail, vertices, 4, indices, 6); } + else if (n.d == CONTENT_LADDER) { + u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); + video::SColor c(255,l,l,l); + + float d = (float)BS/16; + + // Assume wall is at X+ + video::S3DVertex vertices[4] = + { + video::S3DVertex(BS/2-d,-BS/2,-BS/2, 0,0,0, c, 0,1), + video::S3DVertex(BS/2-d,-BS/2,BS/2, 0,0,0, c, 1,1), + video::S3DVertex(BS/2-d,BS/2,BS/2, 0,0,0, c, 1,0), + video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0), + }; + + v3s16 dir = unpackDir(n.dir); + + for(s32 i=0; i<4; i++) + { + 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); + if(dir == v3s16(0,-1,0)) + vertices[i].Pos.rotateXYBy(-90); + if(dir == v3s16(0,1,0)) + vertices[i].Pos.rotateXYBy(90); + + vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); + } + + video::SMaterial material_ladder; + material_ladder.setFlag(video::EMF_LIGHTING, false); + material_ladder.setFlag(video::EMF_BACK_FACE_CULLING, false); + material_ladder.setFlag(video::EMF_BILINEAR_FILTER, false); + material_ladder.setFlag(video::EMF_FOG_ENABLE, true); + material_ladder.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + material_ladder.setTexture(0, g_texturesource->getTextureRaw("ladder.png")); + + u16 indices[] = {0,1,2,2,3,0}; + // Add to mesh collector + collector.append(material_ladder, vertices, 4, indices, 6); + } } } #endif -- cgit v1.2.3 From 8e67f4c4e617a8fcbb9176de1bf0b267acfc6e2f Mon Sep 17 00:00:00 2001 From: Mark Holmquist Date: Sat, 30 Jul 2011 17:26:13 -0700 Subject: Fixed a few problems in the ladder update, and changed the speed to account for gravity --- src/content_mapblock.cpp | 4 ++-- src/game.cpp | 2 +- src/player.cpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/content_mapblock.cpp') diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index ceb673606..ed2cd766a 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -1134,7 +1134,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data, u16 indices[] = {0,1,2,2,3,0}; collector.append(material_rail, vertices, 4, indices, 6); } - else if (n.d == CONTENT_LADDER) { + else if (n.getContent() == CONTENT_LADDER) { u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); video::SColor c(255,l,l,l); @@ -1149,7 +1149,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data, video::S3DVertex(BS/2-d,BS/2,-BS/2, 0,0,0, c, 0,0), }; - v3s16 dir = unpackDir(n.dir); + v3s16 dir = unpackDir(n.param2); for(s32 i=0; i<4; i++) { diff --git a/src/game.cpp b/src/game.cpp index d8ea45fb1..fb5d7cb93 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -541,7 +541,7 @@ void getPointedNode(Client *client, v3f player_position, else if(n.getContent() == CONTENT_LADDER) { - v3s16 dir = unpackDir(n.dir); + v3s16 dir = unpackDir(n.param2); v3f dir_f = v3f(dir.X, dir.Y, dir.Z); dir_f *= BS/2 - BS/6 - BS/20; v3f cpf = npf + dir_f; diff --git a/src/player.cpp b/src/player.cpp index 3846cd8f9..270f795b5 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -382,8 +382,8 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d, try { v3s16 pp = floatToInt(position + v3f(0,0.5*BS,0), BS); v3s16 pp2 = floatToInt(position + v3f(0,-0.2*BS,0), BS); - is_climbing = (content_features(map.getNode(pp).d).climbable || - content_features(map.getNode(pp2).d).climbable); + is_climbing = (content_features(map.getNode(pp).getContent()).climbable || + content_features(map.getNode(pp2).getContent()).climbable); } catch(InvalidPositionException &e) { @@ -832,7 +832,7 @@ void LocalPlayer::applyControl(float dtime) if (is_climbing) { if (control.up || control.left || control.right || control.down) { v3f speed = getSpeed(); - speed.Y = 2*BS; + speed.Y = 2.5*BS; setSpeed(speed); } else { -- cgit v1.2.3