osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthDrivers/engine_droam/Plugin.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 #include <osgDB/FileNameUtils>
00020 #include <osgDB/FileUtils>
00021 #include <osgDB/Registry>
00022 #include <osgEarth/MapNode>
00023 #include <string>
00024 #include "DRoamNode"
00025 
00026 class DRoamEnginePlugin : public osgDB::ReaderWriter
00027 {
00028 public:
00029     DRoamEnginePlugin() {}
00030 
00031     virtual const char* className()
00032     {
00033         return "OSG Earth D-ROAM Engine";
00034     }
00035 
00036     virtual bool acceptsExtension(const std::string& extension) const
00037     {
00038         return osgDB::equalCaseInsensitive( extension, "engine_droam" );
00039     }
00040 
00041     virtual ReadResult readNode(const std::string& uri, const Options* options) const
00042     {
00043         if ( "osgearth_engine_droam" == osgDB::getFileExtension( uri ) )
00044         {
00045             std::string earthFile = osgDB::getNameLessExtension( uri );
00046 
00047             osg::ref_ptr<osg::Node> node = osgDB::readNodeFile(earthFile);
00048             osgEarth::MapNode* mapNode = osgEarth::MapNode::findMapNode(node.get());
00049             if ( mapNode )
00050             {
00051                 return ReadResult( new DRoamNode( mapNode->getMap() ) );
00052             }
00053             else
00054             {
00055                 return ReadResult::FILE_NOT_FOUND;
00056             }
00057         }
00058         else
00059             return ReadResult::FILE_NOT_HANDLED;
00060     }           
00061 };
00062 
00063 REGISTER_OSGPLUGIN(engine_droam, DRoamEnginePlugin)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines