1 // moon.hxx -- model earth's moon 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_MOON_HXX_ 29 #define _SG_MOON_HXX_ 30 31 32 #include <osg/ref_ptr> 33 #include <osg/MatrixTransform> 34 #include <osg/Material> 35 36 #include <simgear/math/SGMath.hxx> 37 #include <simgear/structure/SGReferenced.hxx> 38 39 #include <simgear/misc/sg_path.hxx> 40 41 42 class SGMoon : public SGReferenced { 43 44 osg::ref_ptr<osg::MatrixTransform> moon_transform; 45 osg::ref_ptr<osg::Material> orb_material; 46 47 double prev_moon_angle; 48 49 public: 50 51 // Constructor 52 SGMoon( void ); 53 54 // Destructor 55 ~SGMoon( void ); 56 57 // build the moon object 58 osg::Node *build( SGPath path, double moon_size ); 59 60 // repaint the moon colors based on current value of moon_anglein 61 // degrees relative to verticle 62 // 0 degrees = high noon 63 // 90 degrees = moon rise/set 64 // 180 degrees = darkest midnight 65 bool repaint( double moon_angle ); 66 67 // reposition the moon at the specified right ascension and 68 // declination, offset by our current position (p) so that it 69 // appears fixed at a great distance from the viewer. Also add in 70 // an optional rotation (i.e. for the current time of day.) 71 bool reposition( double rightAscension, double declination, 72 double moon_dist ); 73 }; 74 75 76 #endif // _SG_MOON_HXX_ 77