Index: /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneTraverser.h
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneTraverser.h	(revision 40)
+++ /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneTraverser.h	(revision 41)
@@ -59,6 +59,6 @@
 		
 		void pullUpVisibility( Octree *octree );
-		void traverseOctree( Camera *cam, Octree *octree );
-		void renderOctree( Camera *cam, Octree *octree );
+		void traverseOctant(Camera *cam, Octree *octant );
+		void renderOctant( Camera *cam, Octree *octant );
 
 		OctreePriorityQueue *mDistanceQueue;
Index: /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h	(revision 39)
+++ /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneTraverser.h	(revision 41)
@@ -93,4 +93,9 @@
 		void setNumSceneNodes(int num );
 
+		/** Sets the required number of occlusion queries.
+		@param num number occlusion queries
+		*/
+		void setNumQueries( int num );
+
 	protected:
 		/** query mode (= without color) or RENDER_MODE */
@@ -114,6 +119,9 @@
 		/** Renders the scene with the coherent hierarchical algorithm and the query queye. */
 		void renderCoherentWithQueue( Camera *cam );
-		/** Issue a occlusion query for this node. */
-		HardwareOcclusionQuery *issueOcclusionQuery( SceneNode *node, bool wasVisible );
+		/** Issue a occlusion query for this node. 
+		@param box the axis aligned bounding box of the node
+		@wasVisible if the node was visible in previous frame
+		*/
+		HardwareOcclusionQuery *issueOcclusionQuery( AxisAlignedBox *box, bool wasVisible );
 		/** Pulls up the visibility from the child nodes. */
 		void pullUpVisibility( SceneNode *node );
@@ -121,9 +129,8 @@
 		void deleteQueries();
 		/** Renders bounding box of specified node.
-		@param the scene node contained in the bounding box to be rendered
-		*/
-		void renderBoundingBox( SceneNode *node );
+		@param box the bounding box of the scene node to be rendered */
+		void renderBoundingBox( AxisAlignedBox *box );
 		/** Returns one half of the bounding box.
-		@param the half of the bouding box
+		@param half the half index of the bouding box (0 or 1)
 		*/
 		SolidHalfBoundingBox *getSolidHalfBoundingBox( int half );
@@ -147,4 +154,6 @@
 		int mQueryMode;
 
+		unsigned int mNumQueries;
+
 		//--- statistics
 		unsigned int mNumSceneNodes;
Index: /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneManager.h
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneManager.h	(revision 40)
+++ /trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingTerrainSceneManager.h	(revision 41)
@@ -55,6 +55,11 @@
 
 	protected:
-		//OcclusionCullingTerrainSceneTraverser *mOcclusionCullingTerrainSceneTraverser;
-		OcclusionCullingSceneTraverser *mOcclusionCullingTerrainSceneTraverser;
+		/** Recursively counts octree size (i.e., number of octree instances)
+		@param root current octree
+		*/
+		unsigned int countOctreeSize(Octree *root);
+
+		OcclusionCullingTerrainSceneTraverser *mOcclusionCullingTerrainSceneTraverser;
+		//OcclusionCullingSceneTraverser *mOcclusionCullingTerrainSceneTraverser;
 	};
 
