00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _SG_CLOUD_HXX_
00028 #define _SG_CLOUD_HXX_
00029
00030 #include <simgear/compiler.h>
00031 #include <simgear/misc/sg_path.hxx>
00032 #include <simgear/math/SGMath.hxx>
00033 #include <simgear/structure/SGReferenced.hxx>
00034
00035 #include <string>
00036 using std::string;
00037
00038 #include <osg/ref_ptr>
00039 #include <osg/Array>
00040 #include <osg/Geode>
00041 #include <osg/Group>
00042 #include <osg/MatrixTransform>
00043 #include <osg/Switch>
00044
00045 class SGCloudField;
00046
00050 class SGCloudLayer : public SGReferenced {
00051 public:
00052
00056 enum Coverage {
00057 SG_CLOUD_OVERCAST = 0,
00058 SG_CLOUD_BROKEN,
00059 SG_CLOUD_SCATTERED,
00060 SG_CLOUD_FEW,
00061 SG_CLOUD_CIRRUS,
00062 SG_CLOUD_CLEAR,
00063 SG_MAX_CLOUD_COVERAGES
00064 };
00065
00070 SGCloudLayer( const string &tex_path );
00071
00075 ~SGCloudLayer( void );
00076
00078 float getSpan_m () const;
00083 void setSpan_m (float span_m);
00084
00086 float getElevation_m () const;
00094 void setElevation_m (float elevation_m, bool set_span = true);
00095
00097 float getThickness_m () const;
00102 void setThickness_m (float thickness_m);
00103
00109 float getTransition_m () const;
00110
00115 void setTransition_m (float transition_m);
00116
00118 Coverage getCoverage () const;
00119
00124 void setCoverage (Coverage coverage);
00125
00130 inline void setDirection(float dir) {
00131
00132 direction = dir;
00133 }
00134
00136 inline float getDirection() { return direction; }
00137
00142 inline void setSpeed(float sp) {
00143
00144 speed = sp;
00145 }
00146
00148 inline float getSpeed() { return speed; }
00149
00156 inline void setAlpha( float alpha ) {
00157 if ( alpha < 0.0 ) { alpha = 0.0; }
00158 if ( alpha > 1.0 ) { alpha = 1.0; }
00159 cloud_alpha = alpha;
00160 }
00161
00163 void rebuild();
00164
00166 void set_enable3dClouds(bool enable);
00167
00172 bool repaint( const SGVec3f& fog_color );
00173
00185 bool reposition( const SGVec3f& p, const SGVec3f& up,
00186 double lon, double lat, double alt,
00187 double dt = 0.0 );
00188
00189 osg::Switch* getNode() { return cloud_root.get(); }
00190
00191 static bool enable_bump_mapping;
00192
00194 SGCloudField *get_layer3D(void) { return layer3D; }
00195
00196 protected:
00197 void setTextureOffset(const osg::Vec2& offset);
00198 private:
00199
00200 osg::ref_ptr<osg::Switch> cloud_root;
00201 osg::ref_ptr<osg::Switch> layer_root;
00202 osg::ref_ptr<osg::Group> group_top, group_bottom;
00203 osg::ref_ptr<osg::MatrixTransform> layer_transform;
00204 osg::ref_ptr<osg::Geode> layer[4];
00205
00206 float cloud_alpha;
00207
00208 osg::ref_ptr<osg::Vec4Array> cl[4];
00209 osg::ref_ptr<osg::Vec3Array> vl[4];
00210 osg::ref_ptr<osg::Vec2Array> tl[4];
00211 osg::ref_ptr<osg::Vec3Array> tl2[4];
00212
00213
00214 SGPath texture_path;
00215 float layer_span;
00216 float layer_asl;
00217 float layer_thickness;
00218 float layer_transition;
00219 Coverage layer_coverage;
00220 float scale;
00221 float speed;
00222 float direction;
00223
00224
00225
00226
00227
00228 double last_lon, last_lat, last_course;
00229
00230 osg::Vec2 base;
00231
00232 SGCloudField *layer3D;
00233
00234 };
00235
00236 #endif // _SG_CLOUD_HXX_