Index: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
===================================================================
--- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 2321)
+++ GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp	(revision 2333)
@@ -26,4 +26,12 @@
 void OgreDepthShadowMapRenderingRun::createDepthMap()
 {
+	if(light->getType() == Light::LT_POINT)
+	{
+		depthMapTexture = createCubeRenderTexture(name, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White);
+		if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
+		blurredDepthMapTexture = createCubeRenderTexture(blurredname, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White);
+	}
+	else
+	{
 	
 		TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, 
@@ -46,5 +54,5 @@
 		rt->setAutoUpdated(false);
 		
-		if(OgreIlluminationManager::getSingleton().getBlurShadowMap())
+		if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
 		{
 			texPtr = Ogre::TextureManager::getSingleton().createManual(blurredname, 
@@ -64,4 +72,5 @@
 			rt->setAutoUpdated(false);
 		}
+	}
 }
 
@@ -72,5 +81,10 @@
 	if(light->getType() == Light::LT_POINT)
 	{
-		updateDepthMap();
+		//static int currentFace = 0;
+		//updateDepthCubeFace(currentFace);
+		//currentFace = (currentFace+1)%6;
+
+		for(int i = 0; i < 6 ; i++)
+			updateDepthCubeFace(i);
 	}
 	else
@@ -82,4 +96,28 @@
 void OgreDepthShadowMapRenderingRun::updateDepthCubeFace(int facenum)
 {
+	Vector3 lightpos = light->getDerivedPosition();			
+	
+	RenderTarget* rt = depthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget();	
+	Camera*  cam = 	rt->getViewport(0)->getCamera();
+	cam->setPosition(lightpos);	
+	cam->setFarClipDistance(lightFarPlane);
+
+	setMaterialForVisibles(materialName, cam, false);
+	rt->update();
+	restoreMaterials();
+
+	//rt->writeContentsToFile("shadowmap_" + StringConverter::toString(facenum) + ".dds");
+
+	if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
+	{
+		rt = blurredDepthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget();
+		Material*  mat = (Material*) MaterialManager::getSingleton().getByName("GameTools/BlurCubeFace").getPointer();
+		mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(depthMapTexture->getName());
+		mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("face", facenum);
+		renderFullscreenQuad("GameTools/BlurCubeFace", rt);		
+		
+		//rt->writeContentsToFile("shadowmap_blurred_" + StringConverter::toString(facenum) + ".dds");
+	}
+	
 }
 
@@ -93,5 +131,5 @@
 	restoreMaterials();
 	
-	if(OgreIlluminationManager::getSingleton().getBlurShadowMap())
+	if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
 	{
 		rt = blurredDepthMapTexture->getBuffer().getPointer()->getRenderTarget();
@@ -108,5 +146,5 @@
 const String& OgreDepthShadowMapRenderingRun::getDepthMapTextureName()
 {
-		if(OgreIlluminationManager::getSingleton().getBlurShadowMap())
+		if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType()))
 			return blurredname;
 
@@ -119,6 +157,6 @@
 	if(light!= 0)
 	{
-		bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM();
-		bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap();
+		bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM(light->getType());
+		bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap(light->getType());
 		if(light->getType() == Light::LT_DIRECTIONAL)
 		{
@@ -129,6 +167,6 @@
 			frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix());
 
-			Vector3 lightpos = light->getParentSceneNode()->getWorldPosition();
-			Vector3 lightdir = light->getDirection();
+			Vector3 lightpos = light->getDerivedPosition();
+			Vector3 lightdir = light->getDerivedDirection();
 			lightdir.normalise();		
 			
@@ -234,6 +272,6 @@
 			frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix());
 
-			Vector3 lightpos = light->getParentSceneNode()->getWorldPosition ();
-			Vector3 lightdir = light->getDirection();
+			Vector3 lightpos = light->getDerivedPosition();
+			Vector3 lightdir = light->getDerivedDirection();
 			lightdir.normalise();		
 			Radian lightangle = light->getSpotlightOuterAngle();
@@ -359,22 +397,6 @@
 		else//point light
 		{
-	/*		Vector3 pos = light->getParentNode()->getWorldPosition();
-			Vector3 dir = -pos;
-			depthMapCamera->setDirection( dir );
-			depthMapCamera->setPosition(pos);
-			depthMapCamera->setProjectionType(PT_PERSPECTIVE);
-			depthMapCamera->setFOVy(Radian(Degree(140)));
-			depthMapCamera->setNearClipDistance(1);
-			// depthMapCamera->setFarClipDistance(200);
-	
-			//OGRE_EXCEPT(0, "NOT implemented for Pointlight", "OgreDepthShadowMapRenderingRun::refreshLight");
-		*/	
-			/*Vector3 pos = light->getParentNode()->getWorldPosition();
-			Vector3 dir = -pos;
-			depthMapCamera->setDirection( dir );
-			depthMapCamera->setPosition(pos);
-			depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC);
-			depthMapCamera->*/
-			
+			lightFarPlane = light->getAttenuationRange();
+			//no other adjustment needed			
 		}
 	}
@@ -383,10 +405,18 @@
 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix()
 {
-	return depthMapCamera->getViewMatrix();
+	Camera* cam = depthMapCamera;
+	if(light->getType() == Light::LT_POINT)
+	 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera();	
+	
+	return cam->getViewMatrix();
 }
 
 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix()
 {
-	return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix();
+	Camera* cam = depthMapCamera;
+	if(light->getType() == Light::LT_POINT)
+	 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera();	
+	
+	return cam->getProjectionMatrixWithRSDepth() * cam->getViewMatrix();
 }
 
