]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/oursun.hxx
Merge branch 'ehofman/sound'
[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 #include <osg/Array>
32 #include <osg/Node>
33 #include <osg/MatrixTransform>
34
35 #include <simgear/structure/SGReferenced.hxx>
36
37 #include <simgear/misc/sg_path.hxx>
38 #include <simgear/props/props.hxx>
39
40 class SGSun : public SGReferenced {
41
42     osg::ref_ptr<osg::MatrixTransform> sun_transform;
43
44     osg::ref_ptr<osg::Vec4Array> sun_cl;
45     osg::ref_ptr<osg::Vec4Array> scene_cl;
46     osg::ref_ptr<osg::Vec4Array> ihalo_cl;
47     osg::ref_ptr<osg::Vec4Array> ohalo_cl;
48
49     double visibility;
50     double prev_sun_angle;
51     // distance of light traveling through the atmosphere
52     double path_distance;
53     double sun_exp2_punch_through;
54
55     SGPropertyNode_ptr env_node;
56
57 public:
58
59     // Constructor
60     SGSun( void );
61
62     // Destructor
63     ~SGSun( void );
64
65     // return the sun object
66     osg::Node* build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node );
67
68     // repaint the sun colors based on current value of sun_anglein
69     // degrees relative to verticle
70     // 0 degrees = high noon
71     // 90 degrees = sun rise/set
72     // 180 degrees = darkest midnight
73     bool repaint( double sun_angle, double new_visibility );
74
75     // reposition the sun at the specified right ascension and
76     // declination, offset by our current position (p) so that it
77     // appears fixed at a great distance from the viewer.  Also add in
78     // an optional rotation (i.e. for the current time of day.)
79     bool reposition( double rightAscension, double declination,
80                      double sun_dist, double lat, double alt_asl, double sun_angle );
81
82     // retrun the current color of the sun
83     SGVec4f get_color();
84     SGVec4f get_scene_color();
85 };
86
87
88 #endif // _SG_SUN_HXX_