當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。