/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield 
 *
 * This library is open source and may be redistributed and/or modified under  
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 * 
 * This library 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 
 * OpenSceneGraph Public License for more details.
*/

#ifndef OSG_CAMERA_GROUP_H
#define OSG_CAMERA_GROUP_H


#include <Producer/CameraGroup>

#include <osg/Group>
#include <osg/StateSet>
#include <osg/FrameStamp>
#include <osg/DisplaySettings>

#include <osgProducer/SceneHandler>

namespace osgProducer {

class OSGPRODUCER_EXPORT CameraGroup : public Producer::CameraGroup
{
    public :

        typedef std::vector <osgProducer::SceneHandler *> SceneHandlerList;

        CameraGroup();

        CameraGroup(Producer::CameraConfig *cfg);

        CameraGroup(const std::string& configFile);

        virtual ~CameraGroup() {}



        void setSceneData( osg::Node *scene );
        
        osg::Node *getSceneData() { return _scene_data.get(); }

        const osg::Node *getSceneData() const { return _scene_data.get(); }

        

        void setSceneDecorator( osg::Group* decorator);
        
        osg::Group* getSceneDecorator() { return _scene_decorator.get(); }

        const osg::Group* getSceneDecorator() const { return _scene_decorator.get(); }


        
        void setDisplaySettings( osg::DisplaySettings *ds ) { _ds = ds; }

        osg::DisplaySettings *getDisplaySettings() { return _ds.get(); }
        
        const osg::DisplaySettings *getDisplaySettings() const { return _ds.get(); }
        
        
        
        void setFrameStamp( osg::FrameStamp* fs );

        osg::FrameStamp *getFrameStamp() { return _frameStamp.get(); }

        const osg::FrameStamp *getFrameStamp() const { return _frameStamp.get(); }


        void setGlobalStateSet( osg::StateSet *sset );

        osg::StateSet *getGlobalStateSet() { return _global_stateset.get(); }

        const osg::StateSet *getGlobalStateSet() const { return _global_stateset.get(); }


        void setBackgroundColor( const osg::Vec4& backgroundColor );

        osg::Vec4& getBackgroundColor() { return _background_color; }

        const osg::Vec4& getBackgroundColor() const { return _background_color; }


        void setLODScale( float scale );

        void setFusionDistance( osgUtil::SceneView::FusionDistanceMode mode,float value=1.0f);


        void advance();


        virtual void realize( ThreadingModel thread_model= SingleThreaded );


        virtual void frame();


    protected :

        void setUpSceneViewsWithData();


        osg::ref_ptr<osg::Node>                 _scene_data;
        osg::ref_ptr<osg::Group>                _scene_decorator;

        osg::ref_ptr<osg::StateSet>             _global_stateset;
        osg::Vec4                               _background_color;
        float                                   _LODScale;
        
        osgUtil::SceneView::FusionDistanceMode  _fusionDistanceMode;
        float                                   _fusionDistanceValue;
        
        SceneHandlerList                        _shvec;
        osg::ref_ptr<osg::DisplaySettings>      _ds;
        bool                                    _initialized;
        osg::ref_ptr<osg::FrameStamp>           _frameStamp;

        void _init();
};

}

#endif
