http://www.gamasutra.com/features/20000210/lander_01.htm
For those who are not registered:
Quote:
A better strategy is to divide the polygon into quadrants centered on the test point, as in Figure 4. Start at the first vertex in the polygon and set a counter to 0. Anytime an edge crosses from one quadrant to the next, add one to the counter if it crosses clockwise around the test point and subtract one if it crosses counter-clockwise. If the edge crosses diagonally across two quadrants, you need to determine which side of the test point it crossed, and then either add or subtract 2. Try it yourself on Figure 4. Start at vertex 1. Add 1 when edge 3-4 crosses from quadrant I to II, and subtract it again with edge 4-5. When you reach the last edge (11-1), you should have 4. When using the routine, if the counter is equal to 4 or –4, the test point is inside the polygon. You can see the code for this routine in Listing 1.
Well this is just perfect for me i think. But unfortunately i don't understand the following sentence:
Quote:
If the edge crosses diagonally across two quadrants, you need to determine which side of the test point it crossed, and then either add or subtract 2
determine which side? what is he talking about? left, right, up, down, diagonal? when do i have to add 2 and when to subtract 2?
Are there any other easy ways for 3D collision detection that are 100% accurate?