/usr/include/osgEarthUtil/Sky is in libosgearth-dev 2.9.0+dfsg-1.
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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 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.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* 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
#define OSGEARTHUTIL_SKY
#include <osgEarthUtil/Common>
#include <osgEarthUtil/Ephemeris>
#include <osgEarth/DateTime>
#include <osgEarth/GeoData>
#include <osgEarth/Config>
#include <osgEarth/Profile>
#include <osg/Group>
#include <osg/Uniform>
#include <osg/View>
#include <osgDB/ReaderWriter>
namespace osgEarth {
class MapNode;
}
namespace osgDB {
class Options;
}
namespace osgEarth { namespace Util
{
using namespace osgEarth;
/**
* Base Options structure for loading an environment node from
* a plugin.
*/
class SkyOptions : public DriverConfigOptions
{
public:
/** Time of day - Hours [0..24] component of DateTime */
optional<float>& hours() { return _hours; }
const optional<float>& hours() const { return _hours; }
/** Ambient light level [0..1] */
optional<float>& ambient() { return _ambient; }
const optional<float>& ambient() const { return _ambient; }
public:
SkyOptions( const ConfigOptions& options =ConfigOptions() ) : DriverConfigOptions(options) {
fromConfig(_conf);
}
virtual ~SkyOptions() { }
virtual Config getConfig() const {
Config conf = DriverConfigOptions::getConfig();
conf.addIfSet("hours", _hours);
conf.addIfSet("ambient", _ambient);
return conf;
}
protected:
virtual void mergeConfig( const Config& conf ) {
DriverConfigOptions::mergeConfig( conf );
fromConfig( conf );
}
private:
void fromConfig( const Config& conf ) {
conf.getIfSet("hours", _hours);
conf.getIfSet("ambient", _ambient);
}
optional<float> _hours;
optional<float> _ambient;
};
/**
* Interface for classes that provide sky, lighting, and other
* environmental effect.
*/
class OSGEARTHUTIL_EXPORT SkyNode : public osg::Group
{
public:
/**
* Creates a new SkyNode with the default built-in sky driver
* and default options.
*/
static SkyNode* create(
osgEarth::MapNode* mapNode );
/**
* Creates a new SkyNode with custom options.
*/
static SkyNode* create(
const SkyOptions& options,
osgEarth::MapNode* mapNode );
/**
* Creates a new SkyNode with a named driver.
*/
static SkyNode* create(
const std::string& driver,
osgEarth::MapNode* mapNode );
protected:
// CTOR (abstract base class)
SkyNode();
SkyNode(const SkyOptions& options);
// protected DTOR (heap-only)
virtual ~SkyNode();
public:
/**
* Gets/Sets the Ephemeris used to position the sun and the moon
* based on date/time.
*/
void setEphemeris(Ephemeris* ephemeris);
const Ephemeris* getEphemeris() const;
/**
* The ephemeris reference point for projected maps. Not applicable
* for geocentric maps.
*/
void setReferencePoint(const GeoPoint& point);
const GeoPoint& getReferencePoint() const { return *_refpoint; }
/**
* Whether the sky lights its subgraph.
*/
void setLighting(osg::StateAttribute::OverrideValue value);
osg::StateAttribute::OverrideValue getLighting() const { return _lightingValue; }
/**
* Gets the date/time for which the enviroment is configured.
* Pass in an optional View to get the date/time specific to
* that View.
*/
void setDateTime(const DateTime& dt);
const DateTime& getDateTime() const { return _dateTime; }
/** Whether the sun is visible */
void setSunVisible(bool value);
bool getSunVisible() const { return _sunVisible; }
/** Whether the moon is visible */
void setMoonVisible(bool value);
bool getMoonVisible() const { return _moonVisible; }
/** Whether the stars are visible */
void setStarsVisible(bool value);
bool getStarsVisible() const { return _starsVisible; }
/** Whether the atmosphere is visible */
void setAtmosphereVisible(bool value);
bool getAtmosphereVisible() const { return _atmosphereVisible; }
/** Access the osg::Light representing the sun */
virtual osg::Light* getSunLight() const = 0;
//virtual const osg::Light* getSunLight() const = 0;
/** @deprecated. use getSunLight()->setAmbient instead */
void setMinimumAmbient(const osg::Vec4f& ambient) { if (getSunLight()) getSunLight()->setAmbient(ambient); }
/** @deprecated; use getSunLight()->getAmbient instead */
const osg::Vec4 getMinimumAmbient() const { if (!getSunLight()) return osg::Vec4(0,0,0,0); return getSunLight()->getAmbient(); }
public:
/** Attaches this sky node to a view (placing a sky light). Optional */
virtual void attach(osg::View* view, int lightNum) { }
void attach(osg::View* view) { attach(view, 0); }
protected:
// impl class can override these events.
virtual void onSetEphemeris() { }
virtual void onSetDateTime() { }
virtual void onSetReferencePoint() { }
virtual void onSetMoonVisible() { }
virtual void onSetStarsVisible() { }
virtual void onSetSunVisible() { }
virtual void onSetAtmosphereVisible() { }
private:
osg::ref_ptr<Ephemeris> _ephemeris;
DateTime _dateTime;
bool _sunVisible;
bool _moonVisible;
bool _starsVisible;
bool _atmosphereVisible;
osg::Vec4f _minimumAmbient;
optional<GeoPoint> _refpoint;
osg::StateAttribute::OverrideValue _lightingValue;
osg::ref_ptr<osg::Uniform> _lightingUniform;
void baseInit(const SkyOptions&);
};
/**
* Base class for an sky driver plugin implementation.
*/
class OSGEARTHUTIL_EXPORT SkyDriver : public osgDB::ReaderWriter
{
protected:
MapNode* getMapNode(const osgDB::Options* opt) const;
const SkyOptions& getSkyOptions(const osgDB::Options* opt) const;
};
/**
* Factory interface that sky extensions need to implement. Someday we will
* convert the sky extensions into proper NodeKits, at which point this method
* will probably be no longer necessary since you can just link with the library
* and create the SkyNode normally.
*/
class /*header-only*/ SkyNodeFactory
{
public:
virtual SkyNode* createSkyNode(const Profile* profile) =0;
};
} } // namespace osgEarth::Util
#endif // OSGEARTHUTIL_SKY
|