00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CAELUM__FLAT_CLOUD_LAYER_H
00022 #define CAELUM__FLAT_CLOUD_LAYER_H
00023
00024 #include "CaelumPrerequisites.h"
00025 #include "InternalUtilities.h"
00026 #include "PrivatePtr.h"
00027 #include "FastGpuParamRef.h"
00028
00029 namespace Caelum
00030 {
00042 class CAELUM_EXPORT FlatCloudLayer
00043 {
00044 public:
00045 FlatCloudLayer(
00046 Ogre::SceneManager *sceneMgr,
00047 Ogre::SceneNode *cloudRoot);
00048
00049 ~FlatCloudLayer();
00050
00054 void update (
00055 Ogre::Real timePassed,
00056 const Ogre::Vector3 &sunDirection,
00057 const Ogre::ColourValue &sunLightColour,
00058 const Ogre::ColourValue &fogColour,
00059 const Ogre::ColourValue &sunSphereColour);
00060
00062 void advanceAnimation (Ogre::Real timePassed);
00063
00066 void reset ();
00067
00068 private:
00069 Ogre::Vector2 mCloudSpeed;
00070 Ogre::Vector2 mCloudMassOffset;
00071 Ogre::Vector2 mCloudDetailOffset;
00072
00073
00074
00075 void setCloudMassOffset(const Ogre::Vector2 &cloudMassOffset);
00076 void setCloudDetailOffset(const Ogre::Vector2 &cloudDetailOffset);
00077
00078 public:
00082 void setCloudSpeed (const Ogre::Vector2 &cloudSpeed);
00083
00087 const Ogre::Vector2 getCloudSpeed () const { return mCloudSpeed; }
00088
00089 private:
00090 Ogre::Vector3 mSunDirection;
00091 Ogre::ColourValue mSunLightColour;
00092 Ogre::ColourValue mSunSphereColour;
00093 Ogre::ColourValue mFogColour;
00094
00095 public:
00096 void setSunDirection(const Ogre::Vector3 &sunDirection);
00097 void setSunLightColour(const Ogre::ColourValue &sunLightColour);
00098 void setSunSphereColour(const Ogre::ColourValue &sunSphereColour);
00099 void setFogColour(const Ogre::ColourValue &fogColour);
00100 const Ogre::Vector3 getSunDirection () const;
00101 const Ogre::ColourValue getSunLightColour () const;
00102 const Ogre::ColourValue getSunSphereColour () const;
00103 const Ogre::ColourValue getFogColour () const;
00104
00105 private:
00107 Ogre::SceneManager *mSceneMgr;
00108
00109
00110
00111
00113 PrivateMaterialPtr mMaterial;
00114
00115 struct Params
00116 {
00117 void setup(Ogre::GpuProgramParametersSharedPtr fpParams, Ogre::GpuProgramParametersSharedPtr vpParams);
00118
00119 Ogre::GpuProgramParametersSharedPtr vpParams;
00120 Ogre::GpuProgramParametersSharedPtr fpParams;
00121
00122 FastGpuParamRef cloudCoverageThreshold;
00123 FastGpuParamRef cloudMassOffset;
00124 FastGpuParamRef cloudDetailOffset;
00125 FastGpuParamRef cloudMassBlend;
00126 FastGpuParamRef vpSunDirection;
00127 FastGpuParamRef fpSunDirection;
00128 FastGpuParamRef sunLightColour;
00129 FastGpuParamRef sunSphereColour;
00130 FastGpuParamRef fogColour;
00131 FastGpuParamRef layerHeight;
00132 FastGpuParamRef cloudUVFactor;
00133 FastGpuParamRef heightRedFactor;
00134 FastGpuParamRef nearFadeDist;
00135 FastGpuParamRef farFadeDist;
00136 FastGpuParamRef fadeDistMeasurementVector;
00137 } mParams;
00138
00139 private:
00140 PrivateMeshPtr mMesh;
00141 PrivateSceneNodePtr mNode;
00142 PrivateEntityPtr mEntity;
00143
00144
00145 bool mMeshDirty;
00146 Real mMeshWidth, mMeshHeight;
00147 int mMeshWidthSegments, mMeshHeightSegments;
00148
00149 public:
00153 void _ensureGeometry();
00154
00158 void _invalidateGeometry();
00159
00162 void setMeshParameters (
00163 Real meshWidth, Real meshHeight,
00164 int meshWidthSegments, int meshHeightSegments);
00165
00167 inline void setMeshWidth (Real value) { mMeshWidth = value; _invalidateGeometry (); }
00168 inline void setMeshHeight (Real value) { mMeshHeight = value; _invalidateGeometry (); }
00169 inline void setMeshWidthSegments (int value) { mMeshWidthSegments = value; _invalidateGeometry (); }
00170 inline void setMeshHeightSegments (int value) { mMeshHeightSegments = value; _invalidateGeometry (); }
00171 inline Real getMeshWidth () const { return mMeshWidth; }
00172 inline Real getMeshHeight () const { return mMeshHeight; }
00173 inline int getMeshWidthSegments () const { return mMeshWidthSegments; }
00174 inline int getMeshHeightSegments () const { return mMeshHeightSegments; }
00175
00176 private:
00178 std::auto_ptr<Ogre::Image> mCloudCoverLookup;
00179
00181 Ogre::String mCloudCoverLookupFileName;
00182
00184 Ogre::Real mCloudCover;
00185
00186 public:
00190 void setCloudCover (const Ogre::Real cloudCover);
00191
00195 inline Ogre::Real getCloudCover () const { return mCloudCover; }
00196
00209 void setCloudCoverLookup (const Ogre::String& fileName);
00210
00215 const Ogre::String getCloudCoverLookupFileName () const;
00216
00220 void disableCloudCoverLookup ();
00221
00222 private:
00223 Ogre::Real mCloudCoverVisibilityThreshold;
00224
00225 protected:
00228 void _updateVisibilityThreshold ();
00229
00230 public:
00233 Ogre::Real getCloudCoverVisibilityThreshold () const { return mCloudCoverVisibilityThreshold; }
00234
00241 void setCloudCoverVisibilityThreshold (const Ogre::Real value);
00242
00243 private:
00245 Ogre::Real mHeight;
00246
00247 public:
00251 void setHeight(Ogre::Real height);
00252
00256 Ogre::Real getHeight() const;
00257
00258 private:
00260 Ogre::Real mCloudBlendPos;
00261
00264 int mCurrentTextureIndex;
00265
00267 Ogre::Real mCloudBlendTime;
00268
00270 std::vector<String> mNoiseTextureNames;
00271
00272 public:
00277 void setCloudBlendTime (const Ogre::Real value);
00278
00282 Ogre::Real getCloudBlendTime () const;
00283
00289 void setCloudBlendPos (const Ogre::Real value);
00290
00292 Ogre::Real getCloudBlendPos () const;
00293
00294 private:
00295 Ogre::Real mCloudUVFactor;
00296
00297 public:
00302 void setCloudUVFactor (const Ogre::Real value);
00304 inline Ogre::Real getCloudUVFactor () const { return mCloudUVFactor; }
00305
00306 private:
00307 Ogre::Real mHeightRedFactor;
00308
00309 public:
00313 void setHeightRedFactor (const Ogre::Real value);
00315 Ogre::Real getHeightRedFactor () const { return mHeightRedFactor; }
00316
00317 private:
00318 Ogre::Real mNearFadeDist;
00319 Ogre::Real mFarFadeDist;
00320 Ogre::Vector3 mFadeDistMeasurementVector;
00321
00322 public:
00333 void setFadeDistances (Ogre::Real nearValue, Ogre::Real farValue);
00334
00336 void setNearFadeDist (const Ogre::Real value);
00338 Ogre::Real getNearFadeDist () const { return mNearFadeDist; }
00339
00341 void setFarFadeDist (const Ogre::Real value);
00343 Ogre::Real getFarFadeDist () const { return mFarFadeDist; }
00344
00354 void setFadeDistMeasurementVector (const Ogre::Vector3& value);
00356 const Ogre::Vector3 getFadeDistMeasurementVector () const { return mFadeDistMeasurementVector; }
00357
00358 public:
00359 void setQueryFlags (uint flags) { mEntity->setQueryFlags (flags); }
00360 uint getQueryFlags () const { return mEntity->getQueryFlags (); }
00361 void setVisibilityFlags (uint flags) { mEntity->setVisibilityFlags (flags); }
00362 uint getVisibilityFlags () const { return mEntity->getVisibilityFlags (); }
00363 };
00364 }
00365
00366 #endif // CAELUM__FLAT_CLOUD_LAYER_H