From a73b10eb1c17d7be32c432cb15f508c7f99c5209 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 29 Apr 2011 17:53:07 +0300 Subject: [PATCH] made proper skyboxes for dawn/evening and night --- data/skybox1_dawn.png | Bin 0 -> 598 bytes data/skybox1_night.png | Bin 0 -> 2247 bytes data/skybox2_dawn.png | Bin 0 -> 199 bytes data/skybox2_night.png | Bin 0 -> 2583 bytes data/skybox3_dawn.png | Bin 0 -> 190 bytes data/skybox3_night.png | Bin 0 -> 190 bytes src/game.cpp | 66 +++++++++++++++++++++++++++++++++++------ src/utility.h | 3 +- 8 files changed, 59 insertions(+), 10 deletions(-) create mode 100644 data/skybox1_dawn.png create mode 100644 data/skybox1_night.png create mode 100644 data/skybox2_dawn.png create mode 100644 data/skybox2_night.png create mode 100644 data/skybox3_dawn.png create mode 100644 data/skybox3_night.png diff --git a/data/skybox1_dawn.png b/data/skybox1_dawn.png new file mode 100644 index 0000000000000000000000000000000000000000..9711c47819be9d823169536679c8c1dbc5e6cf56 GIT binary patch literal 598 zcmV-c0;&CpP)Px#32;bRa{vGf6951U69E94oEQKA00(qQO+^RW1RV|`7v>Do-~a#s9cffpbVF}# zZDnqB0000007G(RVRU6=Aa`kWXdp*PO;BVmWd{HN0l!H^K~zY`?UhSz)ld*bPxUpC zkRnEm7_%03!BW^2`(PuC5DHO}*N4Hijd^(qLI_6mz`Az3Kklk7=iU1c{7ozVvi&dc zOIv~fg!OQCUhf~<40Ln)*pI;S!qZd5x4h<3cFDXRvR^2+y!4JI;%j|Vptf9l?^~_} zn*wKnJ`@I)Yj2MMduw|?(X*t-p$QW6+s@eRYSTwYdQ?2WZ7Q^aUL<&q49X#yz$P$@1p)m&EE0oTxyh*J+x-sBRNIS%xap z208_dv_fJhkZOtA)`^UA`P?^G>5;CO6l9F1_db$xb}4C6Wnp0@sdPHdi6sN1oBI>r z?#I3L@WAr%)72Pp2glTg*&J4tF%1oxQ6fFzH3eXsCOe_sFsitGy&0(pt~3h@G-P8% zCRL_`1p2_&Y~Tk2BOWM_L;Q#;t literal 0 HcmV?d00001 diff --git a/data/skybox1_night.png b/data/skybox1_night.png new file mode 100644 index 0000000000000000000000000000000000000000..32e43a63e88afa5f207d9e7db45860d55742b0b1 GIT binary patch literal 2247 zcmeAS@N?(olHy`uVBq!ia0y~yU}|7sV0^&A1Qgk|*?TjPVk{1FcVbv~PUa<$!&%@F zSC~?lu%}vcK0dg4_oQqNu zOHxx5$}>wc6x=<115)%-*%=r(3_M*NLn>~)z3ZDN>@Cu8Q7=ULfY2eq$@dnj>TKdX z(jZ!up_aydRA&K;)9u3VYv&iI`TK9Yr#9={uGq=xIXGn;Cufqs52!s?4fKUSi za|45M-|3$zf(&^RYWO4=d=TQy3`{&AgscIkhmf4ZY`y1~PyGK4v^STD!GIBH4R$Tl z7#LV2Ku92gLEu3e&%a!0hAStxD>624!i5tU92yuM8XDjJSRiY1>i7hP11uO01N#JK z1(Kt`9K8OD(fMO(3qt}E8v`R7l5J3989|~Dgm4K=POHRnz7ErE@7;fML~&c&z!1#@ z_5e&9+`NX>wsQPpiJ`!7Sj)sP1LO^ueaMyxBzOZ86w#jId0%7~$+AF~cvC|}6Y77< zG2A;e-H^e-S{NMv8@i4^PFxyZ#wkT%tQSlLC7^Ya%6{L}VnC0#1+qIux)~VMfYFN) zI{Y3&;r z6dJrQFbEuQjsRr}1Gec47@fdQx$7{v)Z?-+x(s!pGH_ciM+tF0_EwtauMzs{wh{t`x7XSS7zCUfR>tmp8P9m7EXDS*oWbn8eI>86m;Jt4-uvI_ zK;_prssDdJ-YF8yVtCv3?)%!JHaAcHuyN(I``8*#ty6XT@1mW&-uOH z6V32yjtt9;SKGeU)*okC@fm1!*8Q97bMlU|YT0ZOQ?s-_#4#oB?j5z{1?N6z{oFWN z-QV%@t@XV{+*boz$!yI;G{{6<09Yu9}@b1~-7x#8Y@bKj&a zI(lCwRBXkQJ+o|B&stQ=E@)QP7EhPG_(xSI;lSrpsu^c?GcZ1%x?Y*3fni?LvMld) z-)&*sN{q&Kh4wAc&iY`!EgcNJo3r~pL0gEE9lbG2KQO+=KV*!~2Hw;TTGm_;9hcLd- eAGC5`9*DDaP0reWUPgU*mKJj}%A=%83h!W@g+}zZ>5+Ij>!MP|ku_QG` zp**uBL&4qCHy}kXl^rN<;OXKR;&D8=qz>% literal 0 HcmV?d00001 diff --git a/data/skybox2_night.png b/data/skybox2_night.png new file mode 100644 index 0000000000000000000000000000000000000000..beb07a9cf8add64e0d98f45ad7b6552b8bb399cf GIT binary patch literal 2583 zcmeAS@N?(olHy`uVBq!ia0y~yU}^wi4kn;T^ZK|FAjMc5oeRDC7i+23>^Uee)E-PeU*!J}_2ZKWcBM>n#vVjnb1PBQvfDlB2e7WDD z-rpuNUuY7zoWaGAzzj0~-&T=zA}lIv7yw-XR#&&BsDZ_UZwhb-P>9liY?4pKdolo|D2A@FB4Hy8a%Df z+HhvF;sNvh>^ww-?XKr#?__s!LsK9k9Ua(T@Mfp1A6jaL+W`thZ0Yl5jP6YVhI!9x z4=`N#&9>*vwK2ttpGy9U8WO`}i~U3wkUP?JY=H0LcThV|o}G&b4m%m%ct6SO|V`24{Dih53W` z(<-Ze-j__0@)cuvS1fMA@Wlm}j*Rn1IT#YS?e(v6IW{mRtbX_Jhjae|#)R9y_zpj? zPGGpPZyzuL|Atf|Kr&&k05BWe%Gz)r=v!Z@H%fdAH)^H7aY!+g!QBfkn-6zh1(pdF zLEy4*$NPuUy}%;BzyMNUgYyKAfPu)BJWXO@D0w$CoC_YVka`4YOMalY84HU&$&@upd4u~MG!ID^zPu1%9e(#AuA=%83h!W@g+}zZ>5+Ij>!MP|ku_QG` zp**uBL&4qCHy}kXl^rOq?&;zf;&D7VWOHZ20@Z}11%?t^6RtD`a=Yom84LIr7;3v2 UUg@>Xl>(XN>FVdQ&MBb@05?Z4JOBUy literal 0 HcmV?d00001 diff --git a/data/skybox3_night.png b/data/skybox3_night.png new file mode 100644 index 0000000000000000000000000000000000000000..bb509789b694aca038a40912fc18f1e6f893feff GIT binary patch literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Eu!2~2l3^S5}6k~CayA#8@b22Z19L@rd$YKTt zZeb8+WSBKa0w~B{;_2(kew#&>&rsG!T5~;6NH#MhqQp5rH#aq}1juDza4t$sEJ;mK zD9TWe19@d%8G=cpOiD@<=>+foek10z-+d30Il|x!rW(j0JoQ41FaG U@h?0#?EsnO>FVdQ&MBb@0M1%3_W%F@ literal 0 HcmV?d00001 diff --git a/src/game.cpp b/src/game.cpp index 8981638a..771b05d8 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -580,6 +580,47 @@ void getPointedNode(Client *client, v3f player_position, } // for coords } +void update_skybox(video::IVideoDriver* driver, + scene::ISceneManager* smgr, scene::ISceneNode* &skybox, + float brightness) +{ + if(skybox) + { + skybox->remove(); + } + + if(brightness >= 0.5) + { + skybox = smgr->addSkyBoxSceneNode( + driver->getTexture(porting::getDataPath("skybox2.png").c_str()), + driver->getTexture(porting::getDataPath("skybox3.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1.png").c_str())); + } + else if(brightness >= 0.2) + { + skybox = smgr->addSkyBoxSceneNode( + driver->getTexture(porting::getDataPath("skybox2_dawn.png").c_str()), + driver->getTexture(porting::getDataPath("skybox3_dawn.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1_dawn.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1_dawn.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1_dawn.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1_dawn.png").c_str())); + } + else + { + skybox = smgr->addSkyBoxSceneNode( + driver->getTexture(porting::getDataPath("skybox2_night.png").c_str()), + driver->getTexture(porting::getDataPath("skybox3_night.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1_night.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1_night.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1_night.png").c_str()), + driver->getTexture(porting::getDataPath("skybox1_night.png").c_str())); + } +} + void the_game( bool &kill, bool random_input, @@ -718,14 +759,9 @@ void the_game( /* Create skybox */ - scene::ISceneNode* skybox; - skybox = smgr->addSkyBoxSceneNode( - driver->getTexture(porting::getDataPath("skybox2.png").c_str()), - driver->getTexture(porting::getDataPath("skybox3.png").c_str()), - driver->getTexture(porting::getDataPath("skybox1.png").c_str()), - driver->getTexture(porting::getDataPath("skybox1.png").c_str()), - driver->getTexture(porting::getDataPath("skybox1.png").c_str()), - driver->getTexture(porting::getDataPath("skybox1.png").c_str())); + float old_brightness = 1.0; + scene::ISceneNode* skybox = NULL; + update_skybox(driver, smgr, skybox, 1.0); /* Create the camera node @@ -1682,12 +1718,24 @@ void the_game( skycolor.getGreen() * l / 255, skycolor.getBlue() * l / 255);*/ + float brightness = (float)l/255.0; + + /* + Update skybox + */ + if(fabs(brightness - old_brightness) > 0.01) + update_skybox(driver, smgr, skybox, brightness); + /* Update coulds */ clouds->step(dtime); - clouds->update(v2f(player_position.X, player_position.Z), (float)l/255.0); + clouds->update(v2f(player_position.X, player_position.Z), + 0.05+brightness*0.95); + // Store brightness value + old_brightness = brightness; + /* Fog */ diff --git a/src/utility.h b/src/utility.h index 9c2099fb..5cb3080a 100644 --- a/src/utility.h +++ b/src/utility.h @@ -2001,7 +2001,8 @@ inline u32 time_to_daynight_ratio(u32 time_of_day) s32 d = daylength; s32 t = (((time_of_day)%24000)/(24000/d)); if(t < nightlength/2 || t >= d - nightlength/2) - return 300; + //return 300; + return 350; else if(t >= d/2 - daytimelength/2 && t < d/2 + daytimelength/2) return 1000; else -- 2.30.2