]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/oursun.hxx
57d4b0cb906633b49a46c60801413de9a8a64239
[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 Library General Public
22 // License along with this library; if not, write to the
23 // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 // Boston, MA  02111-1307, USA.
25 //
26 // $Id$
27
28
29 #ifndef _SG_SUN_HXX_
30 #define _SG_SUN_HXX_
31
32
33 #include <plib/ssg.h>
34
35 #include <simgear/misc/sg_path.hxx>
36
37 class SGSun {
38
39     ssgTransform *sun_transform;
40     ssgSimpleState *orb_state;
41     ssgSimpleState *halo_state;
42
43     ssgColourArray *cl;
44
45     ssgVertexArray *halo_vl;
46     ssgTexCoordArray *halo_tl;
47
48     GLuint sun_texid;
49     GLubyte *sun_texbuf;
50
51     double visibility;
52     double prev_sun_angle;
53
54 public:
55
56     // Constructor
57     SGSun( void );
58
59     // Destructor
60     ~SGSun( void );
61
62     // return the sun object
63     ssgBranch *build( SGPath path, double sun_size );
64
65     // repaint the sun colors based on current value of sun_anglein
66     // degrees relative to verticle
67     // 0 degrees = high noon
68     // 90 degrees = sun rise/set
69     // 180 degrees = darkest midnight
70     bool repaint( double sun_angle, double new_visibility );
71
72     // reposition the sun at the specified right ascension and
73     // declination, offset by our current position (p) so that it
74     // appears fixed at a great distance from the viewer.  Also add in
75     // an optional rotation (i.e. for the current time of day.)
76     bool reposition( sgVec3 p, double angle,
77                      double rightAscension, double declination,
78                      double sun_dist );
79
80     // retrun the current color of the sun
81     inline float *get_color() { return  cl->get( 0 ); }
82
83     // return the texture id of the sun halo texture
84     inline GLuint get_texture_id() { return halo_state->getTextureHandle(); }
85 };
86
87
88 #endif // _SG_SUN_HXX_