]> git.mxchange.org Git - simgear.git/blob - simgear/sky/cloud.hxx
5f7258e73819a6f68c310f66937645d1c5359d98
[simgear.git] / simgear / 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 #define SG_MAX_CLOUD_TYPES 4    // change this if we add/remove cloud
37                                 // types en the enum below
38
39 enum SGCloudType {
40     SG_CLOUD_OVERCAST = 0,
41     SG_CLOUD_MOSTLY_CLOUDY,
42     SG_CLOUD_MOSTLY_SUNNY,
43     SG_CLOUD_CIRRUS
44 };
45
46
47 class SGCloudLayer {
48
49 private:
50
51     ssgRoot *layer_root;
52     ssgTransform *layer_transform;
53     ssgSimpleState *layer_state;
54
55     ssgColourArray *cl; 
56     ssgVertexArray *vl;
57     ssgTexCoordArray *tl;
58
59     // height above sea level (meters)
60     float layer_asl;
61     float layer_thickness;
62     float layer_transition;
63     float size;
64     float scale;
65
66     // for handling texture coordinates to simulate cloud movement
67     // from winds, and to simulate the clouds being tied to ground
68     // position, not view position
69     // double xoff, yoff;
70     double last_lon, last_lat;
71
72 public:
73
74     // Constructor
75     SGCloudLayer( void );
76
77     // Destructor
78     ~SGCloudLayer( void );
79
80     // build the cloud object
81     void build( double size, double asl, double thickness,
82                 double transition, ssgSimpleState *state );
83
84     // repaint the cloud colors based on current value of sun_angle,
85     // sky, and fog colors.  This updates the color arrays for
86     // ssgVtxTable.
87     // sun angle in degrees relative to verticle
88     // 0 degrees = high noon
89     // 90 degrees = sun rise/set
90     // 180 degrees = darkest midnight
91     bool repaint( sgVec3 fog_color );
92
93     // reposition the cloud layer at the specified origin and
94     // orientation
95     // lon specifies a rotation about the Z axis
96     // lat specifies a rotation about the new Y axis
97     // spin specifies a rotation about the new Z axis (and orients the
98     // sunrise/set effects
99     bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt );
100
101     // draw the cloud layer
102     void draw();
103
104     inline float get_asl() const { return layer_asl; }
105     inline float get_thickness() const { return layer_thickness; }
106     inline float get_transition() const { return layer_transition; }
107 };
108
109
110 // make an ssgSimpleState for a cloud layer given the named texture
111 ssgSimpleState *SGCloudMakeState( const string &path );
112
113
114 #endif // _SG_CLOUD_HXX_