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

#ifndef SKY_SKY_HH
#define SKY_SKY_HH 1

#include <utility>
#include "base/singleton.hh"
using namespace base;
#include "gfx/module.hh"
#include "gfx/graphics.hh"
using namespace gfx;
#include "graph/module.hh"
using namespace graph;

namespace sky {

#define GET_SKY()       (Sky::GetInstance())        // returns ref
#define GET_SKY_DOME()  (GET_SKY().GetSkyDome())    // returns ref also

// This header is the public interface, so avoid including implementation headers.
class SkyDome; class CloudParticleSystem; class Sun; class Moon; class Stars;

// Functions:
void SetSkyFog( RefPtr<Node> node );

////////////////////////////////////////////////////////////////////////////////
/// @brief Sky model (Singleton).
///
class Sky
{
PREVENT_COPYING(Sky)
private:
                        Sky( void );
                        ~Sky();

public:
                        DEFINE_GetInstance( Sky )  // Singleton
    void                Make( void );
    void                Make( const fp hour );
    void                SetHour( const fp hour );  // fp to allow gradations of sun's movement

public:
// LIMITED TO SKY-RELATED CLASSES:
    BoxVolume           GetVolume( void );
    SkyDome&            GetSkyDome( void );
    Sun&                GetSun( void );

private:
    void                ArrangeNodes( void );
    std::pair<Degree,Degree> ComputeLatLonFromHour( const fp hour );  // compute sun's position

private:
    CLASS_VAR Sky*              msInstance;             ///< Singleton
    shptr<SkyDome>              mSkyDome;               ///< sky dome
    shptr<CloudParticleSystem>  mCloudParticleSystem0;  ///< clouds
    shptr<CloudParticleSystem>  mCloudParticleSystem1;
    shptr<CloudParticleSystem>  mCloudParticleSystem2;
    shptr<CloudParticleSystem>  mCloudParticleSystem3;
    shptr<Sun>                  mSun;                   ///< position of sun in sky
    shptr<Moon>                 mMoon;                  ///< Object-derivative
    shptr<Stars>                mStars;                 ///< the Stars (Object-derivative)
    fp                          mHour;
    bool                        mNeedToSetHour;
};

} // namespace sky

#endif // SKY_SKY_HH
