Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Freeride Designs

2D Polygons

This topic is 6787 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!