2D Polygons

Started by
0 comments, last by Freeride Designs 24 years, 4 months ago
I'm programming in directX 7 and VB.
Does anyone know how to draw a texture inside a polygon.

Some other info on whether a point is within the polygon etc. would be helpful aswell

Thanks

----------------
Black Edge Games
----------------
Advertisement
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.

This topic is closed to new replies.

Advertisement