Index: /code/branches/main_reto/include/ExampleApplication.h
===================================================================
--- /code/branches/main_reto/include/ExampleApplication.h	(revision 123)
+++ /code/branches/main_reto/include/ExampleApplication.h	(revision 123)
@@ -0,0 +1,257 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+(Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+You may use this sample code for anything you like, it is not covered by the
+LGPL like the rest of the engine.
+-----------------------------------------------------------------------------
+*/
+/*
+-----------------------------------------------------------------------------
+Filename:    ExampleApplication.h
+Description: Base class for all the OGRE examples
+-----------------------------------------------------------------------------
+*/
+
+#ifndef __ExampleApplication_H__
+#define __ExampleApplication_H__
+
+#include "Ogre.h"
+#include "OgreConfigFile.h"
+#include "ExampleFrameListener.h"
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+#include <CoreFoundation/CoreFoundation.h>
+
+// This function will locate the path to our application on OS X,
+// unlike windows you can not rely on the curent working directory
+// for locating your configuration files and resources.
+std::string macBundlePath()
+{
+	char path[1024];
+	CFBundleRef mainBundle = CFBundleGetMainBundle();
+	assert(mainBundle);
+
+	CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
+	assert(mainBundleURL);
+
+	CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
+	assert(cfStringRef);
+
+	CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
+
+	CFRelease(mainBundleURL);
+	CFRelease(cfStringRef);
+
+	return std::string(path);
+}
+#endif
+
+using namespace Ogre;
+
+/** Base class which manages the standard startup of an Ogre application.
+Designed to be subclassed for specific examples if required.
+*/
+class ExampleApplication
+{
+public:
+	/// Standard constructor
+	ExampleApplication()
+	{
+		mFrameListener = 0;
+		mRoot = 0;
+		// Provide a nice cross platform solution for locating the configuration files
+		// On windows files are searched for in the current working directory, on OS X however
+		// you must provide the full path, the helper function macBundlePath does this for us.
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+		mResourcePath = macBundlePath() + "/Contents/Resources/";
+#else
+		mResourcePath = "";
+#endif
+	}
+	/// Standard destructor
+	virtual ~ExampleApplication()
+	{
+		if (mFrameListener)
+			delete mFrameListener;
+		if (mRoot)
+			delete mRoot;
+	}
+
+	/// Start the example
+	virtual void go(void)
+	{
+		if (!setup())
+			return;
+
+		mRoot->startRendering();
+
+		// clean up
+		destroyScene();
+	}
+
+protected:
+	Root *mRoot;
+	Camera* mCamera;
+	SceneManager* mSceneMgr;
+	ExampleFrameListener* mFrameListener;
+	RenderWindow* mWindow;
+	Ogre::String mResourcePath;
+
+	// These internal methods package up the stages in the startup process
+	/** Sets up the application - returns false if the user chooses to abandon configuration. */
+	virtual bool setup(void)
+	{
+
+		String pluginsPath;
+		// only use plugins.cfg if not static
+#ifndef OGRE_STATIC_LIB
+		pluginsPath = mResourcePath + "plugins.cfg";
+#endif
+
+		mRoot = new Root(pluginsPath, 
+			mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");
+
+		setupResources();
+
+		bool carryOn = configure();
+		if (!carryOn) return false;
+
+		chooseSceneManager();
+		createCamera();
+		createViewports();
+
+		// Set default mipmap level (NB some APIs ignore this)
+		TextureManager::getSingleton().setDefaultNumMipmaps(5);
+
+		// Create any resource listeners (for loading screens)
+		createResourceListener();
+		// Load resources
+		loadResources();
+
+		// Create the scene
+		createScene();
+
+		createFrameListener();
+
+		return true;
+
+	}
+	/** Configures the application - returns false if the user chooses to abandon configuration. */
+	virtual bool configure(void)
+	{
+		// Show the configuration dialog and initialise the system
+		// You can skip this and use root.restoreConfig() to load configuration
+		// settings if you were sure there are valid ones saved in ogre.cfg
+		if(mRoot->showConfigDialog())
+		{
+			// If returned true, user clicked OK so initialise
+			// Here we choose to let the system create a default rendering window by passing 'true'
+			mWindow = mRoot->initialise(true);
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+
+	virtual void chooseSceneManager(void)
+	{
+		// Create the SceneManager, in this case a generic one
+		mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "ExampleSMInstance");
+	}
+	virtual void createCamera(void)
+	{
+		// Create the camera
+		mCamera = mSceneMgr->createCamera("PlayerCam");
+
+		// Position it at 500 in Z direction
+		mCamera->setPosition(Vector3(0,0,500));
+		// Look back along -Z
+		mCamera->lookAt(Vector3(0,0,-300));
+		mCamera->setNearClipDistance(5);
+
+	}
+	virtual void createFrameListener(void)
+	{
+		mFrameListener= new ExampleFrameListener(mWindow, mCamera);
+		mFrameListener->showDebugOverlay(true);
+		mRoot->addFrameListener(mFrameListener);
+	}
+
+	virtual void createScene(void) = 0;    // pure virtual - this has to be overridden
+
+	virtual void destroyScene(void){}    // Optional to override this
+
+	virtual void createViewports(void)
+	{
+		// Create one viewport, entire window
+		Viewport* vp = mWindow->addViewport(mCamera);
+		vp->setBackgroundColour(ColourValue(0,0,0));
+
+		// Alter the camera aspect ratio to match the viewport
+		mCamera->setAspectRatio(
+			Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
+	}
+
+	/// Method which will define the source of resources (other than current folder)
+	virtual void setupResources(void)
+	{
+		// Load resource paths from config file
+		ConfigFile cf;
+		cf.load(mResourcePath + "resources.cfg");
+
+		// Go through all sections & settings in the file
+		ConfigFile::SectionIterator seci = cf.getSectionIterator();
+
+		String secName, typeName, archName;
+		while (seci.hasMoreElements())
+		{
+			secName = seci.peekNextKey();
+			ConfigFile::SettingsMultiMap *settings = seci.getNext();
+			ConfigFile::SettingsMultiMap::iterator i;
+			for (i = settings->begin(); i != settings->end(); ++i)
+			{
+				typeName = i->first;
+				archName = i->second;
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+				// OS X does not set the working directory relative to the app,
+				// In order to make things portable on OS X we need to provide
+				// the loading with it's own bundle path location
+				ResourceGroupManager::getSingleton().addResourceLocation(
+					String(macBundlePath() + "/" + archName), typeName, secName);
+#else
+				ResourceGroupManager::getSingleton().addResourceLocation(
+					archName, typeName, secName);
+#endif
+			}
+		}
+	}
+
+	/// Optional override method where you can create resource listeners (e.g. for loading screens)
+	virtual void createResourceListener(void)
+	{
+
+	}
+
+	/// Optional override method where you can perform resource group loading
+	/// Must at least do ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+	virtual void loadResources(void)
+	{
+		// Initialise, parse scripts etc
+		ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+
+	}
+
+
+
+};
+
+
+#endif
Index: /code/branches/main_reto/include/ExampleFrameListener.h
===================================================================
--- /code/branches/main_reto/include/ExampleFrameListener.h	(revision 123)
+++ /code/branches/main_reto/include/ExampleFrameListener.h	(revision 123)
@@ -0,0 +1,401 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2006 Torus Knot Software Ltd
+Also see acknowledgements in Readme.html
+
+You may use this sample code for anything you like, it is not covered by the
+LGPL like the rest of the engine.
+-----------------------------------------------------------------------------
+*/
+/*
+-----------------------------------------------------------------------------
+Filename:    ExampleFrameListener.h
+Description: Defines an example frame listener which responds to frame events.
+This frame listener just moves a specified camera around based on
+keyboard and mouse movements.
+Mouse:    Freelook
+W or Up:  Forward
+S or Down:Backward
+A:        Step left
+D:        Step right
+             PgUp:     Move upwards
+             PgDown:   Move downwards
+             F:        Toggle frame rate stats on/off
+			 R:        Render mode
+             T:        Cycle texture filtering
+                       Bilinear, Trilinear, Anisotropic(8)
+             P:        Toggle on/off display of camera position / orientation
+-----------------------------------------------------------------------------
+*/
+
+#ifndef __ExampleFrameListener_H__
+#define __ExampleFrameListener_H__
+
+#include "Ogre.h"
+#include "OgreStringConverter.h"
+#include "OgreException.h"
+
+//Use this define to signify OIS will be used as a DLL
+//(so that dll import/export macros are in effect)
+#define OIS_DYNAMIC_LIB
+#include <OIS/OIS.h>
+
+using namespace Ogre;
+
+class ExampleFrameListener: public FrameListener, public WindowEventListener
+{
+protected:
+	void updateStats(void)
+	{
+		static String currFps = "Current FPS: ";
+		static String avgFps = "Average FPS: ";
+		static String bestFps = "Best FPS: ";
+		static String worstFps = "Worst FPS: ";
+		static String tris = "Triangle Count: ";
+		static String batches = "Batch Count: ";
+
+		// update stats when necessary
+		try {
+			OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
+			OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
+			OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
+			OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");
+
+			const RenderTarget::FrameStats& stats = mWindow->getStatistics();
+			guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
+			guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
+			guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS)
+				+" "+StringConverter::toString(stats.bestFrameTime)+" ms");
+			guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)
+				+" "+StringConverter::toString(stats.worstFrameTime)+" ms");
+
+			OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
+			guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount));
+
+			OverlayElement* guiBatches = OverlayManager::getSingleton().getOverlayElement("Core/NumBatches");
+			guiBatches->setCaption(batches + StringConverter::toString(stats.batchCount));
+
+			OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
+			guiDbg->setCaption(mDebugText);
+		}
+		catch(...) { /* ignore */ }
+	}
+
+public:
+	// Constructor takes a RenderWindow because it uses that to determine input context
+	ExampleFrameListener(RenderWindow* win, Camera* cam, bool bufferedKeys = false, bool bufferedMouse = false,
+			     bool bufferedJoy = false ) :
+		mCamera(cam), mTranslateVector(Vector3::ZERO), mWindow(win), mStatsOn(true), mNumScreenShots(0),
+		mMoveScale(0.0f), mRotScale(0.0f), mTimeUntilNextToggle(0), mFiltering(TFO_BILINEAR),
+		mAniso(1), mSceneDetailIndex(0), mMoveSpeed(100), mRotateSpeed(36), mDebugOverlay(0),
+		mInputManager(0), mMouse(0), mKeyboard(0), mJoy(0)
+	{
+		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 ));
+		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);
+	}
+
+	//Adjust mouse clipping area
+	virtual void windowResized(RenderWindow* rw)
+	{
+		unsigned int width, height, depth;
+		int left, top;
+		rw->getMetrics(width, height, depth, left, top);
+
+		const OIS::MouseState &ms = mMouse->getMouseState();
+		ms.width = width;
+		ms.height = height;
+	}
+
+	//Unattach OIS before window shutdown (very important under Linux)
+	virtual void windowClosed(RenderWindow* rw)
+	{
+		//Only close for window that created OIS (the main window in these demos)
+		if( rw == mWindow )
+		{
+			if( mInputManager )
+			{
+				mInputManager->destroyInputObject( mMouse );
+				mInputManager->destroyInputObject( mKeyboard );
+				mInputManager->destroyInputObject( mJoy );
+
+				OIS::InputManager::destroyInputSystem(mInputManager);
+				mInputManager = 0;
+			}
+		}
+	}
+
+	virtual ~ExampleFrameListener()
+	{
+		//Remove ourself as a Window listener
+		WindowEventUtilities::removeWindowEventListener(mWindow, this);
+		windowClosed(mWindow);
+	}
+
+	virtual bool processUnbufferedKeyInput(const FrameEvent& evt)
+	{
+		using namespace OIS;
+
+		if(mKeyboard->isKeyDown(KC_A))
+			mTranslateVector.x = -mMoveScale;	// Move camera left
+
+		if(mKeyboard->isKeyDown(KC_D))
+			mTranslateVector.x = mMoveScale;	// Move camera RIGHT
+
+		if(mKeyboard->isKeyDown(KC_UP) || mKeyboard->isKeyDown(KC_W) )
+			mTranslateVector.z = -mMoveScale;	// Move camera forward
+
+		if(mKeyboard->isKeyDown(KC_DOWN) || mKeyboard->isKeyDown(KC_S) )
+			mTranslateVector.z = mMoveScale;	// Move camera backward
+
+		if(mKeyboard->isKeyDown(KC_PGUP))
+			mTranslateVector.y = mMoveScale;	// Move camera up
+
+		if(mKeyboard->isKeyDown(KC_PGDOWN))
+			mTranslateVector.y = -mMoveScale;	// Move camera down
+
+		if(mKeyboard->isKeyDown(KC_RIGHT))
+			mCamera->yaw(-mRotScale);
+
+		if(mKeyboard->isKeyDown(KC_LEFT))
+			mCamera->yaw(mRotScale);
+
+		if( mKeyboard->isKeyDown(KC_ESCAPE) || mKeyboard->isKeyDown(KC_Q) )
+			return false;
+
+       	if( mKeyboard->isKeyDown(KC_F) && mTimeUntilNextToggle <= 0 )
+		{
+			mStatsOn = !mStatsOn;
+			showDebugOverlay(mStatsOn);
+			mTimeUntilNextToggle = 1;
+		}
+
+		if( mKeyboard->isKeyDown(KC_T) && mTimeUntilNextToggle <= 0 )
+		{
+			switch(mFiltering)
+			{
+			case TFO_BILINEAR:
+				mFiltering = TFO_TRILINEAR;
+				mAniso = 1;
+				break;
+			case TFO_TRILINEAR:
+				mFiltering = TFO_ANISOTROPIC;
+				mAniso = 8;
+				break;
+			case TFO_ANISOTROPIC:
+				mFiltering = TFO_BILINEAR;
+				mAniso = 1;
+				break;
+			default: break;
+			}
+			MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering);
+			MaterialManager::getSingleton().setDefaultAnisotropy(mAniso);
+
+			showDebugOverlay(mStatsOn);
+			mTimeUntilNextToggle = 1;
+		}
+
+		if(mKeyboard->isKeyDown(KC_SYSRQ) && mTimeUntilNextToggle <= 0)
+		{
+			std::ostringstream ss;
+			ss << "screenshot_" << ++mNumScreenShots << ".png";
+			mWindow->writeContentsToFile(ss.str());
+			mTimeUntilNextToggle = 0.5;
+			mDebugText = "Saved: " + ss.str();
+		}
+
+		if(mKeyboard->isKeyDown(KC_R) && mTimeUntilNextToggle <=0)
+		{
+			mSceneDetailIndex = (mSceneDetailIndex+1)%3 ;
+			switch(mSceneDetailIndex) {
+				case 0 : mCamera->setPolygonMode(PM_SOLID); break;
+				case 1 : mCamera->setPolygonMode(PM_WIREFRAME); break;
+				case 2 : mCamera->setPolygonMode(PM_POINTS); break;
+			}
+			mTimeUntilNextToggle = 0.5;
+		}
+
+		static bool displayCameraDetails = false;
+		if(mKeyboard->isKeyDown(KC_P) && mTimeUntilNextToggle <= 0)
+		{
+			displayCameraDetails = !displayCameraDetails;
+			mTimeUntilNextToggle = 0.5;
+			if (!displayCameraDetails)
+				mDebugText = "";
+		}
+
+		// Print camera details
+		if(displayCameraDetails)
+			mDebugText = "P: " + StringConverter::toString(mCamera->getDerivedPosition()) +
+						 " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation());
+
+		// Return true to continue rendering
+		return true;
+	}
+
+	bool processUnbufferedMouseInput(const FrameEvent& evt)
+	{
+		using namespace OIS;
+
+		// Rotation factors, may not be used if the second mouse button is pressed
+		// 2nd mouse button - slide, otherwise rotate
+		const MouseState &ms = mMouse->getMouseState();
+		if( ms.buttonDown( MB_Right ) )
+		{
+			mTranslateVector.x += ms.X.rel * 0.13;
+			mTranslateVector.y -= ms.Y.rel * 0.13;
+		}
+		else
+		{
+			mRotX = Degree(-ms.X.rel * 0.13);
+			mRotY = Degree(-ms.Y.rel * 0.13);
+		}
+
+		return true;
+	}
+
+	void moveCamera()
+	{
+		// Make all the changes to the camera
+		// Note that YAW direction is around a fixed axis (freelook style) rather than a natural YAW
+		//(e.g. airplane)
+		mCamera->yaw(mRotX);
+		mCamera->pitch(mRotY);
+		mCamera->moveRelative(mTranslateVector);
+	}
+
+	void showDebugOverlay(bool show)
+	{
+		if (mDebugOverlay)
+		{
+			if (show)
+				mDebugOverlay->show();
+			else
+				mDebugOverlay->hide();
+		}
+	}
+
+	// Override frameStarted event to process that (don't care about frameEnded)
+	bool frameStarted(const FrameEvent& evt)
+	{
+		using namespace OIS;
+
+		if(mWindow->isClosed())	return false;
+
+		//Need to capture/update each device
+		mKeyboard->capture();
+		mMouse->capture();
+		if( mJoy ) mJoy->capture();
+
+		bool buffJ = (mJoy) ? mJoy->buffered() : true;
+
+		//Check if one of the devices is not buffered
+		if( !mMouse->buffered() || !mKeyboard->buffered() || !buffJ )
+		{
+			// one of the input modes is immediate, so setup what is needed for immediate movement
+			if (mTimeUntilNextToggle >= 0)
+				mTimeUntilNextToggle -= evt.timeSinceLastFrame;
+
+			// If this is the first frame, pick a speed
+			if (evt.timeSinceLastFrame == 0)
+			{
+				mMoveScale = 1;
+				mRotScale = 0.1;
+			}
+			// Otherwise scale movement units by time passed since last frame
+			else
+			{
+				// Move about 100 units per second,
+				mMoveScale = mMoveSpeed * evt.timeSinceLastFrame;
+				// Take about 10 seconds for full rotation
+				mRotScale = mRotateSpeed * evt.timeSinceLastFrame;
+			}
+			mRotX = 0;
+			mRotY = 0;
+			mTranslateVector = Ogre::Vector3::ZERO;
+		}
+
+		//Check to see which device is not buffered, and handle it
+		if( !mKeyboard->buffered() )
+			if( processUnbufferedKeyInput(evt) == false )
+				return false;
+		if( !mMouse->buffered() )
+			if( processUnbufferedMouseInput(evt) == false )
+				return false;
+
+		if( !mMouse->buffered() || !mKeyboard->buffered() || !buffJ )
+			moveCamera();
+
+		return true;
+	}
+
+	bool frameEnded(const FrameEvent& evt)
+	{
+		updateStats();
+		return true;
+	}
+
+protected:
+	Camera* mCamera;
+
+	Vector3 mTranslateVector;
+	RenderWindow* mWindow;
+	bool mStatsOn;
+
+	std::string mDebugText;
+
+	unsigned int mNumScreenShots;
+	float mMoveScale;
+	Degree mRotScale;
+	// just to stop toggles flipping too fast
+	Real mTimeUntilNextToggle ;
+	Radian mRotX, mRotY;
+	TextureFilterOptions mFiltering;
+	int mAniso;
+
+	int mSceneDetailIndex ;
+	Real mMoveSpeed;
+	Degree mRotateSpeed;
+	Overlay* mDebugOverlay;
+
+	//OIS Input devices
+	OIS::InputManager* mInputManager;
+	OIS::Mouse*    mMouse;
+	OIS::Keyboard* mKeyboard;
+	OIS::JoyStick* mJoy;
+};
+
+#endif
Index: /code/branches/main_reto/include/MyListener.h
===================================================================
--- /code/branches/main_reto/include/MyListener.h	(revision 123)
+++ /code/branches/main_reto/include/MyListener.h	(revision 123)
@@ -0,0 +1,23 @@
+#ifndef __MyListener__
+#define __MyListener__
+
+#include "OgreControl.h"
+#include "ExampleFrameListener.h"
+
+// Declare a subclass of the ExampleFrameListener class
+class MyListener : public ExampleFrameListener
+{
+public:
+	MyListener(RenderWindow* win, Camera* cam);
+
+	void setReceiver(OgreControl*);
+
+	bool frameStarted(const FrameEvent& evt);
+
+	bool frameEnded(const FrameEvent& evt);
+
+private:
+	OgreControl *myApp;
+};
+
+#endif
Index: /code/branches/main_reto/include/OgreControl.h
===================================================================
--- /code/branches/main_reto/include/OgreControl.h	(revision 123)
+++ /code/branches/main_reto/include/OgreControl.h	(revision 123)
@@ -0,0 +1,43 @@
+#ifndef __OgreControl__
+#define __OgreControl__
+
+#include "Ogre.h"
+#include "OgreConfigFile.h"
+
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
+using namespace Ogre;
+
+class OgreControl
+{
+public:
+	OgreControl();
+
+	virtual ~OgreControl();
+
+	/** Sets up the application - returns false if the user chooses to abandon configuration. */
+	virtual bool initialise(void);
+
+	virtual Root* getRoot(void);
+
+	virtual RenderWindow* getRenderWindow(void);
+
+	virtual Ogre::String getResourcePath(void);
+
+protected:
+	Root         *mRoot;
+	RenderWindow *mWindow;
+	Ogre::String  mResourcePath;
+
+	/** Configures the application - returns false if the user chooses to abandon configuration. */
+	virtual bool configure(void);
+
+	/// Method which will define the source of resources (other than current folder)
+	virtual void setupResources(void);
+
+};
+
+#endif
Index: /code/branches/main_reto/include/Orxonox.h
===================================================================
--- /code/branches/main_reto/include/Orxonox.h	(revision 123)
+++ /code/branches/main_reto/include/Orxonox.h	(revision 123)
@@ -0,0 +1,26 @@
+#ifndef __Orxonox__
+#define __Orxonox__
+
+#include "Ogre.h"
+#include "OgreTimer.h"
+
+#include "OgreControl.h"
+#include "RunManager.h"
+
+class Orxonox
+{
+public:
+	virtual void go(void);
+
+protected:
+	OgreControl *mOgre;
+	RunManager  *mRunMgr;
+	Timer       *mTimer;
+
+	virtual bool setup(void);
+
+	virtual void destroy(void);
+
+};
+
+#endif
Index: /code/branches/main_reto/include/OrxonoxScene.h
===================================================================
--- /code/branches/main_reto/include/OrxonoxScene.h	(revision 123)
+++ /code/branches/main_reto/include/OrxonoxScene.h	(revision 123)
@@ -0,0 +1,34 @@
+#ifndef __DemoScene__
+#define __DemoScene__
+
+#include "Ogre.h"
+
+using namespace Ogre;
+
+class OrxonoxScene
+{
+public:
+	OrxonoxScene(SceneManager*);
+
+	virtual ~OrxonoxScene();
+
+	virtual bool initialise();
+
+	virtual void tick(unsigned long, float);
+
+private:
+	SceneManager* mSceneMgr;
+
+	//specific variables for test purposes
+	Light        *mLight;
+	SceneNode    *lightNode;
+	BillboardSet *bbs;
+	float distance, radius;
+
+	/// method where you can perform resource group loading
+	virtual void loadResources(void);
+
+	// Define what is in the scene
+	virtual void createScene(void);
+};
+#endif
Index: /code/branches/main_reto/include/RunManager.h
===================================================================
--- /code/branches/main_reto/include/RunManager.h	(revision 123)
+++ /code/branches/main_reto/include/RunManager.h	(revision 123)
@@ -0,0 +1,97 @@
+#ifndef __RunManager__
+#define __RunManager__
+
+#include "Ogre.h"
+#include "OgreStringConverter.h"
+#include "OgreException.h"
+
+#include "OgreControl.h"
+#include "OrxonoxScene.h"
+
+//Use this define to signify OIS will be used as a DLL
+//(so that dll import/export macros are in effect)
+#define OIS_DYNAMIC_LIB
+#include <OIS/OIS.h>
+
+using namespace Ogre;
+
+
+// let the class inherit from WindowEventListener in order for the RunMgr
+// to act as the central point of all the calcuations in Orxonox
+class RunManager : WindowEventListener
+{
+public:
+	RunManager(OgreControl*, bool = false, bool = false, bool = false);
+
+	virtual ~RunManager();
+
+	virtual bool tick(unsigned long, float);
+
+protected:
+	OgreControl  *mOgre;
+
+	// these objects are meant to be static in existance.
+	OrxonoxScene *mScene;
+	SceneManager *mSceneMgr;
+	Camera* mCamera;
+	RenderWindow* mWindow;
+
+	Vector3 mTranslateVector;
+	bool mStatsOn;
+
+	std::string mDebugText;
+
+	unsigned int mNumScreenShots;
+	float mMoveScale;
+	Degree mRotScale;
+	// just to stop toggles flipping too fast
+	Real mTimeUntilNextToggle ;
+	Radian mRotX, mRotY;
+	TextureFilterOptions mFiltering;
+	int mAniso;
+
+	int mSceneDetailIndex ;
+	Real mMoveSpeed;
+	Degree mRotateSpeed;
+	Overlay* mDebugOverlay;
+
+	//OIS Input devices
+	OIS::InputManager* mInputManager;
+	OIS::Mouse*    mMouse;
+	OIS::Keyboard* mKeyboard;
+	OIS::JoyStick* mJoy;
+
+	// previously elapsed render time
+	unsigned long mTime;
+
+	virtual void createCamera(void);
+
+	virtual void createViewports(void);
+
+
+	/** EVENT HANDLING **/
+
+	//Adjust mouse clipping area
+	virtual void windowResized(RenderWindow*);
+
+	//Unattach OIS before window shutdown (very important under Linux)
+	virtual void windowClosed(RenderWindow*);
+
+
+	/** INPUT PROCESSING **/
+	virtual bool processUnbufferedKeyInput();
+
+	virtual bool processUnbufferedMouseInput();
+
+
+	/** OUTPUT **/
+
+	virtual void updateStats(void);
+
+	virtual void moveCamera();
+
+	virtual void showDebugOverlay(bool);
+
+};
+
+#endif
Index: /code/branches/main_reto/src/MyListener.cpp
===================================================================
--- /code/branches/main_reto/src/MyListener.cpp	(revision 123)
+++ /code/branches/main_reto/src/MyListener.cpp	(revision 123)
@@ -0,0 +1,22 @@
+#include "MyListener.h"
+
+// Declare a subclass of the ExampleFrameListener class
+MyListener::MyListener(RenderWindow* win, Camera* cam) : ExampleFrameListener(win, cam)
+{
+}
+
+bool MyListener::frameStarted(const FrameEvent& evt)
+{
+	myApp->render(evt.timeSinceLastFrame);
+	return ExampleFrameListener::frameStarted(evt);        
+}
+
+bool MyListener::frameEnded(const FrameEvent& evt)
+{
+	return ExampleFrameListener::frameEnded(evt);        
+}
+
+void MyListener::setReceiver(OgreControl* app)
+{
+	myApp = app;
+}
Index: /code/branches/main_reto/src/OgreControl.cpp
===================================================================
--- /code/branches/main_reto/src/OgreControl.cpp	(revision 123)
+++ /code/branches/main_reto/src/OgreControl.cpp	(revision 123)
@@ -0,0 +1,139 @@
+#include "OgreControl.h"
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+// This function will locate the path to our application on OS X,
+// unlike windows you can not rely on the curent working directory
+// for locating your configuration files and resources.
+std::string macBundlePath()
+{
+	char path[1024];
+	CFBundleRef mainBundle = CFBundleGetMainBundle();
+	assert(mainBundle);
+
+	CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
+	assert(mainBundleURL);
+
+	CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
+	assert(cfStringRef);
+
+	CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
+
+	CFRelease(mainBundleURL);
+	CFRelease(cfStringRef);
+
+	return std::string(path);
+}
+#endif
+
+
+OgreControl::OgreControl()
+{
+	mRoot = 0;
+	// Provide a nice cross platform solution for locating the configuration files
+	// On windows files are searched for in the current working directory, on OS X however
+	// you must provide the full path, the helper function macBundlePath does this for us.
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+	mResourcePath = macBundlePath() + "/Contents/Resources/";
+#else
+	mResourcePath = "";
+#endif
+}
+
+
+// standard destructor
+OgreControl::~OgreControl()
+{
+	if (mRoot)
+		delete mRoot;
+}
+
+
+/**------------- SETTING UP OGRE --------------**/
+
+bool OgreControl::initialise(void)
+{
+	String pluginsPath;
+	// only use plugins.cfg if not static
+#ifndef OGRE_STATIC_LIB
+	pluginsPath = mResourcePath + "plugins.cfg";
+#endif
+
+	mRoot = new Root(pluginsPath, 
+		mResourcePath + "ogre.cfg", mResourcePath + "Ogre.log");
+
+	setupResources();
+
+	if (!configure())
+		return false;
+
+	return true;
+}
+
+
+/// Method which will define the source of resources (other than current folder)
+void OgreControl::setupResources(void)
+{
+	// Load resource paths from config file
+	ConfigFile cf;
+	cf.load(mResourcePath + "resources.cfg");
+
+	// Go through all sections & settings in the file
+	ConfigFile::SectionIterator seci = cf.getSectionIterator();
+
+	String secName, typeName, archName;
+	while (seci.hasMoreElements())
+	{
+		secName = seci.peekNextKey();
+		ConfigFile::SettingsMultiMap *settings = seci.getNext();
+		ConfigFile::SettingsMultiMap::iterator i;
+		for (i = settings->begin(); i != settings->end(); ++i)
+		{
+			typeName = i->first;
+			archName = i->second;
+#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
+			// OS X does not set the working directory relative to the app,
+			// In order to make things portable on OS X we need to provide
+			// the loading with it's own bundle path location
+			ResourceGroupManager::getSingleton().addResourceLocation(
+				String(macBundlePath() + "/" + archName), typeName, secName);
+#else
+			ResourceGroupManager::getSingleton().addResourceLocation(
+				archName, typeName, secName);
+#endif
+		}
+	}
+}
+
+
+bool OgreControl::configure(void)
+{
+	// Show the configuration dialog and initialise the system
+	// You can skip this and use root.restoreConfig() to load configuration
+	// settings if you were sure there are valid ones saved in ogre.cfg
+	if(!mRoot->restoreConfig() && !mRoot->showConfigDialog())
+		return false;
+
+	// user clicked OK so initialise
+	// Here we choose to let the system create a default rendering window by passing 'true'
+	mWindow = mRoot->initialise(true);
+	mRoot->saveConfig();
+	return true;
+}
+
+
+Root* OgreControl::getRoot(void)
+{
+	return mRoot;
+}
+
+
+RenderWindow* OgreControl::getRenderWindow(void)
+{
+	return mWindow;
+}
+
+
+Ogre::String OgreControl::getResourcePath(void)
+{
+	return mResourcePath;
+}
Index: /code/branches/main_reto/src/Orxonox.cpp
===================================================================
--- /code/branches/main_reto/src/Orxonox.cpp	(revision 123)
+++ /code/branches/main_reto/src/Orxonox.cpp	(revision 123)
@@ -0,0 +1,49 @@
+#include "Orxonox.h"
+
+
+void Orxonox::go(void)
+{
+	if (!setup())
+		return;
+
+	mTimer = new Timer();
+
+	unsigned long lastTime = mTimer->getMilliseconds();
+
+	while (true)
+	{
+		//Pump messages in all registered RenderWindow windows
+		WindowEventUtilities::messagePump();
+
+		mOgre->getRoot()->renderOneFrame();
+
+		if (!mRunMgr->tick(mTimer->getMilliseconds(), (mTimer->getMilliseconds() - lastTime) / 1000.0))
+			break;
+		lastTime = mTimer->getMilliseconds();
+	}
+
+	// clean up
+	destroy();
+}
+
+bool Orxonox::setup(void)
+{
+	// create new 3D ogre render engine
+	mOgre = new OgreControl();
+	mOgre->initialise();
+
+	mRunMgr = new RunManager(mOgre);
+
+	return true;
+}
+
+
+void Orxonox::destroy()
+{
+	if (mTimer)
+		delete mTimer;
+	if (mRunMgr)
+		delete mRunMgr;
+	if (mOgre)
+		delete mOgre;
+}
Index: /code/branches/main_reto/src/OrxonoxScene.cpp
===================================================================
--- /code/branches/main_reto/src/OrxonoxScene.cpp	(revision 123)
+++ /code/branches/main_reto/src/OrxonoxScene.cpp	(revision 123)
@@ -0,0 +1,85 @@
+#include "OrxonoxScene.h"
+
+
+OrxonoxScene::OrxonoxScene(SceneManager *mSceneMgr) : mSceneMgr(mSceneMgr)
+{
+}
+
+
+OrxonoxScene::~OrxonoxScene()
+{
+}
+
+
+bool OrxonoxScene::initialise()
+{
+	// Load resources
+	loadResources();
+
+	distance = 0;
+	radius = 100;
+
+	createScene();
+
+	return true;
+}
+
+
+/// method where you can perform resource group loading
+/// Must at least do ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+void OrxonoxScene::loadResources(void)
+{
+	// Initialise, parse scripts etc
+	ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+}
+
+
+// Currently just a test scene with an ogre head an a surrounding light
+void OrxonoxScene::createScene(void)
+{
+	mSceneMgr->setAmbientLight(ColourValue(0.3,0.3,0.3));
+
+	//create first entity
+	Entity *head = mSceneMgr->createEntity("head", "ogrehead.mesh");
+
+	//create a scene node to attach the head to
+	SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode",
+		Vector3(0,0,0));
+	//attach the ogre head
+	node->attachObject(head);
+
+	// set up skybox
+	mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
+
+	// set up one mLight source
+	mLight = mSceneMgr->createLight("Light1");
+	mLight->setType(Light::LT_POINT);
+	mLight->setPosition(Vector3(0, 0, 0));
+	mLight->setDiffuseColour(1.0, 1.0, 1.0);
+	mLight->setSpecularColour(1.0, 1.0, 1.0);
+
+	//create billboard
+	bbs = mSceneMgr->createBillboardSet("bb", 1);
+	bbs->createBillboard(Vector3::ZERO, ColourValue(1.0, 1.0, 1.0));
+	bbs->setMaterialName("Examples/Flare");
+
+	lightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("LightNode",
+		Vector3(0, 100, 0));
+
+	lightNode->attachObject(bbs);
+	lightNode->attachObject(mLight);
+}
+
+
+// compute something between frames if neccessary
+void OrxonoxScene::tick(unsigned long time, float deltaTime)
+{
+	float t = time/1000.0;
+
+	lightNode->setPosition(radius*sin(5*t), radius*cos(5*t), sin(1*t)*distance);
+	
+	mLight->setDiffuseColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2));
+	mLight->setSpecularColour(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2));
+
+	bbs->getBillboard(0)->setColour(ColourValue(sin(1*t), sin(1*t + 2.09), sin(1*t + 2.09*2)));
+}
Index: /code/branches/main_reto/src/RunManager.cpp
===================================================================
--- /code/branches/main_reto/src/RunManager.cpp	(revision 123)
+++ /code/branches/main_reto/src/RunManager.cpp	(revision 123)
@@ -0,0 +1,374 @@
+#include "RunManager.h"
+
+
+// Constructor takes a RenderWindow because it uses that to determine input context
+RunManager::RunManager(OgreControl * mOgre, bool bufferedKeys, bool bufferedMouse,
+					   bool bufferedJoy ) :
+mOgre(mOgre), mWindow(mOgre->getRenderWindow()),
+mTranslateVector(Vector3::ZERO), mStatsOn(true), mNumScreenShots(0),
+mMoveScale(0.0f), mRotScale(0.0f), mTimeUntilNextToggle(0), mFiltering(TFO_BILINEAR),
+mAniso(1), mSceneDetailIndex(0), mMoveSpeed(100), mRotateSpeed(36), mDebugOverlay(0),
+mInputManager(0), mMouse(0), mKeyboard(0), mJoy(0)
+{
+	// create new scene
+	mSceneMgr = mOgre->getRoot()->createSceneManager(ST_GENERIC,"mScene");
+	mScene = new OrxonoxScene(mSceneMgr);
+
+	// create camera and viewport
+	createCamera();
+	createViewports();
+
+	mScene->initialise();
+
+
+	using namespace OIS;
+
+	mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");
+
+	LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
+	ParamList pl;
+	size_t windowHnd = 0;
+	std::ostringstream windowHndStr;
+
+	mWindow->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 ));
+	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);
+}
+
+
+RunManager::~RunManager()
+{
+	//Remove ourself as a Window listener
+	WindowEventUtilities::removeWindowEventListener(mWindow, this);
+	windowClosed(mWindow);
+
+	if (mScene)
+		delete mScene;
+}
+
+
+// Override frameStarted event to process that (don't care about frameEnded)
+bool RunManager::tick(unsigned long time, float deltaTime)
+{
+	mTime = time;
+
+	updateStats();
+	
+	mScene->tick(time, deltaTime);
+
+	using namespace OIS;
+
+	if(mWindow->isClosed())	return false;
+
+	//Need to capture/update each device
+	mKeyboard->capture();
+	mMouse->capture();
+	if( mJoy ) mJoy->capture();
+
+	bool buffJ = (mJoy) ? mJoy->buffered() : true;
+
+	//Check if one of the devices is not buffered
+	if( !mMouse->buffered() || !mKeyboard->buffered() || !buffJ )
+	{
+		// one of the input modes is immediate, so setup what is needed for immediate movement
+		if (mTimeUntilNextToggle >= 0)
+			mTimeUntilNextToggle -= deltaTime;
+
+		// If this is the first frame, pick a speed
+		if (deltaTime == 0)
+		{
+			mMoveScale = 1;
+			mRotScale = 0.1;
+		}
+		// Otherwise scale movement units by time passed since last frame
+		else
+		{
+			// Move about 100 units per second,
+			mMoveScale = mMoveSpeed * deltaTime;
+			// Take about 10 seconds for full rotation
+			mRotScale = mRotateSpeed * deltaTime;
+		}
+		mRotX = 0;
+		mRotY = 0;
+		mTranslateVector = Ogre::Vector3::ZERO;
+	}
+
+	//Check to see which device is not buffered, and handle it
+	if( !mKeyboard->buffered() )
+		if( processUnbufferedKeyInput() == false )
+			return false;
+	if( !mMouse->buffered() )
+		if( processUnbufferedMouseInput() == false )
+			return false;
+
+	if( !mMouse->buffered() || !mKeyboard->buffered() || !buffJ )
+		moveCamera();
+
+	return true;
+}
+
+
+//Adjust mouse clipping area
+void RunManager::windowResized(RenderWindow* rw)
+{
+	unsigned int width, height, depth;
+	int left, top;
+	rw->getMetrics(width, height, depth, left, top);
+
+	const OIS::MouseState &ms = mMouse->getMouseState();
+	ms.width = width;
+	ms.height = height;
+}
+
+
+//Unattach OIS before window shutdown (very important under Linux)
+void RunManager::windowClosed(RenderWindow* rw)
+{
+	//Only close for window that created OIS (the main window in these demos)
+	if( rw == mWindow )
+	{
+		if( mInputManager )
+		{
+			mInputManager->destroyInputObject( mMouse );
+			mInputManager->destroyInputObject( mKeyboard );
+			mInputManager->destroyInputObject( mJoy );
+
+			OIS::InputManager::destroyInputSystem(mInputManager);
+			mInputManager = 0;
+		}
+	}
+}
+
+
+bool RunManager::processUnbufferedKeyInput()
+{
+	using namespace OIS;
+
+	if(mKeyboard->isKeyDown(KC_A))
+		mTranslateVector.x = -mMoveScale;	// Move camera left
+
+	if(mKeyboard->isKeyDown(KC_D))
+		mTranslateVector.x = mMoveScale;	// Move camera RIGHT
+
+	if(mKeyboard->isKeyDown(KC_UP) || mKeyboard->isKeyDown(KC_W) )
+		mTranslateVector.z = -mMoveScale;	// Move camera forward
+
+	if(mKeyboard->isKeyDown(KC_DOWN) || mKeyboard->isKeyDown(KC_S) )
+		mTranslateVector.z = mMoveScale;	// Move camera backward
+
+	if(mKeyboard->isKeyDown(KC_PGUP))
+		mTranslateVector.y = mMoveScale;	// Move camera up
+
+	if(mKeyboard->isKeyDown(KC_PGDOWN))
+		mTranslateVector.y = -mMoveScale;	// Move camera down
+
+	if(mKeyboard->isKeyDown(KC_RIGHT))
+		mCamera->yaw(-mRotScale);
+
+	if(mKeyboard->isKeyDown(KC_LEFT))
+		mCamera->yaw(mRotScale);
+
+	if( mKeyboard->isKeyDown(KC_ESCAPE) || mKeyboard->isKeyDown(KC_Q) )
+		return false;
+
+	if( mKeyboard->isKeyDown(KC_F) && mTimeUntilNextToggle <= 0 )
+	{
+		mStatsOn = !mStatsOn;
+		showDebugOverlay(mStatsOn);
+		mTimeUntilNextToggle = 1;
+	}
+
+	if( mKeyboard->isKeyDown(KC_T) && mTimeUntilNextToggle <= 0 )
+	{
+		switch(mFiltering)
+		{
+		case TFO_BILINEAR:
+			mFiltering = TFO_TRILINEAR;
+			mAniso = 1;
+			break;
+		case TFO_TRILINEAR:
+			mFiltering = TFO_ANISOTROPIC;
+			mAniso = 8;
+			break;
+		case TFO_ANISOTROPIC:
+			mFiltering = TFO_BILINEAR;
+			mAniso = 1;
+			break;
+		default: break;
+		}
+		MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering);
+		MaterialManager::getSingleton().setDefaultAnisotropy(mAniso);
+
+		showDebugOverlay(mStatsOn);
+		mTimeUntilNextToggle = 1;
+	}
+
+	if(mKeyboard->isKeyDown(KC_SYSRQ) && mTimeUntilNextToggle <= 0)
+	{
+		std::ostringstream ss;
+		ss << "screenshot_" << ++mNumScreenShots << ".png";
+		mWindow->writeContentsToFile(ss.str());
+		mTimeUntilNextToggle = 0.5;
+		mDebugText = "Saved: " + ss.str();
+	}
+
+	if(mKeyboard->isKeyDown(KC_R) && mTimeUntilNextToggle <=0)
+	{
+		mSceneDetailIndex = (mSceneDetailIndex+1)%3 ;
+		switch(mSceneDetailIndex) {
+				case 0 : mCamera->setPolygonMode(PM_SOLID); break;
+				case 1 : mCamera->setPolygonMode(PM_WIREFRAME); break;
+				case 2 : mCamera->setPolygonMode(PM_POINTS); break;
+		}
+		mTimeUntilNextToggle = 0.5;
+	}
+
+	static bool displayCameraDetails = false;
+	if(mKeyboard->isKeyDown(KC_P) && mTimeUntilNextToggle <= 0)
+	{
+		displayCameraDetails = !displayCameraDetails;
+		mTimeUntilNextToggle = 0.5;
+		if (!displayCameraDetails)
+			mDebugText = "";
+	}
+
+	// Print camera details
+	if(displayCameraDetails)
+		mDebugText = "P: " + StringConverter::toString(mCamera->getDerivedPosition()) +
+		" " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation());
+
+	// Return true to continue rendering
+	return true;
+}
+
+
+bool RunManager::processUnbufferedMouseInput()
+{
+	using namespace OIS;
+
+	// Rotation factors, may not be used if the second mouse button is pressed
+	// 2nd mouse button - slide, otherwise rotate
+	const MouseState &ms = mMouse->getMouseState();
+	if( ms.buttonDown( MB_Right ) )
+	{
+		mTranslateVector.x += ms.X.rel * 0.13;
+		mTranslateVector.y -= ms.Y.rel * 0.13;
+	}
+	else
+	{
+		mRotX = Degree(-ms.X.rel * 0.13);
+		mRotY = Degree(-ms.Y.rel * 0.13);
+	}
+
+	return true;
+}
+
+
+void RunManager::moveCamera()
+{
+	// Make all the changes to the camera
+	// Note that YAW direction is around a fixed axis (freelook style) rather than a natural YAW
+	//(e.g. airplane)
+	mCamera->yaw(mRotX);
+	mCamera->pitch(mRotY);
+	mCamera->moveRelative(mTranslateVector);
+}
+
+
+void RunManager::showDebugOverlay(bool show)
+{
+	if (mDebugOverlay)
+	{
+		if (show)
+			mDebugOverlay->show();
+		else
+			mDebugOverlay->hide();
+	}
+}
+
+
+
+void RunManager::updateStats(void)
+{
+	static String currFps = "Current FPS: ";
+	static String avgFps = "Average FPS: ";
+	static String bestFps = "Best FPS: ";
+	static String worstFps = "Worst FPS: ";
+	static String tris = "Triangle Count: ";
+	static String batches = "Batch Count: ";
+
+	// update stats when necessary
+	try {
+		OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
+		OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
+		OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
+		OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");
+		//OverlayElement* asfd = OverlayManager::getSingleton().getOverlayElement(
+
+		const RenderTarget::FrameStats& stats = mWindow->getStatistics();
+		guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
+		guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
+		guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS)
+			+" "+StringConverter::toString(stats.bestFrameTime)+" ms");
+		guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS)
+			+" "+StringConverter::toString(stats.worstFrameTime)+" ms");
+
+		OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
+		guiTris->setCaption(tris + StringConverter::toString(stats.triangleCount));
+
+		OverlayElement* guiBatches = OverlayManager::getSingleton().getOverlayElement("Core/NumBatches");
+		guiBatches->setCaption(batches + StringConverter::toString(stats.batchCount));
+
+		OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
+		guiDbg->setCaption(mDebugText);
+	}
+	catch(...) { /* ignore */ }
+}
+
+
+
+// create camera
+void RunManager::createCamera(void)
+{
+	mCamera = mSceneMgr->createCamera("PlayerCam");
+	mCamera->setNearClipDistance(5);
+	mCamera->setPosition(Vector3(0,10,500));
+	mCamera->lookAt(Vector3(0,0,0));
+}
+
+
+void RunManager::createViewports(void)
+{
+	// Create one viewport, entire window
+	Viewport* vp = mWindow->addViewport(mCamera);
+	vp->setBackgroundColour(ColourValue(0,0,0));
+
+	// Alter the camera aspect ratio to match the viewport
+	mCamera->setAspectRatio(
+		Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
+
+	// Set default mipmap level (NB some APIs ignore this)
+	TextureManager::getSingleton().setDefaultNumMipmaps(5);
+}
+
+
Index: /code/branches/main_reto/src/main.cpp
===================================================================
--- /code/branches/main_reto/src/main.cpp	(revision 123)
+++ /code/branches/main_reto/src/main.cpp	(revision 123)
@@ -0,0 +1,36 @@
+#include "Orxonox.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 
+#define WIN32_LEAN_AND_MEAN 
+#include "windows.h" 
+	INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT) 
+#else 
+	int main(int argc, char **argv) 
+#endif 
+	{
+		try {
+			Orxonox myApp;
+
+			// ExampleApplication provides a go method, which starts the rendering.
+			myApp.go();
+		}
+		catch (Ogre::Exception& e) {
+#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 
+			MessageBoxA(NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
+#else
+			std::cerr << "Exception:\n";
+			std::cerr << e.getFullDescription().c_str() << "\n";
+#endif
+			return 1;
+		}
+
+		return 0;
+	}
+
+#ifdef __cplusplus
+}
+#endif
Index: /code/branches/main_reto/weapon_framework/weapon_framework.sln
===================================================================
--- /code/branches/main_reto/weapon_framework/weapon_framework.sln	(revision 123)
+++ /code/branches/main_reto/weapon_framework/weapon_framework.sln	(revision 123)
@@ -0,0 +1,20 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "weapon_framework", "weapon_framework.vcproj", "{C5DA441F-E90E-4FDA-8BAC-4B12EBBFD00B}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{C5DA441F-E90E-4FDA-8BAC-4B12EBBFD00B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{C5DA441F-E90E-4FDA-8BAC-4B12EBBFD00B}.Debug|Win32.Build.0 = Debug|Win32
+		{C5DA441F-E90E-4FDA-8BAC-4B12EBBFD00B}.Release|Win32.ActiveCfg = Release|Win32
+		{C5DA441F-E90E-4FDA-8BAC-4B12EBBFD00B}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Index: /code/branches/main_reto/weapon_framework/weapon_framework.vcproj
===================================================================
--- /code/branches/main_reto/weapon_framework/weapon_framework.vcproj	(revision 123)
+++ /code/branches/main_reto/weapon_framework/weapon_framework.vcproj	(revision 123)
@@ -0,0 +1,237 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="weapon_framework"
+	ProjectGUID="{C5DA441F-E90E-4FDA-8BAC-4B12EBBFD00B}"
+	RootNamespace="weapon_framework"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(OGRE_HOME)\Samples\Common\bin$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\include;$(OGRE_HOME)\OgreMain\include;$(OGRE_HOME)\Samples\Common\include;$(OGRE_HOME)\Dependencies\include"
+				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="OgreMain_d.lib OIS_d.lib"
+				OutputFile="..\bin\$(ConfigurationName)$(ProjectName).exe"
+				LinkIncremental="2"
+				AdditionalLibraryDirectories="$(OGRE_HOME)\lib;$(OGRE_HOME)\Dependencies\lib\$(ConfigurationName)"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			CharacterSet="1"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="..\include;$(OGRE_HOME)\OgreMain\include;$(OGRE_HOME)\Samples\Common\include;$(OGRE_HOME)\Dependencies\include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="OgreMain.lib OIS.lib"
+				OutputFile="..\bin\$(ConfigurationName)$(ProjectName).exe"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="$(OGRE_HOME)\lib;$(OGRE_HOME)\Dependencies\lib\$(ConfigurationName)"
+				GenerateDebugInformation="true"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\src\main.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\OgreControl.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\Orxonox.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\OrxonoxScene.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\RunManager.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\include\OgreControl.h"
+				>
+			</File>
+			<File
+				RelativePath="..\include\Orxonox.h"
+				>
+			</File>
+			<File
+				RelativePath="..\include\OrxonoxScene.h"
+				>
+			</File>
+			<File
+				RelativePath="..\include\RunManager.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/main_reto/weapon_framework/weapon_framework.vcproj.RGRIEDERT60.rgrieder.user
===================================================================
--- /code/branches/main_reto/weapon_framework/weapon_framework.vcproj.RGRIEDERT60.rgrieder.user	(revision 123)
+++ /code/branches/main_reto/weapon_framework/weapon_framework.vcproj.RGRIEDERT60.rgrieder.user	(revision 123)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="8.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory="$(OGRE_HOME)\Samples\Common\bin\debug"
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="RGRIEDERT60"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor="0"
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="RGRIEDERT60"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>
