Index: trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 159)
+++ trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp	(revision 160)
@@ -11,7 +11,5 @@
 #include "OgreItemBufferQueryManager.h"
 #include "OgreOcclusionQueriesQueryManager.h"
-
-
-
+#include "TestCullingTerrainApplication.h"
 
 // output file for frame info
@@ -48,4 +46,16 @@
 };
 
+Real currentObjectTerrainOffsets[] = 
+{
+	0,
+	7,
+	0
+};
+Real currentObjectScales[] = 
+{
+	0.1,
+	0.1,
+	0.07
+};
 //-----------------------------------------------------------------------
 TerrainFrameListener::TerrainFrameListener(RenderWindow* win, Camera* cam, 
@@ -55,5 +65,6 @@
 									   Camera *vizCamera,
 									   SceneNode *camNode,
-									   Light *sunLight): 
+									   Light *sunLight,
+									   TestCullingTerrainApplication *app): 
 mCamera(cam),
 mWindow(win),
@@ -79,5 +90,5 @@
 mAppState(WALKTHROUGH),
 mCurrentFrame(0),
-mTimeElapsed(0),
+mReplayTimeElapsed(0),
 mRotateSpeed(72),
 mMoveSpeed(50),
@@ -105,5 +116,7 @@
 mDelayedTraversedNodes(0.0),
 mUseItemBuffer(false),
-mRenderPatchesForItemBuffer(false)
+mRenderPatchesForItemBuffer(false),
+mCurrentObjectType(0),
+mApplication(app)
 {
 	//mInputDevice = PlatformManager::getSingleton().createInputReader();
@@ -118,63 +131,22 @@
 	mEventProcessor->addKeyListener(this);
 
-	mInputDevice = mEventProcessor->getInputReader();
-	
+	mInputDevice = mEventProcessor->getInputReader();	
 
 	// create ray query executor, used to place objects in terrain
 	mRayQueryExecutor = new RayQueryExecutor(mSceneMgr);
 	
+	//-- overlays
+	mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");
 	mHelpOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/HelpOverlay"); 
-	mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay");
 	mQueryOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/QueryOverlay"); 
-
-	//-- visibility culling stats overlay
-	mCullStatsOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/DemoOverlay"); 
-	
-	mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AlgorithmInfo");
-	mThresholdInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ThresholdInfo");
-	mTestGeometryForVisibleLeavesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/TestGeometryForVisibleLeavesInfo");
-	mUseDepthPassInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/UseDepthPassInfo");
-	mAssumedVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AssumedVisibilityInfo");
-
-	mFrustumCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/FrustumCulledNodesInfo");
-	mQueryCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueryCulledNodesInfo");
-    mTraversedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/TraversedNodesInfo");
-	mHierarchyNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/HierarchyNodesInfo");
-	mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo");
-	mObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo");
-	mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo");
-	mDelayedQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/DelayedQueriesIssuedInfo");
-	mDelayedTraversedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/DelayedTraversedNodesInfo");
-
-	mAlgorithmInfo->setCaption(": " + currentAlgorithmCaptions[mCurrentAlgorithm]);
-	mThresholdInfo->setCaption(": 0");
-	mFrustumCulledNodesInfo->setCaption(": 0");
-	mQueryCulledNodesInfo->setCaption(": 0");
-	mTraversedNodesInfo->setCaption(": 0");
-	mHierarchyNodesInfo->setCaption(": 0");
-	mRenderedNodesInfo->setCaption(": 0");
-	mObjectsInfo->setCaption(": 0");
-	mTestGeometryForVisibleLeavesInfo->setCaption(": true");
-	mUseDepthPassInfo->setCaption(": false");
-	mQueriesIssuedInfo->setCaption(": 0");
-	mAssumedVisibilityInfo->setCaption(": 0");
-	mDelayedQueriesIssuedInfo->setCaption(": 0");
-	mDelayedTraversedNodesInfo->setCaption(": 0");
-
-	//-- visibility query stats overlay
-	mQueryTypeInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/QueryTypeInfo");
-	
-	mQueryVisibleNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleNodesInfo");
-    mQueryVisibleGeometryInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleGeometryInfo");
-	mQueryVisiblePatchInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisiblePatchInfo");
-	
-	mQueryNodeVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/NodeVisibilityInfo");
-	mQueryGeometryVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/GeometryVisibilityInfo");
-	mQueryPatchVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/PatchVisibilityInfo");
+	mCullStatsOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/CullStatsOverlay"); 
+
+	initVisStatsOverlay(); // visibility stats overlay
+	initHelpOverlay(); // help overlay
+	initQueryOverlay(); // visibility query stats overlay
 
 	// show stats overlays
 	showStats(true);
-	//mHelpOverlay->show();
-
+	
 	// set culling algorithm type
 	setAlgorithm(mCurrentAlgorithm);
@@ -193,4 +165,6 @@
 	mSceneMgr->setOption("CullCamera", &mCullCamera);
 	mSceneMgr->setOption("PrepareVisualization", &mShowVisualization);
+
+	setObjectType(mCurrentObjectType);
 
 	// reset statistics
@@ -229,8 +203,21 @@
 		 //Vector3 queryResult; mRayQueryExecutor->executeRayQuery(&queryResult, mouseRay);
 		 
-		 // Get results, create a node/entity on the position
+		 // get results, create a node/entity on the position
 		 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject(
-			 mouseRay.getOrigin()/*queryResult*/, Vector3::ZERO, "robot");
+			 mouseRay.getOrigin()/*queryResult*/, Vector3::ZERO, 
+			 mApplication->getCurrentObjectCaption(mCurrentObjectType));
 		
+		 if (mCurrentObjectType == 0) // only robot has animation phases
+		 {
+			 Entity *ent = mTerrainContentGenerator->GetGeneratedEntities()->back();
+			 AnimationState *st = ent->getAnimationState("Walk");
+
+			 st->setLoop(true);
+			 st->setEnabled(true);
+					
+			 mApplication->getAnimationStates().push_back(st);
+			 mApplication->getAnimationSpeed().push_back(Math::RangeRandom(0.5, 1.5));
+		 }
+
          mLMouseDown = true; 
      }
@@ -271,4 +258,7 @@
 			 if (mCurrentObject)
 			 {
+				 // apply offset so object is ON terrain
+				 queryResult.y += currentObjectTerrainOffsets[mCurrentObjectType];
+
 				 mCurrentObject->setPosition(queryResult);
 			 }
@@ -292,4 +282,10 @@
 	}
 
+	for (int i = 0; i < (int)mApplication->getAnimationStates().size(); ++i)
+    {
+		mApplication->getAnimationStates()[i]->addTime(evt.timeSinceLastFrame * 
+			 mApplication->getAnimationSpeed()[i]);
+    }
+
 	if (mDisplayCameraDetails)
     {
@@ -299,7 +295,4 @@
     }
 
-	//-- IMPORTANT: must be set, otherwise terrain is not rendered correctly
-	mSceneMgr->endFrame();
-
 	//-- setup what is needed for immediate mouse/key movement
 	if (mTimeDelay >= 0) 
@@ -307,5 +300,5 @@
 		mTimeDelay -= evt.timeSinceLastFrame;
 	}
-
+	
 	// If this is the first frame, pick a speed
 	if (evt.timeSinceLastFrame == 0)
@@ -387,5 +380,5 @@
 }
 //-----------------------------------------------------------------------
-void TerrainFrameListener::ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility, 
+void TerrainFrameListener::applyVisibilityQuery(bool fromPoint, bool relativeVisibility, 
 												bool useItemBuffer)
 {
@@ -523,5 +516,5 @@
 
 	// show the results
-	if (!mShowQueryStats)
+	if (!mShowQueryStats && !mShowHelp)
 	{
 		mQueryOverlay->show();
@@ -552,4 +545,10 @@
 
     updateStats();
+
+	//-- IMPORTANT: must be set, otherwise terrain is not rendered correctly
+	mSceneMgr->endFrame();
+
+	if (mTimeDelay <= 0) // approx. one second
+		mTimeDelay = 1.0;
 
 	return true;
@@ -660,5 +659,5 @@
 
 			//-- initialise frame data
-			mTimeElapsed = 0;
+			mReplayTimeElapsed = 0;
 
 			mCamNode->setPosition(mFrameInfo[0].position);
@@ -716,4 +715,18 @@
 }
 //-----------------------------------------------------------------------
+void TerrainFrameListener::setObjectType(int objectType)
+{
+	if (mCurrentObjectType >= 3)
+		mCurrentObjectType = 0;
+
+	// parameters for new object
+	mTerrainContentGenerator->SetOffset(currentObjectTerrainOffsets[mCurrentObjectType]);
+	Real scale = currentObjectScales[mCurrentObjectType];
+	mTerrainContentGenerator->SetScale(Vector3(scale, scale, scale));
+
+	mCurrentObjectTypeInfo->setCaption(": " + 
+		mApplication->getCurrentObjectCaption(mCurrentObjectType));
+}
+//-----------------------------------------------------------------------
 void TerrainFrameListener::setAlgorithm(int algorithm)
 {
@@ -739,4 +752,6 @@
 	static String trisString = "Triangle Count: ";
 
+	// HACK: compute average fps ourselfs, because ogre avg. fps is wrong
+	// TODO: update only once per second
 	mAvgFps += mWindow->getStatistics().lastFPS;
 	++ mFrameCount;
@@ -755,10 +770,11 @@
 
 		//guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
-		guiAvg->setCaption(avgFpsString + StringConverter::toString(avgFps));
+		if (mTimeDelay < 0) // only update once per second
+			guiAvg->setCaption(avgFpsString + StringConverter::toString(avgFps) + " ms");
 		guiCurr->setCaption(currFpsString + StringConverter::toString(stats.lastFPS));
 		guiBest->setCaption(bestFpsString + StringConverter::toString(stats.bestFPS)
-			+" "+StringConverter::toString(stats.bestFrameTime)+" ms");
+			+" "+StringConverter::toString(stats.bestFrameTime) + " ms");
 		guiWorst->setCaption(worstFpsString + StringConverter::toString(stats.worstFPS)
-			+" "+StringConverter::toString(stats.worstFrameTime)+" ms");
+			+" "+StringConverter::toString(stats.worstFrameTime) + " ms");
 
 		OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
@@ -772,15 +788,7 @@
 		mFrustumCulledNodesInfo->setCaption(str);
 
-		// delay so there is no jump
-		mSceneMgr->getOption("NumQueriesIssued", &opt); 
-		sprintf(str,": %d", (int)opt); 
-		mQueriesIssuedInfo->setCaption(str);
-
 		mSceneMgr->getOption("NumQueryCulledNodes", &opt); sprintf(str,": %d", opt); 
 		mQueryCulledNodesInfo->setCaption(str);
 	
-		mSceneMgr->getOption("NumTraversedNodes", &opt); sprintf(str,": %d", opt); 
-		mTraversedNodesInfo->setCaption(str);
-
 		mSceneMgr->getOption("NumHierarchyNodes", &opt); sprintf(str,": %d", opt); 
 		mHierarchyNodesInfo->setCaption(str);
@@ -790,16 +798,16 @@
 
 		sprintf(str,": %d", mTerrainContentGenerator->GetObjectCount()); 
-		mObjectsInfo->setCaption(str);
-
-		// delay so there is no jump
+		mObjectsCountInfo->setCaption(str);
+
+		// take old value into account in order to create no sudden changes
 		mSceneMgr->getOption("NumQueriesIssued", &opt); 
 		mDelayedQueriesIssued = mDelayedQueriesIssued * 0.8 + (float)opt * 0.2;
 		sprintf(str,": %d", (int)mDelayedQueriesIssued); 
-		mDelayedQueriesIssuedInfo->setCaption(str);
+		mQueriesIssuedInfo->setCaption(str);
 
 		mSceneMgr->getOption("NumTraversedNodes", &opt); 
 		mDelayedTraversedNodes = mDelayedTraversedNodes * 0.8 + (float)opt * 0.2;
 		sprintf(str,": %d", (int)mDelayedTraversedNodes); 
-		mDelayedTraversedNodesInfo->setCaption(str);
+		mTraversedNodesInfo->setCaption(str);
 
 	}
@@ -815,7 +823,8 @@
 	mSceneMgr->setOption("TestGeometryForVisibleLeaves", &mTestGeometryForVisibleLeaves);
 	
-	// disable optimization which tests geometry instead of aabb
-	// for delayed rendering (i.e., render transparents after all the solids)
-	// because otherwise visible transparents could be skipped
+	/* disable optimization which tests geometry instead of aabb
+	 * for "delayed" rendering of transparents (i.e., render transparents after all the solids)
+	 * because otherwise visible transparents could be skipped
+	 */
 	bool delayedRendering = !mTestGeometryForVisibleLeaves;
 
