3 * Provides a class to model a single cloud layer
6 // Written by Curtis Olson, started June 2000.
8 // Copyright (C) 2000 Curtis L. Olson - http://www.flightgear.org/~curt
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Library General Public
12 // License as published by the Free Software Foundation; either
13 // version 2 of the License, or (at your option) any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Library General Public License for more details.
20 // You should have received a copy of the GNU Library General Public
21 // License along with this library; if not, write to the
22 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 // Boston, MA 02111-1307, USA.
28 #ifndef _SG_CLOUD_HXX_
29 #define _SG_CLOUD_HXX_
31 #include <simgear/compiler.h>
38 // #include <iostream>
39 // SG_USING_STD(cout);
40 // SG_USING_STD(endl);
44 * A class layer to model a single cloud layer
50 * This is the list of available cloud coverages/textures
53 SG_CLOUD_OVERCAST = 0,
59 SG_MAX_CLOUD_COVERAGES
64 * @param tex_path the path to the set of cloud textures
66 SGCloudLayer( const string &tex_path );
71 ~SGCloudLayer( void );
73 /** get the cloud span (in meters) */
74 float getSpan_m () const;
77 * @param span_m the cloud span in meters
79 void setSpan_m (float span_m);
81 /** get the layer elevation (in meters) */
82 float getElevation_m () const;
84 * set the layer elevation. Note that this specifies the bottom
85 * of the cloud layer. The elevation of the top of the layer is
86 * elevation_m + thickness_m.
87 * @param elevation_m the layer elevation in meters
88 * @param set_span defines whether it is allowed to adjust the span
90 void setElevation_m (float elevation_m, bool set_span = true);
92 /** get the layer thickness */
93 float getThickness_m () const;
95 * set the layer thickness.
96 * @param thickness_m the layer thickness in meters.
98 void setThickness_m (float thickness_m);
101 * get the transition/boundary layer depth in meters. This
102 * allows gradual entry/exit from the cloud layer via adjusting
105 float getTransition_m () const;
108 * set the transition layer size in meters
109 * @param transition_m the transition layer size in meters
111 void setTransition_m (float transition_m);
113 /** get coverage type */
114 Coverage getCoverage () const;
118 * @param coverage the coverage type
120 void setCoverage (Coverage coverage);
123 * set the cloud movement direction
124 * @param dir the cloud movement direction
126 inline void setDirection(float dir) {
127 // cout << "cloud dir = " << dir << endl;
131 /** get the cloud movement direction */
132 inline float getDirection() { return direction; }
135 * set the cloud movement speed
136 * @param sp the cloud movement speed
138 inline void setSpeed(float sp) {
139 // cout << "cloud speed = " << sp << endl;
143 /** get the cloud movement speed */
144 inline float getSpeed() { return speed; }
147 * set the alpha component of the cloud base color. Normally this
148 * should be 1.0, but you can set it anywhere in the range of 0.0
149 * to 1.0 to fade a cloud layer in or out.
150 * @param alpha cloud alpha value (0.0 to 1.0)
152 inline void setAlpha( float alpha ) {
153 if ( alpha < 0.0 ) { alpha = 0.0; }
154 if ( alpha > 1.0 ) { alpha = 1.0; }
158 /** build the cloud object */
162 * repaint the cloud colors based on the specified fog_color
163 * @param fog_color the fog color
165 bool repaint( sgVec3 fog_color );
168 * reposition the cloud layer at the specified origin and
170 * @param p position vector
171 * @param up the local up vector
172 * @param lon specifies a rotation about the Z axis
173 * @param lat specifies a rotation about the new Y axis
174 * @param spin specifies a rotation about the new Z axis
175 * (and orients the sunrise/set effects)
176 * @param dt the time elapsed since the last call
178 bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt,
181 /** draw the cloud layer */
182 void draw( bool top );
184 static bool enable_bump_mapping;
191 sgVec3 tangentSpLight;
198 CloudVertex *vertices;
199 unsigned int *indices;
202 ssgTransform *layer_transform;
204 ssgStateSelector *state_sel;
206 float cloud_alpha; // 1.0 = drawn fully, 0.0 faded out completely
208 ssgColourArray *cl[4];
209 ssgVertexArray *vl[4];
210 ssgTexCoordArray *tl[4];
212 // height above sea level (meters)
216 float layer_thickness;
217 float layer_transition;
218 Coverage layer_coverage;
223 // for handling texture coordinates to simulate cloud movement
224 // from winds, and to simulate the clouds being tied to ground
225 // position, not view position
226 // double xoff, yoff;
227 double last_lon, last_lat, last_course;
231 // make an ssgSimpleState for a cloud layer given the named texture
232 ssgSimpleState *sgCloudMakeState( const string &path );
235 #endif // _SG_CLOUD_HXX_