#ifndef __MyFrameListener_H__
#define __MyFrameListener_H__

#include "Ogre.h"
#include "OgreStringConverter.h"
#include "OgreException.h"

#include "ExampleFrameListener.h"

#include "NxOgre.h"

using namespace Ogre;

class MyFrameListener: public ExampleFrameListener{//FrameListener, public WindowEventListener

public:

	AnimationState* mAnimState;
	NxOgre::Body* camBody;
	//Camera* cam;
/*
	void setupConst(RenderWindow* win, Camera* cam, bool bufferedKeys = false, bool bufferedMouse = false,
			     bool bufferedJoy = false );
*/
	MyFrameListener(RenderWindow* win, Camera* cam, float moveSpeed = 1, bool bufferedKeys = false, bool bufferedMouse = false,
		bool bufferedJoy = false ) : ExampleFrameListener(win,cam,bufferedKeys,bufferedMouse,bufferedJoy){
				
			//setupConst();

			mAnimState = 0;
			mMoveSpeed = mMoveSpeed/100 * moveSpeed;
			mRotateSpeed = mRotateSpeed/100 * moveSpeed;

			camBody = 0;
	}

	bool frameStarted(const FrameEvent& evt){
		
		if(mAnimState){
			mAnimState->addTime(evt.timeSinceLastFrame);
		}

		if(camBody){
			//camBody->setGlobalPosition(mCamera->getPosition()+Vector3(1,-1,1));
			camBody->setCMassGlobalPosition(mCamera->getPosition());//+Vector3(0,-1,0));
			camBody->setLinearMomentum(Vector3::ZERO);
			camBody->setAngularMomentum(Vector3::ZERO);
		}
		
		return ExampleFrameListener::frameStarted(evt);
	}
};
/*
void MyFrameListener::setupConst(RenderWindow* win, Camera* cam, bool bufferedKeys = false, bool bufferedMouse = false,
			     bool bufferedJoy = false ){
		using namespace OIS;

		mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");

		LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
		ParamList pl;
		size_t windowHnd = 0;
		std::ostringstream windowHndStr;

		win->getCustomAttribute("WINDOW", &windowHnd);
		windowHndStr << windowHnd;
		pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

		mInputManager = InputManager::createInputSystem( pl );

		//Create all devices (We only catch joystick exceptions here, as, most people have Key/Mouse)
		mKeyboard = static_cast<Keyboard*>(mInputManager->createInputObject( OISKeyboard, bufferedKeys ));
		mMouse = static_cast<Mouse*>(mInputManager->createInputObject( OISMouse, bufferedMouse ));
		
		#if defined OIS_WIN32_PLATFORM
		//p1.insert
		#elif defined OIS_LINUX_PLATFORM
		#endif

		try {
			mJoy = static_cast<JoyStick*>(mInputManager->createInputObject( OISJoyStick, bufferedJoy ));
		}
		catch(...) {
			mJoy = 0;
		}

		//Set initial mouse clipping size
		windowResized(mWindow);

		showDebugOverlay(true);

		//Register as a Window listener
		WindowEventUtilities::addWindowEventListener(mWindow, this);
	}
*/
#endif