osgEarth 2.1.1
|
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 #ifndef OSGEARTH_OVERLAY_DECORATOR 00020 #define OSGEARTH_OVERLAY_DECORATOR 00021 00022 #include <osgEarth/Common> 00023 #include <osgEarth/ShaderComposition> 00024 #include <osgEarth/TerrainEngineNode> 00025 #include <osg/Camera> 00026 #include <osg/CoordinateSystemNode> 00027 #include <osg/Texture2D> 00028 #include <osg/TexGenNode> 00029 #include <osg/Uniform> 00030 #include <osgUtil/CullVisitor> 00031 00032 namespace osgEarth 00033 { 00043 class OSGEARTH_EXPORT OverlayDecorator : public TerrainDecorator 00044 { 00045 public: 00046 OverlayDecorator(); 00047 00051 void setOverlayGraph( osg::Node* node ); 00052 osg::Node* getOverlayGraph() const { return _overlayGraph.get(); } 00053 00059 void setTextureUnit( int unit ); 00060 int getTextureUnit() const { return *_textureUnit; } 00061 00067 void setTextureSize( int texSize ); 00068 int getTextureSize() const { return *_textureSize; } 00069 00075 void setMipmapping( bool value ); 00076 bool getMipmapping() const { return _mipmapping; } 00077 00083 void setVertexWarping( bool value ); 00084 bool getVertexWarping() const { return _warping; } 00085 00092 void setOverlayBlending( bool value ); 00093 bool getOverlayBlending() const { return _rttBlending; } 00094 00095 public: // TerrainDecorator 00096 virtual void onInstall( TerrainEngineNode* engine ); 00097 virtual void onUninstall( TerrainEngineNode* engine ); 00098 00099 public: // osg::Node 00100 void traverse( osg::NodeVisitor& nv ); 00101 00102 private: 00103 void updateRTTCamera( osg::NodeVisitor& nv ); 00104 void cull( osgUtil::CullVisitor* cv ); 00105 void reinit(); 00106 void initSubgraphShaders( osg::StateSet* set ); 00107 void initRTTShaders( osg::StateSet* set ); 00108 00109 private: 00110 osg::ref_ptr<osg::Node> _overlayGraph; 00111 osg::ref_ptr<osg::Camera> _rttCamera; 00112 osg::ref_ptr<osg::Texture2D> _projTexture; 00113 osg::ref_ptr<osg::TexGenNode> _texGenNode; 00114 osg::ref_ptr<osg::Uniform> _texGenUniform; 00115 osg::ref_ptr<osg::Uniform> _warpUniform; 00116 osg::ref_ptr<osg::StateSet> _subgraphStateSet; 00117 optional<int> _explicitTextureUnit; 00118 optional<int> _textureUnit; 00119 optional<int> _textureSize; 00120 bool _useShaders; 00121 bool _useWarping; 00122 float _warp; 00123 bool _warping; 00124 bool _visualizeWarp; 00125 bool _isGeocentric; 00126 double _maxProjectedMapExtent; 00127 bool _mipmapping; 00128 bool _rttBlending; 00129 osg::Matrixd _rttViewMatrix; 00130 osg::Matrixd _rttProjMatrix; 00131 osg::Matrixd _projectorViewMatrix; 00132 osg::Matrixd _projectorProjMatrix; 00133 00134 osg::ref_ptr<const osg::EllipsoidModel> _ellipsoid; 00135 osg::ref_ptr<osgEarth::VirtualProgram> _vp; 00136 osg::ref_ptr<TerrainEngineNode> _engine; 00137 }; 00138 00139 } // namespace osgEarth 00140 00141 #endif //OSGEARTH_OVERLAY_DECORATOR