/*
-----------------------------------------------------------------------------
Filename:    TutorialApplication.h
-----------------------------------------------------------------------------

This source file is part of the
   ___                 __    __ _ _    _ 
  /___\__ _ _ __ ___  / / /\ \ (_) | _(_)
 //  // _` | '__/ _ \ \ \/  \/ / | |/ / |
/ \_// (_| | | |  __/  \  /\  /| |   <| |
\___/ \__, |_|  \___|   \/  \/ |_|_|\_\_|
      |___/                              
      Tutorial Framework
      http://www.ogre3d.org/tikiwiki/
-----------------------------------------------------------------------------
*/
#ifndef __TutorialApplication_h_
#define __TutorialApplication_h_

#include "BaseApplication.h"
#include "fglove.h"

class TutorialApplication : public BaseApplication
{

public:
    TutorialApplication(void);
    virtual ~TutorialApplication(void);

protected:
	void ConnectGlove(void);

    virtual void createScene(void);
	virtual void createCamera(void);
	//virtual void createViewports(void);

	//virtual void createFrameListener(void);
	virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
	
	// OIS::KeyListener
    virtual bool keyPressed( const OIS::KeyEvent& evt );
    virtual bool keyReleased( const OIS::KeyEvent& evt );
    //OIS::MouseListener
    virtual bool mouseMoved( const OIS::MouseEvent& evt );
    virtual bool mousePressed( const OIS::MouseEvent& evt, OIS::MouseButtonID id );
    virtual bool mouseReleased( const OIS::MouseEvent& evt, OIS::MouseButtonID id );
	// Called when a any button of the GUI is clicked
	virtual void buttonHit(OgreBites::Button* b);

	Ogre::Real m_fRotateSpeed;			// The rotate constant
	Ogre::Real m_fRotateDecel;			// The rotate deceleration constant
	Ogre::Real m_fZoomSpeed;			// The zoom constant
	Ogre::Real m_fZoomDecel;			// The zoom deceleration
	Ogre::Real m_fMaxZoom;				// Max zoom distance	
	Ogre::Real m_fMinZoom;				// Min zoom distance
	Ogre::Real m_fPivotPitch;			// Current pitch of the camera   
 	
	Ogre::SceneNode* m_pCameraNode;		// Current position of cam
	Ogre::SceneNode* m_pCameraGoal;		// Where the camera should be (for smoother movement)
	Ogre::SceneNode* m_pCameraPivot;	// Pivot around which cam will rotate
	
	

private:
	
	void Update5SensorGlove();
	void Update14SensorGlove();
	void UpdateCam(Ogre::Real fdT);
	void setupCamera();
	void updateCameraGoal(Ogre::Real deltaYaw, Ogre::Real deltaPitch, Ogre::Real deltaZoom);

	fdGlove* m_pGlove;					// our one and only glove
};

#endif // #ifndef __TutorialApplication_h_
