Index: trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp	(revision 104)
+++ trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.cpp	(revision 106)
@@ -69,5 +69,5 @@
 {
 	Vector3 queryResult;
-	
+	Vector3 pos(position.x, 5000, position.z);
 	if (mRayQueryExecutor->executeRayQuery(&queryResult, position, Vector3::NEGATIVE_UNIT_Y))
 	{
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 105)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 106)
@@ -192,6 +192,6 @@
 mCamNode(camNode),
 mCullCamera(false),
-mDirection(Vector3::ZERO),
-mDistance(0)
+mState(WALKTHROUGH),
+mCurrentFrame(1)
 {
 	// Reduce move speed
@@ -241,13 +241,4 @@
 	mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz);
 
-	// Create the walking list
-	/*Vector3 queryResult;
-	mWalkList.push_back(Vector3(1550.0f, 5000.0f, 250.0f));
-	mWalkList.push_back(Vector3(100.0f, 5000.0f, 750.0f));
-
-	mTerrainContentGenerator->GenerateSceneObject(mCamera->getPosition(), Vector3::ZERO, "knot.mesh");
-	mTerrainContentGenerator->GenerateSceneObject(Vector3(1550.0f, 5000.0f, 250.0f), Vector3::ZERO, "knot.mesh");
-	mTerrainContentGenerator->GenerateSceneObject(Vector3(100.0f, 5000.0f, 750.0f), Vector3::ZERO, "knot.mesh");
-*/
 	pOver->show();
 } 
@@ -337,21 +328,20 @@
 	switch (mState)
 	{
-	case STATE_RECORD:
+	case REPLAY:
+		SetCurrentCameraPath(mCamNode);
+		mCamNode->setPosition(mCameraPath[mCurrentFrame].position);
+		mCamNode->setOrientation(mCameraPath[mCurrentFrame].orientation);
+		(mCurrentFrame++) % mCameraPath.size();
+		break;
+	case WALKTHROUGH:
 		Clamp2Terrain();
-	case STATE_REPLAY:
-		
-		mCamera->setPosition(mPosition[mCurrentFrame]);
-		mCamera->setOrientation(
-	case STATE_:
-	
-
-	// save for walkthrough
-	if(mState == STATE_RECORD)
-	{
-		mPositions.push_back(mCamera->GetPosition());
-		mOrientations.push_back(mCamera->GetOrientation());
-	}
-	
-
+
+	case RECORD:
+		AddCameraPath(mCamNode);
+		break;
+	default:
+		break;
+	};
+	
 	if (mShowVisualization)
 	{
@@ -413,5 +403,7 @@
 	KEY_PRESSED(KC_3, 0, zoomVizCamera(50));
 	KEY_PRESSED(KC_4, 0, zoomVizCamera(-50));
-	
+	KEY_PRESSED(KC_F1, 0, setState(RECORD));
+	KEY_PRESSED(KC_F2, 0, setState(REPLAY));
+	KEY_PRESSED(KC_F3, 0, setState(WALKTHROUGH));
 	updateStats();
 
@@ -593,7 +585,24 @@
 	e->consume();
 }
+//-----------------------------------------------------------------------
+void MouseQueryListener::AddCameraPath(SceneNode *camNode)
+{
+	frame_info info;
+	info.orientation = mCamNode->getOrientation();
+	info.position = mCamNode->getPosition();
+	mCameraPath.push_back(info);
+}
+//-----------------------------------------------------------------------
+void MouseQueryListener::SetCurrentCameraPath(SceneNode *camNode)
+{
+	mCamNode->setPosition(mCameraPath[mCurrentFrame].position);
+	mCamNode->setOrientation(mCameraPath[mCurrentFrame].orientation);
+	(mCurrentFrame++) % mCameraPath.size();
+}
+
 /**************************************************************/
 /*      VisualizationRenderTargetListener implementation      */
 /**************************************************************/
+
 VisualizationRenderTargetListener::VisualizationRenderTargetListener(SceneManager *sceneMgr)
 :RenderTargetListener(), mSceneMgr(sceneMgr)
Index: trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h	(revision 104)
+++ trunk/VUT/work/TestCullingTerrain/TerrainContentGenerator.h	(revision 106)
@@ -22,5 +22,6 @@
 };
 
-/** Class which fills a terrain with content in a random fashion 
+/** 
+	Class which randomly fills a terrain with objects.
 */
 class TerrainContentGenerator: public SceneContentGenerator
@@ -30,7 +31,11 @@
 	~TerrainContentGenerator();
 
+	/** 
+		Generates objects and places it on the terrain
+	*/
 	SceneNode *GenerateSceneObject(const Vector3 &position, 
 		const Vector3 &rotation, const String &objName);
-
+	
+	/** maximum height where objects can be put into the terrain */
 	void SetMaxHeight(Real maxHeight);
 	
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 105)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 106)
@@ -8,5 +8,5 @@
 #include "VisibilityEnvironment.h"
 #include <OgreRenderTargetListener.h>
-#include <vector.h>
+#include <vector>
 
 Real timeDelay = 0;
@@ -26,10 +26,13 @@
 	"Coherent Hierarchical Culling"
 };
-typedef struct frame_info
+
+/** The information about camera position and orienation per frame */
+typedef struct
 {
+	Vector3 position;
+	Quaternion orientation;
+} frame_info;
 
-}
-	Position
-typedef std::pair<Vector3 frame_pair
+
 class VisualizationRenderTargetListener: public RenderTargetListener
 {
@@ -47,5 +50,5 @@
 {
 public:
-
+	
     MouseQueryListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 
 		CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera,
@@ -92,11 +95,13 @@
 	void zoomVizCamera(int zoom);
 	void moveCamera();
+	void AddCameraPath(SceneNode *camNode);
+	void SetCurrentCameraPath(SceneNode *camNode);
+
+	enum {WALKTHROUGH, REPLAY} State;
 
 
 protected:
 	void Clamp2Terrain();
-
-	bool NextLocation();
-
+	
     bool mLMouseDown, mRMouseDown;     // True if the mouse buttons are down
     SceneManager *mSceneMgr;           // A pointer to the scene manager
@@ -107,5 +112,5 @@
 	int mCurrentAlgorithm;
 	int mVisibilityThreshold;
-
+	
 	OverlayElement *mAlgorithmInfo;
 	OverlayElement *mThresholdInfo;
@@ -120,5 +125,5 @@
 
 	SceneNode *mCurrentObject;         // The newly created object
-	int mCount;                        // The number of robots on the screen
+	int mObjectCount;                 // The number of robots on the screen
 
 	RayQueryExecutor *mRayQueryExecutor;
@@ -136,14 +141,11 @@
 	Camera *mVizCamera;
 	SceneNode *mCamNode;
-	Real mWalkSpeed;
-	Real mDistance;
-	Vector3 mDestination;
-	Vector3 mDirection;
-
+	
 	//std::deque<Vector3> mWalkList;   // The list of points we are walking to
-	vector<
-	std::vector<Ogre::Vector3> mPositions;
-	std::vector<Ogre::Quaternion> mOrientations;
-
+	std::vector<frame_info> mCameraPath;
+		
+	int mCurrentFrame;
+	// the current application state
+	int mState;
 };
 
Index: trunk/VUT/work/TestCullingTerrain/IoManager.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/IoManager.cpp	(revision 105)
+++ 	(revision )
@@ -1,31 +1,0 @@
-#include "IoManager.h"
-
-IoManager::IoManager(Ogre::String fileName)
-{
-	mFile.open(fileName.c_str());
-}
-
-IoManager::~IoManager()
-{
-	 mFile.close();
-}
-
-void IoManager::Write()
-{
-	std::vector<Ogre::Vector3>::const_iterator posit, posit_end;
-    posit_end = mPositions.end();
-	
-	std::vector<Ogre::Quaternion>::const_iterator orit;
-	orit = mOrientations.begin();
-
-    for (posit = mPositions.begin(); posit != posit_end; ++posit)
-	{
-		mFile << (*posit) << (*(orit++));
-	}
-}
-
-void IoManager::AddNode(Ogre::SceneNode *node)
-{
-	mPositions.push_back(node->getPosition());
-	mOrientations.push_back(node->getOrientation());
-}
Index: trunk/VUT/work/TestCullingTerrain/IoManager.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/IoManager.h	(revision 105)
+++ 	(revision )
@@ -1,24 +1,0 @@
-#ifndef _IoManager_H__
-#define _IoManager_H__
-
-#include <OgrePrerequisites.h>
-#include <OgreMath.h>
-#include <Ogre.h>
-#include <OgreSceneNode.h>
-
-class IoManager
-{
-public:
-	IoManager(Ogre::String fileName);
-
-	void Write();
-	void AddNode(Ogre::SceneNode *node);
-
-	std::vector<Ogre::Vector3> mPositions;
-	std::vector<Ogre::Quaternion> mOrientations;
-
-protected:
-	std::ofstream mFile;
-};
-
-#endif // IoManager
Index: trunk/VUT/work/TestCulling/SceneContentGenerator.cpp
===================================================================
--- trunk/VUT/work/TestCulling/SceneContentGenerator.cpp	(revision 104)
+++ trunk/VUT/work/TestCulling/SceneContentGenerator.cpp	(revision 106)
@@ -15,5 +15,5 @@
 //-----------------------------------------------------------------------
 SceneContentGenerator::SceneContentGenerator(SceneManager *sm):
-mSceneMgr(sm), mCount(0),
+mSceneMgr(sm), mObjectCount(0),
 mMinPos(Vector3(-70.0f, -70.0f, 0.0f)),
 mMaxPos(Vector3(70.0f, 70.0f, 600.0f)), 
@@ -32,9 +32,9 @@
 	Vector3 translationRatio;
 
-	int currentCount = mCount;
+	int currentCount = mObjectCount;
 	int limit = 0;
 
 	//-- create random values between zero and one
-	while ((mCount - currentCount < numObjects) && (limit < 50000))
+	while ((mObjectCount - currentCount < numObjects) && (limit < 50000))
 	{
 		rotationRatio.x = rand() / (float) RAND_MAX;
@@ -59,5 +59,5 @@
 {
 	char name[25];
-	sprintf(name, "Entity%d", mCount++);
+	sprintf(name, "Entity%d", mObjectCount++);
 		
 	Entity *ent = mSceneMgr->createEntity(name, objName);
@@ -98,5 +98,5 @@
 int SceneContentGenerator::GetObjectCount()
 {
-	return mCount;
+	return mObjectCount;
 }
 //-----------------------------------------------------------------------
Index: trunk/VUT/work/TestCulling/SceneContentGenerator.h
===================================================================
--- trunk/VUT/work/TestCulling/SceneContentGenerator.h	(revision 86)
+++ trunk/VUT/work/TestCulling/SceneContentGenerator.h	(revision 106)
@@ -46,5 +46,5 @@
 
 	SceneManager *mSceneMgr;
-	int mCount;		// The number of objects on the screen
+	int mObjectCount;		// The number of objects on the screen
 };
 
