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 OSGEARTHUTIL_OCEANSURFACENODE 00020 #define OSGEARTHUTIL_OCEANSURFACENODE 00021 00022 #include <osgEarthUtil/Common> 00023 #include <osgEarth/ImageLayer> 00024 #include <osg/Group> 00025 #include <osg/observer_ptr> 00026 #include <osg/CoordinateSystemNode> 00027 #include <osg/Program> 00028 #include <osg/Texture3D> 00029 00030 namespace osgEarth { namespace Util 00031 { 00032 using namespace osgEarth; 00033 00038 class OSGEARTHUTIL_EXPORT OceanSurfaceNode : public osg::Group 00039 { 00040 public: 00044 OceanSurfaceNode(); 00045 00049 void setOceanMaskImageLayer( const ImageLayer* layer ); 00050 00054 const ImageLayer* getOceanMaskImageLayer() const { return _maskLayer.get(); } 00055 00059 float getWaveHeight() const; 00060 00064 void setWaveHeight(float waveHeight); 00065 00069 float getMaxRange() const; 00070 00074 void setMaxRange(float maxRange); 00075 00079 float getPeriod() const; 00080 00084 void setPeriod(float period); 00085 00089 bool getEnabled() const; 00090 00094 void setEnabled(bool enabled); 00095 00099 bool getInvertMask() const; 00100 00105 void setInvertMask(bool invertMask); 00106 00111 void setModulationColor( const osg::Vec4f& color ); 00112 00113 osg::Vec4f getModulationColor() const; 00114 00118 float getOceanAnimationPeriod() const; 00119 00123 void setOceanAnimationPeriod(float oceanAnimationPeriod); 00124 00128 osg::Image* getOceanSurfaceImage() const; 00129 00133 void setOceanSurfaceImage( osg::Image* image); 00134 00138 float getOceanSurfaceImageSizeRadians() const; 00139 00143 void setOceanSurfaceImageSizeRadians( float size ); 00144 00148 void setAdjustToMSL( bool adjustToMSL); 00149 00153 bool getAdjustToMSL() const; 00154 00155 public: 00156 virtual void traverse( osg::NodeVisitor& nv ); 00157 00158 private: 00159 void rebuildShaders(); 00160 00161 void shadersDirty(bool value); 00162 bool _shadersDirty; 00163 00164 float _maxRange; 00165 UID _oceanMaskLayerUID; 00166 int _oceanSurfaceTextureUnit; 00167 bool _oceanSurfaceTextureApplied; 00168 float _waveHeight; 00169 float _period; 00170 bool _enabled; 00171 bool _invertMask; 00172 bool _adjustToMSL; 00173 osg::observer_ptr<osg::CoordinateSystemNode> _csn; 00174 optional<osg::Vec4f> _oceanColor; 00175 float _oceanAnimationPeriod; 00176 float _oceanSurfaceImageSizeRadians; 00177 osg::ref_ptr< osg::Image > _oceanSurfaceImage; 00178 osg::ref_ptr< osg::Texture3D > _oceanSurfaceTexture; 00179 osg::observer_ptr< const ImageLayer > _maskLayer; 00180 }; 00181 00182 } } // namespace osgEarth::Util 00183 00184 #endif //OSGEARTHUTIL_OCEANSURFACENODE