/*****************************************************************************
 * $LastChangedDate: 2010-01-24 20:49:54 -0500 (Sun, 24 Jan 2010) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Planet class is a Facade over a flat or spherical world.
 * @remarks Planet is a private implementation of the world module.
 *//*
 * 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).
 *****************************************************************************/

#if NEED_PLANET_CLASS  // private implementation
#ifndef WORLD_PLANET_HH
#define WORLD_PLANET_HH 1

#define GET_PLANET() (world::Planet::GetInstance())

namespace world {

////////////////////////////////////////////////////////////////////////////////
/// @brief Planet class is a Facade over a flat or spherical world.
///
/// Planet is a private implementation of the world module.
/// Unconventionally, this singleton class instantiates a derivative of itself.
///
class Planet
{
protected:
                            Planet( void ) { }
    virtual                 ~Planet() { }

private:
    CLASS_METHOD Planet*    CreateInstance( void );  // creates derivative

public:
    CLASS_METHOD Planet&    GetInstance( void )  // Singleton
    {
        if ( UX( msInstance == NULL ) )
            msInstance = CreateInstance();  // creates derivative
        return *msInstance;
    }

// Abstract methods:
    virtual shptr<Object>   GetRootObject( void ) = 0;
    virtual bool            IfFlat( void ) = 0;
    virtual const Matrix&   GetTangentMatrix( const SphereVertex& sv ) = 0;
    virtual WorldVertex     ComputeUpVector( const SphereVertex& sv ) = 0;
    virtual WorldVertex     SphereVertex2WorldVertex( const SphereVertex& sv ) = 0;  // clients of world should use geo::SphereVertex2WorldVertex()
    virtual SphereVertex    WorldVertex2SphereVertex( const WorldVertex& wv ) = 0;  // clients of world should use geo::WorldVertex2SphereVertex()
    virtual fpx             MeterSimRatio( void ) = 0;
    virtual fp              RadiusGraphical( void ) = 0;
    virtual BoxVolume       GetVolume( void ) = 0;

private:
    CLASS_VAR Planet*       msInstance;
};

} // namespace world

#endif // WORLD_PLANET_HH
#endif // NEED_PLANET_CLASS  // private implementation
