# error This library requires C++
#endif
-
-#include <plib/ssg.h> // plib include
-
#include <simgear/compiler.h>
#include <simgear/misc/sg_path.hxx>
+#include <simgear/props/props.hxx>
#include <vector>
+#include <osg/ref_ptr>
+#include <osg/MatrixTransform>
+#include <osg/Node>
+#include <osg/Switch>
+
+#include <simgear/ephemeris/ephemeris.hxx>
+#include <simgear/math/SGMath.hxx>
+
#include <simgear/scene/sky/cloud.hxx>
#include <simgear/scene/sky/dome.hxx>
#include <simgear/scene/sky/moon.hxx>
#include <simgear/scene/sky/oursun.hxx>
#include <simgear/scene/sky/stars.hxx>
-SG_USING_STD(vector);
+using std::vector;
-typedef vector < SGCloudLayer* > layer_list_type;
-typedef layer_list_type::iterator layer_list_iterator;
-typedef layer_list_type::const_iterator layer_list_const_iterator;
-
typedef struct {
- float *view_pos, *zero_elev, *view_up;
- double lon, lat, alt, spin;
+ SGVec3d pos;
+ SGGeod pos_geod;
+ SGQuatd ori;
+ double spin;
double gst;
- double sun_ra, sun_dec, sun_dist;
- double moon_ra, moon_dec, moon_dist;
+ double sun_dist;
+ double moon_dist;
+ double sun_angle;
} SGSkyState;
typedef struct {
- float *sky_color, *fog_color, *cloud_color;
+ SGVec3f sky_color;
+ SGVec3f adj_sky_color;
+ SGVec3f fog_color;
+ SGVec3f cloud_color;
double sun_angle, moon_angle;
- int nplanets, nstars;
- sgdVec3 *planet_data, *star_data;
} SGSkyColor;
/**
class SGSky {
private:
+ typedef std::vector<SGSharedPtr<SGCloudLayer> > layer_list_type;
+ typedef layer_list_type::iterator layer_list_iterator;
+ typedef layer_list_type::const_iterator layer_list_const_iterator;
// components of the sky
- SGSkyDome *dome;
- SGSun *oursun;
- SGMoon *moon;
- SGStars *planets;
- SGStars *stars;
+ SGSharedPtr<SGSkyDome> dome;
+ SGSharedPtr<SGSun> oursun;
+ SGSharedPtr<SGMoon> moon;
+ SGSharedPtr<SGStars> planets;
+ SGSharedPtr<SGStars> stars;
layer_list_type cloud_layers;
- ssgRoot *pre_root, *post_root;
+ osg::ref_ptr<osg::Group> pre_root, cloud_root;
+ osg::ref_ptr<osg::Switch> pre_selector;
+ osg::ref_ptr<osg::Group> pre_transform;
- ssgSelector *pre_selector, *post_selector;
- ssgTransform *pre_transform, *post_transform;
+ osg::ref_ptr<osg::MatrixTransform> _ephTransform;
SGPath tex_path;
double ramp_up; // in seconds
double ramp_down; // in seconds
+ // 3D clouds enabled
+ bool clouds_3d_enabled;
+
+ // 3D cloud density
+ double clouds_3d_density;
+
public:
/** Constructor */
*/
void build( double h_radius_m, double v_radius_m,
double sun_size, double moon_size,
- int nplanets, sgdVec3 *planet_data,
- int nstars, sgdVec3 *star_data );
+ const SGEphemeris& eph, SGPropertyNode *property_tree_node );
/**
* Repaint the sky components based on current value of sun_angle,
* @param star_data an array of star right ascensions, declinations,
* and magnitudes
*/
- bool repaint( const SGSkyColor &sc );
+ bool repaint( const SGSkyColor &sc, const SGEphemeris& eph );
/**
* Reposition the sky at the specified origin and orientation
* @param moon_dec the moon's current declination
* @param moon_dist the moon's distance from the current view point.
*/
- bool reposition( SGSkyState &st, double dt = 0.0 );
+ bool reposition( const SGSkyState &st, const SGEphemeris& eph, double dt = 0.0 );
/**
* Modify the given visibility based on cloud layers, thickness,
*/
void modify_vis( float alt, float time_factor );
- /**
- * Draw background portions of the sky ... do this before you draw
- * the rest of your scene. See discussion in detailed
- * class description.
- * @param alt current altitude
- */
- void preDraw( float alt, float fog_exp2_density );
-
- /**
- * Draw upper translucent clouds ... do this before you've drawn
- * all the translucent elements of your scene. See discussion in
- * detailed class description.
- * @param fog_exp2_density fog density of the current cloud layer
- */
- void drawUpperClouds();
-
- /**
- * Draw lower translucent clouds ... do this after you've drawn
- * all the opaque elements of your scene. See discussion in detailed
- * class description.
- */
- void drawLowerClouds();
+ osg::Node* getPreRoot() { return pre_root.get(); }
+ osg::Node* getCloudRoot() { return cloud_root.get(); }
/**
* Specify the texture path (optional, defaults to current directory)
* @param path base path to texture locations
*/
- inline void texture_path( const string& path ) {
- tex_path = SGPath( path );
- }
+ void texture_path( const string& path );
/** Enable drawing of the sky. */
inline void enable() {
- pre_selector->select( 1 );
- post_selector->select( 1 );
+ pre_selector->setValue(0, 1);
}
/**
* there, how ever it won't be traversed on by ssgCullandRender()
*/
inline void disable() {
- pre_selector->select( 0 );
- post_selector->select( 0 );
+ pre_selector->setValue(0, 0);
}
-
/**
* Get the current sun color
*/
- inline float *get_sun_color() { return oursun->get_color(); }
+ inline SGVec4f get_sun_color() { return oursun->get_color(); }
/**
- * Get the sun halo texture handle
+ * Get the current scene color
*/
- inline GLuint get_sun_texture_id() { return oursun->get_texture_id(); }
-
+ inline SGVec4f get_scene_color() { return oursun->get_scene_color(); }
/**
* Add a cloud layer.
inline void set_visibility( float v ) {
effective_visibility = visibility = (v <= 25.0) ? 25.0 : v;
}
+
+ /** Get 3D cloud density */
+ virtual double get_3dCloudDensity() const;
+
+ /** Set 3D cloud density
+ * @param density 3D cloud density
+ */
+ virtual void set_3dCloudDensity(double density);
+
+ /** Get 3D cloud visibility range*/
+ virtual float get_3dCloudVisRange() const;
+
+ /** Set 3D cloud visibility range
+ * @param density 3D cloud visibility range
+ */
+ virtual void set_3dCloudVisRange(float vis);
+
};