将图像映射到不规则多边形?
假设用户点击 iPhone 上的 4 个点,定义一个不规则的 4 边多边形(在 2d 空间中)。有没有一种方法可以在不使用 OpenGL 的情况下将(可能高度扭曲的)图像映射/拟合到该形状上?
类似于:
是我以某种方式计算我的不规则 4 边形状所在的 3d 空间的唯一选择(基于位置)点击的 2d 点坐),在该空间中创建一个 OpenGL 平面,并将我的纹理平坦地映射到它?似乎应该有一种更简单的方法...
提前致谢。
更新:深入了解 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:
Is my only option to somehow calculate the 3d space that my irregular 4 sided shape sits in (based on where the tapped 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:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法完全回答你的问题,但我要说的一件事是,你不需要考虑任何到 3D 的转换/映射。使用 OpenGL,您可以轻松地绘制 2D 形状并根据需要映射纹理。不需要任何花哨的数学或转换。这并不比画一个矩形更复杂。 OpenGL 并不关心你的 4 边形状实际上不是矩形。
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.