Index: GTP/trunk/App/Demos/Illum/Ogre/src/DiffuseTest/include/DiffuseTest.h
===================================================================
--- GTP/trunk/App/Demos/Illum/Ogre/src/DiffuseTest/include/DiffuseTest.h	(revision 1590)
+++ GTP/trunk/App/Demos/Illum/Ogre/src/DiffuseTest/include/DiffuseTest.h	(revision 1598)
@@ -225,4 +225,78 @@
 };
 
+
+class FloorRenderTargetListener : public RenderTargetListener
+{
+public:
+	Entity* scene;
+	FloorRenderTargetListener(Entity* scene)
+	{
+		this->scene = scene;
+	}
+	void preRenderTargetUpdate(const RenderTargetEvent& evt)
+    {
+		scene->getSubEntity(0)->setVisible(false);
+		scene->getSubEntity(17)->setVisible(false);
+		scene->getSubEntity(35)->setVisible(false);
+		scene->getSubEntity(52)->setVisible(false);
+    }
+    void postRenderTargetUpdate(const RenderTargetEvent& evt)
+    {
+       scene->getSubEntity(0)->setVisible(true);
+		scene->getSubEntity(17)->setVisible(true);
+		scene->getSubEntity(35)->setVisible(true);
+		scene->getSubEntity(52)->setVisible(true);
+    }
+
+};
+
+class CeilRenderTargetListener : public RenderTargetListener
+{
+public:
+	Entity* scene;
+	CeilRenderTargetListener(Entity* scene)
+	{
+		this->scene = scene;
+	}
+	void preRenderTargetUpdate(const RenderTargetEvent& evt)
+    {
+		scene->getSubEntity(1)->setVisible(false);
+		scene->getSubEntity(18)->setVisible(false);
+		scene->getSubEntity(36)->setVisible(false);
+		scene->getSubEntity(53)->setVisible(false);
+    }
+    void postRenderTargetUpdate(const RenderTargetEvent& evt)
+    {
+       scene->getSubEntity(1)->setVisible(true);
+		scene->getSubEntity(18)->setVisible(true);
+		scene->getSubEntity(36)->setVisible(true);
+		scene->getSubEntity(53)->setVisible(true);
+    }
+
+};
+
+class ReflectionCameraFrameListener : public FrameListener
+{
+public:
+	Camera* floorReflCam;
+	Camera* ceilReflCam;
+	Camera* mainCamera;
+    ReflectionCameraFrameListener(Camera* floorcam, Camera* ceilCam, Camera* mainCam)
+	{
+		floorReflCam = floorcam;
+		ceilReflCam = ceilCam;
+		mainCamera = mainCam;
+	}
+	bool frameStarted(const FrameEvent& evt)
+    {
+		floorReflCam->setOrientation(mainCamera->getOrientation());
+        floorReflCam->setPosition(mainCamera->getPosition());
+
+	//	ceilReflCam->setOrientation(mainCamera->getOrientation());
+    //    ceilReflCam->setPosition(mainCamera->getPosition());
+
+		return true;
+	}
+};
 /** Application class */
 class RaytraceDemoApplication : public ExampleApplication
@@ -258,7 +332,18 @@
 		mCamera->setPosition(0,10,10);		
 		mCamera->setFOVy(Radian(Degree(80)));
-		mCamera->setFarClipDistance(100);
+		mCamera->setFarClipDistance(200);
 		mCamera->setNearClipDistance(0.1);
-		// Set ambient light
+		
+		//createScene1();
+		createScene2();
+		
+		OgreIlluminationManager::getSingleton().initTechniques();
+		
+		
+   }
+
+   void createScene1()
+   {
+	   
         mSceneMgr->setAmbientLight(ColourValue(0.1, 0.0537, 0.0));
 		//mSceneMgr->setAmbientLight(ColourValue(0.0, 0.0, 0.0));
@@ -355,9 +440,123 @@
 		redlight2Node->setPosition(18.689,7.743,-10.838);
 		redlight2Node->attachObject(redlight2); 
-		
-		OgreIlluminationManager::getSingleton().initTechniques();
-		
-		
    }
