简体   繁体   English

搅拌器可以导出每个顶点的 UV 坐标吗?

[英]can blender export per vertex UV coordinates?

Is it possible to write an exporter for Blender that exports the meshes UV texture coordinates on a per vertex level aposed to the standard UVs from faces?是否可以为 Blender 编写一个导出器,将每个顶点级别上的网格 UV 纹理坐标导出到面的标准 UV?

I'm not really a python person and have only been using it for two days, but I've managed to write a simple mesh exporter for Android... I'm able to export the Vertices and indices to arrays, but I can't get the UVs to export in the same fashion... I can only get them in relation to face vertices which isn't overly helpful....我不是真正的 Python 人,只使用了两天,但我已经设法为 Android 编写了一个简单的网格导出器......我能够将顶点和索引导出到数组,但我可以不让 UV 以相同的方式导出......我只能让它们与面部顶点相关,这并没有太大帮助......

I'm not really sure how to post the python code because of the formatting, but here is the part where I grab all the information and place it into arrays:由于格式的原因,我不确定如何发布 python 代码,但这是我获取所有信息并将其放入数组的部分:

    obverts = bpy.context.active_object.data.vertices
    obfaces = bpy.context.active_object.data.faces
    verts = []
    indices = []
    tex = []

    for vertex in obverts:
        verts.append(vertex.co.x)
        verts.append(vertex.co.y)
        verts.append(vertex.co.z)

    for face in obfaces:
        indices.append(face.vertices[0])
        indices.append(face.vertices[1])
        indices.append(face.vertices[2])
        face_index = face.index
        for u,v in bpy.context.active_object.data.uv_textures.active.data[ face_index ].uv:
            tex.append(u)
            tex.append(v)

Now that all works fine, except the last four lines that get the UV coordinates... This is where it gets the UVs from the faces... but how can I get the UVs in relation to the data.vertices?现在一切正常,除了获得 UV 坐标的最后四行......这是它从面获取 UV 的地方......但是我怎样才能获得与 data.vertices 相关的 UV? I read something about "sticky uv coordinates" but I can't find the option on my version of Blender.我阅读了一些关于“粘性 uv 坐标”的内容,但在我的 Blender 版本中找不到该选项。 I'm using Blender 2.57 and have spent all day trying to find the answer, so if anyone could help;我正在使用 Blender 2.57 并且花了一整天的时间试图找到答案,所以如果有人可以提供帮助; I'd be very thankful.我会很感激。

I'm able to export the Vertices and indices to arrays, but I can't get the UVs to export in the same fashion... I can only get them in relation to face vertices which isn't overly helpful....我能够将顶点和索引导出到数组,但我无法以相同的方式导出 UV……我只能将它们与面部顶点相关联,这并不太有用……

UVs will have to be in relation to faces because each vertex might have a different uv for each polygon it's part of. UV 必须与面相关,因为每个顶点对于它所属的每个多边形可能具有不同的 uv。

For example think of a cube that has a different texture on each face.例如,想象一个立方体,每个面上都有不同的纹理。 A vertex will be the top left on one face, and the top right of the face next to it.顶点将在一个面的左上角和旁边面的右上角。

you can export UV per vertex, if you separate all faces of the object.如果将对象的所有面分开,则可以按顶点导出 UV。

(yes this will duplicate vertices used by two or more faces) (是的,这将复制两个或多个面使用的顶点)


goto edit mode转到编辑模式

mark all edges as sharp将所有边缘标记为锐利


goto object mode转到对象模式

assign and apply the "edge split" modifier分配并应用“边缘分割”修饰符


now all faces use unique verts and edges,现在所有的面都使用独特的顶点和边缘,

thus each vertex has its own single UV coord因此每个顶点都有自己的单个 UV 坐标

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

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