本文整理汇总了Python中bmesh.update_edit_mesh方法的典型用法代码示例。如果您正苦于以下问题:Python bmesh.update_edit_mesh方法的具体用法?Python bmesh.update_edit_mesh怎么用?Python bmesh.update_edit_mesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bmesh
的用法示例。
在下文中一共展示了bmesh.update_edit_mesh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: remove_base_mesh
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def remove_base_mesh(obj):
bpy.ops.object.mode_set(mode="EDIT")
bm = bmesh.from_edit_mesh(obj.data)
bm.verts.ensure_lookup_table()
verts = []
if "coa_base_sprite" in obj.vertex_groups:
v_group_idx = obj.vertex_groups["coa_base_sprite"].index
for i,vert in enumerate(obj.data.vertices):
for g in vert.groups:
if g.group == v_group_idx:
verts.append(bm.verts[i])
break
bmesh.ops.delete(bm,geom=verts,context=1)
bm = bmesh.update_edit_mesh(obj.data)
bpy.ops.object.mode_set(mode="OBJECT")
示例2: unwrap_with_bounds
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def unwrap_with_bounds(obj,uv_idx):
bpy.ops.object.mode_set(mode="EDIT")
me = obj.data
bm = bmesh.from_edit_mesh(me)
bm.verts.ensure_lookup_table()
uv_layer = bm.loops.layers.uv[uv_idx]
scale_x = 1.0 / get_local_dimension(obj)[0] * obj.coa_tiles_x
scale_z = 1.0 / get_local_dimension(obj)[1] * obj.coa_tiles_y
offset = [get_local_dimension(obj)[2][0] * scale_x , get_local_dimension(obj)[2][1] * scale_z]
for i,v in enumerate(bm.verts):
for l in v.link_loops:
uv_data = l[uv_layer]
uv_data.uv[0] = (bm.verts[i].co[0] * scale_x) - offset[0]
uv_data.uv[1] = (bm.verts[i].co[2] * scale_z)+1 - offset[1]
bmesh.update_edit_mesh(me)
bm.free()
bpy.ops.object.mode_set(mode="OBJECT")
示例3: collapse_short_edges
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def collapse_short_edges(bm,obj,threshold=1.0):
### collapse short edges
edges_len_average = 0
edges_count = 0
shortest_edge = 10000
for edge in bm.edges:
if True:
edges_count += 1
length = edge.calc_length()
edges_len_average += length
if length < shortest_edge:
shortest_edge = length
edges_len_average = edges_len_average/edges_count
verts = []
for vert in bm.verts:
if not vert.is_boundary:
verts.append(vert)
bmesh.update_edit_mesh(obj.data)
bmesh.ops.remove_doubles(bm,verts=verts,dist=edges_len_average*threshold)
bmesh.update_edit_mesh(obj.data)
示例4: clean_mesh
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def clean_mesh(self,obj):
bm = bmesh.from_edit_mesh(obj.data)
faces = []
for face in bm.faces:
if not face.hide:
face_ok = False
invalid_edges = 0
for edge in face.edges:
if not edge.is_manifold and not edge.is_wire and not edge.is_boundary:
invalid_edges += 1
if invalid_edges == len(face.edges):
faces.append(face)
bmesh.ops.delete(bm,geom=faces,context=3)
bmesh.update_edit_mesh(obj.data)
示例5: main
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def main(context):
obj = context.active_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
uv_layer = bm.loops.layers.uv.verify()
bm.faces.layers.tex.verify() # currently blender needs both layers.
# adjust UVs
for f in bm.faces:
for l in f.loops:
luv = l[uv_layer]
if luv.select:
# apply the location of the vertex as a UV
luv.uv = l.vert.co.xy
bmesh.update_edit_mesh(me)
示例6: build
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def build(cls, context, prop):
verify_facemaps_for_object(context.object)
me = get_edit_mesh()
bm = bmesh.from_edit_mesh(me)
if cls.validate(bm):
cls.add_floor_facemaps(context, prop)
selected_faces = [f for f in bm.faces if f.select]
if selected_faces:
create_floors(bm, selected_faces, prop)
select(bm.faces, False)
else:
all_faces = [f for f in bm.faces]
create_floors(bm, all_faces, prop)
bmesh.update_edit_mesh(me, True)
return {"FINISHED"}
return {"CANCELLED"}
示例7: noise_obj
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def noise_obj(obj, context, self):
bm = bmesh.from_edit_mesh(obj.data)
verts = [v for v in bm.verts if v.select]
if not verts:
verts = [v for v in bm.verts if v.hide is False]
for vert in verts:
noise_pos = self.frequency * vert.co.copy()
noise_pos.x += self.offset_x
noise_pos.z += self.offset_y
noise_pos.z += self.offset_z
noise_val = None
if self.noise_type == 'Turbulence':
noise_val = mathu.noise.turbulence(noise_pos, self.octaves, self.hard, mathu.noise.types.STDPERLIN, self.amplitude_scale, self.frequency_scale)
elif self.noise_type == 'Fractal':
noise_val = mathu.noise.fractal(noise_pos, self.amplitude_scale, self.frequency_scale, self.octaves, mathu.noise.types.STDPERLIN)
else:
noise_val = mathu.noise.hetero_terrain(noise_pos, self.amplitude_scale, self.frequency_scale, self.octaves, 0, mathu.noise.types.STDPERLIN)
vert_offset = vert.normal.copy().normalized() * noise_val
vert.co += vert_offset * self.intensity
bm.normal_update()
bmesh.update_edit_mesh(obj.data)
示例8: noise_obj
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def noise_obj(obj, context, self):
bm = bmesh.from_edit_mesh(obj.data)
verts = [v for v in bm.verts if v.select]
if not verts:
verts = [v for v in bm.verts if v.hide is False]
for vert in verts:
noise_pos = self.frequency * vert.co.copy()
noise_pos.x += self.offset_x
noise_pos.z += self.offset_y
noise_pos.z += self.offset_z
noise_val = None
if self.noise_type == 'Turbulence':
noise_val = mathu.noise.turbulence(noise_pos, self.octaves, self.hard, noise_basis="PERLIN_ORIGINAL", amplitude_scale=self.amplitude_scale, frequency_scale=self.frequency_scale)
elif self.noise_type == 'Fractal':
noise_val = mathu.noise.fractal(noise_pos, self.amplitude_scale, self.frequency_scale, self.octaves, noise_basis="PERLIN_ORIGINAL")
else:
noise_val = mathu.noise.hetero_terrain(noise_pos, self.amplitude_scale, self.frequency_scale, self.octaves, 0, noise_basis="PERLIN_ORIGINAL")
vert_offset = vert.normal.copy().normalized() * noise_val
vert.co += vert_offset * self.intensity
bm.normal_update()
bmesh.update_edit_mesh(obj.data)
示例9: hide_base_sprite
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def hide_base_sprite(obj):
context = bpy.context
selected_object = bpy.data.objects[context.active_object.name]
if "coa_sprite" in obj and obj.type == "MESH":
orig_mode = obj.mode
context.scene.objects.active = obj
bpy.ops.object.mode_set(mode="OBJECT")
bpy.ops.object.mode_set(mode="EDIT")
me = obj.data
bm = bmesh.from_edit_mesh(me)
bm.verts.ensure_lookup_table()
vertex_idxs = []
if "coa_base_sprite" in obj.vertex_groups:
v_group_idx = obj.vertex_groups["coa_base_sprite"].index
for i,vert in enumerate(obj.data.vertices):
for g in vert.groups:
if g.group == v_group_idx:
vertex_idxs.append(i)
for idx in vertex_idxs:
vert = bm.verts[idx]
vert.hide = True
vert.select = False
for edge in vert.link_edges:
edge.hide = True
edge.select = False
for face in vert.link_faces:
face.hide = obj.data.coa_hide_base_sprite
face.select = False
if "coa_base_sprite" in obj.modifiers:
mod = obj.modifiers["coa_base_sprite"]
mod.show_viewport = obj.data.coa_hide_base_sprite
mod.show_render = obj.data.coa_hide_base_sprite
bmesh.update_edit_mesh(me)
bpy.ops.object.mode_set(mode=orig_mode)
context.scene.objects.active = selected_object
示例10: update_uv_unwrap
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def update_uv_unwrap(context):
obj = context.active_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
### pin uv boundary vertex
uv_layer = bm.loops.layers.uv.active
for vert in bm.verts:
uv_vert = get_uv_from_vert(uv_layer, vert)
if uv_vert != None:
pass
bmesh.update_edit_mesh(me)
示例11: remove_base_sprite
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def remove_base_sprite(obj):
bpy.context.scene.objects.active = obj
obj.hide = False
bpy.ops.object.mode_set(mode="EDIT")
bm = bmesh.from_edit_mesh(obj.data)
bm.verts.ensure_lookup_table()
verts = []
if "coa_base_sprite" in obj.vertex_groups and obj.data.coa_hide_base_sprite:
v_group_idx = obj.vertex_groups["coa_base_sprite"].index
for i,vert in enumerate(obj.data.vertices):
for g in vert.groups:
if g.group == v_group_idx:
verts.append(bm.verts[i])
break
bpy.ops.mesh.reveal()
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.quads_convert_to_tris(quad_method='BEAUTY', ngon_method='BEAUTY')
bmesh.ops.delete(bm,geom=verts,context=1)
bm = bmesh.update_edit_mesh(obj.data)
bpy.ops.object.mode_set(mode="OBJECT")
##### get mesh data like vertices, edges, triangles and uvs ##### Start
示例12: clean_boundary_edges
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def clean_boundary_edges(bm,obj):
edges_len_average, shortest_edge = get_average_edge_length(bm,obj)
edges = []
for edge in bm.edges:
if edge.calc_length() < edges_len_average*.12 and not edge.tag:
edges.append(edge)
bmesh.ops.collapse(bm,edges=edges,uvs=False)
bmesh.update_edit_mesh(obj.data)
示例13: average_edge_cuts
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def average_edge_cuts(bm,obj,cuts=1):
### collapse short edges
edges_len_average, shortest_edge = get_average_edge_length(bm,obj)
subdivide_edges = []
for edge in bm.edges:
cut_count = int(edge.calc_length()/shortest_edge)*cuts
if cut_count < 0:
cut_count = 0
if not edge.is_boundary:
subdivide_edges.append([edge,cut_count])
for edge in subdivide_edges:
bmesh.ops.subdivide_edges(bm,edges=[edge[0]],cuts=edge[1])
bmesh.update_edit_mesh(obj.data)
示例14: triangle_fill
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def triangle_fill(bm,obj):
edges = []
for edge in bm.edges:
if edge.select == True:
edges.append(edge)
triangle_fill = bmesh.ops.triangle_fill(bm,edges=edges,use_beauty=True)
bmesh.update_edit_mesh(obj.data)
if triangle_fill["geom"] == []:
return False
else:
return True
示例15: triangulate
# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import update_edit_mesh [as 别名]
def triangulate(bm,obj):
bmesh.ops.triangulate(bm,faces=bm.faces)
bmesh.update_edit_mesh(obj.data)