Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
clouds.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
8#include "constants.h"
9#include "irr_ptr.h"
10#include "skyparams.h"
11#include <iostream>
12#include <ISceneNode.h>
13#include <SMaterial.h>
14#include <SMeshBuffer.h>
15
16class IShaderSource;
17
18namespace irr::scene
19{
20 class ISceneManager;
21}
22
23// Menu clouds
24// The mainmenu and the loading screen use the same Clouds object so that the
25// clouds don't jump when switching between the two.
26class Clouds;
27extern scene::ISceneManager *g_menucloudsmgr;
28extern Clouds *g_menuclouds;
29
30class Clouds : public scene::ISceneNode
31{
32public:
33 Clouds(scene::ISceneManager* mgr, IShaderSource *ssrc,
34 s32 id,
35 u32 seed
36 );
37
38 ~Clouds();
39
40 /*
41 ISceneNode methods
42 */
43
44 virtual void OnRegisterSceneNode();
45
46 virtual void render();
47
48 virtual const aabb3f &getBoundingBox() const
49 {
50 return m_box;
51 }
52
53 virtual u32 getMaterialCount() const
54 {
55 return 1;
56 }
57
58 virtual video::SMaterial& getMaterial(u32 i)
59 {
60 return m_material;
61 }
62
63 /*
64 Other stuff
65 */
66
67 void step(float dtime);
68
69 void update(const v3f &camera_p, const video::SColorf &color);
70
71 void updateCameraOffset(v3s16 camera_offset)
72 {
73 m_camera_offset = camera_offset;
74 updateBox();
75 }
76
77 void readSettings();
78
79 void setDensity(float density)
80 {
81 if (m_params.density == density)
82 return;
83 m_params.density = density;
85 }
86
87 void setColorBright(video::SColor color_bright)
88 {
89 m_params.color_bright = color_bright;
90 }
91
92 void setColorAmbient(video::SColor color_ambient)
93 {
94 m_params.color_ambient = color_ambient;
95 }
96
97 void setColorShadow(video::SColor color_shadow)
98 {
99 if (m_params.color_shadow == color_shadow)
100 return;
101 m_params.color_shadow = color_shadow;
103 }
104
105 void setHeight(float height)
106 {
107 if (m_params.height == height)
108 return;
109 m_params.height = height;
110 updateBox();
112 }
113
114 void setSpeed(v2f speed)
115 {
116 m_params.speed = speed;
117 }
118
119 void setThickness(float thickness)
120 {
121 if (m_params.thickness == thickness)
122 return;
123 m_params.thickness = thickness;
124 updateBox();
126 }
127
129
130 const video::SColor getColor() const { return m_color.toSColor(); }
131
132private:
134 {
135 float height_bs = m_params.height * BS;
136 float thickness_bs = m_params.thickness * BS;
137 m_box = aabb3f(-BS * 1000000.0f, height_bs, -BS * 1000000.0f,
138 BS * 1000000.0f, height_bs + thickness_bs, BS * 1000000.0f);
139 }
140
141 void updateMesh();
143 {
144 m_mesh_valid = false;
145 }
146
147 bool gridFilled(int x, int y) const;
148
149 // Are the clouds 3D?
150 inline bool is3D() const {
151 return m_enable_3d && m_params.thickness >= 0.01f;
152 }
153
154 video::SMaterial m_material;
155 irr_ptr<scene::SMeshBuffer> m_meshbuffer;
156 // Value of m_origin at the time the mesh was last updated
158 // Value of center_of_drawing_in_noise_i at the time the mesh was last updated
160 // Was the mesh ever generated?
161 bool m_mesh_valid = false;
162
168
171
173 video::SColorf m_color = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f);
175};
Definition clouds.h:31
void setColorAmbient(video::SColor color_ambient)
Definition clouds.h:92
irr_ptr< scene::SMeshBuffer > m_meshbuffer
Definition clouds.h:155
bool gridFilled(int x, int y) const
Definition clouds.cpp:462
virtual u32 getMaterialCount() const
Definition clouds.h:53
video::SColorf m_color
Definition clouds.h:173
bool isCameraInsideCloud() const
Definition clouds.h:128
virtual video::SMaterial & getMaterial(u32 i)
Definition clouds.h:58
bool m_enable_3d
Definition clouds.h:172
bool is3D() const
Definition clouds.h:150
CloudParams m_params
Definition clouds.h:174
void step(float dtime)
Definition clouds.cpp:420
v3f m_camera_pos
Definition clouds.h:167
v2f m_origin
Definition clouds.h:164
void invalidateMesh()
Definition clouds.h:142
u32 m_seed
Definition clouds.h:166
virtual void OnRegisterSceneNode()
Definition clouds.cpp:67
void setThickness(float thickness)
Definition clouds.h:119
void update(const v3f &camera_p, const video::SColorf &color)
Definition clouds.cpp:425
void updateBox()
Definition clouds.h:133
void setColorShadow(video::SColor color_shadow)
Definition clouds.h:97
void readSettings()
Definition clouds.cpp:450
void setHeight(float height)
Definition clouds.h:105
const video::SColor getColor() const
Definition clouds.h:130
void setColorBright(video::SColor color_bright)
Definition clouds.h:87
u16 m_cloud_radius_i
Definition clouds.h:165
void setDensity(float density)
Definition clouds.h:79
bool m_enable_shaders
Definition clouds.h:172
void setSpeed(v2f speed)
Definition clouds.h:114
~Clouds()
Definition clouds.cpp:62
aabb3f m_box
Definition clouds.h:163
bool m_camera_inside_cloud
Definition clouds.h:170
video::SMaterial m_material
Definition clouds.h:154
v3s16 m_camera_offset
Definition clouds.h:169
Clouds(scene::ISceneManager *mgr, IShaderSource *ssrc, s32 id, u32 seed)
Definition clouds.cpp:28
bool m_mesh_valid
Definition clouds.h:161
v2s16 m_last_noise_center
Definition clouds.h:159
void updateCameraOffset(v3s16 camera_offset)
Definition clouds.h:71
v2f m_mesh_origin
Definition clouds.h:157
virtual const aabb3f & getBoundingBox() const
Definition clouds.h:48
virtual void render()
Definition clouds.cpp:366
void updateMesh()
Definition clouds.cpp:77
Definition shader.h:201
scene::ISceneManager * g_menucloudsmgr
Definition clouds.cpp:17
Clouds * g_menuclouds
Definition clouds.cpp:18
#define BS
Definition constants.h:61
core::aabbox3d< f32 > aabb3f
Definition irr_aabb3d.h:11
core::vector2d< s16 > v2s16
Definition irr_v2d.h:12
core::vector2d< f32 > v2f
Definition irr_v2d.h:11
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
Definition clientmap.h:30
Definition skyparams.h:65
video::SColor color_shadow
Definition skyparams.h:69
video::SColor color_bright
Definition skyparams.h:67
float thickness
Definition skyparams.h:70
video::SColor color_ambient
Definition skyparams.h:68
v2f speed
Definition skyparams.h:72
float height
Definition skyparams.h:71
float density
Definition skyparams.h:66