> I've been working on my viewport culling and I just wanted to test
something
> out
> I was wondering if anyone could tell me how to render a portion of a plane
> around
> a particular point using the
> Normal + distance version of a plane...
This code will create a huge quad liying on a plane.
In your case - you can create such a quad for each frustum plane and
clip it to the other frustum planes.
int maxaxis=0, a2, a3;
for( int i=1; i<3; i++ )
if( fabs(P.Normal[i]) > fabs(P.Normal[maxaxis]) )
maxaxis=i;
switch( maxaxis )
{
case 0: a2=1; a3=2;
break;
case 1: a2=0; a3=2;
break;
case 2: a2=1; a3=0;
break;
}
Verts[0][a2] = Verts[0][a3] = Verts[1][a2] = Verts[3][a3] = LEVEL_BOX_SIZE;
Verts[1][a3] = Verts[2][a2] = Verts[2][a3] = Verts[3][a2]
= -LEVEL_BOX_SIZE;
Verts[0][maxaxis]= ( P.D - P.Normal[a2] * LEVEL_BOX_SIZE - P.Normal[a3] *
LEVEL_BOX_SIZE )/P.Normal[maxaxis];
Verts[1][maxaxis]= ( P.D - P.Normal[a2] * LEVEL_BOX_SIZE + P.Normal[a3] *
LEVEL_BOX_SIZE )/P.Normal[maxaxis];
Verts[2][maxaxis]= ( P.D + P.Normal[a2] * LEVEL_BOX_SIZE + P.Normal[a3] *
LEVEL_BOX_SIZE )/P.Normal[maxaxis];
Verts[3][maxaxis]= ( P.D + P.Normal[a2] * LEVEL_BOX_SIZE - P.Normal[a3] *
LEVEL_BOX_SIZE )/P.Normal[maxaxis];
|