From 9e0ea98abcf1539234dbbb9c886030b9e2cc7392 Mon Sep 17 00:00:00 2001 From: darkrose Date: Tue, 26 Jan 2016 23:13:31 +1000 Subject: [PATCH] add light flare effect to light sources --- data/textures/flare.png | Bin 0 -> 5092 bytes src/content_mapblock.cpp | 91 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 data/textures/flare.png diff --git a/data/textures/flare.png b/data/textures/flare.png new file mode 100644 index 0000000000000000000000000000000000000000..686f163952cb13467cf1923387c57362db080c60 GIT binary patch literal 5092 zcmVPx#32;bRa{vGf6951U69E94oEQKA00(qQO+^Rb0U8Vf0u6T6qW}OCc1c7*RCwCW zo5_+K*_EEZbFOE^M9`!{{Wkw zedd4-y9U^DulzXwDo+fX2tN@0??w050mz<@p$R)G!h;dl2N%a4ur=Z+t& z&h)T^+lvk*Rj_+x<4e9wYAe%Zj~=84!9>snt&!;c(m9e-HzAyZ+yKp$WWfgR*} z{uw~EC!fbZDggBC(*oxBWs2xC!#X3zc|o}nF1`-(5z{)rWITl9Kd$pqZWB@AQoeL zZxG%Iz%|X^9ia`-P71C@sH{M+aIAN1zNiWfzvpOf5Ds&LxuG`@rx4HI4~W~w<5xu| zfBw!OeeieOnYwNhRL^Hx|C-)u3j6*ZJQrl1L8Ueer5QTWja>T$)7j6x;=i} z3cwKUSHf>RVmWHtJhVJ)#E6vzSjGbDHk>GrPYi2T&(U<#|8IhE6Z?fr_?2bKy>PrU ztU9K`>IX3f*J9DG%7CrxL>zHrzk#h45cL=|2V2eHZDqvYP=naiP0rV-jI)igV zmxfIZpBe#Z^_0!pheg38Y&tx9ZurzQ;0_gX6hT?0NT7eG1q`OY-nzbz^0!@QXw1q2 zEaQR9Hhq6Q6h8C(UoQ-u4BFfPcf$5_3C~dQVh4ybt zGuMyUjZ-$b0cNNUTFZ_WuSQhI=A^dHvl65;I3xGFSb?_Gx(16#YeBs3Cs40a5@Z}`Vq za4|A;9%x#DIs1Q6&0H%N=)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oWB7= zd1TmuVfS+JL6V(8{3eM19qbE`he2!{IbRE7kXYXI%SQmJGdoM=Fjz6z@_8BmCY;Vv|uVisf1AQ&xg<-FhCSFAB zL`MB(QKA)%KxR5CLJ>LlFcMTHPta^?dt2+fzLP82DqaIGLG!pW{%1Y$x3bY+-uXGr zdsAX|{CU-@f9pwL&LL((r%?Yki2noj-7utWbj}pBFT&E|nRY+#>L`W6Q16@?(h`=hhBv zUJ>@>mw(z1Cjo4N;D7Z1dj5;yL&~L`Yac>v0Rcd7g=WI~A=A%pMEDz=FYdb{kO2k-@nl7+y4itn>ia%<81Q)0000append(tiles[j].getMaterial(), vertices, 4, indices, 6, colours); } + + if (data->mesh_detail > 2 && data->light_detail > 2 && content_features(n.getContent()).light_source > 0) { + TileSpec tile; + tile.texture = g_texturesource->getTexture("flare.png"); + tile.material_flags = 0; + tile.material_type = MATERIAL_ALPHA_BLEND; + s16 angle[4] = { + 45, + -45, + 45, + -45 + }; + for (u32 j=0; j<4; j++) { + video::S3DVertex vertices[4] = { + video::S3DVertex(-1.125*BS,-1.125*BS,0., 0,0,0, video::SColor(255,255,255,255), 0.,1.), + video::S3DVertex( 1.125*BS,-1.125*BS,0., 0,0,0, video::SColor(255,255,255,255), 1.,1.), + video::S3DVertex( 1.125*BS, 1.125*BS,0., 0,0,0, video::SColor(255,255,255,255), 1.,0.), + video::S3DVertex(-1.125*BS, 1.125*BS,0., 0,0,0, video::SColor(255,255,255,255), 0.,0.) + }; + + for (u16 i=0; i<4; i++) { + if (j > 1) { + vertices[i].Pos.rotateYZBy(angle[j]); + }else{ + vertices[i].Pos.rotateXZBy(angle[j]); + } + vertices[i].Pos += pos; + vertices[i].TCoords *= tile.texture.size; + vertices[i].TCoords += tile.texture.pos; + } + + u16 indices[] = {0,1,2,2,3,0}; + std::vector colours; + meshgen_custom_lights(colours,255,255,255,255,4); + + data->append(tile.getMaterial(), vertices, 4, indices, 6, colours); + } + } } void meshgen_torchlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected) @@ -2939,6 +2977,7 @@ void meshgen_torchlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &se v3s16( 0, 0, 1), v3s16( 0, 0,-1), }; + v3f os(0,0,0); v3s16 dir = unpackDir(n.param2); video::S3DVertex vertices[6][4] = { { // up @@ -2979,6 +3018,7 @@ void meshgen_torchlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &se f32 sy = tile.texture.y1()-tile.texture.y0(); if (dir.Y == 1) { // roof + os.Y = -0.125*BS; for (s32 i=0; i<6; i++) { for (int j=0; j<4; j++) { vertices[i][j].Pos.rotateXYBy(175); @@ -2991,6 +3031,7 @@ void meshgen_torchlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &se } } }else if (dir.Y == -1) { // floor + os.Y = 0.125*BS; for (s32 i=0; i<6; i++) { for (int j=0; j<4; j++) { vertices[i][j].TCoords *= v2f(sx,sy); @@ -3001,6 +3042,17 @@ void meshgen_torchlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &se } } }else{ // wall + os.Y = 0.375*BS; + os.Z = 0.375*BS; + if (dir.X == 1) { + os.rotateXZBy(-90); + }else if (dir.X == -1) { + os.rotateXZBy(90); + }else if (dir.Z == 1) { + os.rotateXZBy(0); + }else if (dir.Z == -1) { + os.rotateXZBy(180); + } for (s32 i=0; i<6; i++) { for (int j=0; j<4; j++) { vertices[i][j].Pos.Y += 0.25*BS; @@ -3010,8 +3062,6 @@ void meshgen_torchlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &se vertices[i][j].Pos.rotateXZBy(-90); }else if (dir.X == -1) { vertices[i][j].Pos.rotateXZBy(90); - }else if (dir.Z == 1) { - vertices[i][j].Pos.rotateXZBy(0); }else if (dir.Z == -1) { vertices[i][j].Pos.rotateXZBy(180); } @@ -3044,6 +3094,43 @@ void meshgen_torchlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &se data->append(tile.getMaterial(), vertices[j], 4, indices, 6, colours); } + + if (data->mesh_detail > 2 && data->light_detail > 2) { + tile.texture = g_texturesource->getTexture("flare.png"); + tile.material_flags = 0; + tile.material_type = MATERIAL_ALPHA_BLEND; + s16 angle[4] = { + 45, + -45, + 45, + -45 + }; + for (u32 j=0; j<4; j++) { + video::S3DVertex vertices[4] = { + video::S3DVertex(-0.5*BS,-0.5*BS,0., 0,0,0, video::SColor(255,255,255,255), 0.,1.), + video::S3DVertex( 0.5*BS,-0.5*BS,0., 0,0,0, video::SColor(255,255,255,255), 1.,1.), + video::S3DVertex( 0.5*BS, 0.5*BS,0., 0,0,0, video::SColor(255,255,255,255), 1.,0.), + video::S3DVertex(-0.5*BS, 0.5*BS,0., 0,0,0, video::SColor(255,255,255,255), 0.,0.) + }; + + for (u16 i=0; i<4; i++) { + if (j > 1) { + vertices[i].Pos.rotateYZBy(angle[j]); + }else{ + vertices[i].Pos.rotateXZBy(angle[j]); + } + vertices[i].Pos += pos+os; + vertices[i].TCoords *= tile.texture.size; + vertices[i].TCoords += tile.texture.pos; + } + + u16 indices[] = {0,1,2,2,3,0}; + std::vector colours; + meshgen_custom_lights(colours,255,255,255,255,4); + + data->append(tile.getMaterial(), vertices, 4, indices, 6, colours); + } + } } void meshgen_fencelike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected)