/* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
 * Copyright 2008-2013 Pelican Mapping
 * http://osgearth.org
 *
 * osgEarth is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */
#ifndef OSGEARTH_DRIVER_OCEAN_SURFACE_CONTAINER
#define OSGEARTH_DRIVER_OCEAN_SURFACE_CONTAINER 1

#include "OceanSurface"
#include <osgEarth/MapNode>
#include <osgEarth/MapNodeObserver>
#include <osgEarth/ImageLayer>
#include <osgEarth/URI>
#include <osg/Node>
#include <osg/Image>
#include <osg/Uniform>

namespace osgEarth_ocean_surface
{
    using namespace osgEarth;
    using namespace osgEarth::Drivers;

    class OceanSurfaceContainer : public osg::Group,
                                  public MapNodeObserver
    {
    public:
        OceanSurfaceContainer( MapNode* mapNode, const OceanSurfaceOptions& options );

        /** dtor */
        virtual ~OceanSurfaceContainer() { }

        void apply( const OceanSurfaceOptions& options );

    public:
        MapNode* getMapNode() { return _parentMapNode.get(); }
        void setMapNode( MapNode* mapNode );

    private:
        osg::observer_ptr<MapNode> _parentMapNode;
        OceanSurfaceOptions        _options;
        osg::ref_ptr<osg::Uniform> _seaLevel, _lowFeather, _highFeather;
        osg::ref_ptr<osg::Uniform> _maxRange, _fadeRange;
        osg::ref_ptr<osg::Uniform> _baseColor;

        void rebuild();
    };

} // namespace osgEarth_ocean_surface

#endif // OSGEARTH_DRIVER_OCEAN_SURFACE_CONTAINER
