]> git.mxchange.org Git - simgear.git/blob - simgear/sky/cloud.hxx
Collapsed the init() method into the constructor.
[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 program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifndef _SG_CLOUD_HXX_
25 #define _SG_CLOUD_HXX_
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <simgear/compiler.h>
32
33 #include <plib/ssg.h>
34
35 #include STL_STRING
36 FG_USING_STD(string);
37
38
39 #define SG_MAX_CLOUD_TYPES 4    // change this if we add/remove cloud
40                                 // types en the enum below
41
42 enum SGCloudType {
43     SG_CLOUD_OVERCAST = 0,
44     SG_CLOUD_MOSTLY_CLOUDY = 1,
45     SG_CLOUD_MOSTLY_SUNNY = 2,
46     SG_CLOUD_CIRRUS = 3,
47 };
48
49
50 class SGCloudLayer {
51
52 private:
53
54     ssgRoot *layer_root;
55     ssgTransform *layer_transform;
56     ssgSimpleState *layer_state;
57
58     ssgColourArray *cl; 
59     ssgVertexArray *vl;
60     ssgTexCoordArray *tl;
61
62     // height above sea level (meters)
63     float layer_asl;
64     float layer_thickness;
65     float layer_transition;
66     float size;
67     float scale;
68
69     // for handling texture coordinates to simulate cloud movement
70     // from winds, and to simulate the clouds being tied to ground
71     // position, not view position
72     // double xoff, yoff;
73     double last_lon, last_lat;
74
75 public:
76
77     // Constructor
78     SGCloudLayer( void );
79
80     // Destructor
81     ~SGCloudLayer( void );
82
83     // build the cloud object
84     void build( double size, double asl, double thickness,
85                 double transition, ssgSimpleState *state );
86
87     // repaint the cloud colors based on current value of sun_angle,
88     // sky, and fog colors.  This updates the color arrays for
89     // ssgVtxTable.
90     // sun angle in degrees relative to verticle
91     // 0 degrees = high noon
92     // 90 degrees = sun rise/set
93     // 180 degrees = darkest midnight
94     bool repaint( sgVec3 fog_color );
95
96     // reposition the cloud layer at the specified origin and
97     // orientation
98     // lon specifies a rotation about the Z axis
99     // lat specifies a rotation about the new Y axis
100     // spin specifies a rotation about the new Z axis (and orients the
101     // sunrise/set effects
102     bool reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt );
103
104     // draw the cloud layer
105     void draw();
106
107     inline float get_asl() const { return layer_asl; }
108     inline float get_thickness() const { return layer_thickness; }
109     inline float get_transition() const { return layer_transition; }
110 };
111
112
113 // make an ssgSimpleState for a cloud layer given the named texture
114 ssgSimpleState *SGCloudMakeState( const string &path );
115
116
117 #endif // _SG_CLOUD_HXX_