/usr/include/osgEarth/ModelLayer 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 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | /* -*-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.
*
* 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 OSGEARTH_MODEL_LAYER_H
#define OSGEARTH_MODEL_LAYER_H 1
#include <osgEarth/Common>
#include <osgEarth/VisibleLayer>
#include <osgEarth/Cache>
#include <osgEarth/Config>
#include <osgEarth/ModelSource>
#include <osgEarth/MaskSource>
#include <osgEarth/ShaderUtils>
#include <osgEarth/Containers>
#include <osgEarth/SceneGraphCallback>
#include <osg/Node>
#include <osg/Array>
#include <vector>
namespace osgEarth
{
class Map;
/**
* Configuration options for a ModelLayer.
*/
class OSGEARTH_EXPORT ModelLayerOptions : public VisibleLayerOptions
{
public:
/** Construct or deserialize new model layer options. */
ModelLayerOptions(
const ConfigOptions& options =ConfigOptions());
/** Construct or deserialize new model layer options. */
ModelLayerOptions(
const std::string& name,
const ModelSourceOptions& driverOptions =ModelSourceOptions() );
/** Copy ctor*/
ModelLayerOptions(const ModelLayerOptions& rhs);
/** dtor */
virtual ~ModelLayerOptions() { }
/** Assignment operator */
ModelLayerOptions& operator = (const ModelLayerOptions&);
/**
* Options for the underlying model source driver.
*/
optional<ModelSourceOptions>& driver() { return _driver; }
const optional<ModelSourceOptions>& driver() const { return _driver; }
/**
* Whether to enable OpenGL lighting on the model node.
*/
optional<bool>& lightingEnabled() { return _lighting; }
const optional<bool>& lightingEnabled() const { return _lighting; }
/**
* Masking options for cutting a hole in the terrain to accommodate this model.
* Note; the mask will NOT honor any visibility or opacity settings on the
* model layer.
*/
optional<MaskSourceOptions>& mask() { return _maskOptions; }
const optional<MaskSourceOptions>& mask() const { return _maskOptions; }
/**
* Minimum terrain LOD at which to apply the mask (if there if one)
*/
optional<unsigned>& maskMinLevel() { return _maskMinLevel; }
const optional<unsigned>& maskMinLevel() const { return _maskMinLevel; }
/**
* Whether this layer should be treated as part of the terrain
* for the purposes of elevation queries, clamping, etc.
*/
optional<bool>& terrainPatch() { return _terrainPatch; }
const optional<bool>& terrainPatch() const { return _terrainPatch; }
public:
virtual Config getConfig() const;
virtual void mergeConfig( const Config& conf );
private:
void fromConfig( const Config& conf );
void setDefaults();
optional<ModelSourceOptions> _driver;
optional<bool> _lighting;
optional<MaskSourceOptions> _maskOptions;
optional<unsigned> _maskMinLevel;
optional<bool> _terrainPatch;
optional<CachePolicy> _cachePolicy;
optional<std::string> _cacheId;
};
struct ModelLayerCallback : public VisibleLayerCallback
{
// Nothing - placeholder
typedef void (ModelLayerCallback::*MethodPtr)(class ModelLayer* layer);
};
/**
* Layer that contains an OSG scene graph
*/
class OSGEARTH_EXPORT ModelLayer : public VisibleLayer
{
public:
META_Layer(osgEarth, ModelLayer, ModelLayerOptions);
/**
* Blank ModelLayer. Use options() to setup before calling open.
*/
ModelLayer();
/**
* Constructs a new model layer.
*/
ModelLayer(const ModelLayerOptions& options);
/**
* Constructs a new model layer with a user-provided driver options.
*/
ModelLayer(const std::string& name, const ModelSourceOptions& options);
/**
* Constructs a new model layer with a user-provided model source.
*
* Note: the ModelLayerOptions contains a driver() member for configuring a
* TileSource. But in this constructor, you are passing in an existing TileSource,
* and thus the driver() member in ModelLayerOptions will not be used.
*/
ModelLayer(const ModelLayerOptions& options, ModelSource* source );
/**
* Constructs a new model layer with a user provided name and an existing node
*/
ModelLayer(const std::string& name, osg::Node* node);
public:
/**
* Access the underlying model source.
*/
ModelSource* getModelSource() const { return _modelSource.get(); }
/**
* The underlying mask source, if one exists.
*/
MaskSource* getMaskSource() const { return _maskSource.get(); }
/**
* The minimum terrain LOD at which to apply the mask.
*/
unsigned getMaskMinLevel() const { return options().maskMinLevel().get(); }
/**
* The boundary geometry for the mask.
*/
osg::Vec3dArray* getOrCreateMaskBoundary(
float heightScale,
const SpatialReference* srs,
ProgressCallback* progress);
/**
* Whether this model layer is a terrain patch for the purposes of
* intersection testing. (convenience function)
*/
bool isTerrainPatch() const { return options().terrainPatch().get(); }
/** Access scene graph callbacks */
SceneGraphCallbacks* getSceneGraphCallbacks() { return _sgCallbacks.get(); }
public:
/**
* Creates the scene graph representing this model layer for the given Map,
* or returns one that already exists.
*/
osg::Node* getOrCreateSceneGraph(const Map* map, ProgressCallback* progress);
/**
* Gets a scene graph what was previously created with getOrCreateSceneGraph.
*/
osg::Node* getSceneGraph(const UID& mapUID) const;
public: // deprecated
/** @deprecated */
osg::Node* getOrCreateSceneGraph(
const Map* map,
const osgDB::Options* readOptions,
ProgressCallback* progress ) { return getOrCreateSceneGraph(map, progress); }
public: // properties
/** whether to apply lighting to the model layer's root node */
void setLightingEnabled( bool value );
bool isLightingEnabled() const;
public: // Layer
/** Open the layer and return its status */
virtual const Status& open();
/** Serialize this layer */
virtual Config getConfig() const;
/** Node created by this model layer */
virtual osg::Node* getOrCreateNode();
//! Generate a cache ID for this layer
virtual std::string getCacheID() const;
protected:
/** post-ctor initialization */
virtual void init();
protected:
virtual ~ModelLayer();
osg::ref_ptr<ModelSource> _modelSource;
osg::ref_ptr<MaskSource> _maskSource;
Revision _modelSourceRev;
osg::ref_ptr<osg::Vec3dArray> _maskBoundary;
osg::ref_ptr<CacheSettings> _cacheSettings;
osg::ref_ptr<SceneGraphCallbacks> _sgCallbacks;
typedef fast_map<UID, osg::ref_ptr<osg::Node> > Graphs;
Graphs _graphs;
mutable Threading::Mutex _mutex; // general-purpose mutex.
void fireCallback(ModelLayerCallback::MethodPtr method);
void setLightingEnabledNoLock(bool value);
};
typedef std::vector< osg::ref_ptr<ModelLayer> > ModelLayerVector;
}
#endif // OSGEARTH_MODEL_LAYER_H
|