@@ -928,4 +937,11 @@
 void TerrainFrameListener::keyPressed(KeyEvent* e)
 {
+	// hide exact visibility query overlay
+	if (mShowQueryStats)
+	{
+		mQueryOverlay->hide();
+		mShowQueryStats = false;
+	}
+
 	switch(e->getKey())
 	{
@@ -997,8 +1013,15 @@
 		break;
 	case KC_F5:
-		ApplyVisibilityQuery(false, mShiftPressed, mUseItemBuffer);
+		applyVisibilityQuery(false, mShiftPressed, mUseItemBuffer);
 		break;
 	case KC_F6:
-		ApplyVisibilityQuery(true, mShiftPressed, mUseItemBuffer);
+		applyVisibilityQuery(true, mShiftPressed, mUseItemBuffer);
+		break;
+	
+	case KC_F7:
+		setObjectType(++mCurrentObjectType);
+		break;
+	case KC_F8:
+		mApplication->generateScene(500, mCurrentObjectType);
 		break;
 	
@@ -1018,4 +1041,9 @@
 	case KC_LSHIFT:
 		mShiftPressed = true;
+		break;
+	case KC_DELETE:
+		mTerrainContentGenerator->RemoveGeneratedObjects();
+		mApplication->getAnimationStates().clear();
+		mApplication->getAnimationSpeed().clear();
 		break;
 	//KEY_PRESSED(KC_F3, 0.3, writeFrames());
@@ -1060,9 +1088,9 @@
 {
 	//-- find current frame relative to elapsed frame time		
-	mTimeElapsed -= timeElapsed;
-
-	while ((mTimeElapsed <= 0) && (mCurrentFrame < (int)mFrameInfo.size() - 1))
-	{
-		mTimeElapsed += mFrameInfo[mCurrentFrame ++].timeElapsed;
+	mReplayTimeElapsed -= timeElapsed;
+
+	while ((mReplayTimeElapsed <= 0) && (mCurrentFrame < (int)mFrameInfo.size() - 1))
+	{
+		mReplayTimeElapsed += mFrameInfo[mCurrentFrame ++].timeElapsed;
 	}
 
@@ -1075,5 +1103,5 @@
 	if (old_frame.timeElapsed > 0)
 	{
-		factor = mTimeElapsed / old_frame.timeElapsed;
+		factor = mReplayTimeElapsed / old_frame.timeElapsed;
 	}
 
@@ -1241,2 +1269,137 @@
 	}
 }
+//-----------------------------------------------------------------------
+void TerrainFrameListener::initOverlayElement(OverlayElement **elInfo, String ext, 
+											  String name, int top, String caption)
+{
+	OverlayElement *el = 
+		OverlayManager::getSingleton().getOverlayElement(ext + name);
+
+	(*elInfo) = OverlayManager::getSingleton().getOverlayElement(ext + name + "Info");
+	(*elInfo)->setCaption(caption);
+
+	el->setTop(top);
+	(*elInfo)->setTop(top);
+}
+//-----------------------------------------------------------------------
+void TerrainFrameListener::initHelpOverlayElement(String name, int top)
+{
+	OverlayElement *el = OverlayManager::getSingleton().getOverlayElement(
+		"Example/Visibility/Help/" + name);
+
+	el->setTop(top);
+}
+//-----------------------------------------------------------------------
+void TerrainFrameListener::initHelpOverlay()
+{
+	const int vert_space = 15;
+	int top = 30;
+
+	initHelpOverlayElement("ShowHelp", top); top += vert_space;
+	initHelpOverlayElement("Stats", top); top += vert_space;
+	initHelpOverlayElement("AppState", top); top += vert_space;
+	initHelpOverlayElement("Recorded", top); top += vert_space;
+	initHelpOverlayElement("Screenshots", top); top += vert_space;
+	initHelpOverlayElement("WriteOut", top); top += vert_space;
+
+	top +=vert_space;
+	initHelpOverlayElement("SceneDetail", top); top += vert_space;
+	initHelpOverlayElement("DisplayCameraDetails", top); top += vert_space;
+	initHelpOverlayElement("DisplayOctree", top); top += vert_space;
+	initHelpOverlayElement("UseShadows", top); top += vert_space;
+	initHelpOverlayElement("Filter", top); top += vert_space;
+
+	//-- visualization
+	top += vert_space;
+	initHelpOverlayElement("VizSection", top); top += vert_space;
+	initHelpOverlayElement("Viz", top); top += vert_space;
+	initHelpOverlayElement("NextVizMode", top); top += vert_space;
+	initHelpOverlayElement("ZoomViz", top); top += vert_space;
+
+
+	//-- visibility queries
+	top += vert_space;
+	initHelpOverlayElement("VisQuery", top); top += vert_space;
+	initHelpOverlayElement("FromCameraQuery", top); top += vert_space;
+	initHelpOverlayElement("FromPointQuery", top); top += vert_space;
+	initHelpOverlayElement("QueryType", top); top += vert_space;
+	initHelpOverlayElement("QueryTarget", top); top += vert_space;
+
+	//-- object generation
+	top += vert_space;
+	initHelpOverlayElement("SceneObjects", top); top += vert_space;
+	initHelpOverlayElement("GenerateObjects", top); top += vert_space;
+	initHelpOverlayElement("RemoveObjects", top); top += vert_space;
+	initHelpOverlayElement("DropObject", top); top += vert_space;
+
+	OverlayElement *helpPanel = OverlayManager::getSingleton().getOverlayElement(
+		"Example/Visibility/Help/HelpPanel");
+
+	helpPanel->setHeight(top + 10);
+}
+//-----------------------------------------------------------------------
+void TerrainFrameListener::initVisStatsOverlay()
+{
+	const int border_height = 10;
+	const int vert_space = 15;
+
+	//-- visibility culling stats overlay
+	int top = border_height;
+
+	String ext = "Example/Visibility/";
+	
+	initOverlayElement(&mAlgorithmInfo, ext, "Algorithm", top,
+		": " + currentAlgorithmCaptions[mCurrentAlgorithm]); top += vert_space;
+
+	initOverlayElement(&mThresholdInfo, ext, "Threshold", top, ": 0"); top += vert_space;
+	initOverlayElement(&mTestGeometryForVisibleLeavesInfo, ext, 
+		"TestGeometryForVisibleLeaves", top, ": true"); top += vert_space;
+	initOverlayElement(&mUseDepthPassInfo, ext, "UseDepthPass", top, ": false"); top += vert_space;
+	initOverlayElement(&mAssumedVisibilityInfo, ext, "AssumedVisibility", top, ": 0"); top += vert_space;
+	initOverlayElement(&mCurrentObjectTypeInfo, ext, "CurrentObjectType", top, ": "); top += vert_space;
+
+	OverlayElement *optionsPanel = OverlayManager::getSingleton().
+		getOverlayElement("Example/Visibility/VisibilityPanel");
+
+	optionsPanel->setHeight(top + border_height);
+
+	top = border_height;
+	//ext = "Example/Visibility/";
+	initOverlayElement(&mFrustumCulledNodesInfo, ext, "FrustumCulledNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mQueryCulledNodesInfo, ext, "QueryCulledNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mTraversedNodesInfo, ext, "TraversedNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mHierarchyNodesInfo, ext, "HierarchyNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mRenderedNodesInfo, ext, "RenderedNodes", top, ": 0"); top += vert_space;
+	initOverlayElement(&mObjectsCountInfo, ext, "ObjectsCount", top, ": 0"); top += vert_space;
+	initOverlayElement(&mQueriesIssuedInfo, ext, "QueriesIssued", top, ": 0"); top += vert_space;
+
+	OverlayElement *visPanel = OverlayManager::getSingleton().
+		getOverlayElement("Example/Visibility/VisibilityStatsPanel");
+
+	visPanel->setHeight(top + border_height);
+}
+//-----------------------------------------------------------------------
+void TerrainFrameListener::initQueryOverlay()
+{
+	const int border_height = 10;
+	const int vert_space = 15;
+
+	//-- visibility culling stats overlay
+	int top = border_height + 25;
+
+	String ext = "Example/Visibility/Query/";
+	    
+	initOverlayElement(&mQueryTypeInfo , ext, "QueryType", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryVisibleGeometryInfo , ext, "VisibleGeometry", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryVisibleNodesInfo , ext, "VisibleNodes", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryVisiblePatchInfo , ext, "VisiblePatches", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryNodeVisibilityInfo , ext, "NodeVisibility", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryGeometryVisibilityInfo , ext, "GeometryVisibility", top,	": 0"); top += vert_space;
+	initOverlayElement(&mQueryPatchVisibilityInfo , ext, "PatchVisibility", top,	": 0"); top += vert_space;
+
+
+	OverlayElement *queryPanel = OverlayManager::getSingleton().
+		getOverlayElement("Example/Visibility/Query/QueryPanel");
+
+	queryPanel->setHeight(top + border_height);
+}
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 159)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 160)
@@ -15,7 +15,17 @@
 #include <windows.h>
 
-/*******************************************************/
-/*     TestCullingTerrainApplication implementation    */
-/*******************************************************/
+String currentObjectCaptions[] =
+{
+	"robot",
+	"athene",
+	"ninja"
+	//"ogrehead"
+};
+
+/*********************************************************/
+/*      TestCullingTerrainApplication implementation     */
+/*********************************************************/
+
+
 TestCullingTerrainApplication::TestCullingTerrainApplication():
 mTerrainContentGenerator(NULL)
@@ -30,5 +40,4 @@
 		mTerrainContentGenerator = NULL;
 	}
-	//if(mRenderTargetListener)	delete mRenderTargetListener;
 }
 //-----------------------------------------------------------------------
@@ -127,9 +136,6 @@
 	setupGui();
 
-	
 	/* // occluder plane to test visibility
-	Plane plane;
-	plane.normal = Vector3::UNIT_Y;
-	plane.d = -60;
+	Plane plane; plane.normal = Vector3::UNIT_Y;	plane.d = -60;
 	MeshManager::getSingleton().createPlane("Myplane",
 		ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
@@ -152,16 +158,14 @@
 	mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr);
 	
-	// if no objects file generate yourself
+	// if no objects in file, we generate new objects
 	if (!mTerrainContentGenerator->LoadObjects("objects.out"))
 	{
 		// to provide much occlusion,
-		// height is restricted to 50, so no objects appear on peaks
+		// height is restricted to 50 => no objects appear on peaks
 		mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 50.0f, 3000.0f));
 		mTerrainContentGenerator->SetOffset(0);
 
-		// the objects are generated on the whole terrain
-		//mTerrainContentGenerator->GenerateScene(1500, "robot");
-		mTerrainContentGenerator->GenerateScene(1500, "athene");
-		//mTerrainContentGenerator->GenerateScene(500, "ninja");
+		// the objects are generated randomly distributed over the terrain
+		generateScene(1500, 0);
 	}
 
@@ -169,4 +173,36 @@
 	// objects also on peaks of terrain
 	mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 5000.0f, 3000.0f));
+}
+//-----------------------------------------------------------------------
+void  TestCullingTerrainApplication::generateScene(int num, int objectType)
+{
+	mTerrainContentGenerator->GenerateScene(num, currentObjectCaptions[objectType]);
+
+	if (objectType != 0) // from our objects, only robot has animation phases
+		return;
+
+	EntityList *entList = mTerrainContentGenerator->GetGeneratedEntities();
+
+	//-- add animation state for new robots (located at the end of the list)
+	for (int i = entList->size() - num; i < entList->size(); ++i)
+	{
+		Entity *ent = (*entList)[i];
+		AnimationState *st = ent->getAnimationState("Idle");
+		st->setEnabled(true);
+		st->setLoop(true);
+
+		mAnimationStates.push_back(st);
+		mAnimationSpeed.push_back(Math::RangeRandom(0.5, 1.5));
+	}
+}
+//-----------------------------------------------------------------------
+std::vector<AnimationState *> &TestCullingTerrainApplication::getAnimationStates()
+{
+	return mAnimationStates;
+}
+//-----------------------------------------------------------------------
+std::vector<Real> &TestCullingTerrainApplication::getAnimationSpeed()
+{
+	return mAnimationSpeed;
 }
 //-----------------------------------------------------------------------
@@ -189,15 +225,18 @@
 {
 	mTerrainFrameListener = new TerrainFrameListener(mWindow, mCamera, mSceneMgr, 
-		mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight);
+		mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight, this);
 	
 	mRoot->addFrameListener(mTerrainFrameListener);
 }
 //-----------------------------------------------------------------------
+String TestCullingTerrainApplication::getCurrentObjectCaption(int id)
+{
+	return currentObjectCaptions[id];
+}
+//-----------------------------------------------------------------------
 void TestCullingTerrainApplication::chooseSceneManager()
 {
 	mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE);
 }
-
-
 /**************************************************************/
 /*      VisualizationRenderTargetListener implementation      */
Index: trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h	(revision 159)
+++ trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h	(revision 160)
@@ -13,4 +13,7 @@
 #include "OgrePlatformQueryManager.h"
 
+class TestCullingTerrainApplication;
+
+
 using namespace Ogre;
 
@@ -25,7 +28,13 @@
 public:
 	
-   TerrainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 
-		CEGUI::Renderer *renderer, TerrainContentGenerator *contentGenerator, Camera *vizCamera,
-		SceneNode *camNode, Light *sunLight);
+   TerrainFrameListener(RenderWindow* win, 
+						Camera* cam, 
+						SceneManager *sceneManager, 
+						CEGUI::Renderer *renderer, 
+						TerrainContentGenerator *contentGenerator, 
+						Camera *vizCamera,
+						SceneNode *camNode, 
+						Light *sunLight,
+						TestCullingTerrainApplication *app);
 
    ~TerrainFrameListener();
@@ -122,9 +131,21 @@
 		@param useItemBuffer if item buffer should be used or occlusion queries
 	*/
-	void ApplyVisibilityQuery(bool fromPoint, bool relativeVisibility, bool useItemBuffer);
+	void applyVisibilityQuery(bool fromPoint, bool relativeVisibility, bool useItemBuffer);
 
 	void toggleShowQueryStats();
 
+	/** Sets the type of the objects generated in the scene.
+	*/
+	void setObjectType(int objectType);
+
 protected:
