osgEarth 2.1.1

/home/cube/sources/osgearth/src/osgEarthSymbology/Skins

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 OSGEARTHSYMBOLOGY_SKIN_RESOURCE_H
00021 #define OSGEARTHSYMBOLOGY_SKIN_RESOURCE_H 1
00022 
00023 #include <osgEarthSymbology/Common>
00024 #include <osgEarthSymbology/Resource>
00025 #include <osgEarthSymbology/Symbol>
00026 #include <osgEarth/URI>
00027 #include <osg/TexEnv>
00028 
00029 namespace osgEarth { namespace Symbology
00030 {
00031     using namespace osgEarth;
00032 
00037     class OSGEARTHSYMBOLOGY_EXPORT SkinResource : public Resource
00038     {
00039     public:
00041         SkinResource( const Config& conf =Config() );
00042 
00047         osg::StateSet* createStateSet() const;
00048 
00049     public:
00051         optional<URI>& imageURI() { return _imageURI; }
00052         const optional<URI>& imageURI() const { return _imageURI; }
00053 
00055         optional<float>& imageWidth() { return _imageWidth; }
00056         const optional<float>& imageWidth() const { return _imageWidth; }
00057 
00059         optional<float>& imageHeight() { return _imageHeight; }
00060         const optional<float>& imageHeight() const { return _imageHeight; }
00061 
00063         optional<float>& minObjectHeight() { return _minObjHeight; }
00064         const optional<float>& minObjectHeight() const { return _minObjHeight; }
00065 
00067         optional<float>& maxObjectHeight() { return _maxObjHeight; }
00068         const optional<float>& maxObjectHeight() const { return _minObjHeight; }
00069 
00071         optional<bool>& isTiled() { return _isTiled; }
00072         const optional<bool>& isTiled() const { return _isTiled; }
00073 
00075         optional<osg::TexEnv::Mode>& texEnvMode() { return _texEnvMode; }
00076         const optional<osg::TexEnv::Mode>& texEnvMode() const { return _texEnvMode; }
00077 
00079         optional<unsigned> maxTextureSpan() { return _maxTexSpan; }
00080         const optional<unsigned> maxTextureSpan() const { return _maxTexSpan; }
00081 
00082     public: // serialization methods
00083 
00084         virtual Config getConfig() const;
00085         void mergeConfig( const Config& conf );
00086 
00087     protected:
00088 
00089         osg::StateSet* createStateSet( osg::Image* image ) const;
00090 
00091         osg::Image* createImage() const;
00092 
00093     protected:
00094 
00095         optional<URI>               _imageURI;
00096         optional<float>             _imageWidth;
00097         optional<float>             _imageHeight;
00098         optional<float>             _minObjHeight;
00099         optional<float>             _maxObjHeight;
00100         optional<bool>              _isTiled;
00101         optional<osg::TexEnv::Mode> _texEnvMode;
00102         optional<unsigned>          _maxTexSpan;
00103     };
00104 
00105 
00106     typedef std::map<std::string, osg::ref_ptr<SkinResource> > SkinResourceMap;
00107 
00108 
00113     class OSGEARTHSYMBOLOGY_EXPORT SkinSymbol : public Taggable<Symbol>
00114     {
00115     public:
00116         SkinSymbol( const Config& conf =Config() );
00117 
00118     public: // query parameters
00119 
00121         optional<std::string>& libraryName() { return _libraryName; }
00122         const optional<std::string>& libraryName() const { return _libraryName; }
00123 
00125         optional<float>& objectHeight() { return _objHeight; }
00126         const optional<float>& objectHeight() const { return _objHeight; }
00127 
00129         optional<float>& minObjectHeight() { return _minObjHeight; }
00130         const optional<float>& minObjectHeight() const { return _minObjHeight; }
00131 
00133         optional<float>& maxObjectHeight() { return _maxObjHeight; }
00134         const optional<float>& maxObjectHeight() const { return _minObjHeight; }
00135 
00137         optional<bool>& isTiled() { return _isTiled; }
00138         const optional<bool>& isTiled() const { return _isTiled; }
00139 
00141         optional<unsigned>& randomSeed() { return _randomSeed; }
00142         const optional<unsigned>& randomSeed() const { return _randomSeed; }
00143 
00144     public:
00145         void mergeConfig(const Config& conf);
00146         Config getConfig() const;
00147 
00148     protected:
00149         optional<std::string> _libraryName;
00150         optional<float>       _objHeight;
00151         optional<float>       _minObjHeight;
00152         optional<float>       _maxObjHeight;
00153         optional<bool>        _isTiled;
00154         optional<unsigned>    _randomSeed;
00155     };
00156 
00157     typedef std::vector< osg::ref_ptr<SkinResource> > SkinResourceVector;
00158 
00159 } } // namespace osgEarth::Symbology
00160 
00161 #endif // OSGEARTHSYMBOLOGY_SKIN_RESOURCE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines