]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/cloudfield.hxx
Solaris fix.
[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, 59 Temple Place, Suite 330, Boston, MA 02111-1307, 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         bool operator<(const culledCloud &b) const {
41                 return this->dist < b.dist;
42         }
43 };
44 typedef vector<culledCloud> list_of_culledCloud;
45
46 class SGCloudField {
47
48 private:
49         class Cloud  {
50         public:
51                 SGNewCloud      *aCloud;
52                 sgVec3          pos;
53                 bool            visible;
54 //              float           dist;
55 //              bool            culled;
56
57 //              bool operator<(const Cloud &b) {
58 //                      return this->dist < b.dist;
59 //              }
60         };
61
62
63         typedef vector<Cloud> list_of_Cloud;
64
65         // cull all clouds of a tiled field
66         void cullClouds(sgVec3 eyePos, sgMat4 mat);
67
68         void applyDensity(void);
69
70         list_of_Cloud theField;
71         // this is a relative position only, with that we can move all clouds at once
72         sgVec3 relative_position;
73 //      double lon, lat;
74
75         sgFrustum frustum;
76
77         sgMat4 transform;
78         double deltax, deltay, alt;
79     double last_lon, last_lat, last_course;
80
81         float   last_density;
82
83 public:
84
85         SGCloudField();
86         ~SGCloudField();
87
88         // add one cloud, data is not copied, ownership given
89         void addCloud( sgVec3 pos, SGNewCloud *cloud);
90
91         // for debug only
92         void buildTestLayer(void);
93
94         // Render a cloud field
95         void Render(void);
96
97         // reposition the cloud layer at the specified origin and orientation
98         void reposition( sgVec3 p, sgVec3 up, double lon, double lat, double alt, double dt);
99
100         // visibility distance for clouds in meters
101         static float CloudVis;
102
103         static float density;
104
105         static double fieldSize;
106         static bool enable3D;
107
108         // return the size of the memory pool used by texture impostors
109         static int get_CacheSize(void);
110         static int get_CacheResolution(void);
111         static float get_CloudVis(void) { return CloudVis; }
112         static float get_density(void) { return density; }
113         static bool get_enable3dClouds(void) { return enable3D; }
114
115         static void set_CacheSize(int sizeKb);
116         static void set_CacheResolution(int resolutionPixels);
117         static void set_CloudVis(float distance);
118         static void set_density(float density);
119         static void set_enable3dClouds(bool enable);
120 };
121
122 #endif // _CLOUDFIELD_HXX