+
+	void initHelpOverlayElement(String name, int top);
+	void initOverlayElement(OverlayElement **elInfo, String ext, String name, int top, String caption);
+
+	//-- initialise overlays
+	void initHelpOverlay();
+	void initVisStatsOverlay();
+	void initQueryOverlay();
 
 	void resetStats();
@@ -162,8 +183,9 @@
 	OverlayElement *mUseDepthPassInfo;
 	OverlayElement *mRenderedNodesInfo;
-	OverlayElement *mObjectsInfo;
+	OverlayElement *mObjectsCountInfo;
 	OverlayElement *mQueriesIssuedInfo;
 	OverlayElement *mDelayedQueriesIssuedInfo;
 	OverlayElement *mDelayedTraversedNodesInfo;
+	OverlayElement *mCurrentObjectTypeInfo;
 
 	OverlayElement *mQueryTypeInfo;
@@ -203,5 +225,5 @@
 	std::vector<frame_info> mFrameInfo;
 		
-	Real mTimeElapsed;
+	Real mReplayTimeElapsed;
 	//EventProcessor* mEventProcessor;
     InputReader* mInputDevice;
@@ -211,5 +233,4 @@
     RenderWindow* mWindow;
    
-    //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;
 	unsigned int mNumScreenShots;
     int mSceneDetailIndex;
@@ -248,4 +269,8 @@
 
 	bool mRenderPatchesForItemBuffer;
+
+	int mCurrentObjectType;
+
+	TestCullingTerrainApplication *mApplication;
 };
 
Index: trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
===================================================================
--- trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 145)
+++ trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 160)
@@ -25,5 +25,5 @@
 
 
-class TestCullingTerrainApplication : public ExampleApplication
+class TestCullingTerrainApplication: public ExampleApplication
 {
 public:
@@ -31,5 +31,13 @@
 	~TestCullingTerrainApplication();
 
+	void generateScene(int num, int objectType);
+
+	String getCurrentObjectCaption(int id);
+
+	std::vector<AnimationState *> &getAnimationStates();
+	std::vector<Real> &getAnimationSpeed();
+
 protected:
+
 	//-- inherited from ExampleApplication
 	bool setup();
@@ -40,4 +48,7 @@
 	
 	virtual void createRenderTargetListener();
+
+	std::vector<AnimationState *> mAnimationStates;
+	std::vector<Real> mAnimationSpeed;
 
 	/** cegui setup */
@@ -61,5 +72,4 @@
 	TerrainFrameListener *mTerrainFrameListener;
 	ColourValue mAmbientLight;
-	//VisualizationRenderTargetListener *mVizRenderTargetListener;
 	
 private:
Index: trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp
===================================================================
--- trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp	(revision 158)
+++ trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctree.cpp	(revision 160)
@@ -262,7 +262,4 @@
 	mWorldAABB = mWorldAABB.intersection(box); 
 	
-	//std::stringstream d; d << "updating box: " << mWorldAABB << ", depth: " << mDepth << "null: " << mBox.isNull();
-	//LogManager::getSingleton().logMessage(d.str());
-
 	// recursively update parent bounds
 	if (mParent)
Index: trunk/VUT/work/TestCulling/TestCullingApplication.cpp
===================================================================
--- trunk/VUT/work/TestCulling/TestCullingApplication.cpp	(revision 155)
+++ trunk/VUT/work/TestCulling/TestCullingApplication.cpp	(revision 160)
@@ -31,10 +31,10 @@
 
 	// Position it at 500 in Z direction
-	mCamera->setPosition(Vector3(128,25,128));
+	mCamera->setPosition(Vector3(128, 25, 128));
 
 	// Look back along -Z
-    mCamera->lookAt(Vector3(0,0,-300));
-    mCamera->setNearClipDistance( 1 );
-    mCamera->setFarClipDistance( 1000 );
+    mCamera->lookAt(Vector3(0, 0, -300));
+    mCamera->setNearClipDistance(1);
+    mCamera->setFarClipDistance(1000);
 }*/
 //-----------------------------------------------------------------------
@@ -67,5 +67,6 @@
 void TestCullingApplication::setupGui()
 {
-	 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);
 
@@ -93,13 +94,13 @@
 
 
-/***********************************************/
-/* TerrainFrameListener implementation         */
-/***********************************************/
+/*****************************************************/
+/*       TerrainFrameListener implementation         */
+/*****************************************************/
 //-----------------------------------------------------------------------
 TerrainFrameListener::TerrainFrameListener(RenderWindow* win, Camera* cam, 
 									   SceneManager *sceneManager, 
 									   CEGUI::Renderer *renderer,
-									   SceneContentGenerator *sceneContentGenerator)
-: ExampleFrameListener(win, cam, false, true),
+									   SceneContentGenerator *sceneContentGenerator):
+ExampleFrameListener(win, cam, false, true),
 mSceneMgr(sceneManager),
 mGUIRenderer(renderer), 
@@ -136,5 +137,5 @@
 	mHierarchyNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/HierarchyNodesInfo");
 	mRenderedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/RenderedNodesInfo");
-	mObjectsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo");
+	mObjectsCountInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ObjectsInfo");
 	mTestGeometryForVisibleLeavesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/TestGeometryForVisibleLeavesInfo");
 	mQueriesIssuedInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/QueriesIssuedInfo");
@@ -148,5 +149,5 @@
 	mHierarchyNodesInfo->setCaption(": 0");
 	mRenderedNodesInfo->setCaption(": 0");
-	mObjectsInfo->setCaption(": 0");
+	mObjectsCountInfo->setCaption(": 0");
 	mTestGeometryForVisibleLeavesInfo->setCaption(": true");
 	mQueriesIssuedInfo->setCaption(": 0");
@@ -330,5 +331,5 @@
 
 	sprintf(str,": %d", mSceneContentGenerator->GetObjectCount()); 
-	mObjectsInfo->setCaption(str);
+	mObjectsCountInfo->setCaption(str);
 }
 //-----------------------------------------------------------------------
Index: trunk/VUT/work/TestCulling/TestCullingApplication.h
===================================================================
--- trunk/VUT/work/TestCulling/TestCullingApplication.h	(revision 155)
+++ trunk/VUT/work/TestCulling/TestCullingApplication.h	(revision 160)
@@ -1,6 +1,5 @@
-/**
-    \file 
-        TestCullingApplication.h
-*/
+#ifndef _TerrainFrameListener_H__
+#define _TerrainFrameListener_H__
+
 #include "CEGUIForwardRefs.h"
 #include "ExampleApplication.h"
@@ -29,9 +28,12 @@
 public:
 
-    TerrainFrameListener(RenderWindow* win, Camera* cam, SceneManager *sceneManager, 
-			CEGUI::Renderer *renderer, SceneContentGenerator *sceneContentGenerator);
+    TerrainFrameListener(RenderWindow* win, 
+						 Camera* cam, 
+						 SceneManager *sceneManager, 
+						 CEGUI::Renderer *renderer, 
+						 SceneContentGenerator *sceneContentGenerator);
 
 
-    ~TerrainFrameListener( );
+    ~TerrainFrameListener();
 
 	bool frameStarted(const FrameEvent& evt);
