当前位置: 首页>>代码示例>>Python>>正文


Python BPyMesh.facesUvIslands方法代码示例

本文整理汇总了Python中BPyMesh.facesUvIslands方法的典型用法代码示例。如果您正苦于以下问题:Python BPyMesh.facesUvIslands方法的具体用法?Python BPyMesh.facesUvIslands怎么用?Python BPyMesh.facesUvIslands使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BPyMesh的用法示例。


在下文中一共展示了BPyMesh.facesUvIslands方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: my_mesh_util

# 需要导入模块: import BPyMesh [as 别名]
# 或者: from BPyMesh import facesUvIslands [as 别名]
def my_mesh_util(me):
    # Examples
    S = Mesh.EdgeFlags.SEAM
    edges_seam = set([ed.key for ed in me.edges if ed.flag & S])

    # make an edges_seam
    ed_face_count = {}
    for f in me.faces:
        if not f.hide:  # ignore seams next to hidden faces
            for edkey in f.edge_keys:
                try:
                    ed_face_count[edkey] += 1
                except:
                    ed_face_count[edkey] = 1

                # remove all single edge faces (or on the bounds of a hidden face) from edges_seam to make edges_seam_island - this means
    edges_seam = edges_seam.difference(set([edkey for edkey, eduser in ed_face_count.iteritems() if eduser == 1]))

    uv_key_vec_dict = {}
    uv_connect_dict = {}
    uv_seamconnect_dict = {}

    face_uv_islands = BPyMesh.facesUvIslands(me)
    print len(face_uv_islands), "islands"

    for face_uv_island in face_uv_islands:
        face_uv_island[:] = [f for f in face_uv_island if f.sel]

    face_uv_islands = [face_uv_island for face_uv_island in face_uv_islands if face_uv_island]

    print "totislands =-= ", len(face_uv_islands)

    for face_uv_island in face_uv_islands:

        # For every island!
        for f in face_uv_island:

            vs = f.v
            uv = f.uv
            uv_keys = [tuple(v) for v in uv]
            fkeys = f.edge_keys

            if len(vs) == 3:
                f.uvSel = (0, 0, 0)
                pairs = (0, 1), (1, 2), (2, 0)
            else:
                f.uvSel = (0, 0, 0, 0)
                pairs = (0, 1), (1, 2), (2, 3), (3, 0)

            for i, i_other in pairs:

                # first add to global uvconnect dict.
                # Add all other UVs - for connectivity
                uvk1 = uv_keys[i]
                st = uv_connect_dict.setdefault(uvk1, set())
                st.update([uv_keys[j] for j in xrange(len(f)) if j != i])

                # This dict maps uv keys to a list of face uvs
                ls = uv_key_vec_dict.setdefault(uvk1, [])
                ls.append(uv[i])

                if fkeys[i] in edges_seam:  # This is a seam
                    uvk2 = uv_keys[i_other]

                    ls = uv_seamconnect_dict.setdefault(uvk1, [])
                    if uvk2 not in ls:
                        ls.append(uvk2)

                    ls = uv_seamconnect_dict.setdefault(uvk2, [])
                    if uvk1 not in ls:
                        ls.append(uvk1)

                    # Find UV strips!!!

        def next_uv(uv_ls, uv_prev):
            if len(uv_ls) == 2:
                if uv_ls[0] == uv_prev:
                    return uv_ls[1]
                elif uv_ls[1] == uv_prev:
                    return uv_ls[0]

        uv_strips = []

        for uv_key, uv_brothers in uv_seamconnect_dict.iteritems():
            # print len(uv_brothers), uv_brothers
            if len(uv_brothers) == 1:
                # print "ONE BRO"
                uvlist = [uv_key, uv_brothers[0]]
                uv_brothers[:] = []  # INVALIDATE
                uv_strips.append(uvlist)
                while True:
                    uv_next_bro = uv_seamconnect_dict[uvlist[-1]]
                    if len(uv_next_bro) != 2:
                        uv_next_bro[:] = []  # INVALIDATE
                        break

                    uv_key = next_uv(uv_next_bro, uvlist[-2])

                    # if uv_key==None:
                    # 	return
#.........这里部分代码省略.........
开发者ID:ProductosDavid,项目名称:PapelyLapiz,代码行数:103,代码来源:uv_seam_pin.py


注:本文中的BPyMesh.facesUvIslands方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。