X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fscene%2Fsky%2Fcloud.hxx;h=6a179d9f768719ef2d8d7ac67564d419ad089e3d;hb=68eb7031e2dce999d112d0164fa28d4b8d66922e;hp=3853aeb36032e79c2218549dfa241d38b741fe48;hpb=70f763dbe049b5e52197aece1796b898aa3e3340;p=simgear.git diff --git a/simgear/scene/sky/cloud.hxx b/simgear/scene/sky/cloud.hxx index 3853aeb3..6a179d9f 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 @@ -35,6 +35,11 @@ #include STL_STRING SG_USING_STD(string); +// #include +// SG_USING_STD(cout); +// SG_USING_STD(endl); + +class SGCloudField; /** * A class layer to model a single cloud layer @@ -81,8 +86,9 @@ public: * of the cloud layer. The elevation of the top of the layer is * elevation_m + thickness_m. * @param elevation_m the layer elevation in meters + * @param set_span defines whether it is allowed to adjust the span */ - void setElevation_m (float elevation_m); + void setElevation_m (float elevation_m, bool set_span = true); /** get the layer thickness */ float getThickness_m () const; @@ -98,6 +104,7 @@ public: * visibility. */ float getTransition_m () const; + /** * set the transition layer size in meters * @param transition_m the transition layer size in meters @@ -106,12 +113,49 @@ public: /** get coverage type */ Coverage getCoverage () const; + /** * set coverage type * @param coverage the coverage type */ void setCoverage (Coverage coverage); + /** + * set the cloud movement direction + * @param dir the cloud movement direction + */ + inline void setDirection(float dir) { + // cout << "cloud dir = " << dir << endl; + direction = dir; + } + + /** get the cloud movement direction */ + inline float getDirection() { return direction; } + + /** + * set the cloud movement speed + * @param sp the cloud movement speed + */ + inline void setSpeed(float sp) { + // cout << "cloud speed = " << sp << endl; + speed = sp; + } + + /** 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(); @@ -130,17 +174,40 @@ public: * @param lat specifies a rotation about the new Y axis * @param spin specifies a rotation about the new Z axis * (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( sgVec3 p, sgVec3 up, double lon, double lat, double alt, + double dt = 0.0 ); /** draw the cloud layer */ - void draw(); + void draw( bool top ); + + static bool enable_bump_mapping; + + /** return the 3D layer cloud associated with this 2D layer */ + SGCloudField *get_layer3D(void) { return layer3D; } private: + struct CloudVertex { + sgVec3 position; + sgVec2 texCoord; + sgVec3 tangentSpLight; + sgVec3 sTangent; + sgVec3 tTangent; + sgVec3 normal; + sgVec4 color; + }; + + CloudVertex *vertices; + unsigned int *indices; + ssgRoot *layer_root; ssgTransform *layer_transform; ssgLeaf *layer[4]; + ssgStateSelector *state_sel; + + float cloud_alpha; // 1.0 = drawn fully, 0.0 faded out completely ssgColourArray *cl[4]; ssgVertexArray *vl[4]; @@ -154,13 +221,16 @@ private: float layer_transition; Coverage layer_coverage; float scale; + float speed; + float direction; // for handling texture coordinates to simulate cloud movement // 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; + SGCloudField *layer3D; };