Archived

This topic is now archived and is closed to further replies.

Ronin

Polygon Testing

Recommended Posts

My Octree structure is nearly ready, but I have still a problem. I wrote this function for testing the polygons whether they are in the specific node or not. I know that this function is in work and not ready!!!!!! Ok the function takes three parameters: the first are the polygon vertices the second are the node box vertices. these two parameters should be tested against each other. If the polygon vertices are greater than the nodes one the polygon lies in the node.(Is that right?) the third parameter is for subdividing the node until it has the volume of the object/polygon etc. My question is whether my basic idea is right? void OCTREE::TestNode(float v[][3],float n[][3],float sub[][3]) { oTree.inNode=false; if(v[0][1]>=n[0][1]&&v[0][2]>=n[0][2]&&v[0][3]>=n[0][3]&& v[1][1]>=n[1][1]&&v[1][2]>=n[1][2]&&v[1][3]>=n[1][3]&& v[2][1]>=n[2][1]&&v[2][2]>=n[2][2]&&v[2][3]>=n[2][3]&& v[3][1]>=n[3][1]&&v[3][2]>=n[3][2]&&v[3][3]>=n[3][3]) { oTree.inNode=true; oTree.subdividePoly(sub,0,0,0); } }

Share this post


Link to post
Share on other sites
Hi !

If I grabbed the right code, this should be my test functions ;-)

Hope this is any helpful....

bool CNodeBoundingVolume::TriangleInsideBoundingVolume(Face *pFace)
{
////////////////////////////////////////////////////////////////////////
// Check if the passed face intersects with the bounding volume
////////////////////////////////////////////////////////////////////////

int i;

// Is the face a triangle ?
if (pFace->iNumVertices != 3)
return FALSE;

// Convert the passed face into a CTriangle class
CTriangle cTriangle;
memcpy(cTriangle.m_Vertices[0], pFace->pVertices, sizeof(float) * 9);

// Is a triangle vertex inside the bounding volume ?
for (i=0; i<3; i++)
// Check the vertex
if (PointInsideBoundingVolume(cTriangle.m_Vertices))
// Yes, the triangle is at least partially inside the bounding volume
return TRUE;

// Check the bounding volume triangles for an intersection
for (i=0; i<12; i++)
if (m_BoundingCube[i].CheckTriangleIntersection(&cTriangle))
// Yes, the triangle is at least partially inside the bounding volume
return TRUE;

// No intersection
return FALSE;
}

bool CNodeBoundingVolume:ointInsideBoundingVolume(float fPoint[])
{
////////////////////////////////////////////////////////////////////////
// Check if the passed point is inside the bounding volume
////////////////////////////////////////////////////////////////////////

int i;

// Check the distance to all planes of all cube sides
for (i=0; i<12; i+=2)
// Check distance to the plane
if (m_BoundingCube[i].GetInfinitePlaneDistance(fPoint) > 0.0f)
// On the wrong side of the plane, point is outside
return FALSE;

// Inside
return TRUE;
}


--------------------------
www.gamedev.net/hosted/glvelocity
glvelocity.gamedev.net
www.glvelocity.com

Share this post


Link to post
Share on other sites
I replied to the post, but it still says 0 replies.... maybe this helps...

--------------------------
www.gamedev.net/hosted/glvelocity
glvelocity.gamedev.net
www.glvelocity.com

Share this post


Link to post
Share on other sites
Hello tcs
The GetInfinitePlaneDistance is probably a function which Get the Distance from a point to a plane with the plane equation.(Or from a vertex to a plane)(Is that right). That means that the computer have to calculate each plane for each polygon.
Thanks for the code

Edited by - Ronin on June 19, 2000 6:16:58 AM

Share this post


Link to post
Share on other sites
GetInfinitePlaneDistance ? Download my lightmap triangle class !
It has everything you''ll need...

Tim

--------------------------
www.gamedev.net/hosted/glvelocity
glvelocity.gamedev.net
www.glvelocity.com

Share this post


Link to post
Share on other sites