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 "ImageHelper.h"
00026 #include "OwnedPtr.h"
00027
00028 namespace Caelum
00029 {
00034 class CAELUM_EXPORT FlatCloudLayer
00035 {
00036 public:
00037 FlatCloudLayer(
00038 Ogre::SceneManager *sceneMgr,
00039 Ogre::SceneNode *cloudRoot);
00040
00041 ~FlatCloudLayer();
00042
00045 void update (
00046 Ogre::Real timePassed,
00047 const Ogre::Vector3 &sunDirection,
00048 const Ogre::ColourValue &sunLightColour,
00049 const Ogre::ColourValue &fogColour,
00050 const Ogre::ColourValue &sunSphereColour);
00051
00054 void reset ();
00055
00056 private:
00057 Ogre::Real mHeight;
00058 Ogre::Real mCloudCover;
00059
00060 Ogre::Vector2 mCloudSpeed;
00061 Ogre::Vector2 mCloudMassOffset;
00062 Ogre::Vector2 mCloudDetailOffset;
00063
00065 Ogre::Real mCloudBlendPos;
00068 int mCurrentTextureIndex;
00069
00071 Ogre::Real mCloudBlendTime;
00072
00073 std::vector<String> mNoiseTextureNames;
00074
00076 std::auto_ptr<Ogre::Image> mCloudCoverLookup;
00077
00078 Ogre::GpuProgramParametersSharedPtr getVpParams();
00079 Ogre::GpuProgramParametersSharedPtr getFpParams();
00080
00081
00082 void setCloudMassOffset(const Ogre::Vector2 &cloudMassOffset);
00083 void setCloudDetailOffset(const Ogre::Vector2 &cloudDetailOffset);
00084 void setSunDirection(const Ogre::Vector3 &sunDirection);
00085 void setSunLightColour(const Ogre::ColourValue &sunLightColour);
00086 void setSunSphereColour(const Ogre::ColourValue &sunSphereColour);
00087 void setFogColour(const Ogre::ColourValue &fogColour);
00088
00089 private:
00090 Ogre::SceneManager *mSceneMgr;
00091
00092
00093
00094 OwnedMaterialPtr mMaterial;
00095 OwnedMeshPtr mMesh;
00096 SceneNodePtr mNode;
00097 EntityPtr mEntity;
00098
00099
00100 bool mMeshDirty;
00101 Real mMeshWidth, mMeshHeight;
00102 int mMeshWidthSegments, mMeshHeightSegments;
00103
00104 public:
00108 void _ensureGeometry();
00109
00113 void _invalidateGeometry();
00114
00117 void setMeshParameters (
00118 Real meshWidth, Real meshHeight,
00119 int meshWidthSegments, int meshHeightSegments);
00120
00122 inline void setMeshWidth (Real value) { mMeshWidth = value; _invalidateGeometry (); }
00123 inline void setMeshHeight (Real value) { mMeshHeight = value; _invalidateGeometry (); }
00124 inline void setMeshWidthSegments (int value) { mMeshWidthSegments = value; _invalidateGeometry (); }
00125 inline void setMeshHeightSegments (int value) { mMeshHeightSegments = value; _invalidateGeometry (); }
00126 inline Real getMeshWidth () const { return mMeshWidth; }
00127 inline Real getMeshHeight () const { return mMeshHeight; }
00128 inline int getMeshWidthSegments () const { return mMeshWidthSegments; }
00129 inline int getMeshHeightSegments () const { return mMeshHeightSegments; }
00130
00131 public:
00135 void setHeight(Ogre::Real height);
00136
00140 Ogre::Real getHeight() const;
00141
00145 void setCloudSpeed (const Ogre::Vector2 &cloudSpeed);
00146
00150 const Ogre::Vector2 getCloudSpeed () const { return mCloudSpeed; }
00151
00155 void setCloudCover (const Ogre::Real cloudCover);
00156
00160 inline Ogre::Real getCloudCover () const { return mCloudCover; }
00161
00174 void setCloudCoverLookup (const Ogre::String& fileName);
00175
00179 void disableCloudCoverLookup ();
00180
00185 void setCloudBlendTime (const Ogre::Real value);
00186
00190 Ogre::Real getCloudBlendTime () const;
00191
00197 void setCloudBlendPos (const Ogre::Real value);
00198
00200 Ogre::Real getCloudBlendPos () const;
00201
00202 private:
00203 Ogre::Real mCloudUVFactor;
00204 Ogre::Real mHeightRedFactor;
00205
00206 public:
00211 void setCloudUVFactor (const Ogre::Real value);
00213 inline Ogre::Real getCloudUVFactor () const { return mCloudUVFactor; }
00214
00218 void setHeightRedFactor (const Ogre::Real value);
00220 Ogre::Real getHeightRedFactor () const { return mHeightRedFactor; }
00221
00222 private:
00223 Ogre::Real mNearFadeDist;
00224 Ogre::Real mFarFadeDist;
00225
00226 public:
00237 void setFadeDistances (Ogre::Real nearValue, Ogre::Real farValue);
00238
00239 void setNearFadeDist (const Ogre::Real value);
00240 Ogre::Real getNearFadeDist () const { return mNearFadeDist; }
00241
00242 void setFarFadeDist (const Ogre::Real value);
00243 Ogre::Real getFarFadeDist () const { return mFarFadeDist; }
00244
00245 public:
00246 void setQueryFlags (uint flags) { mEntity->setQueryFlags (flags); }
00247 uint getQueryFlags () const { return mEntity->getQueryFlags (); }
00248 void setVisibilityFlags (uint flags) { mEntity->setVisibilityFlags (flags); }
00249 uint getVisibilityFlags () const { return mEntity->getVisibilityFlags (); }
00250 };
00251 }
00252
00253 #endif // CAELUM__FLAT_CLOUD_LAYER_H