• Advertisement
Sign in to follow this  

Perform intersection between a ray and a triangle

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Here is another problem that has showed up in short time. I am trying to find where a rline is intersecting a triangle side that is a part of the 3D prism in XNA that I have mentioned about in previous threads. I am using this algorithm which I found in a blog, since the previous intersecting algorithm I used before might not worked correctly:


This is how I use the RayIntersectTriangle-function during the update call:

curr3DPos += 0.005f * line3DDir;
pointPreList.SetValue(new VertexPositionColor(line3DStartPos + curr3DPos, Color.Brown), 0);
pointPreList.SetValue(new VertexPositionColor(line3DEndPos + curr3DPos, Color.Brown), 1);

if (RayIntersectTriangle(line3DEndPos + curr3DPos, line3DDir, prismData[0].Position,
prismData[1].Position, prismData[2].Position, ref pickDistance,
ref barycentricU, ref barycentricV))

where line3DEndPos + curr3DPos is the current end position of the line, line3DDir is the ray direction and prismData[0,1,2].Position are the positions of the triangle sides vertices. The problem is that it won´t detect the intersection when the end of the line is hitting the triangle.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement