Original Post
I am having problem with finding point in polygon test. I can generate the BSP tree properly. and donn't know exectly how to check polygon intersection point etc. 1) I don't see anything in lineOfSight() testing if the intersection point is inside the polygon. I think that if the intersection point is inside the polygon, lineOfSight() should return true so the camera is not allowed to pass through the polygon. The logic i am working is something like this: code from lineofsight() function.
[source lang ="cpp"]
if( Node->bIsLeaf)
return false;
int PointA = classifyPoint(Start, Node->Splitter);
int PointB = classifyPoint(End, Node->Splitter);
// Check if only in front or on polygon.
if( PointA != POINTPOSITION_BACK && PointB != POINTPOSITION_BACK )
return lineOfSight(Start,End,Node->Front);
// Check if only in back.
if( PointA != POINTPOSITION_FRONT && PointB != POINTPOSITION_FRONT )
return lineOfSight(Start,End,Node->Back);
// Crossing polygon, need intersection point.
getIntersect( Start, End, (D3DXVECTOR3 *)&Node->Splitter->VertexList[0], &Node->Splitter->Normal, &intersection, &temp);
if( PointA == POINTPOSITION_FRONT )
{
// Crossing from front to back.
return lineOfSight( Start, &intersection, Node->Front ) ||
// Don't allow crossing polygon from front to back.
// pointInPolygon() to be implemented.
pointInPolygon( &intersection, (D3DXVECTOR3 *)&Node->Splitter->VertexList[0],
&Node->Splitter->Normal ) || lineOfSight( &intersection, End, Node->Back );
}
else
{
// Crossing from back to front.
return lineOfSight( Start, &intersection, Node->Back ) ||
lineOfSight( &intersection, End, Node->Front );
}