osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/engine_osgterrain/TransparentLayer

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
00003 * Copyright 2008-2010 Pelican Mapping
00004 * http://osgearth.org
00005 *
00006 * osgEarth is free software; you can redistribute it and/or modify
00007 * it under the terms of the GNU Lesser General Public License as published by
00008 * the Free Software Foundation; either version 2 of the License, or
00009 * (at your option) any later version.
00010 *
00011 * This program is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 * GNU Lesser General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU Lesser General Public License
00017 * along with this program.  If not, see <http://www.gnu.org/licenses/>
00018 */
00019 
00020 #ifndef OSGEARTH_ENGINE_TRANSPARENT_LAYER
00021 #define OSGEARTH_ENGINE_TRANSPARENT_LAYER 1
00022 
00023 #include "Common"
00024 #include <osgEarth/Common>
00025 #include <osgTerrain/Locator>
00026 #include <osgTerrain/Layer>
00027 #include <osgEarth/ImageLayer>
00028 #include <osgEarth/TileKey>
00029 #include <osg/Image>
00030 
00031 class CustomColorLayer
00032 {
00033 public:
00034     CustomColorLayer() { }
00035 
00036     CustomColorLayer(
00037         const osgEarth::ImageLayer* imageLayer,
00038         osg::Image* image,
00039         const osgTerrain::Locator* locator,
00040         int lod,
00041         const osgEarth::TileKey& tileKey,
00042         bool fallbackData =false )
00043         : _layer(imageLayer), _locator(locator), _image(image),  _tileKey(tileKey), _lod(lod), _fallbackData(fallbackData) { }
00044 
00045     CustomColorLayer( const CustomColorLayer& rhs ) :
00046         _layer( rhs._layer.get() ),        
00047         _locator( rhs._locator.get() ),
00048         _image( rhs._image.get() ),
00049         _tileKey( rhs._tileKey ),
00050         _lod( rhs._lod ),
00051         _fallbackData( rhs._fallbackData ) { }
00052 
00053     osgEarth::UID getUID() const {
00054         return _layer->getUID();
00055     }
00056 
00057     const osgTerrain::Locator* getLocator() const {
00058         return _locator.get();
00059     }
00060 
00061     osg::Image* getImage() const { 
00062         return _image.get(); }
00063 
00064     const osgEarth::TileKey& getTileKey() const {
00065         return _tileKey; }
00066 
00067     const osgEarth::ImageLayer* getMapLayer() const {
00068         return _layer.get(); }
00069 
00070     int getLevelOfDetail() const {
00071         return _lod; }
00072 
00073     bool isFallbackData() const {
00074         return _fallbackData; }
00075 
00076     osg::BoundingSphere computeBound() const {
00077         osg::BoundingSphere bs;
00078         osg::Vec3d v;
00079         if (getLocator()->convertLocalToModel(osg::Vec3d(0.5,0.5,0.0), v)) {
00080             bs.center() = v;
00081         }
00082         if (getLocator()->convertLocalToModel(osg::Vec3d(0.0,0.0,0.0), v)) {
00083             bs.radius() = (bs.center() - v).length();
00084         }
00085         return bs;
00086     }
00087 
00088 
00089 private:
00090     osg::ref_ptr<const osgEarth::ImageLayer> _layer;
00091     osg::ref_ptr<const osgTerrain::Locator>  _locator;
00092     osg::ref_ptr<osg::Image>                 _image;
00093     osgEarth::TileKey                        _tileKey;
00094     int                                      _lod;
00095     bool                                     _fallbackData;
00096 };
00097 
00098 class CustomColorLayerRef : public osg::Referenced
00099 {
00100 public:
00101     CustomColorLayerRef( const CustomColorLayer& layer ) : _layer(layer) { }
00102     CustomColorLayer _layer;
00103 };
00104 
00105 class CustomElevLayer
00106 {
00107 public:
00108     CustomElevLayer() { }
00109 
00110     CustomElevLayer( osgTerrain::HeightFieldLayer* hfLayer, bool fallbackData =false )
00111         : _hfLayer(hfLayer), _fallbackData(fallbackData) { }
00112 
00113     osgTerrain::HeightFieldLayer* getHFLayer() {
00114         return _hfLayer.get(); }
00115 
00116     bool isFallbackData() const {
00117         return _fallbackData; }
00118 
00119 private:
00120     osg::ref_ptr<osgTerrain::HeightFieldLayer> _hfLayer;
00121     bool _fallbackData;
00122 };
00123 
00124 #endif // OSGEARTH_ENGINE_TRANSPARENT_LAYER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines