00001 // oursun.hxx -- model earth's sun 00002 // 00003 // Written by Durk Talsma. Originally started October 1997, for distribution 00004 // with the FlightGear project. Version 2 was written in August and 00005 // September 1998. This code is based upon algorithms and data kindly 00006 // provided by Mr. Paul Schlyter. (pausch@saaf.se). 00007 // 00008 // Separated out rendering pieces and converted to ssg by Curt Olson, 00009 // March 2000 00010 // 00011 // This library is free software; you can redistribute it and/or 00012 // modify it under the terms of the GNU Library General Public 00013 // License as published by the Free Software Foundation; either 00014 // version 2 of the License, or (at your option) any later version. 00015 // 00016 // This library is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 // Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU General Public License 00022 // along with this program; if not, write to the Free Software 00023 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00024 // 00025 // $Id: oursun_8hxx_source.html,v 1.3 2010/02/23 22:10:15 curt Exp $ 00026 00027 00028 #ifndef _SG_SUN_HXX_ 00029 #define _SG_SUN_HXX_ 00030 00031 #include <osg/Array> 00032 #include <osg/Node> 00033 #include <osg/MatrixTransform> 00034 00035 #include <simgear/structure/SGReferenced.hxx> 00036 00037 #include <simgear/misc/sg_path.hxx> 00038 #include <simgear/props/props.hxx> 00039 00040 class SGSun : public SGReferenced { 00041 00042 osg::ref_ptr<osg::MatrixTransform> sun_transform; 00043 00044 osg::ref_ptr<osg::Vec4Array> sun_cl; 00045 osg::ref_ptr<osg::Vec4Array> scene_cl; 00046 osg::ref_ptr<osg::Vec4Array> ihalo_cl; 00047 osg::ref_ptr<osg::Vec4Array> ohalo_cl; 00048 00049 double visibility; 00050 double prev_sun_angle; 00051 // distance of light traveling through the atmosphere 00052 double path_distance; 00053 double sun_exp2_punch_through; 00054 00055 SGPropertyNode_ptr env_node; 00056 00057 public: 00058 00059 // Constructor 00060 SGSun( void ); 00061 00062 // Destructor 00063 ~SGSun( void ); 00064 00065 // return the sun object 00066 osg::Node* build( SGPath path, double sun_size, SGPropertyNode *property_tree_Node ); 00067 00068 // repaint the sun colors based on current value of sun_anglein 00069 // degrees relative to verticle 00070 // 0 degrees = high noon 00071 // 90 degrees = sun rise/set 00072 // 180 degrees = darkest midnight 00073 bool repaint( double sun_angle, double new_visibility ); 00074 00075 // reposition the sun at the specified right ascension and 00076 // declination, offset by our current position (p) so that it 00077 // appears fixed at a great distance from the viewer. Also add in 00078 // an optional rotation (i.e. for the current time of day.) 00079 bool reposition( double rightAscension, double declination, 00080 double sun_dist, double lat, double alt_asl, double sun_angle ); 00081 00082 // retrun the current color of the sun 00083 SGVec4f get_color(); 00084 SGVec4f get_scene_color(); 00085 }; 00086 00087 00088 #endif // _SG_SUN_HXX_