]> git.mxchange.org Git - simgear.git/blob - simgear/sky/sky.hxx
Complete overhaul of the sky/sun/moon/stars/planets. It is now an ssg
[simgear.git] / simgear / sky / sky.hxx
1 // sky.hxx -- ssg based sky model
2 //
3 // Written by Curtis Olson, started December 1997.
4 // SSG-ified by Curtis Olson, February 2000.
5 //
6 // Copyright (C) 1997-2000  Curtis L. Olson  - curt@flightgear.org
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 // $Id$
23
24
25 #ifndef _SG_SKY_HXX
26 #define _SG_SKY_HXX
27
28
29 #ifndef __cplusplus                                                          
30 # error This library requires C++
31 #endif                                   
32
33
34 #include <plib/ssg.h>           // plib include
35
36 #include <simgear/misc/fgpath.hxx>
37
38 #include "dome.hxx"
39 #include "moon.hxx"
40 #include "oursun.hxx"
41 #include "stars.hxx"
42
43
44 class SGSky {
45
46     // components of the sky
47     SGSkyDome *dome;
48     SGSun *oursun;
49     SGMoon *moon;
50     SGStars *planets;
51     SGStars *stars;
52
53     ssgSelector *sky_selector;
54     ssgTransform *sky_transform;
55
56     FGPath tex_path;
57
58 public:
59
60     // Constructor
61     SGSky( void );
62
63     // Destructor
64     ~SGSky( void );
65
66     // initialize the sky and connect the components to the scene
67     // graph at the provided branch
68     ssgBranch *build( double sun_size, double moon_size,
69                       int nplanets, sgdVec3 *planet_data, double planet_dist,
70                       int nstars, sgdVec3 *star_data, double star_dist );
71
72     // repaint the sky components based on current value of sun_angle,
73     // sky, and fog colors.
74     //
75     // sun angle in degrees relative to verticle
76     // 0 degrees = high noon
77     // 90 degrees = sun rise/set
78     // 180 degrees = darkest midnight
79     bool repaint( sgVec4 sky_color, sgVec4 fog_color, 
80                   double sun_angle, double moon_angle,
81                   int nplanets, sgdVec3 *planet_data,
82                   int nstars, sgdVec3 *star_data );
83
84     // reposition the sky at the specified origin and orientation
85     //
86     // lon specifies a rotation about the Z axis
87     // lat specifies a rotation about the new Y axis
88     // spin specifies a rotation about the new Z axis (this allows
89     // additional orientation for the sunrise/set effects and is used
90     // by the skydome and perhaps clouds.
91     bool reposition( sgVec3 view_pos, sgVec3 zero_elev, 
92                      double lon, double lat, double spin,
93                      double gst, 
94                      double sun_ra, double sun_dec, double sun_dist,
95                      double moon_ra, double moon_dec, double moon_dist );
96
97     // specify the texture path (optional, defaults to current directory)
98     inline void texture_path( const string& path ) {
99         tex_path = FGPath( path );
100     }
101
102     // enable the sky in the scene graph (default)
103     inline void enable() { sky_selector->select( 1 ); }
104
105     // disable the sky in the scene graph.  The leaf node is still
106     // there, how ever it won't be traversed on by ssgCullandRender()
107     inline void disable() { sky_selector->select( 0 ); }
108 };
109
110
111 #endif // _SG_SKY_HXX
112
113