]> git.lizzy.rs Git - dragonfireclient.git/blob - src/clouds.h
C++11 patchset 9: move hardcoded init parameters to class definitions (part 1) (...
[dragonfireclient.git] / src / clouds.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 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 Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser 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 #ifndef CLOUDS_HEADER
21 #define CLOUDS_HEADER
22
23 #include "irrlichttypes_extrabloated.h"
24 #include <iostream>
25 #include "constants.h"
26 #include "cloudparams.h"
27
28 // Menu clouds
29 class Clouds;
30 extern Clouds *g_menuclouds;
31
32 // Scene manager used for menu clouds
33 namespace irr{namespace scene{class ISceneManager;}}
34 extern irr::scene::ISceneManager *g_menucloudsmgr;
35
36 class Clouds : public scene::ISceneNode
37 {
38 public:
39         Clouds(
40                         scene::ISceneNode* parent,
41                         scene::ISceneManager* mgr,
42                         s32 id,
43                         u32 seed,
44                         s16 cloudheight=0
45         );
46
47         ~Clouds();
48
49         /*
50                 ISceneNode methods
51         */
52
53         virtual void OnRegisterSceneNode();
54
55         virtual void render();
56
57         virtual const aabb3f &getBoundingBox() const
58         {
59                 return m_box;
60         }
61
62         virtual u32 getMaterialCount() const
63         {
64                 return 1;
65         }
66
67         virtual video::SMaterial& getMaterial(u32 i)
68         {
69                 return m_material;
70         }
71
72         /*
73                 Other stuff
74         */
75
76         void step(float dtime);
77
78         void update(v2f camera_p, video::SColorf color);
79
80         void updateCameraOffset(v3s16 camera_offset)
81         {
82                 m_camera_offset = camera_offset;
83                 updateBox();
84         }
85
86         void readSettings();
87
88         void setDensity(float density)
89         {
90                 m_params.density = density;
91                 // currently does not need bounding
92         }
93
94         void setColorBright(const video::SColor &color_bright)
95         {
96                 m_params.color_bright = color_bright;
97         }
98
99         void setColorAmbient(const video::SColor &color_ambient)
100         {
101                 m_params.color_ambient = color_ambient;
102         }
103
104         void setHeight(float height)
105         {
106                 m_params.height = height; // add bounding when necessary
107                 updateBox();
108         }
109
110         void setSpeed(v2f speed)
111         {
112                 m_params.speed = speed;
113         }
114
115         void setThickness(float thickness)
116         {
117                 m_params.thickness = thickness;
118                 updateBox();
119         }
120
121 private:
122         void updateBox()
123         {
124                 float height_bs    = m_params.height    * BS;
125                 float thickness_bs = m_params.thickness * BS;
126                 m_box = aabb3f(-BS * 1000000.0f, height_bs - BS * m_camera_offset.Y, -BS * 1000000.0f,
127                                 BS * 1000000.0f, height_bs + thickness_bs - BS * m_camera_offset.Y, BS * 1000000.0f);
128         }
129
130         video::SMaterial m_material;
131         aabb3f m_box;
132         s16 m_passed_cloud_y;
133         u16 m_cloud_radius_i;
134         bool m_enable_3d;
135         u32 m_seed;
136         v2f m_camera_pos;
137         v2f m_origin;
138         v3s16 m_camera_offset;
139         video::SColorf m_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
140         CloudParams m_params;
141
142 };
143
144
145
146 #endif