Posted 21 December 1999 - 11:29 AM
I really don't know how to draw a texture inside a polygon. But if you want to know about point containment, there are a number of ways to approach the problem, but one of the most straightforward is the half-space test. Basically, if the polygon you're testing is convex, you can think of each side as a segment that is colinear with an infinite plane. Each plane divides space into two half spaces. If the point you're testing is on the interior side of each half-space, the point must be within the polygon because of the convex property of the polygon. Thus, all you need to do is figure out a way to test if a point in 2D space is on one side of a line or the other. This isn't too bad, assuming that you label the lines in some order and convert them to vectors. Then you'll think of each of the line segments as a plane. Using the dot product operator, you can determine if a point is on either side of each plane or on the plane itself. This is the basis of the algorithm.