Jump to content
  • Advertisement
Sign in to follow this  
LoPing

Texture Maps / Coordinate Systems

This topic is 4863 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've got a problem I've been racking my brain over and I can't seem to figure it out. Say I have a polygon, and it's on a plane, and it has 4 vertices. Now, I have a texture as well. Now, I know already how to map a texture to the polygon itself. However, what I want to do is map it the other way around. Basically, if I click on a texture pixel, I want to know what the approximate point within the polygon that texture pixel will be applied to. Or simply put another way, I want to map the coordinates of the polygon to the texture. The situation looks like this: Non-rectangle 4 vertex Polygon P: (x1,y1) ....... (x2,y2) . . . . . . . . (x4,y4) ............ (x5,y5) Texture T: (where width and height are in pixels and px & py is an arbitrary point) 1000 p . . . . . . . . . . . . .(px,py) . 500 p . . . . . . . . . . . So the idea is how can you figure out which coordinate pair on Polygon P do pixels px & py on the texture correspond to.

Share this post


Link to post
Share on other sites
Advertisement
It's not quite the right approach for finding points within a polygon, but I think your not after that exactly. What sounds to be the right thing to research are the various interpolation methods - especially bilinear. Based on what you descibe as wanting to do, I think bilinear interpolation would help find a point within your polygon (assuming the 4 vertices are on the same plane), which you can then use to calculate the appropriate pixel of your texture... if I am following you that is :-) There were some recent topics on interpolation methods, so you should get some quick ideas from doing a search of reading back through the threads here.

Sorry I can't be of more help. Perhaps things will become clearer as the dialogue/thread continues.

hth
F451

Share this post


Link to post
Share on other sites
Quote:
Original post by Fahrenheit451
It's not quite the right approach for finding points within a polygon, but I think your not after that exactly. What sounds to be the right thing to research are the various interpolation methods - especially bilinear. Based on what you descibe as wanting to do, I think bilinear interpolation would help find a point within your polygon (assuming the 4 vertices are on the same plane), which you can then use to calculate the appropriate pixel of your texture... if I am following you that is :-) There were some recent topics on interpolation methods, so you should get some quick ideas from doing a search of reading back through the threads here.

Sorry I can't be of more help. Perhaps things will become clearer as the dialogue/thread continues.

hth
F451



Thank you for responding. I was looking into different interpolation methods, including anisotropic filters. I guess my issue is sort of like texture mapping in reverse, i'm mapping a polygon to a texture. Anyhow I suppose I'll just keep on searching and thinking about it, thanks again for the reply!


Share this post


Link to post
Share on other sites
I fixed up your ASCII diagrams. You can use the < pre > < /pre > tags.

Non-rectangle 4 vertex Polygon P:

(x1,y1) ....... (x2,y2)
. .
. .
. .
. .
(x4,y4) ............ (x5,y5)


Texture T: (where width and height are in pixels and px & py is an arbitrary point)

1000 p
. . . . . . . . .
. .
. .(px,py) . 500 p
. .
. . . . . . . . .

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by James Trotter
I fixed up your ASCII diagrams. You can use the < pre > < /pre > tags.

Non-rectangle 4 vertex Polygon P:

(x1,y1) ....... (x2,y2)
. .
. .
. .
. .
(x4,y4) ............ (x5,y5)


Texture T: (where width and height are in pixels and px & py is an arbitrary point)

1000 p
. . . . . . . . .
. .
. .(px,py) . 500 p
. .
. . . . . . . . .


Thank you :)

Share this post


Link to post
Share on other sites
Quote:
Original post by James Trotter
I fixed up your ASCII diagrams. You can use the < pre > < /pre > tags.

Non-rectangle 4 vertex Polygon P:

(x1,y1) ....... (x2,y2)
. .
. .
. .
. .
(x4,y4) ............ (x5,y5)


Texture T: (where width and height are in pixels and px & py is an arbitrary point)

1000 p
. . . . . . . . .
. .
. .(px,py) . 500 p
. .
. . . . . . . . .


Thank you :)

Share this post


Link to post
Share on other sites
Thanks for the help all, I figured out a solution. It involved backsolving using least squares, and it works pretty well. Hopefully that will be a clue for anyone trying to figure out something similar in the future!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!