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


Python Vector.to_tuple方法代码示例

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


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

示例1: load

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import to_tuple [as 别名]
 def load(self, context):
     pcv = context.object.point_cloud_visualizer
     p = os.path.abspath(bpy.path.abspath(pcv.filepath))
     if(not os.path.exists(p)):
         self.report({'WARNING'}, "File does not exist")
         return {'CANCELLED'}
     
     points = BinPlyPointCloudReader(p).points
     
     rnd = random.Random()
     random.shuffle(points, rnd.random)
     
     # process points
     vertices = []
     colors = []
     for i, p in enumerate(points):
         v = Vector(p[:3])
         vertices.extend(v.to_tuple())
         c = [v / 255 for v in p[3:]]
         colors.extend(c)
     
     # make buffers
     length = len(points)
     vertex_buffer = bgl.Buffer(bgl.GL_FLOAT, len(vertices), vertices)
     color_buffer = bgl.Buffer(bgl.GL_FLOAT, len(colors), colors)
     
     o = context.object
     m = o.matrix_world
     matrix = []
     for v in m.transposed():
         matrix.extend(list(v.to_tuple()))
     matrix_buffer = bgl.Buffer(bgl.GL_FLOAT, len(matrix), matrix)
     
     d = PCVCache.new()
     u = str(uuid.uuid1())
     d['uuid'] = u
     d['path'] = pcv.filepath
     d['ready'] = True
     d['length'] = length
     d['vertex_buffer'] = vertex_buffer
     d['color_buffer'] = color_buffer
     d['matrix'] = m
     d['matrix_buffer'] = matrix_buffer
     d['object'] = o
     d['display_percent'] = pcv.display_percent
     PCVCache.add(d)
     
     pcv.uuid = u
开发者ID:uhlik,项目名称:bpy,代码行数:50,代码来源:view3d_point_cloud_visualizer.py

示例2: make_coil

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import to_tuple [as 别名]
    def make_coil():

        # variables
        amp = prad
        th = height / n_turns
        ipt = n_iter
        radius = crad
        diameter = radius * 2
        section_angle = 360.0 / n_verts
        rad_slice = 2.0 * pi / ipt
        total_segments = (ipt * n_turns) + 1
        z_jump = height / total_segments

        x_rotation = atan2(th / 2, diameter)

        n = n_verts
        Verts = []
        for segment in range(total_segments):
            rad_angle = rad_slice * segment

            for i in range(n):

                # create the vector
                this_angle = section_angle * i
                x_float = amp * sin(radians(this_angle)) + radius
                z_float = amp * cos(radians(this_angle))
                v1 = Vector((x_float, 0.0, z_float))

                # rotate it
                some_euler = Euler((-x_rotation, 0.0, -rad_angle), 'XYZ')
                v1.rotate(some_euler)

                # add extra z height per segment
                v1 += Vector((0, 0, (segment * z_jump)))

                # append it
                Verts.append(v1.to_tuple())

        Faces = []
        for t in range(total_segments - 1):
            for i in range(n - 1):
                p0 = i + (n * t)
                p1 = i + (n * t) + 1
                p2 = i + (n * t + n) + 1
                p3 = i + (n * t + n)
                Faces.append([p0, p1, p2, p3])
            p0 = n * t
            p1 = n * t + n
            p2 = n * t + (2 * n) - 1
            p3 = n * t + n - 1
            Faces.append([p0, p1, p2, p3])

        return Verts, Faces
开发者ID:BitByte01,项目名称:myblendercontrib,代码行数:55,代码来源:parametric_spring_with_polygons.py

示例3: rotate_camera

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import to_tuple [as 别名]
def rotate_camera(p_rotation):
	p_camera = bpy.data.objects['Camera']
	#camera position
	loc = Vector((0,3.0,6.0)) * mathutils.Matrix.Rotation(radians(p_rotation), 4, 'Z')
	p_camera.location = loc.to_tuple()
	
	rx = 35.264 #isometric angle
	mat_rot = mathutils.Matrix.Rotation(radians(180-p_rotation), 4, 'Z')
	mat_rot *= mathutils.Matrix.Rotation(radians(rx), 4, 'X')
	#print(mat_rot)
	#print(mat_rot.to_euler())
	p_camera.rotation_euler = mat_rot.to_euler()
	
	fov = 50.0
	# Set camera fov in degrees
	p_camera.data.angle = radians(fov)
开发者ID:willcode4fun,项目名称:scriptools,代码行数:18,代码来源:camera.py

示例4: uvsphere

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import to_tuple [as 别名]
def uvsphere(u, v, sphereRadius):
    circ = math.pi*2
    
    lp = []
    lf = []
    
    index = 0
    
    lp.append((0, 0, -sphereRadius))
    index += 1
    lastLayer = [0]
    
    for ui in range(1, u):
        phi = circ/u*ui
        radius = math.sin(phi/2) * sphereRadius
        layer = []
        for vi in range(v):
            theta = circ/v*vi
            x = math.cos(theta) * radius
            y = math.sin(theta) * radius
            z = -sphereRadius + sphereRadius*2/u*ui
            
            co = Vector((x, y, z))
            ce = Vector((0, 0, 0))
            dl = co - ce
            co = ce + dl.normalized() * sphereRadius
            
            lp.append(co.to_tuple())
            layer.append(index)
            index += 1
        if len(lastLayer) == len(layer):
            for i in range(v-1):
                lf.append((lastLayer[i], lastLayer[i+1], layer[i+1], layer[i]))
            lf.append((layer[0], layer[v-1], lastLayer[v-1], lastLayer[0]))
        else:
            for i in range(v-1):
                lf.append((0, layer[i+1], layer[i]))
            lf.append((0, layer[0], layer[v-1]))
        lastLayer = layer
        
    lp.append((0, 0, sphereRadius))
    index += 1
    for i in range(v-1):
        lf.append((layer[i], layer[i+1], index-1))
    lf.append((layer[0], index-1, layer[v-1]))
    
    return lp, lf
开发者ID:JustPowell,项目名称:Surfaces-Modeling-Coursework,代码行数:49,代码来源:common.py

示例5: add_uv_sphere

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import to_tuple [as 别名]
 def add_uv_sphere(self, u, v):
     lv = []
     circ = math.pi*2
     index = 1
     lv.append(self.new_vertex(Vector((0,0,-1))))
     lastLayer = [0]
     for ui in range(1, u):
         phi = circ/u*ui
         radius = math.sin(phi/2)
         layer = []
         for vi in range(v):
             theta = circ/v*vi
             x = math.cos(theta) * radius
             y = math.sin(theta) * radius
             z = -1 + 1*2/u*ui
             co = Vector((x, y, z))
             ce = Vector((0, 0, 0))
             dl = co - ce
             co = ce + dl.normalized()
             lv.append(self.new_vertex(Vector((co.to_tuple()))))
             layer.append(index)
             index += 1
         if len(lastLayer) == len(layer):
             for i in range(v-1):
                 self.new_face([lv[lastLayer[i]], lv[lastLayer[i+1]], lv[layer[i+1]], lv[layer[i]]])
             self.new_face([lv[layer[0]], lv[layer[v-1]], lv[lastLayer[v-1]], lv[lastLayer[0]]])
         else:
             for i in range(v-1):
                 self.new_face([lv[0], lv[layer[i+1]], lv[layer[i]]])
             self.new_face([lv[0], lv[layer[0]], lv[layer[v-1]]])
         lastLayer = layer
     lv.append(self.new_vertex(Vector((0, 0, 1))))
     index += 1
     for i in range(v-1):
         self.new_face([lv[layer[i]], lv[layer[i+1]], lv[index-1]])
     self.new_face([lv[layer[0]], lv[index-1], lv[layer[v-1]]])
开发者ID:JustPowell,项目名称:Surfaces-Modeling-Coursework,代码行数:38,代码来源:mesh.py

示例6: tassellate

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import to_tuple [as 别名]
def tassellate(ob0, ob1, offset, zscale, gen_modifiers, com_modifiers, mode, scale_mode, rotation_mode, rand_seed, fill_mode, bool_vertex_group, bool_selection):
    random.seed(rand_seed)

    print(ob0.tissue_tessellate.offset)

    old_me0 = ob0.data
    if gen_modifiers:
        me0 = ob0.to_mesh(bpy.context.scene, apply_modifiers=True, settings = 'PREVIEW')
    else: me0 = ob0.data
    ob0.data = me0

    if com_modifiers:
        me1 = ob1.to_mesh(bpy.context.scene, apply_modifiers=True, settings = 'PREVIEW')
    else: me1 = ob1.data

    verts0 = me0.vertices

    n_verts = len(me1.vertices)
    n_edges = len(me1.edges)
    n_faces = len(me1.polygons)

    loc = ob1.location
    dim = ob1.dimensions
    scale = ob1.scale

    new_verts = []
    new_edges = []
    new_faces = []
    new_verts_np = np.array(())

    min = Vector((0,0,0))
    max = Vector((0,0,0))

    first = True

    for v in me1.vertices:
        vert = ( ob1.matrix_world * v.co )

        if vert[0] < min[0] or first:
            min[0] = vert[0]
        if vert[1] < min[1] or first:
            min[1] = vert[1]
        if vert[2] < min[2] or first:
            min[2] = vert[2]
        if vert[0] > max[0] or first:
            max[0] = vert[0]
        if vert[1] > max[1] or first:
            max[1] = vert[1]
        if vert[2] > max[2] or first:
            max[2] = vert[2]
        first = False

    bb = max-min

    verts1 = []

    for v in me1.vertices:
        if mode=="ADAPTIVE":
            vert = ( ob1.matrix_world * v.co ) - min
            vert[0] = vert[0] / bb[0]
            vert[1] = vert[1] / bb[1]
            vert[2] = (vert[2] + (-0.5 + offset*0.5)*bb[2])*zscale
        else:
            vert = v.co.xyz
            vert[2] *= zscale

        verts1.append(vert)

    # component vertices
    vs1 = np.array([v for v in verts1]).reshape(len(verts1),3,1)
    vx = vs1[:,0]
    vy = vs1[:,1]
    vz = vs1[:,2]

    # component polygons
    fs1 = [[i for i in p.vertices] for p in me1.polygons]
    new_faces = fs1[:]

    j = 0


    # active vertex group

    if bool_vertex_group:
        weight = []
        active_vertex_group = ob0.vertex_groups[ob0.vertex_groups.active_index]
        for v in me0.vertices:
            try:
                weight.append(active_vertex_group.weight(v.index))
            except:
                weight.append(0)



    if fill_mode == 'FAN':
        fan_verts = [v.co.to_tuple() for v in me0.vertices]
        fan_polygons = []
        selected_faces = []

        for p in me0.polygons:
#.........这里部分代码省略.........
开发者ID:Italic-,项目名称:blenderpython,代码行数:103,代码来源:tessellate_numpy.py

示例7: tassellate

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import to_tuple [as 别名]
def tassellate(ob0, ob1, offset, zscale, gen_modifiers, com_modifiers, mode, scale_mode, randomize, rand_seed, fill_mode):
    random.seed(rand_seed)

    if gen_modifiers:
        me0 = ob0.to_mesh(bpy.context.scene, apply_modifiers=True, settings = 'PREVIEW')
    else: me0 = ob0.data

    if com_modifiers:
        me1 = ob1.to_mesh(bpy.context.scene, apply_modifiers=True, settings = 'PREVIEW')
    else: me1 = ob1.data

    verts0 = me0.vertices

    n_verts = len(me1.vertices)
    n_edges = len(me1.edges)
    n_faces = len(me1.polygons)

    loc = ob1.location
    dim = ob1.dimensions
    scale = ob1.scale

    new_verts = []
    new_edges = []
    new_faces = []
    new_verts_np = np.array(())

    min = Vector((0,0,0))
    max = Vector((0,0,0))

    first = True

    for v in me1.vertices:
        vert = ( ob1.matrix_world * v.co )

        if vert[0] < min[0] or first:
            min[0] = vert[0]
        if vert[1] < min[1] or first:
            min[1] = vert[1]
        if vert[2] < min[2] or first:
            min[2] = vert[2]
        if vert[0] > max[0] or first:
            max[0] = vert[0]
        if vert[1] > max[1] or first:
            max[1] = vert[1]
        if vert[2] > max[2] or first:
            max[2] = vert[2]
        first = False

    bb = max-min

    verts1 = []

    for v in me1.vertices:
        if mode=="ADAPTIVE":
            vert = ( ob1.matrix_world * v.co ) - min
            vert[0] = vert[0] / bb[0]
            vert[1] = vert[1] / bb[1]
            vert[2] = (vert[2] + (-0.5 + offset*0.5)*bb[2])*zscale
        else:
            vert = v.co
            vert[2] *= zscale

        verts1.append(vert)

    # component vertices
    vs1 = np.array([v for v in verts1]).reshape(len(verts1),3,1)
    vx = vs1[:,0]
    vy = vs1[:,1]
    vz = vs1[:,2]

    # component polygons
    fs1 = [[i for i in p.vertices] for p in me1.polygons]
    new_faces = fs1[:]

    j = 0

    if fill_mode == 'FAN':
        fan_verts = [v.co.to_tuple() for v in me0.vertices]
        fan_polygons = []
        for p in me0.polygons:
            fan_center = Vector((0,0,0))
            for v in p.vertices:
                fan_center += me0.vertices[v].co
            fan_center /= len(p.vertices)
            last_vert = len(fan_verts)
            fan_verts.append(fan_center.to_tuple())
            for i in range(len(p.vertices)):
                fan_polygons.append((p.vertices[i], p.vertices[(i+1)%len(p.vertices)], last_vert, last_vert))
        print(fan_verts)
        print(fan_polygons)
        fan_me = bpy.data.meshes.new('Fan.Mesh')
        fan_me.from_pydata(tuple(fan_verts), [], tuple(fan_polygons))
        me0 = fan_me
        verts0 = me0.vertices


    for p in me0.polygons:

        #polygon vertices

#.........这里部分代码省略.........
开发者ID:IBaaNB,项目名称:blenderpython,代码行数:103,代码来源:tessellate_numpy.py

示例8: tassellate

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import to_tuple [as 别名]
def tassellate(ob0, ob1, offset, zscale, gen_modifiers, com_modifiers, mode, scale_mode, rotation_mode, rand_seed, fill_mode):
    random.seed(rand_seed)

    print(ob0.tissue_tessellate.offset)

    if gen_modifiers:
        me0 = ob0.to_mesh(bpy.context.scene, apply_modifiers=True, settings = 'PREVIEW')
    else: me0 = ob0.data

    if com_modifiers:
        me1 = ob1.to_mesh(bpy.context.scene, apply_modifiers=True, settings = 'PREVIEW')
    else: me1 = ob1.data

    verts0 = me0.vertices

    n_verts = len(me1.vertices)
    n_edges = len(me1.edges)
    n_faces = len(me1.polygons)

    loc = ob1.location
    dim = ob1.dimensions
    scale = ob1.scale

    new_verts = []
    new_edges = []
    new_faces = []
    new_verts_np = np.array(())

    min = Vector((0,0,0))
    max = Vector((0,0,0))

    first = True

    for v in me1.vertices:
        vert = ( ob1.matrix_world * v.co )

        if vert[0] < min[0] or first:
            min[0] = vert[0]
        if vert[1] < min[1] or first:
            min[1] = vert[1]
        if vert[2] < min[2] or first:
            min[2] = vert[2]
        if vert[0] > max[0] or first:
            max[0] = vert[0]
        if vert[1] > max[1] or first:
            max[1] = vert[1]
        if vert[2] > max[2] or first:
            max[2] = vert[2]
        first = False

    bb = max-min

    verts1 = []

    for v in me1.vertices:
        if mode=="ADAPTIVE":
            vert = ( ob1.matrix_world * v.co ) - min
            vert[0] = vert[0] / bb[0]
            vert[1] = vert[1] / bb[1]
            vert[2] = (vert[2] + (-0.5 + offset*0.5)*bb[2])*zscale
        else:
            vert = v.co.xyz
            vert[2] *= zscale

        verts1.append(vert)

    # component vertices
    vs1 = np.array([v for v in verts1]).reshape(len(verts1),3,1)
    vx = vs1[:,0]
    vy = vs1[:,1]
    vz = vs1[:,2]

    # component polygons
    fs1 = [[i for i in p.vertices] for p in me1.polygons]
    new_faces = fs1[:]

    j = 0

    if fill_mode == 'FAN':
        fan_verts = [v.co.to_tuple() for v in me0.vertices]
        fan_polygons = []
        for p in me0.polygons:
            fan_center = Vector((0,0,0))
            for v in p.vertices:
                fan_center += me0.vertices[v].co
            fan_center /= len(p.vertices)
            last_vert = len(fan_verts)
            fan_verts.append(fan_center.to_tuple())
            for i in range(len(p.vertices)):
                fan_polygons.append((p.vertices[i], p.vertices[(i+1)%len(p.vertices)], last_vert, last_vert))
        #print(fan_verts)
        #print(fan_polygons)
        fan_me = bpy.data.meshes.new('Fan.Mesh')
        fan_me.from_pydata(tuple(fan_verts), [], tuple(fan_polygons))
        me0 = fan_me
        verts0 = me0.vertices


    count = 0   # necessary for UV calculation
    for p in me0.polygons:
#.........这里部分代码省略.........
开发者ID:TakamitsuNobe,项目名称:myblendercontrib,代码行数:103,代码来源:tessellate_numpy.py


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