/*****************************************************************************
 * $LastChangedDate: 2011-04-09 21:58:06 -0400 (Sat, 09 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   The "current craft" as the observer of a view of the scene.
 *//*
 * 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 VIEW_OBSERVER_CURRENT_CRAFT_HH
#define VIEW_OBSERVER_CURRENT_CRAFT_HH 1

#include "control/module.hh"
#include "control/control.hh"
using namespace control;
#include "view/observer.hh"

namespace view {

////////////////////////////////////////////////////////////////////////////////
/// @brief The "current craft" as the observer of a view of the scene.
///
/// The Observer is the source of the Viewpoint (View Matrix).
/// Pass Observer object to OtwViewpoint ctor so it will provide the Observer Matrix.
///
/// Implementation:
/// This is a Singleton in disguise (think of this as a link).
/// Making a shptr using "new ObserverCurrentCraft" is needed for OtwViewpoint and Lua.
/// Regardless, every instance of ObserverCurrentCraft is based on the unique "current craft".
///
class ObserverCurrentCraft : public Observer
{
PREVENT_COPYING(ObserverCurrentCraft)
public:
    ObserverCurrentCraft( void )
    {
        SET_TYPESIG(this,TYPESIG_OBSERVER_CURRENT_CRAFT);
    }

    virtual ~ObserverCurrentCraft()
    {
        INVALIDATE_TYPESIG(this,TYPESIG_OBSERVER_CURRENT_CRAFT);
    }

    virtual Matrix GetObserverMatrix( void )
    {
    CHECK_TYPESIG(this,TYPESIG_OBSERVER);
    CHECK_TYPESIG(GET_CURRENT_CRAFT(),TYPESIG_CRAFT);

        return GET_CURRENT_CRAFT()->GetMatrix();
    }

public:
    DECLARE_TYPESIG(TYPESIG_OBSERVER_CURRENT_CRAFT)
};

} // namespace view

#endif // VIEW_OBSERVER_CURRENT_CRAFT_HH
