本文整理汇总了Python中mathutils.Vector.lerp方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.lerp方法的具体用法?Python Vector.lerp怎么用?Python Vector.lerp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Vector
的用法示例。
在下文中一共展示了Vector.lerp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addFaces
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import lerp [as 别名]
def addFaces(self, fType=None):
Ya = self.Ya
Xb = self.Xb
Xc = self.Xc
if (self.triangleFace == 'DEFAULT'):
self.Faces = [[0, 1, 2]]
return True
if (self.triangleFace == 'TRIANGLES'):
A = Vector([0.0, Ya, 0.0])
B = Vector([Xb, 0.0, 0.0])
C = Vector([Xc, 0.0, 0.0])
D = Vector([((A.x + B.x + C.x) / 3), ((A.y + B.y + C.y) / 3), ((A.z + B.z + C.z) / 3)])
self.Vertices = [A, B, C, D, ]
self.Faces = [[0, 1, 3], [1, 2, 3], [2, 0, 3]]
return True
if (self.triangleFace == 'QUADS'):
A = Vector([0.0, Ya, 0.0])
B = Vector([Xb, 0.0, 0.0])
C = Vector([Xc, 0.0, 0.0])
D = Vector([((A.x + B.x + C.x) / 3), ((A.y + B.y + C.y) / 3), ((A.z + B.z + C.z) / 3)])
AB = A.lerp(B, 0.5)
AC = A.lerp(C, 0.5)
BC = B.lerp(C, 0.5)
self.Vertices = [A, AB, B, BC, C, AC, D, ]
self.Faces = [[0, 1, 6, 5], [1, 2, 3, 6], [3, 4, 5, 6]]
return True
if (self.triangleFace == 'SAFEQUADS'):
A = Vector([0.0, Ya, 0.0])
B = Vector([Xb, 0.0, 0.0])
C = Vector([Xc, 0.0, 0.0])
D = Vector([((A.x + B.x + C.x) / 3), ((A.y + B.y + C.y) / 3), ((A.z + B.z + C.z) / 3)])
E = A.lerp(D, 0.5)
AB = A.lerp(B, 0.5)
AC = A.lerp(C, 0.5)
BC = B.lerp(C, 0.5)
AAB = AB.lerp(A, 0.5)
AAC = AC.lerp(A, 0.5)
BBA = AB.lerp(B, 0.5)
BBC = BC.lerp(B, 0.5)
BCC = BC.lerp(C, 0.5)
CCA = AC.lerp(C, 0.5)
self.Vertices = [A, AAB, BBA, B, BBC, BC, BCC, C, CCA, AAC, D, E, ]
self.Faces = [[0, 1, 11, 9], [1, 2, 10, 11], [2, 3, 4, 10],
[4, 5, 6, 10], [6, 7, 8, 10], [8, 9, 11, 10]]
return True
return False
示例2: do_update_heat_map
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import lerp [as 别名]
def do_update_heat_map(node_list, nodes):
"""
Create a heat map for the node tree,
Needs development.
"""
if not nodes.id_data.sv_user_colors:
color_data = {node.name: (node.color[:], node.use_custom_color) for node in nodes}
nodes.id_data.sv_user_colors = str(color_data)
times = do_update_general(node_list, nodes)
if not times:
return
t_max = max(times)
addon_name = data_structure.SVERCHOK_NAME
addon = bpy.context.user_preferences.addons.get(addon_name)
if addon:
# to use Vector.lerp
cold = Vector(addon.preferences.heat_map_cold)
hot = addon.preferences.heat_map_hot
else:
error("Cannot find preferences")
cold = Vector((1, 1, 1))
hot = (.8, 0, 0)
for name, t in zip(node_list, times):
nodes[name].use_custom_color = True
# linear scale.
nodes[name].color = cold.lerp(hot, t / t_max)
示例3: makecube
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import lerp [as 别名]
def makecube(self, size, divx, divy, divz):
if 0 in (divx, divy, divz):
return [], []
b = size / 2.0
verts = [
[b, b, -b], [b, -b, -b], [-b, -b, -b],
[-b, b, -b], [b, b, b], [b, -b, b],
[-b, -b, b], [-b, b, b]
]
faces = [[0, 1, 2, 3], [4, 7, 6, 5],
[0, 4, 5, 1], [1, 5, 6, 2],
[2, 6, 7, 3], [4, 0, 3, 7]]
if (divx, divy, divz) == (1, 1, 1):
return verts, faces
bm = bmesh.new()
[bm.verts.new(co) for co in verts]
bm.verts.index_update()
for face in faces:
bm.faces.new(tuple(bm.verts[i] for i in face))
bm.faces.index_update()
dist = 0.0001
section_dict = {0: divx, 1: divy, 2: divz}
for axis in range(3):
num_sections = section_dict[axis]
if num_sections == 1:
continue
step = 1 / num_sections
v1 = Vector(tuple((b if (i == axis) else 0) for i in [0, 1, 2]))
v2 = Vector(tuple((-b if (i == axis) else 0) for i in [0, 1, 2]))
for section in range(num_sections):
mid_vec = v1.lerp(v2, section * step)
plane_no = v2 - mid_vec
plane_co = mid_vec
visible_geom = bm.faces[:] + bm.verts[:] + bm.edges[:]
bmesh.ops.bisect_plane(
bm, geom=visible_geom, dist=dist,
plane_co=plane_co, plane_no=plane_no,
use_snap_center=False,
clear_outer=False, clear_inner=False)
indices = lambda i: [j.index for j in i.verts]
verts = [v.co.to_tuple() for v in bm.verts]
faces = [indices(face) for face in bm.faces]
edges = [indices(edge) for edge in bm.edges]
return [verts], edges, [faces]
示例4: sv_main
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import lerp [as 别名]
def sv_main(v=[[]], point=[], mdist=0.4):
in_sockets = [
['v', 'verts', v],
['v', 'point', point],
['s', 'mdist', mdist]
]
affected_verts = {}
return_verts = []
if (v and v[0]) and point:
v = v[0]
size = len(v)
kd = kdtree.KDTree(size)
for i, vtx in enumerate(v):
kd.insert(Vector(vtx), i)
kd.balance()
# makes edges
vtx = point[0][0]
for (co, index, dist) in kd.find_range(vtx, mdist):
affected_verts[index] = dist
v1 = Vector(vtx)
add_vert = return_verts.append
for idx, vert in enumerate(v):
rv = affected_verts.get(idx, 0)
if rv > 0:
amp = mdist / rv
v2 = Vector(v[idx])
v3 = v1.lerp(v2, amp)
# make new vector
rv = v3[:]
else:
rv = vert
add_vert(rv)
# out boilerplate
out_sockets = [
['v', 'Modified', [return_verts]]
]
return in_sockets, out_sockets
示例5: do_update_heat_map
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import lerp [as 别名]
def do_update_heat_map(node_list, nodes):
"""
Create a heat map for the node tree, under development.
"""
global DEBUG_MODE
times = []
total_test = 0
node_list = list(node_list)
for name in node_list:
if name in nodes:
start = time.perf_counter()
nodes[name].update()
delta = time.perf_counter()-start
total_test += delta
if data_structure.DEBUG_MODE:
print("Updated {0} in: {1}".format(name, round(delta, 4)))
times.append(delta)
if data_structure.DEBUG_MODE:
print("Layout updated in: {0} seconds".format(round(total_test, 4)))
if not times:
return
if not nodes.id_data.sv_user_colors:
color_data = {node.name: (node.color[:], node.use_custom_color) for node in nodes}
nodes.id_data.sv_user_colors = str(color_data)
t_max = max(times)
addon_name = data_structure.SVERCHOK_NAME
addon = bpy.context.user_preferences.addons.get(addon_name)
if addon:
# to use Vector.lerp
cold = Vector(addon.preferences.heat_map_cold)
hot = addon.preferences.heat_map_hot
else:
print("Cannot find preferences")
cold = Vector((1, 1, 1))
hot = (.8, 0, 0)
for name, t in zip(node_list, times):
nodes[name].use_custom_color = True
# linear scale.
nodes[name].color = cold.lerp(hot, t / t_max)
示例6: newColorWith
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import lerp [as 别名]
def newColorWith(col,vert2loopMap):
oldcolor = Vector((col[0],col[1],col[2],1))
if seltoolsOpts.bake_vccol_mask[0]:
R = seltoolsOpts.bake_vccol[0]
else:
R = oldcolor[0]
if seltoolsOpts.bake_vccol_mask[1]:
G = seltoolsOpts.bake_vccol[1]
else:
G = oldcolor[1]
if seltoolsOpts.bake_vccol_mask[2]:
B = seltoolsOpts.bake_vccol[2]
else:
B = oldcolor[2]
newcolor = Vector((R,G,B,1))
dopinfluence = 1.0
if vert2loopMap is not None and ivdx in vert2loopMap:
dopinfluence = vert2loopMap[ivdx]
tltInfl = self.opt_influence*dopinfluence
if self.opt_invertInfl:
tltInfl = 1.0-tltInfl
lerped = oldcolor.lerp(newcolor,tltInfl)
return lerped