osgEarth 2.1.1

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

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_OSGTERRAIN_TILE_FACTORY_H
00021 #define OSGEARTH_ENGINE_OSGTERRAIN_TILE_FACTORY_H 1
00022 
00023 #include "OSGTerrainOptions"
00024 #include "TransparentLayer"
00025 
00026 #include <osgEarth/Map>
00027 #include <osgEarth/TileSource>
00028 #include <osgEarth/ImageLayer>
00029 #include <osgEarth/ElevationLayer>
00030 #include <osgEarth/Locators>
00031 
00032 #include <osgDB/ReaderWriter>
00033 #include <osg/CoordinateSystemNode>
00034 #include <osg/ClusterCullingCallback>
00035 #include <vector>
00036 
00037 using namespace osgEarth;
00038 using namespace osgEarth::Drivers;
00039 
00040 class Terrain;
00041 class StreamingTerrain;
00042 class Tile;
00043 class StreamingTile;
00044 
00048 class OSGTileFactory : public osg::Referenced
00049 {
00050 public:
00051     OSGTileFactory(
00052         unsigned                 engineId,
00053         const MapFrame&          cull_thread_mapf,
00054         const OSGTerrainOptions& props =OSGTerrainOptions() );
00055 
00056 public:
00061     osg::Node* createSubTiles(
00062         const MapFrame&  mapf,
00063         Terrain*         terrain,
00064         const TileKey&   key,
00065         bool             populateLayers );
00066 
00070     osg::Node* createTile(
00071         const MapFrame&  mapf,
00072         Terrain*         terrain,
00073         const TileKey&   key,
00074         bool             populateLayers,
00075         bool             wrapInPagedLOD,
00076         bool             fallback,
00077         bool&            out_validData);
00078 
00079 
00080     CustomColorLayerRef* createImageLayer(
00081         const MapInfo&    mapInfo,
00082         ImageLayer*       layer,
00083         const TileKey&    key,
00084         ProgressCallback* progress);
00085 
00086     osgTerrain::HeightFieldLayer* createHeightFieldLayer(
00087         const MapFrame& mapf,
00088         const TileKey&  key,
00089         bool            exactOnly );
00090 
00094     const OSGTerrainOptions& getTerrainOptions() const;
00095 
00099     std::string createURI( unsigned int id, const TileKey& key );
00100 
00104     osg::Node* prepareTile( 
00105         Tile*            tile, 
00106         Terrain*         terrain,
00107         const MapInfo&   mapInfo,
00108         bool             wrapInPagedLOD );
00109 
00110     bool createValidGeoImage(
00111         ImageLayer*       layer,
00112         const TileKey&    key,
00113         GeoImage&         out_image,
00114         TileKey&          out_actualTileKey,
00115         ProgressCallback* progress  = 0);
00116 
00117     osg::Matrixd getTransformFromExtents(double minX, double minY, double maxX, double maxY) const;
00118 
00119     // checks whether more data exists below the specified key's level of detail
00120     bool hasMoreLevels( Map* map, const TileKey& key );
00121 
00122     static osg::HeightField* createEmptyHeightField(
00123         const TileKey& key,
00124         int            numCols =8,
00125         int            numRows =8 );
00126 
00127     osgTerrain::HeightFieldLayer* createPlaceholderHeightfieldLayer(
00128         osg::HeightField* ancestorHF,
00129         const TileKey&    ancestorKey,
00130         const TileKey&    key,
00131         GeoLocator*       locator );
00132 
00133 protected:
00134 
00135     osg::Node* createPlaceholderTile(
00136         const MapFrame&   mapf,
00137         StreamingTerrain* terrain,
00138         const TileKey&    key );
00139 
00140     osg::Node* createPopulatedTile(
00141         const MapFrame&  mapf,
00142         Terrain*         terrain,
00143         const TileKey&   key,
00144         bool             wrapInPagedLOD,
00145         bool             fallback,
00146         bool&            out_validData);
00147 
00148     void addPlaceholderImageLayers( Tile* tile, Tile* ancestorTile );
00149 
00150     void addPlaceholderHeightfieldLayer(
00151         StreamingTile* tile,
00152         StreamingTile* ancestorTile,
00153         GeoLocator*    defaultLocator,
00154         const TileKey& key,
00155         const TileKey& ancestorKey );
00156 
00157     osg::ClusterCullingCallback* createClusterCullingCallback(
00158         Tile*                tile,
00159         osg::EllipsoidModel* et );
00160 
00161     void init();
00162 
00163 protected:
00164 
00165     unsigned          _engineId;
00166     const MapFrame&   _cull_thread_mapf;
00167     OSGTerrainOptions _terrainOptions;
00168 };
00169 
00170 #endif // OSGEARTH_ENGINE_OSGTERRAIN_TILE_FACTORY_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines