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 ].cCoord;<BR> tmp = cNormal.Crossproduct( v1 );<BR> tmp.Normalize();<BR> plane.m_cNormal = tmp;<BR> plane.m_fDistance = - ( tmp.Dotproduct( p ) );<BR> if( plane.m_fDistance < 0 )<BR> plane.m_cNormal.Invert();<BR> if( plane.PlaneSide( p ) < 0) <BR> return 0;<BR> }<BR> return 1;<BR>}<BR></pre><HR></BLOCKQUOTE><BR>But that doesn't work at all <IMG SRC="http://www.gamedev.net/community/forums/ubb/frown.gif"><P>Greets Tobias