Index: trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp	(revision 74)
+++ trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp	(revision 75)
@@ -6,16 +6,16 @@
 */
 #include "TerrainContentGenerator.h"
-
+#include <windows.h>
 /********************************************/
 /*  TerrainContentGenerator implementation  */
 /********************************************/
 //-----------------------------------------------------------------------
-TerrainContentGenerator::TerrainContentGenerator( SceneManager *sm, RayQueryExecutor *rayQueryEx )
+TerrainContentGenerator::TerrainContentGenerator(SceneManager *sm)
 {
 	mSceneMgr = sm;
-	mRayQueryExecutor = rayQueryEx;
+	mRayQueryExecutor = new RayQueryExecutor(sm);
 
-	mMinPos = Vector3(-200.0f, -70.0f, 200.0f);
-	mMaxPos = Vector3(200.0f, 70.0f, 200.0f);
+	mMinPos = Vector3(-500.0f, 5000.0f, -500.0f);
+	mMaxPos = Vector3(500.0f, 5000.0f, 500.0f);
 
 	mMinAngle = 0;
@@ -25,12 +25,17 @@
 }
 //-----------------------------------------------------------------------
-void TerrainContentGenerator::generateScene( int numObjects )
+TerrainContentGenerator::~TerrainContentGenerator()
 {
-	srand (time (0));
+	delete mRayQueryExecutor;
+}
+//-----------------------------------------------------------------------
+void TerrainContentGenerator::generateScene(int numObjects, const String &meshName)
+{
+	srand (time(0));
 	
 	Vector3 rotationRatio;
 	Vector3 translationRatio;
 
-	for(int i=0; i < numObjects; i++)
+	for(int i=0; i < numObjects; ++i)
 	{
 		rotationRatio.x = rand() / (float) RAND_MAX;
@@ -42,5 +47,5 @@
 		translationRatio.z = rand() / (float) RAND_MAX;
 
-		generateSceneObject(translationRatio, rotationRatio, i, "sphere.mesh");
+		generateSceneObject(translationRatio, rotationRatio, i, meshName);
 	}
 }
@@ -53,13 +58,14 @@
 	Vector3 position = mMinPos + translationRatio * (mMaxPos - mMinPos);
 
-	position.y = 5000;
-    
 	Vector3 queryResult;
 
-	if(mRayQueryExecutor->executeRayQuery(&queryResult, position, Vector3::NEGATIVE_UNIT_Y))
+	char msg[100];
+	sprintf(msg, "pos: %3.3f %3.3f %3.3f\n", position.x, position.y, position.z);
+
+	if (mRayQueryExecutor->executeRayQuery(&queryResult, position, Vector3::NEGATIVE_UNIT_Y))
 	{
 		char name[16];
-		sprintf( name, "%s%d", entName.c_str(), mCount++);
-
+		sprintf(name, "%s%d", entName.c_str(), mCount++);
+		OutputDebugString("Creating new object "); OutputDebugString(msg);
 		Entity *ent = mSceneMgr->createEntity(name, entName);
 		SceneNode *currentObject = mSceneMgr->getRootSceneNode()->
@@ -67,4 +73,9 @@
 		currentObject->attachObject(ent);
 		currentObject->setScale(0.1f, 0.1f, 0.1f);
+		currentObject->setPosition(position);
+	}
+	else
+	{
+		OutputDebugString(msg);
 	}
 }
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 74)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 75)
@@ -25,8 +25,6 @@
 TestCullingTerrainApplication::~TestCullingTerrainApplication()
 {
-	delete mRayQueryExecutor;
 	delete mTerrainContentGenerator;
 }
-
 //-----------------------------------------------------------------------
 void TestCullingTerrainApplication::createCamera( void )
@@ -44,9 +42,6 @@
 }
 //-----------------------------------------------------------------------
-void TestCullingTerrainApplication::createScene( void )
-{
-	mRayQueryExecutor = new RayQueryExecutor(mSceneMgr);
-	mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr, mRayQueryExecutor);
-
+void TestCullingTerrainApplication::createScene()
+{
 	// Set ambient light
 	mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));
@@ -93,14 +88,16 @@
 	mCamera->setPosition(707,2500,528);
 	mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329));
-
+	
 	// CEGUI setup
 	setupGui();
 
-	mTerrainContentGenerator->generateScene(100);
+	mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr);
+	mTerrainContentGenerator->generateScene(300, "robot.mesh");
 }
 //-----------------------------------------------------------------------
 void TestCullingTerrainApplication::setupGui( void )
 {
-	 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, ST_EXTERIOR_CLOSE);
+	 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, 
+		 false, 3000, ST_EXTERIOR_CLOSE);
      mGUISystem = new CEGUI::System(mGUIRenderer);
 
@@ -111,10 +108,10 @@
                 (CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
 
-	 CEGUI::MouseCursor::getSingleton().show( );
+	 CEGUI::MouseCursor::getSingleton().show();
 }
 //-----------------------------------------------------------------------
 void TestCullingTerrainApplication::createFrameListener(void)
 {
-	mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer, mRayQueryExecutor);
+	mFrameListener= new MouseQueryListener(mWindow, mCamera, mSceneMgr, mGUIRenderer);
 	mFrameListener->showDebugOverlay(true);
 	mRoot->addFrameListener(mFrameListener);
@@ -130,8 +127,10 @@
 /***********************************************/
 //-----------------------------------------------------------------------
-MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, CEGUI::Renderer *renderer, RayQueryExecutor *rqe)
-        : ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), mShutdownRequested(false), mRayQueryExecutor(rqe)
-{
-
+MouseQueryListener::MouseQueryListener(RenderWindow* win, Camera* cam, 
+									   SceneManager *sceneManager, 
+									   CEGUI::Renderer *renderer): 
+ExampleFrameListener(win, cam, false, true), mGUIRenderer(renderer), 
+mShutdownRequested(false)
+{
 	// Setup default variables
 	mCurrentObject = NULL;
@@ -153,5 +152,5 @@
 
 	mRayQueryExecutor = new RayQueryExecutor(mSceneMgr);
-
+	
 	// show overlay
 	Overlay* pOver = OverlayManager::getSingleton().getByName("Example/VisibilityDemoOverlay"); 
@@ -184,5 +183,6 @@
 {
 	// Update CEGUI with the mouse motion
-    CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * mGUIRenderer->getWidth(), e->getRelY() * mGUIRenderer->getHeight());
+    CEGUI::System::getSingleton().injectMouseMove(e->getRelX() * mGUIRenderer->getWidth(), 
+		e->getRelY() * mGUIRenderer->getHeight());
 }
 //-----------------------------------------------------------------------
@@ -202,11 +202,12 @@
          {
 			 char name[16];
-             sprintf( name, "Robot%d", mCount++ );
+             sprintf(name, "Robot%d", mCount++);
 
              Entity *ent = mSceneMgr->createEntity(name, "robot.mesh");
              mCurrentObject = mSceneMgr->getRootSceneNode()->
-				 createChildSceneNode( String(name) + "Node", queryResult);
-             mCurrentObject->attachObject( ent );
-             mCurrentObject->setScale( 0.1f, 0.1f, 0.1f );
+				 createChildSceneNode(String(name) + "Node", queryResult);
+             mCurrentObject->attachObject(ent);
+             mCurrentObject->setScale(0.1f, 0.1f, 0.1f);
+			 
          }
 
@@ -216,5 +217,5 @@
      else if (e->getButtonID() & InputEvent::BUTTON1_MASK)
      {
-         CEGUI::MouseCursor::getSingleton().hide( );
+         CEGUI::MouseCursor::getSingleton().hide();
          mRMouseDown = true;
      } // else if
@@ -227,5 +228,5 @@
     if (e->getButtonID() & InputEvent::BUTTON0_MASK)
     {
-		CEGUI::MouseCursor::getSingleton().show( );
+		CEGUI::MouseCursor::getSingleton().show();
         mLMouseDown = false;
     }
@@ -233,13 +234,13 @@
     else if (e->getButtonID() & InputEvent::BUTTON1_MASK)
     {
-        CEGUI::MouseCursor::getSingleton().show( );
+        CEGUI::MouseCursor::getSingleton().show();
         mRMouseDown = false;
     }
 } 
 //-----------------------------------------------------------------------
-void MouseQueryListener::mouseDragged (MouseEvent *e)
+void MouseQueryListener::mouseDragged(MouseEvent *e)
  {
 	 // If we are dragging the left mouse button.	 	 
-	 if ( mLMouseDown )
+	 if (mLMouseDown)
      {
 		 Vector3 queryResult;
@@ -252,5 +253,5 @@
      }
 	 // If we are dragging the right mouse button.
-	 if ( mRMouseDown )
+	 if (mRMouseDown)
 	 {
 		 mCamera->yaw( -e->getRelX() * mRotateSpeed );
@@ -271,5 +272,5 @@
 			mCamera->getPosition().z);
 	}
-	 
+	
 	return ExampleFrameListener::frameStarted(evt);
 }
@@ -371,5 +372,6 @@
 	catch( Ogre::Exception& e ) 
 	{
-        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
+        MessageBox( NULL, e.getFullDescription().c_str(), 
+			"An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
     }	
 
Index: trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h	(revision 74)
+++ trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h	(revision 75)
@@ -24,9 +24,11 @@
 {
 public:
-	TerrainContentGenerator(SceneManager *sm, RayQueryExecutor *rayQueryEx);
+	TerrainContentGenerator(SceneManager *sm);
+	~TerrainContentGenerator();
 	/** Generates a the scene hierarchy with random values .
 		@param number of objects to generate
+		@param the name of the mesh to be generated
 	*/
-	void generateScene(int numObjects);
+	void generateScene(int numObjects, const String &meshName);
 	/** Generates a new scene object 
 		@param tranlationRatio ratio between minimal and maximal possible translation
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 74)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 75)
@@ -30,5 +30,5 @@
 
     MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 
-		CEGUI::Renderer *renderer, RayQueryExecutor *rqe);
+		CEGUI::Renderer *renderer);
 
 
@@ -103,6 +103,5 @@
 	CEGUI::OgreCEGUIRenderer *mGUIRenderer;
 	CEGUI::System *mGUISystem;
-	RayQueryExecutor *mRayQueryExecutor;
-	TerrainContentGenerator *mTerrainContentGenerator;
+//	RayQueryExecutor *mRayQueryExecutor;
 
 	Vector3 mMinTranslation;
@@ -112,4 +111,6 @@
 	Vector3 mMaxAngle;
 
+	TerrainContentGenerator *mTerrainContentGenerator;
+
 private:
 	void chooseSceneManager(void);