Index: /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp	(revision 37)
+++ /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp	(revision 41)
@@ -42,4 +42,5 @@
 	{
 		mOcclusionCullingSceneTraverser->setNumSceneNodes(mSceneNodes.size());
+		mOcclusionCullingSceneTraverser->setNumQueries(mSceneNodes.size());
 		mOcclusionCullingSceneTraverser->setRenderSystem(mDestRenderSystem);
 
Index: /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp	(revision 40)
+++ /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp	(revision 41)
@@ -16,5 +16,5 @@
 	mFrameId(1), mDistanceQueue(NULL), mVisibilityThreshold(0), mCurrentTestIdx(0),
 	mQueryMode(MODE_RENDER), mNumSceneNodes(0), mCurrentAlgorithm(RENDER_COHERENT),
-	mNumTraversedNodes(0), mNumQueryCulledNodes(0), mNumFrustumCulledNodes(0), 
+	mNumQueries(0), mNumTraversedNodes(0), mNumQueryCulledNodes(0), mNumFrustumCulledNodes(0), 
 	mNumRenderedGeometry(0), mSceneManager(sm), mRenderSystem(rsys)
 	{		
@@ -42,5 +42,5 @@
 		mCurrentTestIdx = 0;
 
-mCurrentAlgorithm = RENDER_CULL_FRUSTUM;
+//mCurrentAlgorithm = RENDER_CULL_FRUSTUM;
 		switch(mCurrentAlgorithm)
 		{
@@ -99,31 +99,35 @@
 				SceneNode *node = mDistanceQueue->top();
 				mDistanceQueue->pop();
-	
-				if(cam->isVisible(node->_getWorldAABB()))
-				{
-					// identify previously visible nodes
-					bool wasVisible = node->isNodeVisible() && (node->lastVisited() == mFrameId - 1);
+				
+				//TODO: Isvisible also checked inside scenenode::findvisibleobjects
+				if(!cam->isVisible(node->_getWorldAABB()))
+				{
+                    mNumFrustumCulledNodes ++;
+					continue;
+				}
+
+				// identify previously visible nodes
+				bool wasVisible = node->isNodeVisible() && (node->lastVisited() == mFrameId - 1);
 					
-					// identify nodes that we cannot skip queries for
-					bool leafOrWasInvisible = !wasVisible || isLeaf(node);
-
-					// reset node's visibility classification 
-					node->setNodeVisible(false);
-
-					// update node's visited flag
-					node->setLastVisited(mFrameId);
+				// identify nodes that we cannot skip queries for
+				bool leafOrWasInvisible = !wasVisible || isLeaf(node);
+
+				// reset node's visibility classification 
+				node->setNodeVisible(false);
+
+				// update node's visited flag
+				node->setLastVisited(mFrameId);
 				
-					// skip testing previously visible interior nodes
-					if(leafOrWasInvisible)
-					{
-						HardwareOcclusionQuery *query = issueOcclusionQuery(node, wasVisible);
-						queryQueue.push(QueryPair(node, query));
-					}
+				// skip testing previously visible interior nodes
+				if(leafOrWasInvisible)
+				{
+					HardwareOcclusionQuery *query = issueOcclusionQuery(&node->_getWorldAABB(), wasVisible);
+					queryQueue.push(QueryPair(node, query));
+				}
 					
-					// always traverse a node if it was visible
-					if(wasVisible)
-					{
-						traverseNode(cam, node);
-					}
+				// always traverse a node if it was visible
+				if(wasVisible)
+				{
+					traverseNode(cam, node);
 				}
 				else
@@ -144,17 +148,7 @@
 			// interesting for visualization purpose
 			node->setNodeVisible(false);
-				
-			if(cam->isVisible(node->_getWorldAABB()))
-			{
-				// update node's visited flag 
-				char msg2[100];
-				sprintf(msg2,"yes, visible\n");
-				OutputDebugString(msg2);
-
-				node->setLastVisited(mFrameId);
-				node->setNodeVisible(true);
-				traverseNode(cam, node);
-			}
-			else
+
+			//TODO: IsVisible also checked inside scenenode::_findvisibleobjects
+			if(!cam->isVisible(node->_getWorldAABB()))
 			{			
 				char msg2[100];
@@ -163,5 +157,15 @@
 
 				mNumFrustumCulledNodes ++;
+				continue;
 			}
+
+			// update node's visited flag 
+			node->setLastVisited(mFrameId);
+			node->setNodeVisible(true);
+			traverseNode(cam, node);
+
+			char msg2[100];
+			sprintf(msg2,"yes, visible\n");
+			OutputDebugString(msg2);
 		}
 	}	
@@ -178,41 +182,48 @@
 			node->setLastVisited(mFrameId);
 
-			if(cam->isVisible(node->_getWorldAABB()))
+			//TODO: Isvisible also checked inside scenenode::findvisibleobjects
+			if(!cam->isVisible(node->_getWorldAABB()))
 			{
-				HardwareOcclusionQuery *query = issueOcclusionQuery(node, false);
+				mNumFrustumCulledNodes ++;
+				continue;
+			}
+
+			HardwareOcclusionQuery *query = issueOcclusionQuery(&node->_getWorldAABB(), false);
 				
-				unsigned int visiblePixels;
-				// wait if result not available
-				query->pullOcclusionQuery(&visiblePixels);
+			unsigned int visiblePixels;
+			// wait if result not available
+			query->pullOcclusionQuery(&visiblePixels);
 				
-				// node visible
-				if(visiblePixels > mVisibilityThreshold)
-				{
-					traverseNode(cam, node);
-				}
-				else
-				{
-					mNumQueryCulledNodes ++;
-				}
+			// node visible
+			if(visiblePixels > mVisibilityThreshold)
+			{
+				traverseNode(cam, node);
 			}
 			else
 			{
-				mNumFrustumCulledNodes ++;
+				mNumQueryCulledNodes ++;
 			}
 		}
 	}
 	//-----------------------------------------------------------------------
