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