Index: /trunk/VUT/GtpVisibility/include/HierarchyInterface.h
===================================================================
--- /trunk/VUT/GtpVisibility/include/HierarchyInterface.h	(revision 87)
+++ /trunk/VUT/GtpVisibility/include/HierarchyInterface.h	(revision 111)
@@ -110,4 +110,6 @@
 	void SetUseOptimization(bool useOptimization);
 
+	bool mDummy;
+
 protected:
 	
@@ -124,4 +126,6 @@
 	HierarchyNode *mSceneRoot;
 	HierarchyNode *mPreviousNode;
+
+	
 };
 } // namespace GtpVisibility
Index: /trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp	(revision 96)
+++ /trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp	(revision 111)
@@ -7,8 +7,11 @@
 void FrustumCullingManager::RenderScene()
 {
-	InitFrame();
+	//InitFrame();
 	
 	while (!mHierarchyInterface->GetQueue()->empty())
 	{
+		if (mHierarchyInterface->mDummy)
+			Ogre::LogManager::getSingleton().logMessage("shadow pass");
+	//	elseOgre::LogManager::getSingleton().logMessage("no shadow pass");
 		HierarchyNode *node = mHierarchyInterface->GetQueue()->top();
 		mHierarchyInterface->GetQueue()->pop();
@@ -19,5 +22,5 @@
 
 		if (!mHierarchyInterface->CheckFrustumVisible(node))
-		{
+		{if (mHierarchyInterface->mDummy)
 			mNumFrustumCulledNodes ++;
 		}
Index: /trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 96)
+++ /trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp	(revision 111)
@@ -7,5 +7,5 @@
 void CoherentHierarchicalCullingManager::RenderScene()
 {
-	InitFrame();
+	//InitFrame();
 	
 	QueryQueue queryQueue;
@@ -31,4 +31,5 @@
 			else
 			{
+				if (mHierarchyInterface->mDummy)
 				mNumQueryCulledNodes ++;
 			}
@@ -44,5 +45,5 @@
 
 			if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))
-			{
+			{	if (mHierarchyInterface->mDummy)
 				mNumFrustumCulledNodes ++;
 			}
Index: /trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp	(revision 86)
+++ /trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp	(revision 111)
@@ -8,5 +8,6 @@
 HierarchyInterface::HierarchyInterface(): 
 mFrameId(0), mNumTraversedNodes(0), mNumRenderedNodes(0), 
-mSceneRoot(0), mPreviousNode(0), mCurrentTestIdx(0), mUseOptimization(true)
+mSceneRoot(0), mPreviousNode(0), mCurrentTestIdx(0), mUseOptimization(true),
+mDummy(false)
 {	
 	mDistanceQueue = new DistanceQueue(GreaterDistance<HierarchyNode *>(this));
Index: /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp
===================================================================
--- /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 103)
+++ /trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp	(revision 111)
@@ -1,5 +1,4 @@
 #include "StopAndWaitCullingManager.h"
 #include <OgreLogManager.h>
-
 
 namespace GtpVisibility {
@@ -8,5 +7,5 @@
 void StopAndWaitCullingManager::RenderScene()
 {
-	InitFrame();
+	//InitFrame();
 
 	while (!mHierarchyInterface->GetQueue()->empty())
@@ -22,5 +21,5 @@
 
 		if (!mHierarchyInterface->CheckFrustumVisible(node, intersects))
-		{
+		{if (mHierarchyInterface->mDummy)
 			mNumFrustumCulledNodes ++;
 		}
@@ -48,4 +47,5 @@
 			else
 			{
+				if (mHierarchyInterface->mDummy)
 				mNumQueryCulledNodes ++;
 			}
Index: /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
===================================================================
--- /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 110)
+++ /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp	(revision 111)
@@ -52,5 +52,4 @@
 	//mCamera->setPosition(707, 5000, 528);
 	mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329));
-	
 	mCamNode->attachObject(mCamera);
 
@@ -97,17 +96,18 @@
 
 	//-- create light
-	mSunLight = mSceneMgr->createLight("MainLight");
-	mSunLight->setType(Light::LT_POINT);
-    mSunLight->setPosition(-707, 4000, -500);
+	mSunLight = mSceneMgr->createLight("SunLight");
+	mSunLight->setType(Light::LT_DIRECTIONAL);
+	//mSunLight->setType(Light::LT_SPOTLIGHT);
+    mSunLight->setPosition(707, 2000, 500);
+	mSunLight->setCastShadows(true);
+
 	//mSunLight->setSpotlightRange(Degree(30), Degree(50));
 
-    Vector3 dir;
-	dir = -mSunLight->getPosition();
+    Vector3 dir(0.5, 0.1, 0.5);
 	dir.normalise();
-	mSunLight->setDirection(dir);
-	mSunLight->setDiffuseColour(0.8, 0.8, 0.8);
-	mSunLight->setSpecularColour(0.9, 0.9, 1);
-
-	//mSunLight->setCastShadows(true);
+	mSunLight->setDirection(Vector3::NEGATIVE_UNIT_Y);
+
+	mSunLight->setDiffuseColour(1, 1, 1);
+	mSunLight->setSpecularColour(1, 1, 1);
 
 	// --Fog
@@ -130,4 +130,32 @@
 	setupGui();
 
+	//mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
+
+	// Floor plane
+	Plane plane;
+	plane.normal = Vector3::UNIT_Y;
+	plane.d = -60;
+	MeshManager::getSingleton().createPlane("Myplane",
+		ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
+		5000,5000,100,100,true,1,5,5,Vector3::UNIT_Z);
+	Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
+	pPlaneEnt->setMaterialName("Examples/Rockwall");
+	pPlaneEnt->setCastShadows(true);
+	mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt);
+
+	if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_HWRENDER_TO_TEXTURE))
+    {
+		// In D3D, use a 1024x1024 shadow texture
+		mSceneMgr->setShadowTextureSettings(1024, 2);
+	}
+	else
+	{
+		// Use 512x512 texture in GL since we can't go higher than the window res
+		mSceneMgr->setShadowTextureSettings(512, 2);
+	}
+	mSceneMgr->setShadowColour(ColourValue(0, 0, 0));
+ // mSceneMgr->setShowDebugShadows(true);
+
+
 	//-- terrain content setup
 