-	HardwareOcclusionQuery *OcclusionCullingSceneTraverser::issueOcclusionQuery( SceneNode *node, bool wasVisible )
+	HardwareOcclusionQuery *OcclusionCullingSceneTraverser::issueOcclusionQuery( 
+		AxisAlignedBox *box, bool wasVisible )
 	{
 		// change state so the bounding box gets not actually rendered on the screen
+		// TODO: in rendervisibleobjects, the rendermode is changed by ogre itself => change this!!
 		setRenderingMode(MODE_QUERY);
 		//setRenderingMode(MODE_RENDER);
 
+		char msg2[100];
+		sprintf(msg2,"this is query %d of overall %d\n", mCurrentTestIdx, mNumQueries);
+		OutputDebugString(msg2);
+
 		// get next available test id
 		HardwareOcclusionQuery *query = mOcclusionQueries[mCurrentTestIdx++];
-		
+
+		//-- the actual query test
 		query->beginOcclusionQuery();
 				
-		renderBoundingBox(node);
+		renderBoundingBox(box);
 
 		query->endOcclusionQuery();
@@ -258,4 +269,5 @@
 	void OcclusionCullingSceneTraverser::renderSceneNode( Camera *cam, SceneNode *node )
 	{
+		//TODO: does not do any changes
 		setRenderingMode(MODE_RENDER);
 		
@@ -268,5 +280,5 @@
 		deleteQueries();
 
-		for(unsigned int i=0; i < mNumSceneNodes; i++)
+		for(unsigned int i=0; i < mNumQueries; i++)
 		{
 			mOcclusionQueries.push_back(mRenderSystem->createHardwareOcclusionQuery());
@@ -321,5 +333,5 @@
 	}
 	//-----------------------------------------------------------------------
-	void OcclusionCullingSceneTraverser::renderBoundingBox( SceneNode *node )
+	void OcclusionCullingSceneTraverser::renderBoundingBox( AxisAlignedBox *box )
 	{
 		// Render two halfes of the bounding box (using triangle fans)
@@ -327,7 +339,7 @@
 		{
 			//static Matrix4 xform[256];
-
-			SolidHalfBoundingBox *box = getSolidHalfBoundingBox(half);
-			box->setupBoundingBox(node->_getWorldAABB());
+			//TODO: this should be full boudning box
+			SolidHalfBoundingBox *halfbox = getSolidHalfBoundingBox(half);
+			halfbox->setupBoundingBox(*box);
 
 			mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY);
@@ -335,7 +347,7 @@
 			static RenderOperation ro;
 
-			mSceneManager->useRenderableViewProjMode(box);
-			box->getRenderOperation(ro);
-			ro.srcRenderable = box; 
+			mSceneManager->useRenderableViewProjMode(halfbox);
+			halfbox->getRenderOperation(ro);
+			ro.srcRenderable = halfbox; 
 			mRenderSystem->_render(ro);
 
@@ -421,3 +433,8 @@
 		mNumSceneNodes = num;
 	}
+	//-----------------------------------------------------------------------
+	void OcclusionCullingSceneTraverser::setNumQueries(int num)
+	{
+		mNumQueries = num;
+	}
 }	
Index: /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneManager.cpp
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneManager.cpp	(revision 40)
+++ /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneManager.cpp	(revision 41)
@@ -8,5 +8,5 @@
 #include "OgreSolidHalfBoundingBox.h"
 
-//#include <windows.h>
+#include <windows.h>
 
 namespace Ogre {
@@ -14,13 +14,12 @@
 	OcclusionCullingTerrainSceneManager::OcclusionCullingTerrainSceneManager()
 	{
-		//mOcclusionCullingTerrainSceneTraverser = 
-		//	new OcclusionCullingTerrainSceneTraverser(this, mDestRenderSystem);
+		mOcclusionCullingTerrainSceneTraverser = 
+			new OcclusionCullingTerrainSceneTraverser(this, mDestRenderSystem);
+			//new OcclusionCullingSceneTraverser(this, mDestRenderSystem);
 
-		mOcclusionCullingTerrainSceneTraverser = 
-			new OcclusionCullingSceneTraverser(this, mDestRenderSystem);
-
-		mDisplayNodes = true;
+		//mDisplayNodes = true;
 		//mShowBoundingBoxes = true;
 		mShowBoxes = true;
+		mMaxDepth = 20;
 	}
 	//-----------------------------------------------------------------------
@@ -46,7 +45,7 @@
 		setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
 
-		//mOcclusionCullingTerrainSceneTraverser->renderScene(mCameraInProgress, mOctree);
+		mOcclusionCullingTerrainSceneTraverser->renderScene(mCameraInProgress, mOctree);
 		//mOcclusionCullingTerrainSceneTraverser->renderScene(mCameraInProgress, mTerrainRoot);
-		mOcclusionCullingTerrainSceneTraverser->renderScene(mCullCamera, mSceneRoot);
+		//mOcclusionCullingTerrainSceneTraverser->renderScene(mCameraInProgress, mSceneRoot);
 		_deleteRenderedQueueGroups();
 
@@ -67,4 +66,6 @@
 	{
      	mOcclusionCullingTerrainSceneTraverser->setNumSceneNodes(mSceneNodes.size());
+		//HACK
+		mOcclusionCullingTerrainSceneTraverser->setNumQueries(countOctreeSize(mOctree));
 		mOcclusionCullingTerrainSceneTraverser->setRenderSystem(mDestRenderSystem);
 
@@ -98,10 +99,5 @@
 		//Add stuff to be rendered;
         NodeList::iterator it = octant->mNodes.begin();
-
-        if ( mShowBoxes )
-        {
-            mBoxes.push_back( octant->getWireBoundingBox() );
-        }
-
+         
         while ( it != octant->mNodes.end() )
         {
@@ -118,11 +114,12 @@
 
 				if ( mDisplayNodes )
-				{
 					getRenderQueue()->addRenderable( sn );
 
-					// check if the scene manager or this node wants the bounding box shown.
-					if (sn->getShowBoundingBox() || mShowBoundingBoxes)
-						sn->_addBoundingBoxToQueue(getRenderQueue());
-				}
+				// check if the scene manager or this node wants the bounding box shown.
+				if (sn->getShowBoundingBox() || mShowBoundingBoxes)
+					sn->_addBoundingBoxToQueue(getRenderQueue());
+
+				if ( mShowBoxes )
+					getRenderQueue()->addRenderable(octant->getWireBoundingBox());
 			}
             ++it;
@@ -134,3 +131,18 @@
 		_deleteRenderedQueueGroups();
 	}
+	//-----------------------------------------------------------------------
+	unsigned int OcclusionCullingTerrainSceneManager::countOctreeSize(Octree *root)
+	{
+		unsigned int result = 1;
+				
+		for(int i=0; i<8; i++)
+		{
+			Octree *nextChild = root->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1];
+		
+			if(nextChild != 0)
+				result += countOctreeSize(nextChild);
+		}
+		
+		return result;
+	}
 }	
Index: /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp	(revision 40)
+++ /trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneTraverser.cpp	(revision 41)
@@ -1,4 +1,5 @@
 #include "OgreOcclusionCullingTerrainSceneTraverser.h"
 #include "OgreOcclusionCullingTerrainSceneManager.h"
+#include "OgreHardwareOcclusionQuery.h"
 
 #include <windows.h>
@@ -11,21 +12,17 @@
 	}
 	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::traverseOctree( Camera *cam, Octree *octree )
+	void OcclusionCullingTerrainSceneTraverser::traverseOctant(Camera *cam, Octree *octant )
 	{
 		mNumTraversedNodes ++;
 	
-		if(octree->numNodes() > 0)
-		{
-			renderOctree(cam, octree);
-		}
+		//if(octant->numNodes() > 0)
+			renderOctant(cam, octant);
 
 		for(int i=0; i<8; i++)
 		{
-			char msg[100];
-			sprintf(msg,"current node: %d\n", i);
-			OutputDebugString(msg);
-
-			if(octree->mChildren[i & 4][i & 2][i & 1] != 0)
-				traverseOctree(cam, octree->mChildren[i & 4][i & 2][i & 1]);			
+			Octree *nextChild = octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1];
+		
+			if(nextChild != 0)
+				mDistanceQueue->push(nextChild);
 		}
 	}
