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


Python bmesh.from_edit_mesh方法代码示例

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


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

示例1: get_bmesh

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def get_bmesh(ob=None):
    '''Returns a bmesh. Works either in edit or object mode.
    ob can be either an object or a mesh.'''
    obm = bmesh.new()
    if ob is None:
        mesh = bpy.context.object.data
    if 'data' in dir(ob):
        mesh = ob.data
        if ob.mode == 'OBJECT':
            obm.from_mesh(mesh)
        elif ob.mode == 'EDIT':
            obm = bmesh.from_edit_mesh(mesh)    
    else:
        mesh = ob
        obm.from_mesh(mesh)
    return obm 
开发者ID:the3dadvantage,项目名称:Modeling-Cloth,代码行数:18,代码来源:DynamicTensionMap.py

示例2: get_bmesh

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def get_bmesh(ob='empty'):
    '''Returns a bmesh. Works either in edit or object mode.
    ob can be either an object or a mesh.'''
    obm = bmesh.new()
    if ob == 'empty':
        mesh = bpy.context.object.data
    if 'data' in dir(ob):
        mesh = ob.data
        if ob.mode == 'OBJECT':
            obm.from_mesh(mesh)
        elif ob.mode == 'EDIT':
            obm = bmesh.from_edit_mesh(mesh)    
    else:
        mesh = ob
        obm.from_mesh(mesh)
    return obm 
开发者ID:the3dadvantage,项目名称:Modeling-Cloth,代码行数:18,代码来源:SurfaceFollow.py

示例3: bmesh_copy_from_object

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def bmesh_copy_from_object(obj, transform=True, triangulate=True, apply_modifiers=False):
	assert(obj.type == 'MESH')

	if apply_modifiers and obj.modifiers:
		import bpy
		me = obj.to_mesh(bpy.context.scene, True, 'PREVIEW', calc_tessface=False)
		bm = bmesh.new(); bm.from_mesh(me); bpy.data.meshes.remove(me)
		del bpy
	else:
		me = obj.data
		if obj.mode == 'EDIT': bm_orig = bmesh.from_edit_mesh(me); bm = bm_orig.copy()
		else: bm = bmesh.new(); bm.from_mesh(me)

	if transform: bm.transform(obj.matrix_world)
	if triangulate: bmesh.ops.triangulate(bm, faces=bm.faces)
	return bm 
开发者ID:3DMish,项目名称:Blender-Add-ons-3DM-Snow,代码行数:18,代码来源:3dm_snow.py

示例4: remove_base_mesh

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_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") 
开发者ID:ndee85,项目名称:coa_tools,代码行数:19,代码来源:functions.py

示例5: unwrap_with_bounds

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_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") 
开发者ID:ndee85,项目名称:coa_tools,代码行数:20,代码来源:functions.py

示例6: create_verts

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def create_verts(self,width,height,pos,me,tag_hide=False):
        bpy.ops.object.mode_set(mode="EDIT")
        bm = bmesh.from_edit_mesh(me)
        vert1 = bm.verts.new(Vector((0,0,-height))*self.scale)
        vert2 = bm.verts.new(Vector((width,0,-height))*self.scale)
        vert3 = bm.verts.new(Vector((width,0,0))*self.scale)
        vert4 = bm.verts.new(Vector((0,0,0))*self.scale)
        
        bm.faces.new([vert1,vert2,vert3,vert4])
                
        bmesh.update_edit_mesh(me)
        
        if tag_hide:
            for vert in bm.verts:
                vert.hide = True    
                
            for edge in bm.edges:
                edge.hide = True    
        
        bmesh.update_edit_mesh(me)
        bpy.ops.object.mode_set(mode="OBJECT") 
开发者ID:ndee85,项目名称:coa_tools,代码行数:23,代码来源:import_sprites.py

示例7: main

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:operator_mesh_uv.py

示例8: execute

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def execute(self, context):
        import bmesh
        from .bmesh import find_adjacent

        obj = context.active_object
        me = obj.data
        bm = bmesh.from_edit_mesh(me)

        if find_adjacent.select_prev(bm, self.report):
            bm.select_flush_mode()
            bmesh.update_edit_mesh(me, False)

        return {'FINISHED'}


# XXX This is hackish (going forth and back from Object mode...), to be redone once we have proper support of
#     custom normals in BMesh/edit mode. 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:mesh.py

示例9: execute

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def execute(self, context):

        obj = bpy.context.active_object
        self.me = obj.data
        self.bm = bmesh.from_edit_mesh(self.me)
        self.me.update()

        list_0 = [f.index for f in self.bm.faces if f.select]

        if len(list_0) == 0:
            self.report({'INFO'}, 'No faces selected')
            return {'CANCELLED'}
        elif len(list_0) != 0:

            f_(self, list_0)
            context.tool_settings.mesh_select_mode = (True, True, True)
            if self.b_del:
                bpy.ops.mesh.delete(type='FACE')
            else:
                pass
            return {'FINISHED'} 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:split_solidify.py

示例10: execute

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def execute(self, context):
        me = context.active_object.data
        bm = bmesh.from_edit_mesh(me)
        dvert_lay = bm.verts.layers.deform.active
        weights = {}
        for item in self.vgroup_weights:
            weights[item.vgroup] = item.weight

        for v in bm.verts:
            if v.index == self.index:
                dvert = v[dvert_lay]
                for vgroup in dvert.keys():
                    dvert[vgroup] = weights[vgroup]
                break
        context.area.tag_redraw()
        return {'FINISHED'} 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:18,代码来源:mesh_show_vgroup_weights.py

示例11: avail_vgroups

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def avail_vgroups(self, context):
        if context is None:
            return []
        ob = context.active_object
        bm = bmesh.from_edit_mesh(ob.data)
        dvert_lay = bm.verts.layers.deform.active
        items = []
        self.vertex = bm.select_history.active.index

        dvert = bm.select_history.active[dvert_lay]

        #XXX since we need an identifier here, user won't be able to add a vgroup with that name ('-1')
        #XXX could check against vgroup names and find an unused name, but it's a rare case after all.
        items.append(("-1", "New Vertex Group", "Add a new vertex group to the active object", -1))

        for i in ob.vertex_groups:
            if i.index not in dvert.keys():
                items.append((i.name, i.name, str(i.index), i.index))

        return items 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:mesh_show_vgroup_weights.py

示例12: CreateWornEdges

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def CreateWornEdges(context, factor):
    actobj = bpy.context.object

    bpy.ops.object.mode_set(mode="EDIT")
    bm = bmesh.from_edit_mesh(actobj.data)

    sf = [(vert.calc_shell_factor() - 1.0) * factor for vert in bm.verts[:]]

    bpy.ops.object.mode_set(mode="VERTEX_PAINT")
    purge = {}

    for ind, loop in enumerate(bpy.context.object.data.loops[:]):
        if loop.vertex_index not in purge:
            purge[loop.vertex_index] = [ind]
        else:
            purge[loop.vertex_index].append(ind)

    for vert in actobj.data.vertices[:]:
        if vert.select:
            ran = (sf[vert.index], sf[vert.index], sf[vert.index])
            for i in purge[vert.index]:
                actobj.data.vertex_colors.active.data[i].color = ran
    actobj.data.update() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:oscurart_worn_edges_map.py

示例13: initialize

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def initialize(self, context):

		bpy.types.Scene.PreSelOff = bpy.props.BoolProperty(
				name = "PreSelOff",
				description = "Switch off PreSel during FloodSel",
				default = True)

		self.area = context.area
		self.selobj = context.active_object
		self.mesh = self.selobj.data
		self.bm = bmesh.from_edit_mesh(self.mesh)

		self.area.header_text_set(text="FloodSel :  Leftclick selects")

		self.region = None
		self.doneset = set([])

		self.getmatrix() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:mesh_floodsel.py

示例14: __update_uvs

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def __update_uvs(self, context, uv_info_ini, trans_mat):
        """
        Update UV coordinate
        """

        obj = context.active_object
        bm = bmesh.from_edit_mesh(obj.data)
        if muv_common.check_version(2, 73, 0) >= 0:
            bm.faces.ensure_lookup_table()
        if not bm.loops.layers.uv:
            return
        uv_layer = bm.loops.layers.uv.verify()
        for info in uv_info_ini:
            fidx = info[0]
            lidx = info[1]
            uv = info[2]
            v = mathutils.Vector((uv.x, uv.y, 0.0))
            av = trans_mat * v
            bm.faces[fidx].loops[lidx][uv_layer].uv = mathutils.Vector(
                (av.x, av.y)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:muv_uvbb_ops.py

示例15: execute

# 需要导入模块: import bmesh [as 别名]
# 或者: from bmesh import from_edit_mesh [as 别名]
def execute(self, context):
        props = context.scene.muv_props.texlock
        obj = bpy.context.active_object
        bm = bmesh.from_edit_mesh(obj.data)
        if muv_common.check_version(2, 73, 0) >= 0:
            bm.verts.ensure_lookup_table()
            bm.edges.ensure_lookup_table()
            bm.faces.ensure_lookup_table()

        if not bm.loops.layers.uv:
            self.report(
                {'WARNING'}, "Object must have more than one UV map")
            return {'CANCELLED'}
        uv_layer = bm.loops.layers.uv.verify()

        props.verts_orig = [
            {"vidx": v.index, "vco": v.co.copy(), "moved": False}
            for v in bm.verts if v.select]

        return {'FINISHED'} 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:22,代码来源:muv_texlock_ops.py


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