开发者

Map image to irregular polygon?

开发者 https://www.devze.com 2023-02-06 19:08 出处:网络
Say the user taps 4 spots on the iphone, defining an irregular 4 sided polygon (in 2d space).Is there a way to map/fit a (potentially highly distorted) image onto this shape, without using OpenGL?

Say the user taps 4 spots on the iphone, defining an irregular 4 sided polygon (in 2d space). Is there a way to map/fit a (potentially highly distorted) image onto this shape, without using OpenGL?

Something like:

Map image to irregular polygon?

Is my only option to somehow calculate the 3d space that my irregular 4 sided shape sits in (based on where the tapp开发者_C百科ed 2d points sit), create an OpenGL plane in that space, and map my texture to it flatly? Seems like there should be an easier way...

Thanks in advance.

Update: After diving into OpenGL I'm almost there... but I still can't get the texture to distort correctly. The triangulation seems to be messing with the texture mapping:

Map image to irregular polygon?


I can't answer your question completely, but one thing I would say is that you don't need to think about any conversion / mapping to 3D. Using OpenGL you can easily draw the shape in 2D and have the texture mapped as you desire. No need for any fancy maths or conversions. It's no more complicated than drawing a rectangle. OpenGL doesn't care that your 4-sided shape isn't actually rectangular.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号