@@ -43,5 +40,5 @@
 		mCurrentTestIdx = 0;
 		
-mCurrentAlgorithm = RENDER_CULL_FRUSTUM;
+//mCurrentAlgorithm = RENDER_CULL_FRUSTUM;
 		switch(mCurrentAlgorithm)
 		{
@@ -53,5 +50,6 @@
 				break;
 			case RENDER_COHERENT:
-				renderCoherentWithQueue(cam);
+				//renderCoherentWithQueue(cam);
+				renderStopAndWait(cam);
 				break;
 			default:
@@ -68,44 +66,83 @@
 	{
 		AxisAlignedBox box;
-		FrustumPlane plane;
 
 		while(!mDistanceQueue->empty())
 		{
-			Octree *octree = mDistanceQueue->top();
+			Octree *octant = mDistanceQueue->top();
 			mDistanceQueue->pop();
 	
 			// interesting for visualization purpose
 			//TODO: octree->setNodeVisible(false);
-			octree->_getCullBounds(&box);
+			octant->_getCullBounds(&box);
+			
+			if(static_cast<OctreeCamera *>(cam)->getVisibility(box) == OctreeCamera::NONE)
+			if(!cam->isVisible(box))
+			{
+				mNumFrustumCulledNodes ++;
+				continue;
+			}
 
-			//if(cam->isVisible(box, &plane))
-			//{
-				// update node's visited flag 
-				//TODO: octree->setLastVisited(mFrameId);
-				//TODO: octree->setNodeVisible(true);
-				traverseOctree(cam, octree);
-			/*}
-			else
-			{			
-				mNumFrustumCulledNodes ++;
-			}*/
+			// update node's visited flag 
+			//TODO: octree->setLastVisited(mFrameId);
+			//TODO: octree->setNodeVisible(true);
+		
+			traverseOctant(cam, octant);
 		}
 	}	
-	
+	//-----------------------------------------------------------------------
 	/** Renders the scene with the hierarchical stop and wait algorithm. */
 	void OcclusionCullingTerrainSceneTraverser::renderStopAndWait( Camera *cam )
 	{
+		AxisAlignedBox box;
+
+		while(!mDistanceQueue->empty())
+		{
+			Octree *octant = mDistanceQueue->top();
+			mDistanceQueue->pop();
+		
+			// interesting for visualization purpose
+			//octant->setNodeVisible(false);
+			//octant->setLastVisited(mFrameId);
+
+			//TODO: Isvisible also checked inside scenenode::findvisibleobjects
+			octant->_getCullBounds(&box);
+
+			char msg[100]; 
+			Vector3 max = box.getMaximum();
+			Vector3 min = box.getMinimum();
+
+			sprintf(msg, "box max: %3.3f, %3.3f, %3.3f, min: %3.3f, %3.3f, %3.3f\n",max.x,max.y,max.z,min.x,min.y,min.z);
+			OutputDebugString(msg);
+
+			if(static_cast<OctreeCamera *>(cam)->getVisibility(box) == OctreeCamera::NONE)
+			//if(!cam->isVisible(box))
+			{
+				mNumFrustumCulledNodes ++;
+				continue;
+			}
+
+			HardwareOcclusionQuery *query = issueOcclusionQuery(&box, false);
+				
+			unsigned int visiblePixels;
+			// wait if result not available
+			query->pullOcclusionQuery(&visiblePixels);
+//traverseOctant(cam, octant);			
+			// node visible
+			if(visiblePixels > mVisibilityThreshold)
+			{
+				traverseOctant(cam, octant);
+				//mNumQueryCulledNodes ++;
+			}
+			else
+			{
+				mNumQueryCulledNodes ++;
+			}
+		}
 	}
-
+	//-----------------------------------------------------------------------
 	/** Renders the scene with the coherent hierarchical algorithm and the query queye. */
 	void OcclusionCullingTerrainSceneTraverser::renderCoherentWithQueue( Camera *cam )
 	{
 	}
-	
-	//-----------------------------------------------------------------------
-/*	bool OcclusionCullingTerrainSceneTraverser::isLeaf( SceneNode *node )
-	{
-		return (node->numChildren() == 0);
-	}*/
 	//-----------------------------------------------------------------------
 	void OcclusionCullingTerrainSceneTraverser::pullUpVisibility( Octree *node )
@@ -113,5 +150,5 @@
 	}
 	//-----------------------------------------------------------------------
