   Problem with "shadow matrix projection" technique
  Hello everyoneI am trying to implement shadows using the shadow projection technique that I read about in the OpenGL SuperBible (4th edition). My scene consists of the following, (1) a floor made of many quads, (2) a yellow sphere, (3) a blue sphere and (4) a green torus. The problem is that the shadows of every object, besides the yellow sphere which is drawn right after a call to glutLookAt(), are not where they are supposed to be.I've uploaded the application at rapidshare (links are below). Perhaps someone who has implemented the algorithm themselves could take a look and tell me what's wrong with it. I hope it's a major problem, such as having omitted some important step of the algorithm that can be easily rectified, rather than a subtle bug. I can post the code if you want but I have to clean it up a bit.CONTROLS for the applicationCamera moves with W/A/S/D, R/F for vertical movement and mouse for rotation.Light moves with arrow keys and PAGE_UP/PAGE_DOWN for vertical movement.F1 to exitRAPIDSHARE Free LinksLinks can be downloaded 10 times each.http://rapidshare.com/files/391766488/app.rar.htmlhttp://rapidshare.com/files/391764849/app.rar.htmlhttp://rapidshare.com/files/391766719/app.rar.html   
  Ok, I found the solution which was surprisingly easy.For every object in the scene:1. Subtract the object's position from the light source's position (i.e. newLightPos = lightPos - objPos)2. Recalculate the shadow matrix and apply it.// V3D olgLightPos; // defined elsewhere// V4D pEq; // plane equation defined elsewhereM44 shadowMat;V3D newLightPos;//glPushMatrix();V3D objPosA( 5.0f, 0.0f, -5.0f );// calculate the shadow matrixif( shadow ){newLightPos = oldLightPos - objPosA;ShadowMatrix( shadowMat, pEq, newLightPos );glMultMatrixf( shadowMat.m );}// if we're drawing the shadow, then use BLACK, otherwise use GREENif( shadow )glColor3ub(0,0,0);elseglColor3f( 0.0f, 1.0f, 0.0f );glTranslatef( objPosA.x, objPosA.y, objPosA.z );glutSolidCube( 1.0f );glPopMatrix();//glPushMatrix();V3D objPosB( -1.0f, 0.0f, 1.0f );// calculate the shadow matrixif( shadow ){newLightPos = oldLightPos - objPosB;ShadowMatrix( shadowMat, pEq, newLightPos );glMultMatrixf( shadowMat.m );}// if we're drawing the shadow, then use BLACK, otherwise use GREENif( shadow )glColor3ub( 0, 0, 0 );elseglColor3f( 0.0f, 1.0f, 0.0f );glTranslatef( objPosB.x, objPosB.y, objPosB.z );glutSolidCube( 1.0f );glPopMatrix();