My Project
WeatherEffect.h
1 #pragma once
2 #include "BaseObject.h"
3 #include "util/FastRandom.h"
4 #include "util/Tick.h"
5 #include "util/unordered_array.hpp"
6 #include "WeatherParticle.h"
7 
8 namespace ParaEngine
9 {
10  class WeatherParticleSpawner;
11 
14  class CWeatherEffect : public CBaseObject
15  {
16  public:
18  virtual ~CWeatherEffect();
19 
20  ATTRIBUTE_DEFINE_CLASS(CWeatherEffect);
21  ATTRIBUTE_SUPPORT_CREATE_FACTORY(CWeatherEffect);
22 
24  virtual int InstallFields(CAttributeClass* pClass, bool bOverride);
25 
26  ATTRIBUTE_METHOD1(CWeatherEffect, EnableRain_s, bool) { cls->EnableRain(p1); return S_OK; }
27  ATTRIBUTE_METHOD1(CWeatherEffect, EnableSnow_s, bool) { cls->EnableSnow(p1); return S_OK; }
28 
29  ATTRIBUTE_METHOD1(CWeatherEffect, SetRainStrength_s, float) { cls->SetRainStrength(p1); return S_OK; }
30  ATTRIBUTE_METHOD1(CWeatherEffect, SetSnowStrength_s, float) { cls->SetSnowStrength(p1); return S_OK; }
31 
32  public:
33  WeatherParticle* AddParticle(float x, float y, float z, WeatherType weather_type);
34 
35  void SpawnAllParticles();
36 
37  /*spawn particles for the given weather item
38  @param weather_item : can be snow or rain item info.
39  */
40  void SpawnParticles(WeatherParticleSpawner& weather_type, float strength, float spawn_tick_fps);
41 
42  virtual void Cleanup();
43 
44  FastRandom& GetSpawnRand() { return m_spawnRand; }
45  FastRandom& GetSpeedRand() { return m_speedRand; }
46 
48  bool HasActiveSpawners();
49 
50  WeatherParticleSpawner& GetParticleSpawner(WeatherType weather_type);
51 
52  void EnableWeatherItem(WeatherType weather_type, bool bEnabled);
53  bool IsWeatherItemEnabled(WeatherType weather_type);
54 
59  int32 GetTerrainHighestBlock(int32 x, int32 z, int32& outY);
60 
61  int PrepareRender(CBaseCamera* pCamera, SceneState* pSceneState);
62 
68  virtual void Animate(double dTimeDelta, int nRenderNumber = 0);
69 
71  virtual HRESULT Draw(SceneState * sceneState);
72 
73  void EnableSnow(bool bEnabled);
74  void EnableRain(bool bEnabled);
78  void SetRainStrength(float fStrength);
79  void SetSnowStrength(float fStrength);
80 
81  protected:
82  // keep a weak reference for fast access
83  WeatherParticleSpawner* m_particle_spawners[WeatherType_Last];
84 
85  float m_default_strength;
86  FastRandom m_spawnRand;
87  FastRandom m_speedRand;
88 
90  Tick m_updateTick;
91  };
92 }
an attribute class is a collection of attribute fields.
Definition: AttributeClass.h:10
It's used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
bool HasActiveSpawners()
if any spawner is enabled.
Definition: WeatherEffect.cpp:53
different physics engine has different winding order.
Definition: EventBinding.h:32
virtual HRESULT Draw(SceneState *sceneState)
only for drawable objects
Definition: WeatherEffect.cpp:129
base class for weather particle
Definition: WeatherParticle.h:21
Definition: unordered_array.hpp:9
virtual int InstallFields(CAttributeClass *pClass, bool bOverride)
this class should be implemented if one wants to add new attribute.
Definition: WeatherEffect.cpp:239
int32 GetTerrainHighestBlock(int32 x, int32 z, int32 &outY)
get the highest solid block information in coordinate x, z
Definition: WeatherEffect.cpp:93
Definition: BaseCamera.h:70
int PrepareRender(CBaseCamera *pCamera, SceneState *pSceneState)
derived class can override this function to place the object in to the render pipeline.
Definition: WeatherEffect.cpp:232
virtual void Cleanup()
clean up the object.
Definition: WeatherEffect.cpp:73
either rain or snow.
Definition: WeatherEffect.h:14
Definition: FastRandom.h:3
virtual void Animate(double dTimeDelta, int nRenderNumber=0)
animate the model by a given delta time.
Definition: WeatherEffect.cpp:108
Check to see if it is a tick.
Definition: Tick.h:5
Definition: WeatherParticleSpawner.h:16
void SetRainStrength(float fStrength)
Definition: WeatherEffect.cpp:222
Defines the base class of all scene elements:CBaseObject for Parallel World Engine.
Definition: BaseObject.h:230