测绘波前.OBJ的VT OpenGL的纹理坐标纹理、坐标、OBJ、VT

2023-09-08 00:59:21 作者:追梦赤子心

一位艺术家朋友给我发了由3DS Max 2009的其中包含三个纹理坐标作为参数传递给 VT 命令导出的obj文件。而且,根据.OBJ规范是正确的。但是,我不知道如何映射提供了一个普通的2D的.jpg纹理UVW坐标。

an artist friend has sent me an .obj file exported by 3DS Max 2009 which contains three texture coordinates as parameters to the vt command. And that's correct according to .obj specification. However, I'm not sure how to map U-V-W coordinates that are provided for a regular 2D .jpg texture.

这对我来说是比较重要的,因为我已经打了3​​ds Max软件试图找出如何迫使其出口仅仅UV坐标,但似乎没有straightfoward方式。在这种情况下,这仅仅是一个天空盒,但在其他情况下,它可能是一个方式更复杂,不用手定影

This is relatively important for me, since I've played with 3DS Max trying to figure out how to force it to export just U-V coordinates, but there appears to be no straightfoward way. In this case this is just a skybox, but in other cases it might be something way more complex and not hand-fixable.

谢谢!

推荐答案

有文章什么是UVW ?映射解释:

您可能会问,为什么你需要一个   深度坐标像瓦二维   飞机。其中一个原因是因为它的   有时是有用的,以便能够翻转   一个地图的方向,相对于   其几何形状。要做到这一点,你需要的   第三个坐标。在W坐标   还具有用于3维意义   程序材质。

You might question why you need a depth coordinate like W for a 2D plane. One reason is because it's sometimes useful to be able to flip the orientation of a map, relative to its geometry. To do this, you need the third coordinate. The W coordinate also has a meaning for 3-dimensional procedural materials.

在你的情况,你可以简单地忽略在W协调和只读开头的 VT 行的前两个浮动。这是假设你不是很担心采取W上的额外空间的坐标,因为.OBJ是一个相当低效的文件格式开始。

In your case, you can simply ignore the W coordinate and only read the first two floats of lines that begin with vt. This assumes that you're not very worried about the extra space taken by the W coordinate since .obj is quite an inefficient file format to begin with.

我个人不喜欢使用.OBJ在OpenGL,因为它提供了每个面,而不是每个顶点顶点法线。光一个对象正常,你必须要么复制顶点或通过在平均脸周围的顶点法线计算法线。如果你想探索更有效的替代品,来看看二进制格式,如全面记录.md2格式。也可以考虑与glDrawElements使用,如果你不使用它了。

Personally I don't like using .obj in OpenGL because it provides vertex normals per face instead of per vertex. To light an object properly you must either duplicate vertices or calculate normals by averaging the surrounding vertex normals in a face. If you want to explore more efficient alternatives, take a look at binary formats, such as the thoroughly documented .md2 format. Also consider using glDrawElements if you're not utilizing it already.