+
+   Camera* mReflectCamFloor;
+   Camera* mReflectCamCeil;
+   ReflectionCameraFrameListener* reflListener;
+   void createScene2()
+   {
+	   mCamera->setPosition(0,5,10);
+	   MovablePlane *floorPlane = new MovablePlane("ReflectPlaneFloor");
+        floorPlane->d = 0;
+        floorPlane->normal = Vector3::UNIT_Y;
+
+		RenderTexture* rttTexFloor = mRoot->getRenderSystem()->createRenderTexture( "FloorReflection", 512, 512, TEX_TYPE_2D, PF_R8G8B8 );
+        {
+            mReflectCamFloor = mSceneMgr->createCamera("ReflectCamFloor");
+            mReflectCamFloor->setNearClipDistance(mCamera->getNearClipDistance());
+            mReflectCamFloor->setFarClipDistance(mCamera->getFarClipDistance());
+           /* mReflectCamFloor->setAspectRatio(
+                (Real)mWindow->getViewport(0)->getActualWidth() / 
+                (Real)mWindow->getViewport(0)->getActualHeight());*/
+			mReflectCamFloor->setFOVy(mCamera->getFOVy());
+			mReflectCamFloor->setAspectRatio(mCamera->getAspectRatio());
+
+            Viewport *v = rttTexFloor->addViewport( mReflectCamFloor );
+            v->setClearEveryFrame( true );
+            v->setBackgroundColour( ColourValue::Black );
+			
+          
+            // set up linked reflection
+            mReflectCamFloor->enableReflection(floorPlane);
+            // Also clip
+            mReflectCamFloor->enableCustomNearClipPlane(floorPlane);
+        }
+	/*	MovablePlane *ceilPlane = new MovablePlane("ReflectPlaneCeil");
+        ceilPlane->d = -8;
+		ceilPlane->normal = Vector3::NEGATIVE_UNIT_Y;
+		RenderTexture* rttTexCeil = mRoot->getRenderSystem()->createRenderTexture( "CeilReflection", 512, 512, TEX_TYPE_2D, PF_R8G8B8 );
+        {
+            mReflectCamCeil = mSceneMgr->createCamera("ReflectCamCeil");
+            mReflectCamCeil->setNearClipDistance(mCamera->getNearClipDistance());
+            mReflectCamCeil->setFarClipDistance(mCamera->getFarClipDistance());
+            mReflectCamCeil->setAspectRatio(
+                (Real)mWindow->getViewport(0)->getActualWidth() / 
+                (Real)mWindow->getViewport(0)->getActualHeight());
+
+            Viewport *v = rttTexCeil->addViewport( mReflectCamCeil );
+            v->setClearEveryFrame( true );
+            v->setBackgroundColour( ColourValue::Black );
+			
+           
+            // set up linked reflection
+            mReflectCamCeil->enableReflection(floorPlane);
+            // Also clip
+            mReflectCamCeil->enableCustomNearClipPlane(floorPlane);
+        }
+		*/
+		reflListener = new ReflectionCameraFrameListener(mReflectCamFloor, mReflectCamCeil, mCamera);
+		reflListener->setPriority(2);
+
+	   // mSceneMgr->setAmbientLight(ColourValue(0.1, 0.0537, 0.0));
+	   mSceneMgr->setAmbientLight(ColourValue(0.0, 0.0, 0.0));
+		
+		SceneNode* rootNode = mSceneMgr->getRootSceneNode();
+
+      	Entity* object = mSceneMgr->createEntity("object", "athene.mesh");
+		object->setMaterialName("GameTools/Diffuse/use");
+		//object->setMaterialName("GameTools/Diffuse2");
+		objectNode = rootNode->createChildSceneNode();
+		objectNode->attachObject(object);
+		objectNode->scale(0.05,0.05,0.05);
+		objectNode->setPosition(0,4,0);
+		objectNode->_updateBounds();
+
+		Entity* room = mSceneMgr->createEntity("scene", "uvegfolyoso2.mesh");
+		//room->setMaterialName("GameTools/Phong");
+		SceneNode* roomNode = rootNode->createChildSceneNode();
+		roomNode->attachObject(room);
+		roomNode->_updateBounds();
+		rttTexFloor->addListener(new FloorRenderTargetListener(room));
+		//rttTexCeil->addListener(new CeilRenderTargetListener(room));
+
+		Light* light1 = mSceneMgr->createLight("Light1");
+		light1->setType(Light::LT_POINT);
+        light1->setDiffuseColour(ColourValue(0.526,0.535, 0.974));
+		light1->setPowerScale(3);
+		SceneNode* lightNode1 = rootNode->createChildSceneNode();
+		lightNode1->setPosition(-1.266,4.131,-4.438);
+		lightNode1->attachObject(light1); 
+
+		Light* light2 = mSceneMgr->createLight("Light2");
+		light2->setType(Light::LT_POINT);
+        light2->setDiffuseColour(ColourValue(0.391,0.781, 0.974));
+		light2->setPowerScale(3);
+		SceneNode* lightNode2 = rootNode->createChildSceneNode();
+		lightNode2->setPosition(-33.537,4.131,-4.438);
+		lightNode2->attachObject(light2); 
+
+		Light* light3 = mSceneMgr->createLight("Light3");
+		light3->setType(Light::LT_POINT);
+        light3->setDiffuseColour(ColourValue(0.391,0.781, 0.974));
+		light3->setPowerScale(3);
+		SceneNode* lightNode3 = rootNode->createChildSceneNode();
+		lightNode3->setPosition(-97.446,4.131,-4.438);
+		lightNode3->attachObject(light3); 
+
+		Light* light4 = mSceneMgr->createLight("Light4");
+		light4->setType(Light::LT_POINT);
+        light4->setDiffuseColour(ColourValue(0.304,0.974, 0.770));
+		light4->setPowerScale(3);
+		SceneNode* lightNode4 = rootNode->createChildSceneNode();
+		lightNode4->setPosition(-63.277,4.131,-4.438);
+		lightNode4->attachObject(light4); 
+
+		
+
+
+
+   }
+
    void createPlane(Ogre::String _name, Ogre::String _material, Ogre::Vector3 _pos, Ogre::Vector2 _size, Ogre::Vector2 _subdivisions = Ogre::Vector2(1,1)) {
 		
@@ -389,7 +588,8 @@
 											);
 		mFrameListener->setPriority(1);
-		OgreIlluminationManager::getSingleton().setPriority(2);
+		OgreIlluminationManager::getSingleton().setPriority(10);
         mRoot->addFrameListener(&OgreIlluminationManager::getSingleton());
 		mRoot->addFrameListener(mFrameListener);
+		mRoot->addFrameListener(reflListener);
 	
     }
@@ -397,2 +597,3 @@
 };
 
+
