]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/cloud.hxx
Fix a bug in cloud texture state loading which caused the cloud textures to
[simgear.git] / simgear / scene / sky / cloud.hxx
1 // cloud.hxx -- model a single cloud layer
2 //
3 // Written by Curtis Olson, started June 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson  - curt@flightgear.org
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this library; if not, write to the
19 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 // Boston, MA  02111-1307, USA.
21 //
22 // $Id$
23
24
25 #ifndef _SG_CLOUD_HXX_
26 #define _SG_CLOUD_HXX_
27
28 #include <simgear/compiler.h>
29
30 #include <plib/ssg.h>
31
32 #include STL_STRING
33 SG_USING_STD(string);
34
35
36 class SGCloudLayer {
37
38 public:
39
40     enum Coverage {
41         SG_CLOUD_OVERCAST = 0,
42         SG_CLOUD_BROKEN,
43         SG_CLOUD_SCATTERED,
44         SG_CLOUD_FEW,
45         SG_CLOUD_CIRRUS,
46         SG_CLOUD_CLEAR,
47         SG_MAX_CLOUD_COVERAGES
48     };
49
50     // Constructors
51     SGCloudLayer( const string &tex_path );
52
53     // Destructor
54     ~SGCloudLayer( void );
55
56     float getSpan_m () const;
57     void setSpan_m (float span_m);
58
59     float getElevation_m () const;
60     void setElevation_m (float elevation_m);
61
62     float getThickness_m () const;
63     void setThickness_m (float thickness_m);
64
65     float getTransition_m () const;
66     void setTransition_m (float transition_m);
67
68     Coverage getCoverage () const;
69     void setCoverage (Coverage coverage);
70
71     // build the cloud object
72     void rebuild();
73
74     // repaint the cloud colors based on current value of sun_angle,
75     // sky, and fog colors.  This updates the color arrays for
76     // ssgVtxTable.
77     // sun angle in degrees relative to verticle
78     // 0 degrees = high noon
79     // 90 degrees = sun rise/set
80     // 180 degrees = darkest midnight
81     bool repaint( sgVec3 fog_color );
82
83     // reposition the cloud layer at the specified origin and
84     // orientation
85     // lon specifies a rotation about the Z axis
86     // lat specifies a rotation about the new Y axis
87     // spin specifies a rotation about the new Z axis (and orients the
88     // sunrise/set effects
89     bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt );
90
91     // draw the cloud layer
92     void draw();
93
94 private:
95
96     ssgRoot *layer_root;
97     ssgTransform *layer_transform;
98     ssgLeaf *layer[4];
99
100     ssgColourArray *cl[4]; 
101     ssgVertexArray *vl[4];
102     ssgTexCoordArray *tl[4];
103
104     // height above sea level (meters)
105     SGPath texture_path;
106     float layer_span;
107     float layer_asl;
108     float layer_thickness;
109     float layer_transition;
110     Coverage layer_coverage;
111     float scale;
112
113     // for handling texture coordinates to simulate cloud movement
114     // from winds, and to simulate the clouds being tied to ground
115     // position, not view position
116     // double xoff, yoff;
117     double last_lon, last_lat;
118
119 };
120
121
122 // make an ssgSimpleState for a cloud layer given the named texture
123 ssgSimpleState *sgCloudMakeState( const string &path );
124
125
126 #endif // _SG_CLOUD_HXX_