Planeshift
weather.h
Go to the documentation of this file.
1 
2 #ifndef MODE_WEATHER_HEADER
3 #define MODE_WEATHER_HEADER
4 
5 
6 #include "isndsys/ss_structs.h"
7 #include "isndsys/ss_data.h"
8 #include "isndsys/ss_stream.h"
9 #include "isndsys/ss_source.h"
10 
11 /* Defines for the various weather conditions. Some things may need to trigger on
12  a 'general' time of day. */
14 {
20 };
21 
23 {
31 };
32 
33 class WeatherObject;
34 
36 {
37  int value;
39  int fade_time;
40 };
41 
42 
45 {
46  csString sector;
51 
53 
54  int r,g,b;
55 
56  static void Fade(WeatherParams* wp, int delta);
57 };
58 
59 //-----------------------------------------------------------------------------
60 
65 {
66 public:
67  WeatherObject(WeatherInfo* parent);
68  virtual ~WeatherObject();
69 
70  // General
72  virtual void Destroy();
73 
74  virtual bool Valid();
75  virtual void MoveTo(WeatherInfo* new_parent,iSector* sector);
76  virtual void MoveTo(csVector3 pos);
77  virtual void StartFollow();
78  virtual void StopFollow();
79  virtual iSector* GetSector();
80  // If you use this function, you need to call SetupMesh and stuff like that too
81  virtual void SetParent(WeatherInfo* new_parent) { parent = new_parent;}
82  virtual WeatherInfo* GetParent() {return parent;}
83  virtual void SetColor(float /*r*/, float /*g*/, float /*b*/){};
84  virtual void Update(csTicks /*delta*/){};
85 
86  // Specific
87  virtual bool CreateMesh() = 0;
88  virtual void SetupMesh(csBox3 bbox) = 0;
91 
92  virtual WeatherConditions GetType() { return WEATHER_ANY; }
93 
94  // Calculations
95  //virtual float GetDensity(int drops) = 0;
96  virtual csBox3 CreateDefaultBBox() = 0;
97 
98 protected:
99 
100  void RefreshSector(); // For flags
101 
102  // standard members
103  csBox3 bbox; // Used for sector movements
105  csRef<iMeshWrapper> mesh;
106  csRef<iMeshFactoryWrapper> mfw;
107  csRef<iMaterialWrapper> mat;
108 
109  //csRef<iSndSysSource> weather_sound; // looping background weather sound
110 };
111 
112 class RainWeatherObject;
113 class SnowWeatherObject;
114 class FogWeatherObject;
115 
116 //-----------------------------------------------------------------------------
117 
118 
121 {
122 public:
124  virtual ~RainWeatherObject();
125 
126  void Destroy();
127  void MoveTo(WeatherInfo* newParent,iSector* sector);
128 
129  bool CreateMesh();
130  void SetupMesh(csBox3 bbox);
131  void SetDrops(int drops);
132 
133  virtual void Update(csTicks delta);
134 
135  WeatherSound GetWeatherSound();
136  WeatherSound GetWeatherSoundForced();
138 
139  // Calculations
140  static float GetDensity(int drops);
141  csBox3 CreateDefaultBBox();
142 };
143 
144 //-----------------------------------------------------------------------------
145 
148 {
149 public:
151  virtual ~SnowWeatherObject();
152 
153  void Destroy();
154  void MoveTo(WeatherInfo* newParent,iSector* sector);
155 
156  bool CreateMesh();
157  void SetupMesh(csBox3 bbox);
158  void SetDrops(int drops);
159 
160  virtual void Update(csTicks delta);
161 
162  WeatherSound GetWeatherSound();
163  WeatherSound GetWeatherSoundForced();
165 
166  // Calculations
167  static float GetDensity(int drops);
168  csBox3 CreateDefaultBBox();
169 
170 private:
171  csRef<csShaderVariable> snowDensitySV;
172  CS::ShaderVarStringID snowDensity;
173 };
174 
175 //-----------------------------------------------------------------------------
176 
179 {
180 public:
181  FogWeatherObject(WeatherInfo* parent);
182  virtual ~FogWeatherObject();
183 
184  void Destroy();
185  bool Valid();
186  bool CreateMesh();
187  void MoveTo(WeatherInfo* newParent,iSector* sector);
188  void SetupMesh(csBox3 /*bbox*/){}
189  iSector* GetSector();
190 
191  void MoveTo(csVector3 /*pos*/) {}
192  void StartFollow() {}
193  void StopFollow() {}
194 
195  void SetColor(float r,float g,float b);
196  virtual void Update(csTicks delta);
197 
198  WeatherSound GetWeatherSound();
199  WeatherSound GetWeatherSoundForced();
201 
202  // Calculations
203  static float GetDensity(int density);
204  csBox3 CreateDefaultBBox() {return csBox3(0,0,0,0,0,0); }
205 
206  WeatherInfo* GetWeatherInfo() { return parent;} // WeatherInfos are noremaly created for these objects
207 private:
208  bool applied;
209 
210  csColor color;
211  iSector* sector;
212 };
213 
214 #endif
WeatherSound
Definition: weather.h:22
WeatherParams downfall_params
Definition: weather.h:48
virtual void Update(csTicks)
Definition: weather.h:84
WeatherObject * fog
Definition: weather.h:52
virtual void SetParent(WeatherInfo *new_parent)
Definition: weather.h:81
csBox3 bbox
Definition: weather.h:103
csRef< iMeshFactoryWrapper > mfw
Definition: weather.h:106
csRef< iMeshWrapper > mesh
Definition: weather.h:105
virtual WeatherSound GetWeatherSound()
Definition: weather.h:89
WeatherInfo * GetWeatherInfo()
Definition: weather.h:206
WeatherConditions
Definition: weather.h:13
WeatherConditions GetType()
Definition: weather.h:164
csRef< iMaterialWrapper > mat
Definition: weather.h:107
WeatherConditions GetType()
Definition: weather.h:200
virtual WeatherConditions GetType()
Definition: weather.h:92
int fade_time
Definition: weather.h:39
virtual WeatherSound GetWeatherSoundForced()
Definition: weather.h:90
WeatherInfo * parent
Definition: weather.h:104
csString sector
Definition: weather.h:46
Rain, also handles a fog object.
Definition: weather.h:120
Holds the weather object, need this because some things have been created but do not have an object p...
Definition: weather.h:64
void StartFollow()
Definition: weather.h:192
virtual void SetColor(float, float, float)
Definition: weather.h:83
WeatherParams fog_params
Definition: weather.h:50
WeatherConditions downfall_condition
Definition: weather.h:47
void MoveTo(csVector3)
Definition: weather.h:191
int fade_value
Definition: weather.h:38
csBox3 CreateDefaultBBox()
Definition: weather.h:204
WeatherConditions GetType()
Definition: weather.h:137
void StopFollow()
Definition: weather.h:193
virtual WeatherInfo * GetParent()
Definition: weather.h:82
Struct for information about current weather.
Definition: weather.h:44
void SetupMesh(csBox3)
Definition: weather.h:188
WeatherConditions fog_condition
Definition: weather.h:49