Blender:bmesh uv-coordinates bug?

时间:2017-06-05 20:23:27

标签: python blender

我在blender-python中编写了一个函数,该函数应该从bmesh uv层搜索两个循环,这些循环应该既没有相同的u也没有v坐标。他们也应该是同一张脸。然而,它无法正常工作,并且代码在两者之间产生奇怪的输出,这可以通过打印命令的输出进一步向下看。 print(loop1[uv_layer].uv)命令输出正确但如果我用print(loop1[uv_layer].uv[1])打印出各个值,则输出错误。

感谢您的帮助!

def get_different_uv_loops(bm):

loop1 = None
loop2 = None

for f in bm.faces:
    if loop2 is None:
        # set start loop
        for start_loop in f.loops:
            if loop2 is None:
                loop1 = start_loop

                # compare start loop uvs against other loop uvs from face
                for l in f.loops:
                    if loop2 is None:
                        # is u and v of compared loop different from start loop u and v?
                        if loop1[uv_layer].uv[0] != l[uv_layer].uv[0] and \
                            loop1[uv_layer].uv[1] != l[uv_layer].uv[1]:

                            print(loop1[uv_layer].uv[0])
                            print(loop1[uv_layer].uv[1])
                            print(l[uv_layer].uv[0])
                            print(l[uv_layer].uv[1])

                            loop2 = l
                            face = f 

                            print(loop1[uv_layer].uv)
                            print(loop2[uv_layer].uv)
                    else:
                        break
            else:
                break
    else:
        break

return (loop1, loop2, face)

输出:

0.5
1.490115550950577e-07
1.0
0.5 
<Vector (0.5000, 0.000)>
<Vector (1.0000, 0.000)>

0 个答案:

没有答案