Index: /GTP/trunk/App/Demos/Illum/Ogre/src/CausticTest/include/CausticTest.h
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/src/CausticTest/include/CausticTest.h	(revision 2319)
+++ /GTP/trunk/App/Demos/Illum/Ogre/src/CausticTest/include/CausticTest.h	(revision 2340)
@@ -31,4 +31,6 @@
 float cauintens = 40;
 
+class RaytraceDemoApplication;
+
 // Listener class for frame updates
 class RaytraceDemoListener : public ExampleFrameListener
@@ -40,7 +42,8 @@
 	SceneNode* sphereNode;
 	unsigned long framecount;
+	RaytraceDemoApplication* app;
 	
 public:
-    RaytraceDemoListener(RenderWindow* window, Camera* maincam,SceneNode* lightNode, SceneNode* sphereNode, Light* l)
+    RaytraceDemoListener(RenderWindow* window, Camera* maincam,SceneNode* lightNode, SceneNode* sphereNode, Light* l, RaytraceDemoApplication* app)
         :ExampleFrameListener(window, maincam) 
 				 
@@ -50,4 +53,5 @@
 		this->lightNode = lightNode;
 		light = l;
+		this->app = app;
     }
 	bool processUnbufferedKeyInput(const FrameEvent& evt)
@@ -120,20 +124,6 @@
 		return ExampleFrameListener::processUnbufferedKeyInput(evt);
 	}
-    bool frameStarted(const FrameEvent& evt)
-    {
-		static bool first = true;
-	
-
-	//	lightNode->setPosition( 100.0 * Vector3(cos(-(float)framecount/500.0),2.0,sin(-(float)framecount/500.0)));
-		
-		
-		bool result = ExampleFrameListener::frameStarted(evt);
-       framecount++;
-
-	   if (framecount == 60)
-		   OgreIlluminationManager::getSingleton().freeAllResources();
-      return result;     
-    }
-
+    
+	bool frameStarted(const FrameEvent& evt);
 	
 
@@ -145,63 +135,10 @@
 
 public:
-
-protected:
-	SceneNode* mainLightNode;
-	SceneNode* sphereNode;
-	
-	void chooseSceneManager()
-	{
-		//mSceneMgr = mRoot->createSceneManager("OctreeSceneManager");
-		mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager");
-	}
-
-	void loadResources(void)
-	{
-		
-		// Initialise, parse scripts etc
-		ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
-		ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
-		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Basic");
-		ResourceGroupManager::getSingleton().initialiseResourceGroup("PostProc");
-		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_EnvMap");
-		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Caustic");
-	}
-
-	void createPostproc()
-	{		
-		CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
-														"GTP/PostProc/Glow");
-		CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
-														"GTP/PostProc/Glow", true);
-
-		CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
-														"GTP/PostProc/ToneMap");
-		CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
-														"GTP/PostProc/ToneMap", true);		
-	}
-    
-	Light* light;
-	void createScene(void)
-    {
-		std::string occlusion_cfg("OcclusionCulling.cfg");
-		mSceneMgr->setWorldGeometry(occlusion_cfg);
-
-		//createPostproc();
-		OgreIlluminationManager::getSingleton().setBlurShadowMap(true);
-		OgreIlluminationManager::getSingleton().setUseLISPSM(false);
-
-		OgreIlluminationManager::getSingleton().setMainCamera(mCamera);
-		OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
-		
-		OgreIlluminationManager::getSingleton().setMaxJoinRadius(420);		
-
-		Root::getSingleton()._setCurrentSceneManager(mSceneMgr);
-
-		mCamera->setPosition(0,100,240);
-		mCamera->setFOVy(Radian(Degree(80)));
-		//mCamera->setFarClipDistance(1000);
-		// Set ambient light
-        mSceneMgr->setAmbientLight(ColourValue(1, 1, 1));
-
+	void LoadRes()
+	{
+		loadResources();
+	}
+	void setupScene()
+	{
 		// Skybox
         mSceneMgr->setSkyBox(true, "Examples/EveningSkyBox");
@@ -249,5 +186,71 @@
 		//createPlane("ground", "TestPlane", Vector3(0,0,0), Vector2(500,500));
 		OgreIlluminationManager::getSingleton().initTechniques();
+
+		OgreIlluminationManager::getSingleton().setPriority(2);
+        mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());		
+	}
+
+protected:
+	SceneNode* mainLightNode;
+	SceneNode* sphereNode;
+	
+	void chooseSceneManager()
+	{
+		//mSceneMgr = mRoot->createSceneManager("OctreeSceneManager");
+		mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager");
+	}
+
+	void loadResources(void)
+	{
+		
+		// Initialise, parse scripts etc
+		ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
+		ResourceGroupManager::getSingleton().initialiseResourceGroup("General");
+		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Basic");
+		ResourceGroupManager::getSingleton().initialiseResourceGroup("PostProc");
+		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_EnvMap");
+		ResourceGroupManager::getSingleton().initialiseResourceGroup("GTP_Caustic");
+	}
+
+	void createPostproc()
+	{		
+		CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
+														"GTP/PostProc/Glow");
+		CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
+														"GTP/PostProc/Glow", true);
+
+		CompositorManager::getSingleton().addCompositor(mWindow->getViewport(0),
+														"GTP/PostProc/ToneMap");
+		CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0),
+														"GTP/PostProc/ToneMap", true);		
+	}
+    
+	Light* light;
+	void createScene(void)
+    {
+		std::string occlusion_cfg("OcclusionCulling.cfg");
+		mSceneMgr->setWorldGeometry(occlusion_cfg);
+
+		//createPostproc();
+		OgreIlluminationManager::getSingleton().setBlurShadowMap(true);
+		OgreIlluminationManager::getSingleton().setUseLISPSM(false);
+
+		OgreIlluminationManager::getSingleton().setMainCamera(mCamera);
+		OgreIlluminationManager::getSingleton().setMainViewport(mWindow->getViewport(0));
+		
+		OgreIlluminationManager::getSingleton().setMaxJoinRadius(420);		
+
+		Root::getSingleton()._setCurrentSceneManager(mSceneMgr);
+
+		mCamera->setPosition(0,100,240);
+		mCamera->setFOVy(Radian(Degree(80)));
+		//mCamera->setFarClipDistance(1000);
+		// Set ambient light
+        mSceneMgr->setAmbientLight(ColourValue(1, 1, 1));
+
+		setupScene();
 	 }
