made proper skyboxes for dawn/evening and night
authorPerttu Ahola <celeron55@gmail.com>
Fri, 29 Apr 2011 14:53:07 +0000 (17:53 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Fri, 29 Apr 2011 14:53:07 +0000 (17:53 +0300)
data/skybox1_dawn.png [new file with mode: 0644]
data/skybox1_night.png [new file with mode: 0644]
data/skybox2_dawn.png [new file with mode: 0644]
data/skybox2_night.png [new file with mode: 0644]
data/skybox3_dawn.png [new file with mode: 0644]
data/skybox3_night.png [new file with mode: 0644]
src/game.cpp
src/utility.h

diff --git a/data/skybox1_dawn.png b/data/skybox1_dawn.png
new file mode 100644 (file)
index 0000000..9711c47
Binary files /dev/null and b/data/skybox1_dawn.png differ
diff --git a/data/skybox1_night.png b/data/skybox1_night.png
new file mode 100644 (file)
index 0000000..32e43a6
Binary files /dev/null and b/data/skybox1_night.png differ
diff --git a/data/skybox2_dawn.png b/data/skybox2_dawn.png
new file mode 100644 (file)
index 0000000..a761dff
Binary files /dev/null and b/data/skybox2_dawn.png differ
diff --git a/data/skybox2_night.png b/data/skybox2_night.png
new file mode 100644 (file)
index 0000000..beb07a9
Binary files /dev/null and b/data/skybox2_night.png differ
diff --git a/data/skybox3_dawn.png b/data/skybox3_dawn.png
new file mode 100644 (file)
index 0000000..22c8cbe
Binary files /dev/null and b/data/skybox3_dawn.png differ
diff --git a/data/skybox3_night.png b/data/skybox3_night.png
new file mode 100644 (file)
index 0000000..bb50978
Binary files /dev/null and b/data/skybox3_night.png differ
index 8981638a84c29b650b7e16759fe639438c8b7fa5..771b05d87238b10c7974ac5112baa01157024955 100644 (file)
@@ -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
                */
index 9c2099fb8e32e9f3ef9a34b97c6081844d6fa5b8..5cb3080a7337b638b57d45055b8948344c49b698 100644 (file)
@@ -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