纹理贴图的多边形? [英] Texture mapping an NGon?

查看:127
本文介绍了纹理贴图的多边形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何去搞清楚如何映射为一个二维多边形纹理cooridnates(N边形)如何才能做到这一点?

I'm not sure how to go about figuring out how to map texture cooridnates for a 2D NGon (N sided polygon) How can this be done?

我想要达到的效果是纹理以适合多边形,并相应地伸出使整机质感上它适合。

The effect i'm trying to achieve is for the texture to fit on the polygon and stretch out accordingly so the whole texture fits on it.

感谢

推荐答案

请记住,在OpenGL渲染一个口岸时,它只是一大堆三角形。此外,你采取一些形状,并试图将其映射到一个矩形,所以你必须非常关键的,你想如何做到这一点,因为许多不同的映射从任何形状去一个长方形的质感。

Remember that when rendering an ngon in OpenGL, it's just a whole bunch of triangles. Also, you're taking some shape and trying to map it to a rectangle, so you have to be extremely critical of how you wish to do this as there many different mappings going from any shape to a rectangular texture.

例如,如果我有一个5边形的形状像在角落两者之间的一个点一个正方形,可以很容易地映射到纹理。当我拉点了怎么办?不要纹理坐标,当我走动顶点变化?

For example, if I have a 5-gon that is shaped like a square with a point in between two corners, it's easy to map to a texture. What happens when I pull that point out? Do the texture coordinates change when I move vertices around?

要做到这一点的方法之一是在新口岸的圆周映射到矩形,其中距离从顶点行进到顶点的口岸的圆周被映射到的UV围绕纹理的圆周坐标。例如,在它周围的方式1/4,给它的UV坐标(1,0),在围绕口岸中途,给顶点的(1,1)和3/4的方式的UV坐标围绕它,给它的UV(0,1) - 你需要点之间进行插值,当然,因为一个口岸将不是每个顶点完美地排队。

One way to do it is to map the circumference of the ngon to the circumference of the rectangle, where the distance traveled from vertex to vertex on the ngon is mapped to a UV coordinate around the circumference of the texture. For example, at 1/4 of the way around it, give it a UV coordinate of (1,0), at half way around the ngon, give the vertex a UV coordinate of (1,1) and 3/4 the way around it, give it a UV of (0,1)--you'll need to interpolate between points, of course, since an ngon won't line up perfectly at every vertex.

这篇关于纹理贴图的多边形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