X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fsky%2Fcloud.hxx;h=81c9e038b624622ae3fa8a6c61e45cf834197ea1;hb=813b518b6f0c3e772fbd521d75106a650e69a084;hp=4fa8c795ffb50c90fc0fff395873cc4709dbf89a;hpb=a266790a2510e0681cec15f47d8a944b5278a67a;p=simgear.git diff --git a/simgear/scene/sky/cloud.hxx b/simgear/scene/sky/cloud.hxx index 4fa8c795..81c9e038 100644 --- a/simgear/scene/sky/cloud.hxx +++ b/simgear/scene/sky/cloud.hxx @@ -5,7 +5,7 @@ // Written by Curtis Olson, started June 2000. // -// Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org +// Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public @@ -17,10 +17,9 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Library General Public License for more details. // -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the -// Free Software Foundation, Inc., 59 Temple Place - Suite 330, -// Boston, MA 02111-1307, USA. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // // $Id$ @@ -29,21 +28,26 @@ #define _SG_CLOUD_HXX_ #include - -#include +#include +#include +#include #include STL_STRING SG_USING_STD(string); -// #include -// SG_USING_STD(cout); -// SG_USING_STD(endl); +#include +#include +#include +#include +#include +#include +class SGCloudField; /** * A class layer to model a single cloud layer */ -class SGCloudLayer { +class SGCloudLayer : public SGReferenced { public: /** @@ -143,6 +147,18 @@ public: /** get the cloud movement speed */ inline float getSpeed() { return speed; } + /** + * set the alpha component of the cloud base color. Normally this + * should be 1.0, but you can set it anywhere in the range of 0.0 + * to 1.0 to fade a cloud layer in or out. + * @param alpha cloud alpha value (0.0 to 1.0) + */ + inline void setAlpha( float alpha ) { + if ( alpha < 0.0 ) { alpha = 0.0; } + if ( alpha > 1.0 ) { alpha = 1.0; } + cloud_alpha = alpha; + } + /** build the cloud object */ void rebuild(); @@ -150,7 +166,7 @@ public: * repaint the cloud colors based on the specified fog_color * @param fog_color the fog color */ - bool repaint( sgVec3 fog_color ); + bool repaint( const SGVec3f& fog_color ); /** * reposition the cloud layer at the specified origin and @@ -163,21 +179,31 @@ public: * (and orients the sunrise/set effects) * @param dt the time elapsed since the last call */ - bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt, + bool reposition( const SGVec3f& p, const SGVec3f& up, + double lon, double lat, double alt, double dt = 0.0 ); - /** draw the cloud layer */ - void draw(); + osg::Switch* getNode() { return layer_root.get(); } + + static bool enable_bump_mapping; + /** return the 3D layer cloud associated with this 2D layer */ + SGCloudField *get_layer3D(void) { return layer3D; } +protected: + void setTextureOffset(const osg::Vec2& offset); private: - ssgRoot *layer_root; - ssgTransform *layer_transform; - ssgLeaf *layer[4]; + osg::ref_ptr layer_root; + osg::ref_ptr group_top, group_bottom; + osg::ref_ptr layer_transform; + osg::ref_ptr layer[4]; - ssgColourArray *cl[4]; - ssgVertexArray *vl[4]; - ssgTexCoordArray *tl[4]; + float cloud_alpha; // 1.0 = drawn fully, 0.0 faded out completely + + osg::ref_ptr cl[4]; + osg::ref_ptr vl[4]; + osg::ref_ptr tl[4]; + osg::ref_ptr tl2[4]; // height above sea level (meters) SGPath texture_path; @@ -194,13 +220,11 @@ private: // from winds, and to simulate the clouds being tied to ground // position, not view position // double xoff, yoff; - double last_lon, last_lat; - -}; + double last_lon, last_lat, last_course; + osg::Vec2 base; -// make an ssgSimpleState for a cloud layer given the named texture -ssgSimpleState *sgCloudMakeState( const string &path ); - + SGCloudField *layer3D; +}; #endif // _SG_CLOUD_HXX_