Jump to content
  • Advertisement


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


Texture coordinates and Lightmaps

This topic is 6650 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 know how to calculate texture coordinates and lightmaps for quads (using the 2 edge vectors). But know I need to calculate them for n-sided polygons. All I need to know is the two vectors describing the smallest rectangle that contains the poly. Any suggestions?

Share this post

Link to post
Share on other sites

People tend to use axis aligned bounding boxes for this. First you take your polygon and determine the major axis. This is done by looking at the x, y, z components and determining the maximum absolute(!!) value, so for the polygon normal <1, 2, -3>, the major axis would be Z. That means the polygon is facing mostly towards the Z axis. Then you create a bounding box with the values of the other dimensions. Using the bounding box and the plane equation of the polygon, you can solve for the axis vectors ... Oh, the math is kinda hard to describe in this context, so I just redirect you to this site


the tutorial is pretty neat and covers the basics. He also addresses your problems, calculating the axis vectors (right below the picture with the green quad). Sorry, I had to redirect you, but I didn''t feel like rewriting all this information.

- MK42

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!