本文整理汇总了Python中BPyMesh.list2MeshWeight方法的典型用法代码示例。如果您正苦于以下问题:Python BPyMesh.list2MeshWeight方法的具体用法?Python BPyMesh.list2MeshWeight怎么用?Python BPyMesh.list2MeshWeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPyMesh
的用法示例。
在下文中一共展示了BPyMesh.list2MeshWeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: redux
# 需要导入模块: import BPyMesh [as 别名]
# 或者: from BPyMesh import list2MeshWeight [as 别名]
#.........这里部分代码省略.........
# Chech if we have collapsed our quota.
collapse_count-=1
if not collapse_count:
break
current_face_count -= len(ced.faces)
# Find and assign the real weights based on collapse loc.
# Find the weights from the collapse error
if DO_WEIGHTS or DO_UV or DO_VCOL:
i1, i2= ced.key
# Dont use these weights since they may not have been used to make the collapse loc.
#w1= vert_weights[i1]
#w2= vert_weights[i2]
w1= (ced.v2.co-ced.collapse_loc).length
w2= (ced.v1.co-ced.collapse_loc).length
# Normalize weights
wscale= w1+w2
if not wscale: # no scale?
w1=w2= 0.5
else:
w1/= wscale
w2/= wscale
# Interpolate the bone weights.
if DO_WEIGHTS:
# add verts vgroups to eachother
wl1= vWeightList[i1] # v1 weight dict
wl2= vWeightList[i2] # v2 weight dict
for group_index in xrange(len_vgroups):
wl1[group_index]= wl2[group_index]= (wl1[group_index]*w1) + (wl2[group_index]*w2)
# Done finding weights.
if DO_UV or DO_VCOL:
# Handel UV's and vert Colors!
for v, my_weight, other_weight, edge_my_uvs, edge_other_uvs, edge_my_cols, edge_other_cols in (\
(ced.v1, w1, w2, ced.uv1, ced.uv2, ced.col1, ced.col2),\
(ced.v2, w2, w1, ced.uv2, ced.uv1, ced.col2, ced.col1)\
):
uvs_mixed= [ uv_key_mix(edge_my_uvs[iii], edge_other_uvs[iii], my_weight, other_weight) for iii in xrange(len(edge_my_uvs)) ]
cols_mixed= [ col_key_mix(edge_my_cols[iii], edge_other_cols[iii], my_weight, other_weight) for iii in xrange(len(edge_my_cols)) ]
for face_vert_index, cfa in vert_face_users[v.index]:
if len(cfa.verts)==3 and cfa not in ced.faces: # if the face is apart of this edge then dont bother finding the uvs since the face will be removed anyway.
if DO_UV:
# UV COORDS
uvk= cfa.orig_uv[face_vert_index]
try:
tex_index= edge_my_uvs.index(uvk)
except:
tex_index= None
""" # DEBUG!
if DEBUG:
print 'not found', uvk, 'in', edge_my_uvs, 'ed index', ii, '\nwhat about', edge_other_uvs
"""
if tex_index != None: # This face uses a uv in the collapsing face. - do a merge
other_uv= edge_other_uvs[tex_index]
uv_vec= cfa.uv[face_vert_index]
uv_vec.x, uv_vec.y= uvs_mixed[tex_index]
# TEXFACE COLORS
if DO_VCOL:
colk= cfa.orig_col[face_vert_index]
try: tex_index= edge_my_cols.index(colk)
except: pass
if tex_index != None:
other_col= edge_other_cols[tex_index]
col_ob= cfa.col[face_vert_index]
col_ob.r, col_ob.g, col_ob.b= cols_mixed[tex_index]
# DEBUG! if DEBUG: rd()
# Execute the collapse
ced.v1.sel= ced.v2.sel= True # Select so remove doubles removed the edges and faces that use it
ced.v1.co= ced.v2.co= ced.collapse_loc
# DEBUG! if DEBUG: rd()
if current_face_count <= target_face_count:
break
# Copy weights back to the mesh before we remove doubles.
if DO_WEIGHTS:
#BPyMesh.dict2MeshWeight(me, groupNames, vWeightDict)
BPyMesh.list2MeshWeight(me, groupNames, vWeightList)
doubles= me.remDoubles(0.0001)
current_face_count= len(me.faces)
if current_face_count <= target_face_count or not doubles: # not doubles shoule never happen.
break
me.update()
Blender.Mesh.Mode(OLD_MESH_MODE)
示例2: env_from_group
# 需要导入模块: import BPyMesh [as 别名]
# 或者: from BPyMesh import list2MeshWeight [as 别名]
def env_from_group(ob_act, grp, PREF_UPDATE_ACT=True):
me = ob_act.getData(mesh=1)
if PREF_UPDATE_ACT:
act_group = me.activeGroup
if act_group == None:
Draw.PupMenu('Error%t|No active vertex group.')
return
try:
ob = Object.Get(act_group)
except:
Draw.PupMenu('Error%t|No object named "'+ act_group +'".')
return
group_isect = intersection_data(ob)
else:
# get intersection data
# group_isect_data = [intersection_data(ob) for ob in group.objects]
group_isect_data = []
for ob in grp.objects:
if ob != ob_act: # in case we're in the group.
gid = intersection_data(ob)
if gid[1]: # has some triangles?
group_isect_data.append( gid )
# we only need 1 for the active group
if PREF_UPDATE_ACT:
break
# sort by name
group_isect_data.sort()
if PREF_UPDATE_ACT:
group_names, vweight_list = BPyMesh.meshWeight2List(me)
group_index = group_names.index(act_group)
else:
group_names = [gid[0] for gid in group_isect_data]
vweight_list= [[0.0]* len(group_names) for i in xrange(len(me.verts))]
ob_act_mat = ob_act.matrixWorld
for vi, v in enumerate(me.verts):
# Get all the groups for this vert
co = v.co * ob_act_mat
if PREF_UPDATE_ACT:
# only update existing
if point_in_data(co, group_isect): w = 1.0
else: w = 0.0
vweight_list[vi][group_index] = w
else:
# generate new vgroup weights.
for group_index, group_isect in enumerate(group_isect_data):
if point_in_data(co, group_isect):
vweight_list[vi][group_index] = 1.0
BPyMesh.list2MeshWeight(me, group_names, vweight_list)