00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00035 #ifndef __SO3WATER_H__
00036 #define __SO3WATER_H__
00037
00038 #include "SO3EnvironmentComponent.h"
00039 #include "../SCOLBasic/SO3DataScol.h"
00040 #include "../SO3Utils/SO3ColourGradient.h"
00041 #include "Hydrax/Hydrax.h"
00042 #include "Hydrax/Modules/ProjectedGrid/HydraxProjectedGrid.h"
00043 #include "Hydrax/Modules/RadialGrid/HydraxRadialGrid.h"
00044 #include "Hydrax/Modules/SimpleGrid/HydraxSimpleGrid.h"
00045 #include "Hydrax/Noise/Perlin/HydraxPerlin.h"
00046 #include "Hydrax/Noise/FFT/HydraxFFT.h"
00047
00048 namespace SO3
00049 {
00050
00051 class _SO3_Export SWater : public SEnvironmentComponent,
00052 public Hydrax::RttManager::RttListener
00053 {
00054 public:
00057 enum WaterGeometryType
00058 {
00059 SO3_WATER_GEOM_INFINITE_PLANE,
00060 SO3_WATER_GEOM_FINITE_PLANE,
00061 SO3_WATER_GEOM_RADIAL
00062 };
00063
00066 enum WaterComponentType
00067 {
00068 SO3_WATER_COMPONENT_NONE,
00069 SO3_WATER_COMPONENT_SUN,
00070 SO3_WATER_COMPONENT_FOAM,
00071 SO3_WATER_COMPONENT_DEPTH,
00072 SO3_WATER_COMPONENT_SMOOTH,
00073 SO3_WATER_COMPONENT_CAUSTICS,
00074 SO3_WATER_COMPONENT_UNDERWATER,
00075 SO3_WATER_COMPONENT_GODRAYS
00076 };
00077
00081 class WaterComponent
00082 {
00083 public:
00084 protected:
00085 Hydrax::Hydrax* hydraxManager;
00086 SWater* parentWater;
00087 const Hydrax::HydraxComponent hydraxComponentType;
00088 const SWater::WaterComponentType componentType;
00089 private:
00090 bool waterComponentEnable;
00091
00092 public:
00095 WaterComponent(SWater* parentWaterInstance, SWater::WaterComponentType component, Hydrax::HydraxComponent hydraxComponent);
00096
00099 ~WaterComponent();
00100
00104 bool GetEnabled();
00105
00109 void SetEnabled(bool enable);
00110
00113 SWater::WaterComponentType GetType();
00114
00117 virtual void Update(Ogre::Real updateTime)=0;
00118 protected:
00119 private:
00123 WaterComponent();
00124 };
00125
00129 class WaterComponentSun : public WaterComponent
00130 {
00131 public:
00132 protected:
00133 private:
00134 Ogre::Plane horizonPlane;
00135
00136 public:
00139 WaterComponentSun(SWater* parentWaterInstance);
00140
00143 void SetParameters(Ogre::Vector3 position, float strength, float area, Ogre::Vector3 color);
00144
00147 Ogre::Vector3 GetPosition();
00148
00151 void SetPosition(Ogre::Vector3 position);
00152
00155 float GetStrength();
00156
00159 void SetStrength(float strength);
00160
00163 float GetArea();
00164
00167 void SetArea(float area);
00168
00171 Ogre::ColourValue GetColor();
00172
00175 void SetColor(Ogre::ColourValue color);
00176
00179 virtual void Update(Ogre::Real updateTime);
00180 protected:
00181 private:
00185 WaterComponentSun();
00186 };
00187
00191 class WaterComponentFoam : public WaterComponent
00192 {
00193 public:
00194 protected:
00195 private:
00196
00197 public:
00200 WaterComponentFoam(SWater* parentWaterInstance);
00201
00204 void SetParameters(float maxDistance, float scale, float start, float transparency);
00205
00208 float GetMaxDistance();
00209
00212 void SetMaxDistance(float maxDistance);
00213
00216 float GetScale();
00217
00220 void SetScale(float scale);
00221
00224 float GetStart();
00225
00228 void SetStart(float start);
00229
00232 float GetTransparency();
00233
00236 void SetTransparency(float transparency);
00237
00240 virtual void Update(Ogre::Real updateTime);
00241 protected:
00242 private:
00246 WaterComponentFoam();
00247 };
00248
00252 class WaterComponentDepth : public WaterComponent
00253 {
00254 public:
00255 protected:
00256 private:
00257
00258 public:
00261 WaterComponentDepth(SWater* parentWaterInstance);
00262
00265 void SetParameters(float depthLimit, float distortionLimit);
00266
00269 float GetDepthLimit();
00270
00273 void SetDepthLimit(float depthLimit);
00274
00277 void SetDistortionLimit(float distortionLimit);
00278
00281 float GetDistortionLimit();
00282
00285 virtual void Update(Ogre::Real updateTime);
00286 protected:
00287 private:
00291 WaterComponentDepth();
00292 };
00293
00297 class WaterComponentSmooth : public WaterComponent
00298 {
00299 public:
00300 protected:
00301 private:
00302
00303 public:
00306 WaterComponentSmooth(SWater* parentWaterInstance);
00307
00310 float GetPower();
00311
00314 void SetPower(float smoothPower);
00315
00318 virtual void Update(Ogre::Real updateTime);
00319 protected:
00320 private:
00324 WaterComponentSmooth();
00325 };
00326
00330 class WaterComponentCaustics : public WaterComponent
00331 {
00332 public:
00333 protected:
00334 private:
00335
00336 public:
00339 WaterComponentCaustics(SWater* parentWaterInstance);
00340
00343 void SetParameters(float scale, float power, float end);
00344
00347 float GetScale();
00348
00351 void SetScale(float scale);
00352
00355 float GetPower();
00356
00359 void SetPower(float power);
00360
00363 float GetEnd();
00364
00367 void SetEnd(float end);
00368
00371 virtual void Update(Ogre::Real updateTime);
00372 protected:
00373 private:
00377 WaterComponentCaustics();
00378 };
00379
00383 class WaterComponentUnderwater : public WaterComponent
00384 {
00385 public:
00386 protected:
00387 private:
00388
00389 public:
00392 WaterComponentUnderwater(SWater* parentWaterInstance);
00393
00396 virtual void Update(Ogre::Real updateTime);
00397 protected:
00398 private:
00402 WaterComponentUnderwater();
00403 };
00404
00408 class WaterComponentGodRays : public WaterComponent
00409 {
00410 public:
00411 protected:
00412 private:
00413
00414 public:
00417 WaterComponentGodRays(SWater* parentWaterInstance);
00418
00421 void SetParameters(Ogre::Vector3 exposure, float intensity, float speed, int numberOfRays, float raysSize, bool raysIntersections);
00422
00425 Ogre::Vector3 GetExposure();
00426
00429 void SetExposure(Ogre::Vector3 exposure);
00430
00433 float GetIntensity();
00434
00437 void SetIntensity(float intensity);
00438
00441 float GetSpeed();
00442
00445 void SetSpeed(float speed);
00446
00449 int GetNumberOfRays();
00450
00453 void SetNumberOfRays(int numberOfRays);
00454
00457 float GetRaysSize();
00458
00461 void SetRaysSize(float raysSize);
00462
00465 bool GetRaysIntersectionEnable();
00466
00469 void SetRaysIntersectionEnable(bool raysIntersections);
00470
00473 virtual void Update(Ogre::Real updateTime);
00474 protected:
00475 private:
00479 WaterComponentGodRays();
00480 };
00481 protected:
00482 private:
00483 SScene* parentScene;
00484 WaterComponentSun* sunComponent;
00485 WaterComponentFoam* foamComponent;
00486 WaterComponentDepth* depthComponent;
00487 WaterComponentSmooth* smoothComponent;
00488 WaterComponentCaustics* causticsComponent;
00489 WaterComponentUnderwater* underwaterComponent;
00490 WaterComponentGodRays* godRaysComponent;
00491 WaterGeometryType actualGeometryType;
00492 Hydrax::Hydrax* hydraxManager;
00493 Hydrax::Module::Module* hydraxGeometry;
00494 Hydrax::Noise::Noise* hydraxNoise;
00495 Hydrax::Noise::Perlin::Options perlinNoiseOptions;
00496 Hydrax::Noise::FFT::Options fftNoiseOptions;
00497 SViewPort* renderingViewport;
00498 SCamera* renderingCamera;
00499 Ogre::ColourValue baseColour;
00500 SColourGradient waterColourGradient;
00501
00502 public:
00506 SWater(SEnvironment* parent, std::string waterName, SViewPort* targetViewport, SCamera* targetCamera);
00507
00511 SWater(SEnvironment* parent, std::string waterName, SViewPort* targetViewport, SCamera* targetCamera, int planeSizeX, int planeSizeY);
00512
00516 SWater(SEnvironment* parent, std::string waterName, SViewPort* targetViewport, SCamera* targetCamera, float waterRadius);
00517
00521 ~SWater();
00522
00526 Hydrax::Hydrax* GetHydrax();
00527
00531 WaterGeometryType GetGeometryType();
00532
00536 void SetGeometryTypeInfinitePlane();
00537
00541 void SetGeometryTypeFinitePlane(int planeSizeX, int planeSizeY);
00542
00546 void SetGeometryTypeRadialPlane(float waterRadius);
00547
00550 WaterComponent* GetComponent(SWater::WaterComponentType componentType);
00551
00554 WaterComponentSun* GetSun();
00555
00558 WaterComponentFoam* GetFoam();
00559
00562 WaterComponentDepth* GetDepth();
00563
00566 WaterComponentSmooth* GetSmooth();
00567
00570 WaterComponentCaustics* GetCaustics();
00571
00574 WaterComponentUnderwater* GetUnderwater();
00575
00578 WaterComponentGodRays* GetGodRays();
00579
00583 void SetWindSpeed(float newWindSpeed);
00584
00588 void SetWindDirection(Ogre::Vector3 newWindDirection);
00589
00593 const Ogre::Vector3& GetPosition() const;
00594
00598 void SetPosition(const Ogre::Vector3& newSeaLevel);
00599
00602 Ogre::ColourValue GetColor();
00603
00606 void SetColor(Ogre::ColourValue color);
00607
00610 virtual void Update(Ogre::Real updateTime);
00611
00615 float GetAnimationSpeed();
00616
00620 void SetAnimationSpeed(float animationSpeed);
00621
00624 virtual void preRenderTargetUpdate(const Hydrax::RttManager::RttType& Rtt);
00625
00628 virtual void postRenderTargetUpdate(const Hydrax::RttManager::RttType& Rtt);
00629 protected:
00630 private:
00634 SWater();
00635
00639 void CommonConstructorsSequence(SViewPort* targetViewport, SCamera* targetCamera);
00640
00643 void Initialise();
00644
00647 void CreateInfinitePlaneGeometry();
00648
00651 void CreateFinitePlaneGeometry(int planeSizeX, int planeSizeY);
00652
00653
00654
00655 void CreateRadialPlaneGeometry(float waterRadius);
00656
00659 Hydrax::Noise::Noise* CreatePerlinNoise();
00660
00663 Hydrax::Noise::Noise* CreateFftNoise();
00664
00667 void RefreshWaterColourGradient();
00668 };
00669
00670 }
00671
00672 #endif