Pages: 2
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
when perform the same edge test point

When perform the same edge test point

larger than zero) then the point is in front of the plane. As soon as this happens for any edge we know the point is not contained inside the polygon and we can exit.

Figure 12.23 demonstrates testing to see if

// Phase One : Test if Ray intersects polygon’s plane
// Calculate Distance to polygons plane using first vertex as point on plane float PlaneDistance = D3DXVec3Dot( &(Origin – Polygon.VertexList[0]), &Polygon.Normal );

// Calculate Projected Ray Length onto polygons plane normal float ProjRayLength = D3DXVec3Dot( &Direction, &-Polygon.Normal );

// Calculate t
t = PlaneDistance / ProjRayLength ;

// Plane is either before the start of the ray or past the end of the ray so // not intersection
if ( t < 0.0f || t > 1.0f ) return false;

// Generate plane normal
D3DXVec3Cross ( &EdgeNormal, &EdgeVector , &pPoly->m_vecNormal);

//Create vector from point to vertex ( point on plane ) Direction = FirstVertex-IntersectionPoint;


Most often in 3D graphics we are dealing with triangles and not with N-gons. The point in polygon test can be optimized somewhat when being used specifically for “Point in Triangle” tests because we can unwind the loop and lose a bit of overhead. The following snippet of code shows how we might write a function called PointInTriangle whose code could also be substituted into the function shown above to create a RayIntersectTriangle method.

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File

Uploaded by : Marie Castillo

PageId: ELIE37668F