PDA

View Full Version : clip plane problems - plane extraction

supagu
10-11-2004, 01:17 AM
okay, here's the new problem:

http://mathewstwins.customer.netspace.net.au/temp/leftPlane.JPG

the red line show where the left clip plane should be, as you can see the left plane is bent out left more.

i used the plane extraction from here:
http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf

i double checked these values, so im wondering if its my lights transform is screwey possibly?

just to show you (the right clip plane is correct):

// the following are plane extractions from matrices
// http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf
void ExtractLeft(Matrix4&amp; transform)
{
p[0] = transform[3] + transform[0];
p[1] = transform[7] + transform[4];
p[2] = transform[11] + transform[8];
p[3] = transform[15] + transform[12];
}

void ExtractRight(Matrix4&amp; transform)
{
p[0] = transform[3] - transform[0];
p[1] = transform[7] - transform[4];
p[2] = transform[11] - transform[8];
p[3] = transform[15] - transform[12];
}and this is how i setup my projective texture:

void ShadowLight::SetTextureProjection()
{
Camera&amp; camera = *Engine::GetInstance()->GetRenderMgr()->GetActiveCamera();

Matrix4 mBias(0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 0.494, 0.0, //offset bias so we dont need polygonfill offset
0.5, 0.5, 0.5, 1.0);

glMatrixMode(GL_TEXTURE);

mBias.Set();

gluPerspective(45.0f, 1.0f, 1.0f, 6.0f);

Matrix4 trans = GetTransform();
trans.SetM();

Matrix4 temp;
temp.LoadCurrent(GL_TEXTURE_MATRIX);
SetClipPlanes(temp);

Matrix4 cam = camera.GetTransform();
//cam.Inverse(); //Transpose();
cam[12] = 0;
cam[13] = 0;
cam[14] = 0;
cam.Transpose();

glTranslatef(camera.GetPosition()[0], camera.GetPosition()[1], camera.GetPosition()[2]);
cam.SetM();

glMatrixMode(GL_MODELVIEW);
}

void ShadowLight::SetClipPlanes(Matrix4&amp; transform)
{
// http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf

Plane left, right, top, bottom, farp, nearp;
left.ExtractLeft(transform);
right.ExtractRight(transform);
top.ExtractTop(transform);
bottom.ExtractBottom(transform);
farp.ExtractFar(transform);
nearp.ExtractNear(transform);

left.Normalize();
right.Normalize();
top.Normalize();
bottom.Normalize();
farp.Normalize();
nearp.Normalize();

left.BindClipPlane(1);
right.BindClipPlane(0);
top.BindClipPlane(2);
bottom.BindClipPlane(3);
farp.BindClipPlane(4);
nearp.BindClipPlane(5);
}

supagu
10-12-2004, 02:49 AM
hrmm, well is there any way to visualise a projection matrix?

i would assume the planes are generated out 1 unit from the center of the matrix using the negative axis of the matrix as the plane normal. but what about projective matrices? how to do visualise the bend? are the axis bent?