Tune mapgen
[oweals/minetest.git] / src / sky.h
1 /*
2 Minetest-c55
3 Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "common_irrlicht.h"
21 #include <ISceneNode.h>
22
23 #ifndef SKY_HEADER
24 #define SKY_HEADER
25
26 #define SKY_MATERIAL_COUNT 3
27 #define SKY_STAR_COUNT 200
28
29 // Skybox, rendered with zbuffer turned off, before all other nodes.
30 class Sky : public scene::ISceneNode
31 {
32 public:
33         //! constructor
34         Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id);
35
36         virtual void OnRegisterSceneNode();
37
38         //! renders the node.
39         virtual void render();
40
41         virtual const core::aabbox3d<f32>& getBoundingBox() const;
42
43         // Used by Irrlicht for optimizing rendering
44         virtual video::SMaterial& getMaterial(u32 i)
45         { return m_materials[i]; }
46
47         // Used by Irrlicht for optimizing rendering
48         virtual u32 getMaterialCount() const
49         { return SKY_MATERIAL_COUNT; }
50
51         void update(float m_time_of_day, float time_brightness,
52                         float direct_brightness, bool sunlight_seen);
53         
54         float getBrightness(){ return m_brightness; }
55         video::SColor getBgColor(){ return m_bgcolor; }
56         video::SColor getSkyColor(){ return m_skycolor; }
57         
58         bool getCloudsVisible(){ return m_clouds_visible; }
59         video::SColorf getCloudColor(){ return m_cloudcolor_f; }
60
61 private:
62         core::aabbox3d<f32> Box;
63         video::SMaterial m_materials[SKY_MATERIAL_COUNT];
64         
65         bool m_first_update;
66         float m_time_of_day;
67         float m_time_brightness;
68         bool m_sunlight_seen;
69         float m_brightness;
70         float m_cloud_brightness;
71         bool m_clouds_visible;
72         video::SColorf m_bgcolor_bright_f;
73         video::SColorf m_skycolor_bright_f;
74         video::SColorf m_cloudcolor_bright_f;
75         video::SColor m_bgcolor;
76         video::SColor m_skycolor;
77         video::SColorf m_cloudcolor_f;
78         v3f m_stars[SKY_STAR_COUNT];
79         u16 m_star_indices[SKY_STAR_COUNT*4];
80         video::S3DVertex m_star_vertices[SKY_STAR_COUNT*4];
81 };
82
83 #endif
84