Archived

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

Polygon Testing

This topic is 6606 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 on other sites
Hi !

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

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 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 on other sites
Lots of thanks. I''m on coding.

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 on other sites
It has everything you''ll need...

Tim

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

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 22
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631766
• Total Posts
3002218
×