@@ -144,8 +172,9 @@
 		// => there is much occlusion
 		mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 50.0f, 3000.0f));
-		mTerrainContentGenerator->SetOffset(50);
+		mTerrainContentGenerator->SetOffset(0);
 
 		// the objects are generated on the whole terrain
 		mTerrainContentGenerator->GenerateScene(1500, "athene");
+		//mTerrainContentGenerator->GenerateScene(1500, "robot");
 		//	mTerrainContentGenerator->GenerateScene(500, "ninja");
 	}
@@ -215,5 +244,6 @@
 mCurrentFrame(0),
 mRecord(false),
-mTimeElapsed(0)
+mTimeElapsed(0),
+mUseShadows(false)
 {
 	// Reduce move speed
@@ -292,5 +322,5 @@
 		 // Get results, create a node/entity on the position
 		 mCurrentObject = mTerrainContentGenerator->GenerateSceneObject(
-			 mouseRay.getOrigin(), Vector3(0,0,0), "robot.mesh");
+			 mouseRay.getOrigin(), Vector3(0,0,0), "robot");
 		
          mLMouseDown = true; 
@@ -434,4 +464,5 @@
 	KEY_PRESSED(KC_F2, 0.3, toggleRecord());
 	KEY_PRESSED(KC_F3, 0.3, mTerrainContentGenerator->WriteObjects(objects_outfile));
+	KEY_PRESSED(KC_F4, 0.3, toggleUseShadows());
 	//KEY_PRESSED(KC_F3, 0.3, writeFrames());
 	//KEY_PRESSED(KC_F4, 0.3, loadFrames());
