本文整理汇总了Python中mathutils.Vector.length方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.length方法的具体用法?Python Vector.length怎么用?Python Vector.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Vector
的用法示例。
在下文中一共展示了Vector.length方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_arrow
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import length [as 别名]
def draw_arrow(point, orientation, length=1.5, branch_length=0.4, angle=30, colour=[1, 0, 0]):
left = Vector((sin(radians(angle)), -cos(radians(angle)), 0))
right = Vector((-sin(radians(angle)), -cos(radians(angle)), 0))
left.rotate(orientation)
right.rotate(orientation)
left.length = branch_length
right.length = branch_length
direction = Vector((0, 1, 0)) * length
direction.rotate(orientation)
render.drawLine(point, point + direction, colour)
render.drawLine(point + direction, point + direction + right, colour)
render.drawLine(point + direction, point + direction + left, colour)
示例2: moveup
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import length [as 别名]
def moveup(self):
bfvec = Vector((0, 0, 1))
bfvec.length = self.addonprefs.Speed * self.addonprefs.Scale * self.runmulti / self.divi
if self.scn.FPS_Walk:
self.addonprefs.Height += bfvec.length * self.addonprefs.Scale
else:
self.rv3d.view_location += bfvec
示例3: movedown
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import length [as 别名]
def movedown(self):
bfvec = Vector((0, 0, 1))
bfvec.length = self.addonprefs.Speed * self.addonprefs.Scale * self.runmulti / self.divi
if self.scn.FPS_Walk:
self.addonprefs.Height -= bfvec.length * self.addonprefs.Scale
if self.addonprefs.Height <= 0:
self.addonprefs.Height = 0.0001
else:
self.rv3d.view_location -= bfvec
示例4: onKeyPressed
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import length [as 别名]
def onKeyPressed(self, keys):
rot = self.obj.worldOrientation.to_euler()
pos = Vector([0,0,0])
if key.W in keys: rot.x += 0.01
if key.S in keys: rot.x -= 0.01
if key.A in keys: rot.z += 0.01
if key.D in keys: rot.z -= 0.01
if key.WHEELUPMOUSE in keys: pos.z = -self.obj.worldPosition.z * 0.3
if key.WHEELDOWNMOUSE in keys: pos.z = self.obj.worldPosition.z * 0.3
#Max speed is dependent of the Tile sizes, ex (200m/s = size) / 50fps = 4m/tick
#Since we are using an extra radius we can guarante a speed of 8m/tick without glitches: 8*60fps = 480m/s = 1728 km/h
#if pos.length > 8: pos.length = 8
#But we don't care for now
if pos.length > 50: pos.length = 50
pos.rotate(self.obj.worldOrientation)
self.obj.worldPosition += pos
self.obj.worldOrientation = rot
示例5: select_front_facing
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import length [as 别名]
def select_front_facing(context):
"""
from: http://freespace.virgin.net/hugo.elias/routines/r_dot.htm
When deciding if a polygon is facing the camera, you need
only calculate the dot product of the normal vector of
that polygon, with a vector from the camera to one of the
polygon's vertices.
- If the dot product is less than zero, the polygon is facing the camera.
- If the value is greater than zero, it is facing away from the camera.
"""
region, rv3d, obj, vertlist = get_locals(context)
# [ ] be in object mode
# neat eye location code with the help of paleajed
eye = Vector(rv3d.view_matrix[2][:3])
eye.length = rv3d.view_distance
eye_location = rv3d.view_location + eye
face_list = []
for idx, polygon in enumerate(obj.data.polygons):
vert_index = polygon.vertices[0]
pnormal = obj.matrix_world * polygon.normal
world_coordinate = obj.matrix_world * vertlist[vert_index].co
result_vector = eye_location-world_coordinate
dot_value = pnormal.dot(result_vector.normalized())
if dot_value < 0.0:
polygon.select = False
else:
polygon.select = True
face_list.append(idx)
return face_list
示例6: moveback
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import length [as 别名]
def moveback(self):
bfvec = Vector(self.rv3d.view_matrix[2][:3])
bfvec.length = self.addonprefs.Speed * self.addonprefs.Scale * self.runmulti / self.divi
self.rv3d.view_location += bfvec