-	void OcclusionCullingTerrainSceneTraverser::renderOctree( Camera *cam, Octree *octree )
+	void OcclusionCullingTerrainSceneTraverser::renderOctant( Camera *cam, Octree *octree )
 	{
 		setRenderingMode(MODE_RENDER);
Index: /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp
===================================================================
--- /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp	(revision 34)
+++ /trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp	(revision 41)
@@ -62,5 +62,10 @@
 	ColourValue fadeColour(0.93, 0.86, 0.76);
 	mSceneMgr->setFog( FOG_LINEAR, fadeColour, .001, 500, 1000);
+ //mSceneMgr->setFog( FOG_EXP, fadeColour, 0.005 );
 	mWindow->getViewport(0)->setBackgroundColour(fadeColour);
+
+	 // Create a skybox
+     //mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox", 500, false);
+	 //mSceneMgr->setSkyDome( true, "Examples/CloudySky", 5, 8, 500, false );
 
 	std::string terrain_cfg("terrain.cfg");
@@ -70,10 +75,10 @@
 	mSceneMgr -> setWorldGeometry( terrain_cfg );
 	// Infinite far plane?
-	if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE))
+/*	if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE))
 	{
 		mCamera->setFarClipDistance(0);
-	}
-
-	// Define the required skyplane
+	}*/
+
+/*	// Define the required skyplane
 	Plane plane;
 	// 5000 world units from the camera
@@ -81,4 +86,6 @@
 	// Above the camera, facing down
 	plane.normal = -Vector3::UNIT_Y;
+	// Create the plane 10000 units wide, tile the texture 3 times
+    mSceneMgr->setSkyPlane(true, plane, "Examples/SpaceSkyPlane",10000,3);*/
 
 	// Set a nice viewpoint
@@ -89,9 +96,24 @@
 	Ray(mCamera->getPosition(), Vector3::NEGATIVE_UNIT_Y));
 
-     // Create a skybox
-  //   mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox");
-
-	 // CEGUI setup
-	 setupGui();
+	Entity *robotEnt = mSceneMgr->createEntity( "Robot", "robot.mesh" );
+	SceneNode *robotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "RobotNode", Vector3( 750, 25, 600 ));
+	robotNode->attachObject( robotEnt );
+	robotNode->scale( .3, .3, .3 );
+	robotNode->yaw( Degree( 160 ) );
+
+	Entity *ogreEnt = mSceneMgr->createEntity( "Ogre", "ogrehead.mesh" );
+    SceneNode *ogreNode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Ogre", Vector3( 800, 50, 830 ) );
+    ogreNode->attachObject( ogreEnt );
+	ogreNode->scale(.2,.2,.2);
+	ogreNode->yaw( Degree( 20 ) );
+
+	Entity *ogreEnt2 = mSceneMgr->createEntity( "Ogre2", "ogrehead.mesh" );
+    SceneNode *ogreNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode( "Ogre2", Vector3( 700, 50, 730 ) );
+    ogreNode2->attachObject( ogreEnt2 );
+	ogreNode2->scale(.05,.05,.05);
+	ogreNode->yaw( Degree( 40 ) );
+
+	// CEGUI setup
+	setupGui();
 }
 //-----------------------------------------------------------------------
