/usr/include/osgEarthUtil/SkyNode is in libosgearth-dev 2.5.0+dfsg-2+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2008-2013 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTHUTIL_SKY_NODE
#define OSGEARTHUTIL_SKY_NODE
#include <osgEarthUtil/Common>
#include <osgEarth/DateTime>
#include <osgEarth/Map>
#include <osg/MatrixTransform>
#include <osg/Uniform>
#include <osg/Group>
#include <osg/View>
namespace osgEarth { namespace Util
{
using namespace osgEarth;
/**
* Class that provides information about astronomical objects at a given time.
*/
class OSGEARTHUTIL_EXPORT EphemerisProvider : public osg::Referenced
{
public:
/**
* Gets the moon position in geocentric coordinates at the given time
*/
virtual osg::Vec3d getMoonPosition( const DateTime& dt ) = 0;
/**
* Gets the sun position in geocentric coordinates at the given time
*/
virtual osg::Vec3d getSunPosition( const DateTime& dt ) = 0;
};
/**
* The default EphemerisProvider, provides positions based on freely available models
*/
class OSGEARTHUTIL_EXPORT DefaultEphemerisProvider : public EphemerisProvider
{
public:
/**
* Gets the moon position in geocentric coordinates at the given time
*/
virtual osg::Vec3d getMoonPosition( const DateTime& dt );
/**
* Gets the sun position in geocentric coordinates at the given time
*/
virtual osg::Vec3d getSunPosition( const DateTime& dt );
};
/**
* A sky model.
*/
class OSGEARTHUTIL_EXPORT SkyNode : public osg::Group
{
public:
/** Creates a new sky node based on the provided map. */
SkyNode( Map* map, const std::string& starFile="", float minStarMagnitude=-1.0f );
SkyNode( Map* map, float minStarMagnitude );
/** dtor */
virtual ~SkyNode() { }
public:
/**
* Gets/Sets the EphemerisProvider
*/
EphemerisProvider* getEphemerisProvider() const;
void setEphemerisProvider(EphemerisProvider* ephemerisProvider );
/**
* Gets a position from the right ascension, declination and range
* @param ra
* Right ascension in radians
* @param decl
* Declination in radians
* @param range
* Range in meters
*/
static osg::Vec3d getPositionFromRADecl( double ra, double decl, double range );
public:
/** Attached this sky node to a view (placing a sky light). */
void attach( osg::View* view, int lightNum =0 );
/** Gets the date time for the sky position */
void getDateTime(DateTime& output, osg::View* view =0L) const;
/** Sets the sky's position based on a julian date. */
void setDateTime(const DateTime& dt, osg::View* view =0L );
/** The minimum brightness for non-sunlit areas. */
void setAmbientBrightness( float value, osg::View* view =0L );
float getAmbientBrightness( osg::View* view =0L ) const;
/** Enables or disables automatic ambience */
void setAutoAmbience(bool value);
bool getAutoAmbience() const;
/** Whether the moon is visible */
void setMoonVisible( bool value, osg::View* view =0L );
bool getMoonVisible( osg::View* view =0L ) const;
/** Whether the stars are visible */
void setStarsVisible( bool value, osg::View* view =0L );
bool getStarsVisible( osg::View* view =0L ) const;
public: // deprecated
/** @deprecated Please use setDateTime(const DateTime&) above */
void setDateTime( int year, int month, int date, double hoursUTC, osg::View* view =0L );
/** @deprecated Please use getDateTime(DateTime&) above */
void getDateTime( int &year, int &month, int &date, double &hoursUTC, osg::View* view=0L );
public:
//override
virtual void traverse( osg::NodeVisitor& nv );
//override
virtual osg::BoundingSphere computeBound() const;
private:
/** Sets the sun's position as a unit vector. */
void setSunPosition( const osg::Vec3& pos, osg::View* view =0L );
/** Sets the moon position as a geocentric coordinate */
void setMoonPosition( const osg::Vec3d& pos, osg::View* view =0L );
/** Sets the sun's position as a latitude and longitude. */
void setSunPosition( double lat_degrees, double lon_degrees, osg::View* view =0L );
struct StarData
{
std::string name;
double right_ascension;
double declination;
double magnitude;
StarData() { }
StarData( std::stringstream &ss );
};
struct PerViewData
{
osg::Vec3f _lightPos;
osg::ref_ptr<osg::Light> _light;
osg::ref_ptr<osg::Uniform> _lightPosUniform;
osg::Matrixd _sunMatrix;
osg::Matrixd _moonMatrix;
osg::Matrixd _starsMatrix;
bool _starsVisible;
bool _moonVisible;
// only available in per-view structures..not default
osg::ref_ptr<osg::Group> _cullContainer;
osg::ref_ptr<osg::MatrixTransform> _sunXform;
osg::ref_ptr<osg::MatrixTransform> _moonXform;
osg::ref_ptr<osg::MatrixTransform> _starsXform;
DateTime _date;
};
PerViewData _defaultPerViewData;
typedef std::map<osg::View*, PerViewData> PerViewDataMap;
PerViewDataMap _perViewData;
float _innerRadius, _outerRadius, _sunDistance, _starRadius, _minStarMagnitude;
osg::ref_ptr<osg::Node> _sun, _stars, _atmosphere, _moon;
osg::ref_ptr<osg::Uniform> _starAlpha;
osg::ref_ptr<osg::Uniform> _starPointSize;
osg::Vec3d _moonPosition;
bool _autoAmbience;
osg::ref_ptr< const osg::EllipsoidModel > _ellipsoidModel;
void initialize( Map* map, const std::string& starFile="" );
void makeAtmosphere( const osg::EllipsoidModel* );
void makeSun();
void makeMoon();
void makeStars(const std::string& starFile);
osg::Node* buildStarGeometry(const std::vector<StarData>& stars);
void getDefaultStars(std::vector<StarData>& out_stars);
bool parseStarFile(const std::string& starFile, std::vector<StarData>& out_stars);
void setAmbientBrightness( PerViewData& data, float value );
void setSunPosition( PerViewData& data, const osg::Vec3& pos );
void setMoonPosition( PerViewData& data, const osg::Vec3d& pos );
osg::ref_ptr< EphemerisProvider > _ephemerisProvider;
};
} } // namespace osgEarth::Util
#endif //OSGEARTHUTIL_SKY_NODE
|