简体   繁体   English

obj文件中纹理坐标的含义是什么

[英]What's the Meaning of Texture Coordinate in obj Files

So here's the question: what do the values of texture coordinates represent? 所以这就是问题:纹理坐标的值代表什么? For example, in my obj file, texture coordinates look like these: 例如,在我的obj文件中,纹理坐标如下所示:

vt 0.474178 0.050139
vt 0.477308 0.050139
vt 0.480438 0.050139
vt 0.483568 0.050139

The size of my texture (bmp file) is 640*360. 我的纹理(bmp文件)的大小是640 * 360。 Does that mean (0.474178, 0.050139) in the obj file correspond to the (0.474178*640, 0.050139*360) point in the bmp file? 这是否意味着(0.474178,0.050139)在obj文件中对应于bmp文件中的(0.474178 * 640,0.050139 * 360)点? That is, texture coordinates indicate the point position in bmp file by doing: 也就是说,纹理坐标通过执行以下操作来指示bmp文件中的点位置:

 u*width_of_the_bmp,  v*height_of_the_bmp

And if I'm wrong, how can I get the corresponding correlation between vt and bmp point position? 如果我错了,我怎样才能获得vt和bmp点位置之间的相应关联? Because I want to get the RGB values for every vertex, and I can get the RGB values for every pixel in the bmp file, how to link these data together to get what I want? 因为我想获取每个顶点的RGB值,并且我可以获取bmp文件中每个像素的RGB值,如何将这些数据链接在一起以获得我想要的?

That is correct. 那是对的。

Usually , texture coordinate 0,0 is pixel coordinate 0,0, and texture coordinate 1,1 is the opposite corner. 通常 ,纹理坐标0,0是像素坐标0,0,纹理坐标1,1是对角。 Texture coordinates greater than 1 wrap around the texture, so if you go from 0,0 to 2,0, you go around the texture twice. 大于1的纹理坐标环绕纹理,因此如果从0,0到2.0,则会绕纹理两次。

Of course, some programs might interpret them differently. 当然,有些程序可能会以不同方式解释它们。 There's no rule that it must be this way, but it usually is the case. 没有规则必须是这种方式,但通常情况就是如此。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM