Index: trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h
===================================================================
--- trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h	(revision 18)
+++ trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h	(revision 26)
@@ -5,5 +5,5 @@
 #include "CEGUIForwardRefs.h"
 #include "ExampleApplication.h"
-
+#include "OgreOcclusionCullingSceneManager.h"
 
 class MouseQueryListener : public ExampleFrameListener, public MouseListener, public MouseMotionListener
@@ -13,5 +13,5 @@
     MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer,
 					   SceneNode* shipNode)
-        : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), mShipNode(shipNode)
+        : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), mShipNode(shipNode),  mShutdownRequested(false)
     {
 		// Setup default variables
@@ -24,8 +24,13 @@
         mMoveSpeed = 50;
         mRotateSpeed *= 2;
+	
+		mAlgorithmType = OcclusionCullingSceneManager::RENDER_COHERENT;
+
+		 showDebugOverlay(false);
 
 		// Register this so that we get mouse events.
-        mEventProcessor->addMouseListener( this );
-        mEventProcessor->addMouseMotionListener( this );
+        mEventProcessor->addMouseListener(this);
+        mEventProcessor->addMouseMotionListener(this);
+		mEventProcessor->addKeyListener(this);
     } // MouseQueryListener
 
@@ -36,5 +41,28 @@
     bool frameStarted(const FrameEvent &evt)
     {
-        return ExampleFrameListener::frameStarted( evt );
+       Real MoveFactor = 80.0 * evt.timeSinceLastFrame;
+ 
+		mInputDevice->capture();
+ 
+		if(mInputDevice->isKeyDown(Ogre::KC_UP))
+		{
+
+			mAlgorithmType = (mAlgorithmType + 1) % OcclusionCullingSceneManager::NUM_RENDERMODES;
+			//mShipNode->translate(0.0, MoveFactor, 0.0);
+		}
+ 
+		if(mInputDevice->isKeyDown(Ogre::KC_DOWN))
+			mShipNode->translate(0.0, -MoveFactor, 0.0);
+ 
+		if(mInputDevice->isKeyDown(Ogre::KC_LEFT))
+			mShipNode->translate(-MoveFactor, 0.0, 0.0);
+ 
+		if(mInputDevice->isKeyDown(Ogre::KC_RIGHT))
+			mShipNode->translate(MoveFactor, 0.0, 0.0);		
+ 
+		if(mInputDevice->isKeyDown(Ogre::KC_ESCAPE))
+			return false;
+
+		return true;
     }
 
@@ -56,4 +84,40 @@
    virtual void mouseDragged (MouseEvent *e);
 
+   void keyPressed(KeyEvent* e)
+   {
+        if(e->getKey() == KC_ESCAPE)
+        {
+            mShutdownRequested = true;
+            e->consume();
+            return;
+        }
+
+        CEGUI::System::getSingleton().injectKeyDown(e->getKey());
+		CEGUI::System::getSingleton().injectChar(e->getKeyChar());
+        e->consume();
+    }
+
+	void keyReleased(KeyEvent* e)
+	{
+		CEGUI::System::getSingleton().injectKeyUp(e->getKey());
+		e->consume();
+	}
+	void keyClicked(KeyEvent* e) 
+	{
+		// Do nothing
+		e->consume();
+	}
+
+	  bool frameEnded(const FrameEvent& evt)
+    {
+        if (mShutdownRequested)
+            return false;
+        else
+            return ExampleFrameListener::frameEnded(evt);
+    }
+
+	void setAlgorithmType(int type) { mAlgorithmType = type; }
+	int getAlgorithmType() { return mAlgorithmType; }
+
 protected:
     bool mLMouseDown, mRMouseDown;     // True if the mouse buttons are down
@@ -62,42 +126,8 @@
     CEGUI::Renderer *mGUIRenderer;     // cegui renderer
 	SceneNode* mShipNode;
+	bool mShutdownRequested;
+	int mAlgorithmType;
 };
 
-
-class TestCullingFrameListener : public ExampleFrameListener
-{
-protected:
-    SceneNode* mShipNode;
-
-public:
-    TestCullingFrameListener(RenderWindow* win, Camera* cam, SceneNode* shipNode) : ExampleFrameListener(win, cam)
-    {
-		mShipNode = shipNode;
-    };
-
-	bool frameStarted(const FrameEvent& evt)
-	{
-		Real MoveFactor = 80.0 * evt.timeSinceLastFrame;
- 
-		mInputDevice->capture();
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_UP))
-			mShipNode->translate(0.0, MoveFactor, 0.0);
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_DOWN))
-			mShipNode->translate(0.0, -MoveFactor, 0.0);
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_LEFT))
-			mShipNode->translate(-MoveFactor, 0.0, 0.0);
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_RIGHT))
-			mShipNode->translate(MoveFactor, 0.0, 0.0);		
- 
-		if(mInputDevice->isKeyDown(Ogre::KC_ESCAPE))
-			return false;
- 
-		return true;
-	}
-};
 
 class TestCullingApplication : public ExampleApplication
@@ -106,5 +136,4 @@
     /*TestCullingApplication()
     {
-
 
     }*/
@@ -150,28 +179,6 @@
     {
         mSceneMgr = mRoot->getSceneManager(ST_GENERIC);
-		//mSceneMgr = mRoot->getSceneManager(ST_INTERIOR);
     }
-	/*
-    // Scene creation
-    void createScene(void)
-    {
-
-        // Load world geometry
-        mSceneMgr->setWorldGeometry(mQuakeLevel);
-
-        // modify camera for close work
-        mCamera->setNearClipDistance(4);
-        mCamera->setFarClipDistance(4000);
-
-        // Also change position, and set Quake-type orientation
-        // Get random player start point
-        ViewPoint vp = mSceneMgr->getSuggestedViewpoint(true);
-        mCamera->setPosition(vp.position);
-        mCamera->pitch(Degree(90)); // Quake uses X/Y horizon, Z up
-        mCamera->rotate(vp.orientation);
-        // Don't yaw along variable axis, causes leaning
-        mCamera->setFixedYawAxis(true, Vector3::UNIT_Z);
-    }*/
-
+	
 };
 
