]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/cloudfield.hxx
Remove an extern SGSky *thesky reference that isn't used in the code anyway.
[simgear.git] / simgear / scene / sky / cloudfield.hxx
1 // a layer of 3d clouds
2 //
3 // Written by Harald JOHNSEN, started April 2005.
4 //
5 // Copyright (C) 2005  Harald JOHNSEN - hjohnsen@evc.net
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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 //
22
23 #ifndef _CLOUDFIELD_HXX
24 #define _CLOUDFIELD_HXX
25
26 #include <plib/sg.h>
27 #include <simgear/compiler.h>
28 #include <vector>
29
30
31 SG_USING_STD(vector);
32
33 class SGNewCloud;
34
35 class culledCloud {
36 public:
37         SGNewCloud      *aCloud;
38         sgVec3          eyePos;
39         float           dist;
40         float           heading;
41         float           alt;
42         bool operator<(const culledCloud &b) const {
43                 return (this->dist < b.dist);
44         }
45 };
46 typedef vector<culledCloud> list_of_culledCloud;
47
48 /**
49  * A layer of 3D clouds.
50  */
51 class SGCloudField {
52
53 private:
54         class Cloud  {
55         public:
56                 SGNewCloud      *aCloud;
57                 sgVec3          pos;
58                 bool            visible;
59         };
60
61
62         typedef vector<Cloud> list_of_Cloud;
63
64         // cull all clouds of a tiled field
65         void cullClouds(sgVec3 eyePos, sgMat4 mat);
66
67         void applyDensity(void);
68
69         list_of_Cloud theField;
70         // this is a relative position only, with that we can move all clouds at once
71         sgVec3 relative_position;
72 //      double lon, lat;
73
74         sgFrustum frustum;
75
76         sgMat4 transform;
77         double deltax, deltay, alt;
78     double last_lon, last_lat, last_course;
79     sgSphere field_sphere;
80         float   last_density;
81         bool    draw_in_3d;
82
83 public:
84
85         SGCloudField();
86         ~SGCloudField();
87
88         void clear(void);
89
90         // add one cloud, data is not copied, ownership given
91         void addCloud( sgVec3 pos, SGNewCloud *cloud);
92
93         // for debug only
94         void buildTestLayer(void);
95
96         // Render a cloud field
97         void Render( float *sun_color );
98
99         // reposition the cloud layer at the specified origin and orientation
100         void reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double dt, float direction, float speed);
101
102         bool is3D(void) { return draw_in_3d; }
103
104         // visibility distance for clouds in meters
105         static float CloudVis;
106
107         static sgVec3 view_vec, view_X, view_Y;
108
109         static float density;
110         static double timer_dt;
111         static double fieldSize;
112         static bool enable3D;
113
114         // return the size of the memory pool used by texture impostors
115         static int get_CacheSize(void);
116         static int get_CacheResolution(void);
117         static float get_CloudVis(void) { return CloudVis; }
118         static float get_density(void) { return density; }
119         static bool get_enable3dClouds(void) { return enable3D; }
120
121         static void set_CacheSize(int sizeKb);
122         static void set_CacheResolution(int resolutionPixels);
123         static void set_CloudVis(float distance);
124         static void set_density(float density);
125         static void set_enable3dClouds(bool enable);
126 };
127
128 #endif // _CLOUDFIELD_HXX