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

#ifndef WORLD_WORLD_HH
#define WORLD_WORLD_HH 1

#define GET_WORLD() (world::World::GetInstance())

#include "base/singleton.hh"
#include "gfx/module.hh"
#include "gfx/graphics.hh"
using namespace gfx;
namespace object { class Object; }
using namespace object;

namespace world {

////////////////////////////////////////////////////////////////////////////////
/// @brief World class defines the simulated world (excludes scene-graph).
///
/// Historical notes:
/// In previous versions, World served as a facade over the scene-graph,
/// was the container of Objects, etc.  World eventually grew too complex
/// so much of its functionality was factored out to SceneGraph.
/// Currently, World now only has this functionality:
/// - to make the primordial world by World::Make()
/// - provide info about the simulated world
///
class World
{
public:
                    World( void ) { }
                    ~World() { }
                    DEFINE_GetInstance( World );
    void            Make( void );

// Info:
public:
    WorldVertex     GetPosition( void ) { return WorldVertex(0,0,0); }  // center
    fp              GetRadius( void );
    BoxVolume       GetVolume( void );
    string          GetName( void );
    bool            IfFlat( void );  // STRONGLY DEPRECATED
    bool            IfLowAltitude( const WorldVertex& pos );

// Orientation:
public:
    DECLARE_SINGLETON_CLASS_VARS( World )
    CLASS_CONST int ALT_UP_DIR   = 1;  // altitude
    CLASS_CONST int ALT_DOWN_DIR = -1;
    bool            IfDownward( fp n ) { return n < 0; }
    bool            IfUpward( fp n )   { return n >= 0; }
    WorldVertex     ComputeUpVector( const SphereVertex& sv );
    WorldVertex     ComputeUpVector( const WorldVertex& pos );
    void            RotateTangential( Object& object, const SphereVertex& sv );
    const Matrix&   GetTangentMatrix( const SphereVertex& sv );
};

} // namespace world

#endif // WORLD_WORLD_HH
