/*****************************************************************************
 * $LastChangedDate: 2011-04-09 21:58:06 -0400 (Sat, 09 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Weather (Singleton).
 *//*
 * LEGAL:   COPYRIGHT (C) 2009 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef SKY_WEATHER_HH
#define SKY_WEATHER_HH 1

#include "base/singleton.hh"
using namespace base;
#include "graph/module.hh"
#include "graph/graph.hh"
using namespace graph;

#include <osgParticle/PrecipitationEffect>

namespace sky {

#define GET_WEATHER() (sky::Weather::GetInstance())

////////////////////////////////////////////////////////////////////////////////
/// @brief Weather model (Singleton).
///
class Weather
{
PREVENT_COPYING(Weather)
    Weather( void );
    ~Weather();

public:
    enum eWeather
    {
        eWeather_RANDOM,
        eWeather_CLEAR,
        eWeather_RAIN,
        eWeather_SNOW,
        eWeather_DEFAULT = eWeather_RANDOM,
    };

public:
                    DEFINE_GetInstance( Weather )  // Singleton
    void            Enable( const bool enable );
    void            SetWeather( const eWeather weather );
    eWeather        GetWeather( void ) const;
    bool            IfSnowOrRain( void ) const { return (mWeather == eWeather_RAIN) or (mWeather == eWeather_SNOW); }

// LIMITED-USE:
    RefPtr<Node>    GetNode( void ) { return mGraph->GetRootNode(); }

private:
    CLASS_VAR Weather*                          msInstance;     ///< Singleton
    bool                                        mEnabled;       ///< while disabled, force clear weather
    eWeather                                    mWeather;       ///< clear, rain, snow, etc
    RefPtr<osgParticle::PrecipitationEffect>    mPrecipitationEffect;
    RefPtr<GroupNode>                           mGroupNode;     ///< root node of Graph
    shptr<Graph>                                mGraph;         ///< disabling Graph disables Weather
};

} // namespace sky

#endif // SKY_WEATHER_HH
