]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/oursun.hxx
- new FSF addresses
[simgear.git] / simgear / scene / sky / oursun.hxx
1 // oursun.hxx -- model earth's sun
2 //
3 // Written by Durk Talsma. Originally started October 1997, for distribution  
4 // with the FlightGear project. Version 2 was written in August and 
5 // September 1998. This code is based upon algorithms and data kindly 
6 // provided by Mr. Paul Schlyter. (pausch@saaf.se). 
7 //
8 // Separated out rendering pieces and converted to ssg by Curt Olson,
9 // March 2000
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the GNU Library General Public
13 // License as published by the Free Software Foundation; either
14 // version 2 of the License, or (at your option) any later version.
15 //
16 // This library is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 // Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24 //
25 // $Id$
26
27
28 #ifndef _SG_SUN_HXX_
29 #define _SG_SUN_HXX_
30
31
32 #include <plib/ssg.h>
33
34 #include <simgear/misc/sg_path.hxx>
35
36 class SGSun {
37
38     ssgTransform *sun_transform;
39     ssgSimpleState *orb_state;
40     ssgSimpleState *halo_state;
41
42     ssgColourArray *cl;
43
44     ssgVertexArray *halo_vl;
45     ssgTexCoordArray *halo_tl;
46
47     GLuint sun_texid;
48     GLubyte *sun_texbuf;
49
50     double visibility;
51     double prev_sun_angle;
52
53 public:
54
55     // Constructor
56     SGSun( void );
57
58     // Destructor
59     ~SGSun( void );
60
61     // return the sun object
62     ssgBranch *build( SGPath path, double sun_size );
63
64     // repaint the sun colors based on current value of sun_anglein
65     // degrees relative to verticle
66     // 0 degrees = high noon
67     // 90 degrees = sun rise/set
68     // 180 degrees = darkest midnight
69     bool repaint( double sun_angle, double new_visibility );
70
71     // reposition the sun at the specified right ascension and
72     // declination, offset by our current position (p) so that it
73     // appears fixed at a great distance from the viewer.  Also add in
74     // an optional rotation (i.e. for the current time of day.)
75     bool reposition( sgVec3 p, double angle,
76                      double rightAscension, double declination,
77                      double sun_dist );
78
79     // retrun the current color of the sun
80     inline float *get_color() { return  cl->get( 0 ); }
81
82     // return the texture id of the sun halo texture
83     inline GLuint get_texture_id() { return halo_state->getTextureHandle(); }
84 };
85
86
87 #endif // _SG_SUN_HXX_