@@ -706,4 +737,21 @@
 }
 //-----------------------------------------------------------------------
+void MouseQueryListener::toggleUseShadows()
+{
+	mUseShadows = !mUseShadows;
+
+	//mSunLight->setCastShadows(mUseShadows);
+
+	if (mUseShadows)
+	{
+		mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE);
+	}
+	else
+	{
+		mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE);
+	}
+
+}
+//-----------------------------------------------------------------------
 void MouseQueryListener::toggleRenderNodesForViz()
 {
Index: /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
===================================================================
--- /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 109)
+++ /trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h	(revision 111)
@@ -113,4 +113,6 @@
 	void loadFrames();
 
+	void toggleUseShadows();
+
 protected:
 	void Clamp2Terrain();
@@ -162,4 +164,5 @@
 	bool mRecord;
 	Real mTimeElapsed;
+	bool mUseShadows;
 };
 
Index: /trunk/VUT/work/TestCulling/TestCullingApplication.cpp
===================================================================
--- /trunk/VUT/work/TestCulling/TestCullingApplication.cpp	(revision 107)
+++ /trunk/VUT/work/TestCulling/TestCullingApplication.cpp	(revision 111)
@@ -57,5 +57,5 @@
 
 	// Create a skybox
-    //mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 2000, false);
+    mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 2000, true);
     ColourValue fadeColour(0.1, 0.1, 0.6);
 	mWindow->getViewport(0)->setBackgroundColour(fadeColour);
Index: /trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
===================================================================
--- /trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h	(revision 103)
+++ /trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h	(revision 111)
@@ -82,4 +82,6 @@
 	*/
 	void SetOnlyShadowCasters(bool onlyShadowCasters);
+	/** see set */
+	bool GetOnlyShadowCasters();
 
 protected:
Index: /trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 107)
+++ /trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp	(revision 111)
@@ -85,4 +85,5 @@
 void VisibilityTerrainSceneManager::_renderVisibleObjects()
 {
+
 	if (!mShowVisualization)
 	{
Index: /trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp	(revision 110)
+++ /trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp	(revision 111)
@@ -72,4 +72,5 @@
 		createChildSceneNode(String(name) + "Node", position);
 
+	//ent->setCastShadows(false);
 	currentObject->attachObject(ent);
 	currentObject->setScale(mScale);
Index: /trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp	(revision 103)
+++ /trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp	(revision 111)
@@ -25,4 +25,5 @@
 void VisibilitySceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
 {
+	mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters);
 	// does nothing if hierarchical culling is used =>
 	// we interleave identification and rendering of objects 
Index: /trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp	(revision 103)
+++ /trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp	(revision 111)
@@ -177,4 +177,10 @@
 {
 	mOnlyShadowCasters = onlyShadowCasters;
+	mDummy = mOnlyShadowCasters ;
+}
+//-----------------------------------------------------------------------
+bool PlatformHierarchyInterface::GetOnlyShadowCasters()
+{
+	return mOnlyShadowCasters;
 }
 } // namespace Ogre
Index: /trunk/VUT/Ogre/src/OgreTerrainContentGenerator.cpp
===================================================================
--- /trunk/VUT/Ogre/src/OgreTerrainContentGenerator.cpp	(revision 110)
+++ /trunk/VUT/Ogre/src/OgreTerrainContentGenerator.cpp	(revision 111)
@@ -76,8 +76,10 @@
 	if (mRayQueryExecutor->executeRayQuery(&queryResult, position, Vector3::NEGATIVE_UNIT_Y))
 	{
-		queryResult.y += mOffset;
 		// reject if height is too high
 		if (queryResult.y < mMaxPos.y)
 		{
+			// add offset so object is over terrain
+			queryResult.y += mOffset;
+
 			return SceneContentGenerator::GenerateSceneObject(queryResult, rotation, objName);
 		}
