   When to place my cube for my Light POV frustum
  Well I have something rendering but its all messed up. Look at image. The colors are as followsgreen = toporange = bottomred = front yellow = backblue = leftviolet = rightthose are supposed to be the correct order but as you can see my top and bottom are flipped? and why does my quads look no uniform? Guess I am lost on what to do. I am trying to make a cube to represent my lights POV frustum for my shadowmapping  so I can see where the volume is aiming at on my terrain... void CTerrain::DrawShadowFrustum(bool drawFrustum){if(drawFrustum){glDisable(GL_CULL_FACE);CFrustum lightPOVFrustum = CFrustum();glPushMatrix();glTranslatef(0.0f, 5.0f, 0.0f);lightPOVFrustum.calculateFrustum(modelViewMatrix, modelProjectionMatrix, false);glBegin(GL_QUADS);glColor3f(0.0f, 1.0f, 0.0f);// Set The Color To GreenglVertex3f( lightPOVFrustum.frustum[3][0],  lightPOVFrustum.frustum[3][1], -lightPOVFrustum.frustum[3][2]);// Top Right Of The Quad (Top)glVertex3f(-lightPOVFrustum.frustum[3][0],  lightPOVFrustum.frustum[3][1], -lightPOVFrustum.frustum[3][2]);// Top Left Of The Quad (Top)glVertex3f(-lightPOVFrustum.frustum[3][0],  lightPOVFrustum.frustum[3][1],  lightPOVFrustum.frustum[3][2]);// Bottom Left Of The Quad (Top)glVertex3f( lightPOVFrustum.frustum[3][0],  lightPOVFrustum.frustum[3][1],  lightPOVFrustum.frustum[3][2]);// Bottom Right Of The Quad (Top)glColor3f(1.0f, 0.5f, 0.0f);// Set The Color To OrangeglVertex3f( lightPOVFrustum.frustum[2][0], -lightPOVFrustum.frustum[2][1],  lightPOVFrustum.frustum[2][2]);// Top Right Of The Quad (Bottom)glVertex3f(-lightPOVFrustum.frustum[2][0], -lightPOVFrustum.frustum[2][1],  lightPOVFrustum.frustum[2][2]);// Top Left Of The Quad (Bottom)glVertex3f(-lightPOVFrustum.frustum[2][0], -lightPOVFrustum.frustum[2][1], -lightPOVFrustum.frustum[2][2]);// Bottom Left Of The Quad (Bottom)glVertex3f( lightPOVFrustum.frustum[2][0], -lightPOVFrustum.frustum[2][1], -lightPOVFrustum.frustum[2][2]);// Bottom Right Of The Quad (Bottom)glColor3f(1.0f, 0.0f, 0.0f);// Set The Color To RedglVertex3f( lightPOVFrustum.frustum[5][0],  lightPOVFrustum.frustum[5][1], lightPOVFrustum.frustum[5][2]);// Top Right Of The Quad (Front)glVertex3f(-lightPOVFrustum.frustum[5][0],  lightPOVFrustum.frustum[5][1], lightPOVFrustum.frustum[5][2]);// Top Left Of The Quad (Front)glVertex3f(-lightPOVFrustum.frustum[5][0], -lightPOVFrustum.frustum[5][1], lightPOVFrustum.frustum[5][2]);// Bottom Left Of The Quad (Front)glVertex3f( lightPOVFrustum.frustum[5][0], -lightPOVFrustum.frustum[5][1], lightPOVFrustum.frustum[5][2]);// Bottom Right Of The Quad (Front)glColor3f(1.0f, 1.0f, 0.0f);// Set The Color To YellowglVertex3f( lightPOVFrustum.frustum[4][0], -lightPOVFrustum.frustum[4][1], -lightPOVFrustum.frustum[4][2]);// Bottom Left Of The Quad (Back)glVertex3f(-lightPOVFrustum.frustum[4][0], -lightPOVFrustum.frustum[4][1], -lightPOVFrustum.frustum[4][2]);// Bottom Right Of The Quad (Back)glVertex3f(-lightPOVFrustum.frustum[4][0],  lightPOVFrustum.frustum[4][1], -lightPOVFrustum.frustum[4][2]);// Top Right Of The Quad (Back)glVertex3f( lightPOVFrustum.frustum[4][0],  lightPOVFrustum.frustum[4][1], -lightPOVFrustum.frustum[4][2]);// Top Left Of The Quad (Back)glColor3f(0.0f, 0.0f, 1.0f);// Set The Color To BlueglVertex3f(-lightPOVFrustum.frustum[1][0],  lightPOVFrustum.frustum[1][1],  lightPOVFrustum.frustum[1][2]);// Top Right Of The Quad (Left)glVertex3f(-lightPOVFrustum.frustum[1][0],  lightPOVFrustum.frustum[1][1], -lightPOVFrustum.frustum[1][2]);// Top Left Of The Quad (Left)glVertex3f(-lightPOVFrustum.frustum[1][0], -lightPOVFrustum.frustum[1][1], -lightPOVFrustum.frustum[1][2]);// Bottom Left Of The Quad (Left)glVertex3f(-lightPOVFrustum.frustum[1][0], -lightPOVFrustum.frustum[1][1],  lightPOVFrustum.frustum[1][2]);// Bottom Right Of The Quad (Left)glColor3f(1.0f, 0.0f, 1.0f);// Set The Color To VioletglVertex3f(lightPOVFrustum.frustum[0][0],  lightPOVFrustum.frustum[0][1], -lightPOVFrustum.frustum[0][2]);// Top Right Of The Quad (Right)glVertex3f(lightPOVFrustum.frustum[0][0],  lightPOVFrustum.frustum[0][1],  lightPOVFrustum.frustum[0][2]);// Top Left Of The Quad (Right)glVertex3f(lightPOVFrustum.frustum[0][0], -lightPOVFrustum.frustum[0][1],  lightPOVFrustum.frustum[0][2]);// Bottom Left Of The Quad (Right)glVertex3f(lightPOVFrustum.frustum[0][0], -lightPOVFrustum.frustum[0][1], -lightPOVFrustum.frustum[0][2]);// Bottom Right Of The Quad (Right)glEnd();glPopMatrix();glEnable(GL_CULL_FACE);}}BTW I am not normalizing the planes and tried and was no difference...[Edited by - MARS_999 on June 4, 2006 9:15:45 PM]
  bump   ;  You got the 6 frustrum planesso you can calculate the intersection verticesX=(x1,x2,x3) is the vector we are looking forTOP,BOTTOM,FAR,NEAR,LEFT,RIGHTV[8] = the 8 corner vecticesNow to calculate the vectices//your plane definition//as you see its just a linear equationax1 + bx2 +cx3 = -d //now to do the 3 plane intersectiona1x1 + b1x2 +c1x3 = -d1 a2x1 + b2x2 +c2x3 = -d2a3x1 + b3x2 +c3x3 = -d3 x1 = det1/det x2 = det2/det x3 = det3/detThe determinants can be calculated from this matrix|a1 b1 c1| |x1| |-d1||a2 b2 c2|*|x2|=|-d2||a3 b3 c3| |x3| |-d3|The -d is because you define you setup your planeequation as followsn(X-A) = 0n1x1+n2x2+n3x3 - n.dot(A) = n1x1+n2x2+n3x3+d=>n1x1+n2x2+n3x3=-dI start at the (top,right,near) vertex in clockwise order 1. the top vertices v[0-3], then the bottom vectices v[4-7]//top verticesv[0] = intersect(top,right,near)v[1] = intersect(top,left,near)v[2] = intersect(top,left,far)v[3] = intersect(top,right,far)//bottom verticesv[4] = intersect(bottom,right,near)v[5] = intersect(bottom,left,near)v[6] = intersect(bottom,left,far)v[7] = intersect(bottom,right,far)Now you got all 8 vertices and can draw the 6 sides of the light's frustrum with 6 QUADSglBegin(GL_QUADS);//topglVertex3fv(v[0]);glVertex3fv(v[1]);glVertex3fv(v[2]);glVertex3fv(v[3]);//rightglVertex3fv(v[0]);glVertex3fv(v[3]);glVertex3fv(v[7]);glVertex3fv(v[4]);//leftglVertex3fv(v[1]);glVertex3fv(v[5]);glVertex3fv(v[6]);glVertex3fv(v[2]);....glEnd();   