+
+	
    void createPlane(Ogre::String _name, Ogre::String _material, Ogre::Vector3 _pos, Ogre::Vector2 _size, Ogre::Vector2 _subdivisions = Ogre::Vector2(1,1)) {
 		
@@ -278,9 +281,8 @@
 											mainLightNode,
 											sphereNode,
-											light
+											light, 
+											this
 											);
 		mFrameListener->setPriority(1);
-		OgreIlluminationManager::getSingleton().setPriority(2);
-        mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());
 		mRoot->addFrameListener(mFrameListener);
 	
@@ -289,2 +291,7 @@
 };
 
+
+
+
+
+
Index: /GTP/trunk/App/Demos/Illum/Ogre/src/CausticTest/src/CausticTest.cpp
===================================================================
--- /GTP/trunk/App/Demos/Illum/Ogre/src/CausticTest/src/CausticTest.cpp	(revision 1450)
+++ /GTP/trunk/App/Demos/Illum/Ogre/src/CausticTest/src/CausticTest.cpp	(revision 2340)
@@ -33,5 +33,31 @@
 #endif
 
+bool RaytraceDemoListener::frameStarted(const FrameEvent& evt)
+    {
+		static bool first = true;
+	
 
+	//	lightNode->setPosition( 100.0 * Vector3(cos(-(float)framecount/500.0),2.0,sin(-(float)framecount/500.0)));
+		
+		
+		bool result = ExampleFrameListener::frameStarted(evt);
+       framecount++;
+
+	   if (framecount == 60)
+	   {
+		   OgreIlluminationManager::getSingleton().freeAllResources();
+		   Root::getSingleton().removeFrameListener(&OgreIlluminationManager::getSingleton());
+		   Root::getSingleton()._getCurrentSceneManager()->clearScene();
+		   TextureManager::getSingleton().removeAll();
+		   MeshManager::getSingleton().removeAll();
+		   MaterialManager::getSingleton().removeAll();
+	   //}
+	   //if (framecount == 120)
+	   //{
+		   app->LoadRes();
+		   app->setupScene();
+	   }
+      return result;     
+    }
 
 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
@@ -61,2 +87,5 @@
 }
 #endif
+
+
+
