00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _SG_SKY_HXX
00029 #define _SG_SKY_HXX
00030
00031
00032 #ifndef __cplusplus
00033 # error This library requires C++
00034 #endif
00035
00036 #include <simgear/compiler.h>
00037 #include <simgear/misc/sg_path.hxx>
00038 #include <simgear/props/props.hxx>
00039
00040 #include <vector>
00041
00042 #include <osg/ref_ptr>
00043 #include <osg/MatrixTransform>
00044 #include <osg/Node>
00045 #include <osg/Switch>
00046
00047 #include <simgear/ephemeris/ephemeris.hxx>
00048 #include <simgear/math/SGMath.hxx>
00049
00050 #include <simgear/scene/sky/cloud.hxx>
00051 #include <simgear/scene/sky/dome.hxx>
00052 #include <simgear/scene/sky/moon.hxx>
00053 #include <simgear/scene/sky/oursun.hxx>
00054 #include <simgear/scene/sky/stars.hxx>
00055
00056 using std::vector;
00057
00058
00059 typedef struct {
00060 SGVec3d pos;
00061 SGGeod pos_geod;
00062 SGQuatd ori;
00063 double spin;
00064 double gst;
00065 double sun_dist;
00066 double moon_dist;
00067 double sun_angle;
00068 } SGSkyState;
00069
00070 typedef struct {
00071 SGVec3f sky_color;
00072 SGVec3f adj_sky_color;
00073 SGVec3f fog_color;
00074 SGVec3f cloud_color;
00075 double sun_angle, moon_angle;
00076 } SGSkyColor;
00077
00209 class SGSky {
00210
00211 private:
00212 typedef std::vector<SGSharedPtr<SGCloudLayer> > layer_list_type;
00213 typedef layer_list_type::iterator layer_list_iterator;
00214 typedef layer_list_type::const_iterator layer_list_const_iterator;
00215
00216
00217 SGSharedPtr<SGSkyDome> dome;
00218 SGSharedPtr<SGSun> oursun;
00219 SGSharedPtr<SGMoon> moon;
00220 SGSharedPtr<SGStars> planets;
00221 SGSharedPtr<SGStars> stars;
00222 layer_list_type cloud_layers;
00223
00224 osg::ref_ptr<osg::Group> pre_root, cloud_root;
00225 osg::ref_ptr<osg::Switch> pre_selector;
00226 osg::ref_ptr<osg::Group> pre_transform;
00227
00228 osg::ref_ptr<osg::MatrixTransform> _ephTransform;
00229
00230 SGPath tex_path;
00231
00232
00233 float visibility;
00234 float effective_visibility;
00235
00236 int in_cloud;
00237 int cur_layer_pos;
00238
00239
00240 bool in_puff;
00241 double puff_length;
00242 double puff_progression;
00243 double ramp_up;
00244 double ramp_down;
00245
00246
00247 bool clouds_3d_enabled;
00248
00249
00250 double clouds_3d_density;
00251
00252 public:
00253
00255 SGSky( void );
00256
00258 ~SGSky( void );
00259
00275 void build( double h_radius_m, double v_radius_m,
00276 double sun_size, double moon_size,
00277 const SGEphemeris& eph, SGPropertyNode *property_tree_node );
00278
00303 bool repaint( const SGSkyColor &sc, const SGEphemeris& eph );
00304
00333 bool reposition( const SGSkyState &st, const SGEphemeris& eph, double dt = 0.0 );
00334
00343 void modify_vis( float alt, float time_factor );
00344
00345 osg::Node* getPreRoot() { return pre_root.get(); }
00346 osg::Node* getCloudRoot() { return cloud_root.get(); }
00347
00352 void texture_path( const string& path );
00353
00355 inline void enable() {
00356 pre_selector->setValue(0, 1);
00357 }
00358
00363 inline void disable() {
00364 pre_selector->setValue(0, 0);
00365 }
00366
00370 inline SGVec4f get_sun_color() { return oursun->get_color(); }
00371
00375 inline SGVec4f get_scene_color() { return oursun->get_scene_color(); }
00376
00384 void add_cloud_layer (SGCloudLayer * layer);
00385
00386
00395 const SGCloudLayer * get_cloud_layer (int i) const;
00396
00397
00406 SGCloudLayer * get_cloud_layer (int i);
00407
00408
00414 int get_cloud_layer_count () const;
00415
00416
00418 inline float get_visibility() const { return effective_visibility; }
00419
00423 inline void set_visibility( float v ) {
00424 effective_visibility = visibility = (v <= 25.0) ? 25.0 : v;
00425 }
00426
00428 virtual double get_3dCloudDensity() const;
00429
00433 virtual void set_3dCloudDensity(double density);
00434
00436 virtual float get_3dCloudVisRange() const;
00437
00441 virtual void set_3dCloudVisRange(float vis);
00442
00443 };
00444
00445
00446 #endif // _SG_SKY_HXX