@@ -86,5 +88,5 @@
 	OverlayElement *mHierarchyNodesInfo;
 	OverlayElement *mRenderedNodesInfo;
-	OverlayElement *mObjectsInfo;
+	OverlayElement *mObjectsCountInfo;
 	OverlayElement *mTestGeometryForVisibleLeavesInfo;
 	OverlayElement *mQueriesIssuedInfo;
@@ -130,2 +132,3 @@
 };
 
+#endif // _TerrainFrameListener_H__
Index: trunk/VUT/Ogre/include/OgrePlatformOcclusionQuery.h
===================================================================
--- trunk/VUT/Ogre/include/OgrePlatformOcclusionQuery.h	(revision 87)
+++ trunk/VUT/Ogre/include/OgrePlatformOcclusionQuery.h	(revision 160)
@@ -21,5 +21,5 @@
 
 	virtual bool GetQueryResult(unsigned int &queryResult,
-		const bool waitForResult) const;
+	const bool waitForResult) const;
 	virtual void BeginQuery();
 	virtual void EndQuery();
Index: trunk/VUT/Ogre/include/OgreSceneContentGenerator.h
===================================================================
--- trunk/VUT/Ogre/include/OgreSceneContentGenerator.h	(revision 130)
+++ trunk/VUT/Ogre/include/OgreSceneContentGenerator.h	(revision 160)
@@ -7,4 +7,7 @@
 
 namespace Ogre {
+
+typedef std::vector<SceneNode *> SceneNodeList;
+typedef std::vector<Entity *> EntityList;
 
 /** Class which fills a scene with content in a random fashion.
@@ -20,4 +23,5 @@
 	*/
 	void GenerateScene(int numObjects, const String &objName);
+
 	/** Generates a new object in the scene using ray scene queries 
 		and inserts it into thr scene hierarchy.
@@ -31,18 +35,34 @@
 		const Vector3 &rotation, const String &objName);
 
+	/** Minimum angle for the random orientation.
+	*/
 	void SetMinAngle(Vector3 minAngle);
+	
+	/** Maximum angle for the random orientation.
+	*/
 	void SetMaxAngle(Vector3 maxAngle);
+	
+	/** Minimum possible random position.
+	*/
 	void SetMinPos(Vector3 minPos);
+	/** Maximum possible random position.
+	*/
 	void SetMaxPos(Vector3 maxPos);
+	/** Scale factor applied to each generated object.
+	*/
 	void SetScale(Vector3 scale);
 	
-	/** The number of created objects */
+	/** The number of created objects.
+	*/
 	int GetObjectCount();
 
-	/** Writes scene nodes to file */
+	/** Writes scene nodes to file.
+	*/
 	bool WriteObjects(const std::string &filename);
 
-	/** Loads scene nodes from file */
+	/** Loads scene nodes from file.
+	*/
 	bool LoadObjects(const std::string &filename);
+
 	/** Generates a scene object with the specified parameters
 		@param position the position of the scene object
@@ -53,4 +73,16 @@
 	SceneNode *GenerateSceneObject(const Vector3 &position, 
 		const Quaternion &orientation, const String &objName);
+
+	/** Gets pointer to list of generated scene nodes.
+	*/
+	SceneNodeList *GetGeneratedSceneNodes();
+	
+	/** Gets pointer to list of entities.
+	*/
+	EntityList *GetGeneratedEntities();
+
+	/** Removes generated object from scene graph.
+	*/
+	void RemoveGeneratedObjects();
 
 protected:
@@ -64,5 +96,6 @@
 	SceneManager *mSceneMgr;
 	
-	std::vector<SceneNode *> mSceneObjects;
+	SceneNodeList mSceneNodes;
+	EntityList mEntities;
 };
 
Index: trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 159)
+++ trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 160)
@@ -40,5 +40,4 @@
 	//mShowBoundingBoxes = true;
 	//mShowBoxes = true;
-	//mShowBoxes = true;
 
 	// TODO: set maxdepth to reasonable value
Index: trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp
===================================================================
--- trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp	(revision 159)
+++ trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp	(revision 160)
@@ -12,7 +12,7 @@
 namespace Ogre {
 
-/*******************************************************/
-/*     SceneContentGenerator implementation            */
-/*******************************************************/
+/*************************************************************/
+/*           SceneContentGenerator implementation            */
+/*************************************************************/
 
 //-----------------------------------------------------------------------
@@ -23,6 +23,5 @@
 mMinAngle(Vector3(0.0f, 0.0f, 0.0f)),
 mMaxAngle(Vector3(360, 360, 360)),
-mScale(0.1, 0.1, 0.1)
-//, mObjectCount(0)
+mScale(0.1, 0.1, 0.1)//, mObjectCount(0)
 {
 }
@@ -36,9 +35,9 @@
 	Vector3 translationRatio;
 
-	int old_count = GetObjectCount();
+	int new_size = GetObjectCount() + numObjects;
 	int failed_attempts = 0; // counter used to avoid invinite loop
 
 	//-- create random values between zero and one
-	while ((GetObjectCount() < numObjects + old_count) && 
+	while ((GetObjectCount() <  new_size) && 
 		   (failed_attempts < MAX_FAILED_ATTEMPTS))
 	{
@@ -70,16 +69,17 @@
 	Entity *ent = mSceneMgr->createEntity(name, objName + ".mesh");
 		
-	SceneNode *currentObject = mSceneMgr->getRootSceneNode()->
+	SceneNode *node = mSceneMgr->getRootSceneNode()->
 		createChildSceneNode(String(name) + "Node", position);
 
 	//ent->setCastShadows(false);
-	currentObject->attachObject(ent);
-	currentObject->setScale(mScale);
-	currentObject->setOrientation(orientation);
-
-	//-- store pointer to object
-	mSceneObjects.push_back(currentObject);
-
-	return currentObject;
+	node->attachObject(ent);
+	node->setScale(mScale);
+	node->setOrientation(orientation);
+
+	// store pointer to node and object
+	mSceneNodes.push_back(node);
+	mEntities.push_back(ent);
+
+	return node;
 }
 //-----------------------------------------------------------------------
@@ -116,5 +116,5 @@
 int SceneContentGenerator::GetObjectCount()
 {
-	return (int)mSceneObjects.size();
+	return (int)mSceneNodes.size();
 }
 //-----------------------------------------------------------------------
@@ -129,5 +129,5 @@
 	std::vector<SceneNode *>::const_iterator it, it_end;
 
-	it_end = mSceneObjects.end();
+	it_end = mSceneNodes.end();
 
 	if(!ofstr.is_open())
@@ -136,5 +136,5 @@
 	char str[100];
 
-	for(it = mSceneObjects.begin(); it < it_end; ++it)
+	for(it = mSceneNodes.begin(); it < it_end; ++it)
 	{
 		SceneNode *node = (*it);
@@ -164,5 +164,5 @@
 		return false;
 
-	//mSceneObjects.clear(); // reset list of objects
+	//mSceneNodes.clear(); // reset list of objects
 
 	while (!ifstr.eof()) 
@@ -173,8 +173,4 @@
 			&orientation.w, &orientation.x, &orientation.y, &orientation.z,
 			&mScale.x, &mScale.y, &mScale.z);
-		
-		/*Vector3 rot(orientation.getYaw().valueDegrees(), 
-					orientation.getPitch().valueDegrees(), 
-					orientation.getRoll().valueDegrees());*/
 
 		GenerateSceneObject(position, orientation, objName);
@@ -187,4 +183,34 @@
 	return true;
 }
-
+//-----------------------------------------------------------------------
+SceneNodeList *SceneContentGenerator::GetGeneratedSceneNodes()
+{
+	return &mSceneNodes;
+}
+//-----------------------------------------------------------------------
+EntityList *SceneContentGenerator::GetGeneratedEntities()
+{
+	return &mEntities;
+}
+//-----------------------------------------------------------------------
+void SceneContentGenerator::RemoveGeneratedObjects()
+{
+	//-- destroy scene nodes and detach entities
+	while (!mSceneNodes.empty())
+	{
+		SceneNode *node = mSceneNodes.back();
+		mSceneNodes.pop_back();
+		
+		//node->detachAllObjects();
+		mSceneMgr->destroySceneNode(node->getName());
+	}
+	//-- remove and destroy entities
+	while (!mEntities.empty())
+	{
+		Entity *ent = mEntities.back();
+		mEntities.pop_back();
+		
+		mSceneMgr->removeEntity(ent);
+	}
+}
 } // namespace Ogre
