osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarth/ModelSource

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_MODEL_SOURCE_H
00021 #define OSGEARTH_MODEL_SOURCE_H 1
00022 
00023 #include <osgEarth/Common>
00024 #include <osgEarth/Config>
00025 #include <osgEarth/Progress>
00026 #include <osgEarth/Revisioning>
00027 #include <osg/Referenced>
00028 
00029 namespace osgEarth
00030 {   
00031     class Map;
00032     
00036     class OSGEARTH_EXPORT ModelSourceOptions : public DriverConfigOptions
00037     {
00038     public:
00039         ModelSourceOptions( const ConfigOptions& options =ConfigOptions() ) :
00040               DriverConfigOptions( options ),
00041               _minRange(0),
00042               _maxRange(FLT_MAX),
00043               _renderOrder( 11 ),
00044               _depthTestEnabled( true ) { fromConfig(_conf); }
00045 
00046     public: // properties
00047 
00049         optional<float>& minRange() { return _minRange; }
00050         const optional<float>& minRange() const { return _minRange; }
00051 
00053         optional<float>& maxRange() { return _maxRange; }
00054         const optional<float>& maxRange() const { return _maxRange; }
00055 
00057         optional<int>& renderOrder() { return _renderOrder; }
00058         const optional<int>& renderOrder() const { return _renderOrder; }
00059 
00061         optional<bool>& depthTestEnabled() { return _depthTestEnabled; }
00062         const optional<bool>& depthTestEnabled() const { return _depthTestEnabled; }
00063 
00064     public:
00065         virtual Config getConfig() const;
00066 
00067     protected:
00068         virtual void mergeConfig( const Config& conf );
00069         
00070     private:
00071         void fromConfig( const Config& conf );
00072 
00073         optional<float> _minRange, _maxRange;
00074         optional<int> _renderOrder;
00075         optional<bool> _depthTestEnabled;
00076         optional<bool> _overlay;
00077     };
00078 
00082     class OSGEARTH_EXPORT ModelSource : public virtual Revisioned<osg::Object>
00083     {
00084     public:        
00085         ModelSource( const ModelSourceOptions& options =ModelSourceOptions() );
00086 
00090         virtual osg::Node* createNode( ProgressCallback* progress =0L ) =0;
00091 
00092 
00093     public: // META_Object specialization
00094         virtual osg::Object* cloneType() const { return 0; } // cloneType() not appropriate
00095         virtual osg::Object* clone(const osg::CopyOp&) const { return 0; } // clone() not appropriate
00096         virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ModelSource*>(obj)!=NULL; }
00097         virtual const char* className() const { return "ModelSource"; }
00098         virtual const char* libraryName() const { return "osgEarth"; }
00099 
00100     public:
00102                 virtual void initialize(
00103             const std::string& referenceURI,
00104             const Map* map ) { }
00105 
00106         const ModelSourceOptions& getOptions() const {
00107             return _options; }
00108 
00109     protected:
00110         virtual ~ModelSource() { }
00111 
00112     private:
00113         const ModelSourceOptions _options;
00114         optional<double> _minRange;
00115         optional<double> _maxRange;
00116         optional<int>    _renderOrder;
00117 
00118         friend class Map;
00119         friend class MapEngine;
00120         friend class ModelSourceFactory;
00121     };
00122 
00123     //--------------------------------------------------------------------
00124 
00125     class OSGEARTH_EXPORT ModelSourceDriver : public osgDB::ReaderWriter
00126     {
00127     protected:
00128         const ModelSourceOptions& getModelSourceOptions( const osgDB::ReaderWriter::Options* rwOpt ) const;
00129     };
00130 
00131     //--------------------------------------------------------------------
00132 
00137     class OSGEARTH_EXPORT ModelSourceFactory
00138     {   
00139         public:
00140         static ModelSource* create( const ModelSourceOptions& options );
00141     };
00142 }
00143 
00144 #endif // OSGEARTH_MODEL_SOURCE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines