Jump to content

  • Log In with Google      Sign In   
  • Create Account

Point in poly test


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 Ake   Members   -  Reputation: 122

Like
Likes
Like

Posted 05 November 1999 - 06:15 AM

Hi,

I'm trying to write a point in poly function for my lightmap creator.
Before I used a 2d point-in-poly test, but I want to use planes instead.
I tried this:

code:

int CPoly::GetPointInPoly(CVector p)
{
CVector v1, v2, cNormal, tmp;
CPlane plane;

cNormal = GetNormal( NULL );

for(int i = 0; i < m_iNumVertices; i++)
{
v1 = m_pPolyVert->m_pVertices[ m_iVertices[i] ].cCoord;
tmp = cNormal.Crossproduct( v1 );
tmp.Normalize();
plane.m_cNormal = tmp;
plane.m_fDistance = - ( tmp.Dotproduct( p ) );
if( plane.m_fDistance < 0 )
plane.m_cNormal.Invert();
if( plane.PlaneSide( p ) < 0)
return 0;
}
return 1;
}



But that doesn't work at all

Greets Tobias


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS