本文整理汇总了Python中mathutils.Vector.project方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.project方法的具体用法?Python Vector.project怎么用?Python Vector.project使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Vector
的用法示例。
在下文中一共展示了Vector.project方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_prepare
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import project [as 别名]
def draw_prepare(self, context):
from mathutils import Vector
view_inv = self.my_view_orientation(context)
self.view_inv = view_inv
self.rotate_axis = view_inv[2].xyz
self.rotate_up = view_inv[1].xyz
op = self.my_target_operator(context)
co = Vector(op.plane_co)
no = Vector(op.plane_no).normalized()
# Move
no_z = no
no_y = no_z.orthogonal()
no_x = no_z.cross(no_y)
matrix = self.widget_move.matrix_basis
matrix.identity()
matrix.col[0].xyz = no_x
matrix.col[1].xyz = no_y
matrix.col[2].xyz = no_z
matrix.col[3].xyz = co
# Dial
no_z = self.rotate_axis
no_y = (no - (no.project(no_z))).normalized()
no_x = self.rotate_axis.cross(no_y)
matrix = self.widget_dial.matrix_basis
matrix.identity()
matrix.col[0].xyz = no_x
matrix.col[1].xyz = no_y
matrix.col[2].xyz = no_z
matrix.col[3].xyz = co
示例2: Brushes
# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import project [as 别名]
class Brushes():
def __init__(self):
# The brushes are evaluated in world space, so as to avoid distortion
# caused by a nonuniform object space.
self.derived_brushes = list()
self.primary_brush = Brush()
self.symmetry_axes = list()
self.symmetry_center = Vector()
def derive_radial(self, count):
derived_brushes = self.derived_brushes
primary_brush = self.primary_brush
primary_brush_center = primary_brush.center
primary_brush_normal = primary_brush.normal
primary_brush_radius = primary_brush.radius
# Derive radially symmetrical brushes around each axis of symmetry.
for axis in self.symmetry_axes:
# Create a translation matrix to account for an axis of symmetry
# that is offset from the world origin.
symmetry_axis_offset = Matrix.Translation(self.symmetry_center)
for i in range(1, count):
# Create a rotation matrix to rotate a point around the axis of
# symmetry that is centered at the world origin.
rotation_matrix =\
Matrix.Rotation(2 * pi * i / count, 4, axis)
# Create a transformation matrix to rotate a point around the
# axis of symmetry that may be offset from the world origin.
transformation_matrix = symmetry_axis_offset * (
rotation_matrix * symmetry_axis_offset.inverted()
)
# Derive the radial brush, and append it to the list of
# derived brushes.
derived_brush = Brush()
derived_brush.center =\
transformation_matrix * primary_brush_center
derived_brush.normal = ((
transformation_matrix * primary_brush_normal - (
transformation_matrix * Vector((0, 0, 0))
)
).normalized()
)
derived_brush.radius = primary_brush_radius
derived_brush.transformation_matrix = transformation_matrix
derived_brushes.append(derived_brush)
def derive_mirrored(self):
derived_brushes = self.derived_brushes
primary_brush = self.primary_brush
# Derive symmetrical brushes across each plane of symmetry. This
# process generates b * 2 ** p - b derived brushes, where "b" is the
# number of brushes (primary and derived) prior to calling this method,
# and "p" is the number of symmetry planes.
for axis in self.symmetry_axes:
# Create a scaling matrix to mirror a point across the plane of
# symmetry centered at the world origin.
symmetry_mirror = Matrix.Scale(-1, 4, axis)
# Create a translation matrix to account for a plane of symmetry
# that is offset from the world origin.
symmetry_plane_offset = Matrix.Translation(
2 * self.symmetry_center.project(axis)
)
# Create a transformation matrix to mirror a point across the
# plane of symmetry that may be offset from the world origin.
transformation_matrix = symmetry_plane_offset * symmetry_mirror
# Create the mirror image of each brush, and append it to the list
# of derived brushes.
for brush in [primary_brush] + derived_brushes:
derived_brush = Brush()
derived_brush.center = transformation_matrix * brush.center
derived_brush.normal = ((
transformation_matrix * brush.normal - (
transformation_matrix * Vector((0, 0, 0))
)
).normalized()
)
derived_brush.radius = brush.radius
derived_brush.transformation_matrix = transformation_matrix * (
brush.transformation_matrix
)
derived_brushes.append(derived_brush)
def determine_influence(self, octree, falloff_curve,
ignore_backfacing=False, mesh_object=None):
coordinate_map = octree.coordinate_map
map_manager = MapManager()
primary_brush = self.primary_brush
vertex_filter = VertexFilter()
vertex_filter.mesh_object = mesh_object
# Determine the primary brush's influence.
#.........这里部分代码省略.........