Index: trunk/VUT/Ogre/resources/VisibilityDemo.overlay
===================================================================
--- trunk/VUT/Ogre/resources/VisibilityDemo.overlay	(revision 159)
+++ trunk/VUT/Ogre/resources/VisibilityDemo.overlay	(revision 160)
@@ -12,5 +12,5 @@
 }
 
-Example/Visibility/DemoOverlay
+Example/Visibility/CullStatsOverlay
 {
 	zorder 500
@@ -40,5 +40,4 @@
 		{
 			left 5
-			top 5
 			width 180
 			caption [SPACE] Algorithm
@@ -47,5 +46,4 @@
 		{
 			left 210
-			top 5
 			width 120
 			height 30
@@ -56,5 +54,4 @@
 		{
 			left 5
-			top 20
 			width 120
 			height 30
@@ -64,5 +61,4 @@
 		{
 			left 210
-			top 20
 			width 120
 			height 30
@@ -72,5 +68,4 @@
 		{
 			left 5
-			top 35
 			width 120
 			height 30
@@ -80,5 +75,4 @@
 		{
 			left 210
-			top 35
 			width 120
 			height 30
@@ -88,5 +82,4 @@
 		{
 			left 5
-			top 50
 			width 120
 			height 30
@@ -96,5 +89,4 @@
 		{
 			left 210
-			top 50
 			width 120
 			height 30
@@ -104,5 +96,4 @@
 		{
 			left 5
-			top 65
 			width 120
 			height 30
@@ -113,9 +104,22 @@
 		{
 			left 210
-			top 65
-			width 120
-			height 30
-			caption :
-		}
+			width 120
+			height 30
+			caption :
+		}
+		element TextArea(Example/Visibility/CurrentObjectType): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 120
+			height 30
+			caption [F7] Object type
+		}	
+		element TextArea(Example/Visibility/CurrentObjectTypeInfo): Example/Visibility/Templates/BasicText
+		{
+			left 210
+			width 90
+			font_name TrebuchetMSBold
+			caption :			
+		}	
 	}
 
@@ -128,5 +132,5 @@
 		top 5
 		width 320
-		height 150
+		height 135
 		material Core/StatsBlockCenter
         	border_size 1 1 1 1
@@ -144,5 +148,4 @@
 		{
 			left 5
-			top 5
 			width 180
 			height 30
@@ -152,5 +155,4 @@
 		{
 			left 180
-			top 5
 			width 90
 			height 30
@@ -160,5 +162,4 @@
 		{
 			left 5
-			top 20
 			width 180
 			height 30
@@ -168,5 +169,4 @@
 		{
 			left 180
-			top 20
 			width 90
 			height 30
@@ -176,5 +176,4 @@
 		{
 			left 5
-			top 35
 			width 180
 			height 30
@@ -184,5 +183,4 @@
 		{
 			left 180
-			top 35
 			width 90
 			height 30
@@ -192,5 +190,4 @@
 		{
 			left 5
-			top 50
 			width 180
 			height 30
@@ -200,5 +197,4 @@
 		{
 			left 180
-			top 50
 			width 90
 			height 30
@@ -208,5 +204,4 @@
 		{
 			left 5
-			top 65
 			width 180
 			height 30
@@ -216,21 +211,18 @@
 		{
 			left 180
-			top 65
-			width 90
-			height 30
-			caption :
-		}
-		element TextArea(Example/Visibility/Objects): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 80
+			width 90
+			height 30
+			caption :
+		}
+		element TextArea(Example/Visibility/ObjectsCount): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption Number of objects
 		}	
-		element TextArea(Example/Visibility/ObjectsInfo): Example/Visibility/Templates/BasicText
-		{
-			left 180
-			top 80
+		element TextArea(Example/Visibility/ObjectsCountInfo): Example/Visibility/Templates/BasicText
+		{
+			left 180
 			width 90
 			height 30
@@ -240,5 +232,4 @@
 		{
 			left 5
-			top 95
 			width 180
 			height 30
@@ -248,41 +239,9 @@
 		{
 			left 180
-			top 95
 			width 90
 			font_name TrebuchetMSBold
 			caption :			
-		}		
-		element TextArea(Example/Visibility/DelayedQueriesIssued): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 110
-			width 180
-			height 30
-			caption Avg. queries issued 
-		}	
-		element TextArea(Example/Visibility/DelayedQueriesIssuedInfo): Example/Visibility/Templates/BasicText
-		{
-			left 180
-			top 110
-			width 90
-			font_name TrebuchetMSBold
-			caption :			
-		}		
-		element TextArea(Example/Visibility/DelayedTraversedNodes): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 125
-			width 180
-			height 30
-			caption Avg. traversed Nodes
-		}	
-		element TextArea(Example/Visibility/DelayedTraversedNodesInfo): Example/Visibility/Templates/BasicText
-		{
-			left 180
-			top 125
-			width 90
-			font_name TrebuchetMSBold
-			caption :			
-		}			
+		}
+		
 	}
 }
@@ -334,137 +293,178 @@
 			font_name TrebuchetMSBold
 			char_height 19
-			caption Additional Options
+			caption Help: Additional Options
 			colour_top 1 1 0.7
 			colour_bottom 1 1 0.7
 		}
 
-		element TextArea(Example/Visibility/Help/ShowHelpInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 30
+		element TextArea(Example/Visibility/Help/ShowHelp): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [F1] Show / Hide this screen
 		}
-		element TextArea(Example/Visibility/Help/StatsInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 45
+		element TextArea(Example/Visibility/Help/Stats): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [F2] Show / Hide stats
 		}
-		element TextArea(Example/Visibility/Help/AppStateInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 75
+		element TextArea(Example/Visibility/Help/AppState): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [F3] Toggle between interactive / recorded walkthrough
 		}
-		element TextArea(Example/Visibility/Help/RecordedInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 60
+		element TextArea(Example/Visibility/Help/Recorded): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [F4] Start / End frame recording
 		}
-		element TextArea(Example/Visibility/Help/ScreenshotsInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 105
+		element TextArea(Example/Visibility/Help/Screenshots): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [F11] Screenshot
 		}
-		element TextArea(Example/Visibility/Help/WriteOutInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 120
-			width 180
-			height 30
-			caption [F12] Write screen objects to file
-		}
+		element TextArea(Example/Visibility/Help/WriteOut): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
+			height 30
+			caption [F12] Write scene entities to file
+		}
+		
 		//-- visualization
-		element TextArea(Example/Visibility/Help/VizInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 150
+		element TextArea(Example/Visibility/Help/VizSection): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
+			height 30
+			caption ****** Visualization ******
+		}
+		element TextArea(Example/Visibility/Help/Viz): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [1] Show / hide visualization
 		}
-		element TextArea(Example/Visibility/Help/NextVizModeInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 165
+		element TextArea(Example/Visibility/Help/NextVizMode): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 175
 			height 30
 			caption [2] Toggle visualization mode
 		}
-		element TextArea(Example/Visibility/Help/ZoomVizInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 180
+		element TextArea(Example/Visibility/Help/ZoomViz): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 190
 			height 30
 			caption [3][4] Zoom in / out of visualization
 		}
-		element TextArea(Example/Visibility/Help/SceneDetailInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 210
+		element TextArea(Example/Visibility/Help/SceneDetail): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [R] Toggle between solid / wireframe / point based rendering
 		}
-		element TextArea(Example/Visibility/Help/DisplayCameraDetailsInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 225
+		element TextArea(Example/Visibility/Help/DisplayCameraDetails): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [P] Show / hide camera details 
 		}
-		element TextArea(Example/Visibility/Help/DisplayOctreeInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 240
+		element TextArea(Example/Visibility/Help/DisplayOctree): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [T] Show / hide octree 
 		}
-		element TextArea(Example/Visibility/Help/UseShadowsInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 255
+		element TextArea(Example/Visibility/Help/UseShadows): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [S] Show / hide shadows
 		}
-		element TextArea(Example/Visibility/Help/FilterInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 270
+		element TextArea(Example/Visibility/Help/Filter): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [F] toggle filtering method (trilinear, anisotropic, bilinear)
 		}
-		element TextArea(Example/Visibility/Help/FromCameraQueryInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 285
+		element TextArea(Example/Visibility/Help/VisQuery): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
+			height 30
+			caption ****** Visibility Queries ******
+		}
+		element TextArea(Example/Visibility/Help/FromCameraQuery): Example/Visibility/Templates/BasicText
+		{
+			left 5
 			width 180
 			height 30
 			caption [F5] From camera visible pixels (+ SHIFT: relative visibility)
 		}
-		element TextArea(Example/Visibility/Help/FromPointQueryInfo): Example/Visibility/Templates/BasicText
-		{
-			left 5
-			top 60
-			width 300
+		element TextArea(Example/Visibility/Help/FromPointQuery): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
 			height 30
 			caption [F6] From camera visible pixels (+ SHIFT: relative visibility)
+		}
+		element TextArea(Example/Visibility/Help/QueryType): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
+			height 30
+			caption [I] Change between occlusion query / item buffer visibility query
+		}
+		element TextArea(Example/Visibility/Help/QueryTarget): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
+			height 30
+			caption [C] Mesh / Patch visibility (only item buffer)
+		}
+		element TextArea(Example/Visibility/Help/SceneObjects): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
+			height 30
+			caption ******* Generation / Destruction of scene objects ******
+		}
+		element TextArea(Example/Visibility/Help/GenerateObjects): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
+			height 30
+			caption [F8] Generate 500 objects
+		}
+		element TextArea(Example/Visibility/Help/RemoveObjects): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
+			height 30
+			caption [DEL] Remove generated objects 
+		}
+		element TextArea(Example/Visibility/Help/DropObject): Example/Visibility/Templates/BasicText
+		{
+			left 5
+			width 180
+			height 30
+			caption [MOUSE LEFT] Drop object on terrain
 		}
 	}
@@ -524,5 +524,4 @@
 		{
 			left 5
-			top 30
 			width 90
 			height 30
@@ -534,5 +533,4 @@
 		{
 			left 180
-			top 30
 			width 90
 			height 30
@@ -543,5 +541,4 @@
 		{
 			left 5
-			top 45
 			width 90
 			height 30
@@ -551,5 +548,4 @@
 		{
 			left 180
-			top 45
 			width 90
 			height 30
@@ -560,5 +556,4 @@
 		{
 			left 5
-			top 60
 			width 90
 			height 30
@@ -568,5 +563,4 @@
 		{
 			left 180
-			top 60
 			width 90
 			height 30
@@ -578,13 +572,11 @@
 		{
 			left 5
-			top 75
 			width 90
 			height 30
 			caption Visible patches
 		}
-		element TextArea(Example/Visibility/Query/VisiblePatchInfo): Example/Visibility/Templates/BasicText
-		{
-			left 180
-			top 75
+		element TextArea(Example/Visibility/Query/VisiblePatchesInfo): Example/Visibility/Templates/BasicText
+		{
+			left 180
 			width 90
 			height 30
@@ -595,5 +587,4 @@
 		{
 			left 5
-			top 90
 			width 90
 			height 30
@@ -604,5 +595,4 @@
 		{
 			left 180
-			top 90
 			width 90
 			height 30
@@ -613,5 +603,4 @@
 		{
 			left 5
-			top 105
 			width 90
 			height 30
@@ -622,5 +611,4 @@
 		{
 			left 180
-			top 105
 			width 90
 			height 30
@@ -630,5 +618,4 @@
 		{
 			left 5
-			top 120
 			width 90
 			height 30
@@ -639,5 +626,4 @@
 		{
 			left 180
-			top 120
 			width 90
 			height 30
