osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/model_feature_geom/FeatureGeomModelSource.cpp

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 #include <osgEarth/ModelSource>
00021 #include <osgEarth/Registry>
00022 #include <osgEarth/Map>
00023 #include <osgEarthFeatures/GeometryCompiler>
00024 
00025 #include <osg/Notify>
00026 #include <osg/MatrixTransform>
00027 #include <osgDB/FileNameUtils>
00028 
00029 #include "FeatureGeomModelOptions"
00030 
00031 using namespace osgEarth;
00032 using namespace osgEarth::Features;
00033 using namespace osgEarth::Symbology;
00034 using namespace osgEarth::Drivers;
00035 
00036 //------------------------------------------------------------------------
00037 
00038 namespace
00039 {
00040     //------------------------------------------------------------------------
00041 
00043     class FeatureGeomModelSource : public FeatureModelSource
00044     {
00045     public:
00046         FeatureGeomModelSource( const ModelSourceOptions& options )
00047             : FeatureModelSource( options ),
00048               _options( options )
00049         {
00050             //nop
00051         }
00052 
00053         const FeatureGeomModelOptions& getOptions() const { return _options; }
00054 
00055         //override
00056         void initialize( const std::string& referenceURI, const osgEarth::Map* map )
00057         {
00058             FeatureModelSource::initialize( referenceURI, map );
00059         }
00060 
00061         //override
00062         FeatureNodeFactory* createFeatureNodeFactory()
00063         {
00064             return new GeomFeatureNodeFactory( _options.compilerOptions() );
00065         }
00066 
00067     private:
00068         const FeatureGeomModelOptions _options;
00069     };
00070 }
00071 
00072 //------------------------------------------------------------------------
00073 
00075 class FeatureGeomModelSourceDriver : public ModelSourceDriver
00076 {
00077 public:
00078     FeatureGeomModelSourceDriver()
00079     {
00080         supportsExtension( "osgearth_model_feature_geom", "osgEarth feature geom plugin" );
00081     }
00082 
00083     virtual const char* className()
00084     {
00085         return "osgEarth Feature Geom Model Plugin";
00086     }
00087 
00088     virtual ReadResult readObject(const std::string& file_name, const Options* options) const
00089     {
00090         if ( !acceptsExtension(osgDB::getLowerCaseFileExtension( file_name )))
00091             return ReadResult::FILE_NOT_HANDLED;
00092 
00093         return new FeatureGeomModelSource( getModelSourceOptions(options) );
00094     }
00095 };
00096 
00097 REGISTER_OSGPLUGIN(osgearth_model_feature_geom, FeatureGeomModelSourceDriver) 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines