I am writing a Ray Caster in Java and I have everything working (A can cast the ray and accurately record line-plane intersection). The only thing that I have yet to implement is detecting the first intersection (Not the first tested intersection). So if I click on a plane, but that plane has another plane directly behind it, and that plane is being tested first, how can I detect that I clicked the first plane, and not the one behind it?
Asked
Active
Viewed 60 times
1 Answers
0
Do a ray-plane intersection test for all the planes. Use the intersection result, i.e. the coordinate of the intersection (if any) along the ray, to order the planes along the ray (from lowest coordinate to highest). The first plane (the one with the lowest coordinate) is then the closest one.

user3146587
- 4,250
- 1
- 16
- 25
-
Order them how? Lowest values? – zfollette Jan 26 '14 at 21:59
-
@Error, the coordinate of the intersection along the ray indicates how far from the ray origin the plane is located. So the plane with the lowest (positive) coordinate is the closest one. – user3146587 Jan 26 '14 at 22:24