00001 // dome.hxx -- model sky with an upside down "bowl" 00002 // 00003 // Written by Curtis Olson, started December 1997. 00004 // SSG-ified by Curtis Olson, February 2000. 00005 // 00006 // Copyright (C) 1997-2000 Curtis L. Olson - http://www.flightgear.org/~curt 00007 // 00008 // This library is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU Library General Public 00010 // License as published by the Free Software Foundation; either 00011 // version 2 of the License, or (at your option) any later version. 00012 // 00013 // This library is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // Library General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the Free Software 00020 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 00022 #ifndef _SKYDOME_HXX 00023 #define _SKYDOME_HXX 00024 00025 00026 #ifndef __cplusplus 00027 # error This library requires C++ 00028 #endif 00029 00030 #include <osg/ref_ptr> 00031 #include <osg/Array> 00032 #include <osg/MatrixTransform> 00033 00034 #include <simgear/structure/SGReferenced.hxx> 00035 #include <simgear/math/SGMath.hxx> 00036 00037 namespace osg 00038 { 00039 class DrawElementsUShort; 00040 } 00041 00042 class SGSkyDome : public SGReferenced { 00043 osg::ref_ptr<osg::MatrixTransform> dome_transform; 00044 double asl; 00045 00046 osg::ref_ptr<osg::Vec3Array> dome_vl; 00047 osg::ref_ptr<osg::Vec3Array> dome_cl; 00048 public: 00049 00050 // Constructor 00051 SGSkyDome( void ); 00052 00053 // Destructor 00054 ~SGSkyDome( void ); 00055 00056 // initialize the sky object and connect it into our scene graph 00057 // root 00058 osg::Node *build( double hscale = 80000.0, double vscale = 80000.0 ); 00059 00060 // repaint the sky colors based on current value of sun_angle, 00061 // sky, and fog colors. This updates the color arrays for 00062 // ssgVtxTable. 00063 // sun angle in degrees relative to verticle 00064 // 0 degrees = high noon 00065 // 90 degrees = sun rise/set 00066 // 180 degrees = darkest midnight 00067 bool repaint( const SGVec3f& sun_color, const SGVec3f& sky_color, 00068 const SGVec3f& fog_color, double sun_angle, double vis ); 00069 00070 // reposition the sky at the specified origin and orientation 00071 // lon specifies a rotation about the Z axis 00072 // lat specifies a rotation about the new Y axis 00073 // spin specifies a rotation about the new Z axis (and orients the 00074 // sunrise/set effects 00075 bool reposition( const SGVec3f& p, double asl, 00076 double lon, double lat, double spin ); 00077 private: 00078 void makeDome(int rings, int bands, osg::DrawElementsUShort& elements); 00079 }; 00080 00081 00082 #endif // _SKYDOME_HXX