00001 // moon.hxx -- model earth's moon 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: moon_8hxx_source.html,v 1.3 2010/02/23 22:10:15 curt Exp $ 00026 00027 00028 #ifndef _SG_MOON_HXX_ 00029 #define _SG_MOON_HXX_ 00030 00031 00032 #include <osg/ref_ptr> 00033 #include <osg/MatrixTransform> 00034 #include <osg/Material> 00035 00036 #include <simgear/math/SGMath.hxx> 00037 #include <simgear/structure/SGReferenced.hxx> 00038 00039 #include <simgear/misc/sg_path.hxx> 00040 00041 00042 class SGMoon : public SGReferenced { 00043 00044 osg::ref_ptr<osg::MatrixTransform> moon_transform; 00045 osg::ref_ptr<osg::Material> orb_material; 00046 00047 double prev_moon_angle; 00048 00049 public: 00050 00051 // Constructor 00052 SGMoon( void ); 00053 00054 // Destructor 00055 ~SGMoon( void ); 00056 00057 // build the moon object 00058 osg::Node *build( SGPath path, double moon_size ); 00059 00060 // repaint the moon colors based on current value of moon_anglein 00061 // degrees relative to verticle 00062 // 0 degrees = high noon 00063 // 90 degrees = moon rise/set 00064 // 180 degrees = darkest midnight 00065 bool repaint( double moon_angle ); 00066 00067 // reposition the moon at the specified right ascension and 00068 // declination, offset by our current position (p) so that it 00069 // appears fixed at a great distance from the viewer. Also add in 00070 // an optional rotation (i.e. for the current time of day.) 00071 bool reposition( double rightAscension, double declination, 00072 double moon_dist ); 00073 }; 00074 00075 00076 #endif // _SG_MOON_HXX_