fast ray/triangle intersection test
I want to have a fast ray/triangle intersection test alogrithm. I just have a ray start/end vertex and three triangle vertices and want to know if the ray intersects with the triangle, no uv coords needed. Speed is very important.
Any ideas ???
Tim
Hi there,
find the intersection point with the plane the triangle lies in. Then do a point in polygon test. That is the most used method.
For speeds sake precalculate the triangleplane. And if you wanna go really fast then precalculate the edge planes as well (planes that are perpendicular to the triangle going trough the edge, which are often used for point in poly tests).
Jaap Suter
find the intersection point with the plane the triangle lies in. Then do a point in polygon test. That is the most used method.
For speeds sake precalculate the triangleplane. And if you wanna go really fast then precalculate the edge planes as well (planes that are perpendicular to the triangle going trough the edge, which are often used for point in poly tests).
Jaap Suter
Hi !!
The method described above is ok. I have found another algo which can be found here:
http://www.acm.org/jgt/papers/MollerTrumbore97/
Have fun.
Phillip
The method described above is ok. I have found another algo which can be found here:
http://www.acm.org/jgt/papers/MollerTrumbore97/
Have fun.
Phillip
Yeah I know. But may (light) ray has, it ends on the wall ;-))))
Jaap Suter:
I know the tutorial on flipcode. But the stuff with the anti-planes doesn''t work if you use the alog for lightmap calculation. The start/end point of the light ray may be outside the collision box, but still cross the triangle. To make sure that this don''t happens, the anti-planes of the collsion box must be calculated trough adding the ray''s vector, rather than adding the plane normal. This is slow, you need 3 square roots for each intersection test since you have to recalculate your anti-plane normal....
any idea how to avoid this ????
Jaap Suter:
I know the tutorial on flipcode. But the stuff with the anti-planes doesn''t work if you use the alog for lightmap calculation. The start/end point of the light ray may be outside the collision box, but still cross the triangle. To make sure that this don''t happens, the anti-planes of the collsion box must be calculated trough adding the ray''s vector, rather than adding the plane normal. This is slow, you need 3 square roots for each intersection test since you have to recalculate your anti-plane normal....
any idea how to avoid this ????
http://www.acm.org/jgt/papers/MollerTrumbore97/
can''t get this working. The code seems to be somehow wrong !? Just look at the first macro, the author forgot a "\" this code can''t compile, I guess the writer of this document never compiled it !?
can''t get this working. The code seems to be somehow wrong !? Just look at the first macro, the author forgot a "\" this code can''t compile, I guess the writer of this document never compiled it !?
Hi Tcs (and others).
The method I mentioned does work but you probably think I mention another method then I did (that must be the worst sentence I ever wrote in a foreign language).
What I always do is calculating the intersection of the ray and the plane (the plane of the polygon I mean). And then I do a point in polygon test. This point in polygontest is done using the edgeplanes (or antiplanes as you call them). This has always worked for me and I couldn''t see why this wouldn''t work.
or.. ?
Jaap
The method I mentioned does work but you probably think I mention another method then I did (that must be the worst sentence I ever wrote in a foreign language).
What I always do is calculating the intersection of the ray and the plane (the plane of the polygon I mean). And then I do a point in polygon test. This point in polygontest is done using the edgeplanes (or antiplanes as you call them). This has always worked for me and I couldn''t see why this wouldn''t work.
or.. ?
Jaap
I was under the impression that after finding the intersection point on the plane it''s faster to figure the angles between the vertices and the point, add em, and see if they add to 180 degrees or not. :?
The problem is that calculating the angle takes a squareroot unless your vectors are normalized. And with the point in poly test with angles your vectors are never normalized. And these can''t be precalculated either (edge (or anti-) planes can).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement