本文整理汇总了Python中mathutils.geometry.intersect_line_plane函数的典型用法代码示例。如果您正苦于以下问题:Python intersect_line_plane函数的具体用法?Python intersect_line_plane怎么用?Python intersect_line_plane使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了intersect_line_plane函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: find_distant_bmedge_crossing_plane
def find_distant_bmedge_crossing_plane(pt, no, edges, epsilon, e_ind_from, co_from):
'''
returns the farthest edge that *crosses* plane and corresponding intersection point
'''
if(len(edges)==3):
# shortcut (no need to find farthest... just find first)
for edge in edges:
if edge.index == e_ind_from: continue
v0,v1 = edge.verts
co0,co1 = v0.co,v1.co
s0,s1 = no.dot(co0 - pt), no.dot(co1 - pt)
no_cross = not ((s0>epsilon and s1<-epsilon) or (s0<-epsilon and s1>epsilon))
if no_cross: continue
i = intersect_line_plane(co0, co1, pt, no)
return (edge,i)
d_max,edge_max,i_max = -1.0,None,None
for edge in edges:
if edge.index == e_ind_from: continue
v0,v1 = edge.verts
co0,co1 = v0.co, v1.co
s0,s1 = no.dot(co0 - pt), no.dot(co1 - pt)
if s0 > epsilon and s1 > epsilon: continue
if s0 < -epsilon and s1 < -epsilon: continue
#if not ((s0>epsilon and s1<-epsilon) or (s0<-epsilon and s1>epsilon)): # edge cross plane?
# continue
i = intersect_line_plane(co0, co1, pt, no)
d = (co_from - i).length
if d > d_max: d_max,edge_max,i_max = d,edge,i
return (edge_max,i_max)
开发者ID:Cx-01,项目名称:myblendercontrib,代码行数:33,代码来源:cut_algorithms.py
示例2: f_
def f_(me, list_0, arg, context, ob_act):
cb = context.scene.pt_custom_props.b
cen1 = context.scene.pt_custom_props.en1
dict_0 = {}
dict_1 = {}
if arg == 'x':
pn = Vector((0, 1, 0))
pp = Vector((1, 0, 0))
elif arg == 'y':
pn = Vector((1, 0, 0))
pp = Vector((0, 1, 0))
elif arg == 'z':
pn = Vector((0, 0, 1))
pp = Vector((0, 1, 0))
if cb == False:
for vi in list_0:
v = (me.vertices[vi].co).copy()
p = v + (pn * 0.1)
if cen1 == 'opt0':
p3 = intersect_line_plane(v, p, pp, pn)
elif cen1 == 'opt1':
p1 = ob_act.matrix_world * v
gp = p1 + (pn * 0.1)
p2 = intersect_line_plane(p1, gp, pp, pn)
p3 = (ob_act.matrix_world).inverted() * p2
dict_0[vi] = p3
for j in dict_0:
me.vertices[j].co = dict_0[j]
elif cb == True:
for vi in list_0:
v = (me.vertices[vi].co).copy()
p = v + (pn * 0.1)
if cen1 == 'opt0':
p3 = intersect_line_plane(v, p, pp, pn)
elif cen1 == 'opt1':
p1 = ob_act.matrix_world * v
gp = p1 + (pn * 0.1)
p2 = intersect_line_plane(p1, gp, pp, pn)
p3 = (ob_act.matrix_world).inverted() * p2
me.vertices.add(1)
me.vertices[-1].co = p3
me.vertices[-1].select = False
dict_1[vi] = me.vertices[-1].index
edge_copy_(me, dict_1)
faces_copy_(me, dict_1)
开发者ID:TomACPace,项目名称:blenderpython,代码行数:54,代码来源:project_arbitrary.py
示例3: mouse_to_plane
def mouse_to_plane(self, context, event, origin=Vector((0, 0, 0)), normal=Vector((0, 0, 1))):
"""
convert mouse pos to 3d point over plane defined by origin and normal
"""
region = context.region
rv3d = context.region_data
co2d = (event.mouse_region_x, event.mouse_region_y)
view_vector_mouse = region_2d_to_vector_3d(region, rv3d, co2d)
ray_origin_mouse = region_2d_to_origin_3d(region, rv3d, co2d)
pt = intersect_line_plane(ray_origin_mouse, ray_origin_mouse + view_vector_mouse,
origin, normal, False)
# fix issue with parallel plane
if pt is None:
pt = intersect_line_plane(ray_origin_mouse, ray_origin_mouse + view_vector_mouse,
origin, view_vector_mouse, False)
return pt
开发者ID:fjuhec,项目名称:blender-addons,代码行数:16,代码来源:archipack_object.py
示例4: execute
def execute(self, context):
edit_mode_out()
ob_act = context.active_object
me = ob_act.data
list_0 = [v.index for v in me.vertices if v.select]
if len(va_buf.list_f) == 0:
self.report({'INFO'}, 'No face stored in memory')
edit_mode_in()
return {'CANCELLED'}
elif len(va_buf.list_f) != 0:
if len(list_0) == 0:
self.report({'INFO'}, 'No vertices selected')
edit_mode_in()
return {'CANCELLED'}
elif len(list_0) != 0:
f = me.faces[va_buf.list_f[0]]
for i in list_0:
v = (me.vertices[i].co).copy()
p = v + ((f.normal).copy() * 0.1)
pp = (me.vertices[f.vertices[0]].co).copy()
pn = (f.normal).copy()
me.vertices[i].co = intersect_line_plane(v, p, pp, pn)
edit_mode_in()
return {'FINISHED'}
开发者ID:Badcreature,项目名称:sagcg,代码行数:25,代码来源:zmj100_vertex_align.py
示例5: extend_vertex
def extend_vertex():
obj = bpy.context.edit_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
verts = bm.verts
faces = bm.faces
plane = [f for f in faces if f.select][0]
plane_vert_indices = [v for v in plane.verts[:]]
all_selected_vert_indices = [v for v in verts if v.select]
M = set(plane_vert_indices)
N = set(all_selected_vert_indices)
O = N.difference(M)
O = list(O)
(v1_ref, v1_idx, v1), (v2_ref, v2_idx, v2) = [(i, i.index, i.co) for i in O]
plane_co = plane.calc_center_median()
plane_no = plane.normal
new_co = intersect_line_plane(v1, v2, plane_co, plane_no, False)
new_vertex = verts.new(new_co)
A_len = (v1 - new_co).length
B_len = (v2 - new_co).length
vertex_reference = v1_ref if (A_len < B_len) else v2_ref
bm.edges.new([vertex_reference, new_vertex])
bmesh.update_edit_mesh(me, True)
开发者ID:Cx-01,项目名称:myblendercontrib,代码行数:31,代码来源:E2F.py
示例6: mutual_cut
def mutual_cut(sli1, sli2, cut_spec={}):
"""Given two slices, add the appropriate cuts to them if they intersect"""
if sli1.rot == sli2.rot:
return # same orientation, so nothing to intersect
cut_dir = sli1.cut_direction(sli2)
verts_3d = [sli1.to_3d(pt) for pt in sli1.poly.exterior.coords]
points = []
for (pta, ptb) in pairwise(verts_3d):
intersect = intersect_line_plane(pta, ptb, sli2.co, sli2.normal())
# Is the intersecting point between the ends of the segment?
if intersect and (pta - intersect).dot(ptb - intersect) <= 0:
points.append(intersect)
if len(points) > 2:
print("More than one intersection between slices. Not yet supported!")
# There should always be an even number of crossings
assert len(points) % 2 == 0
z_factor = cut_spec.get('z_factor', 0.5)
if len(points) >= 2:
midpt = points[0].lerp(points[1], z_factor)
sli1.add_cut(midpt, cut_dir, sli2.thickness)
sli2.add_cut(midpt, -cut_dir, sli1.thickness)
开发者ID:gjinhui,项目名称:sly,代码行数:27,代码来源:ops.py
示例7: triangle_intersection
def triangle_intersection(self, points: List[Point]):
l = len(points)
assert l == 3, 'triangle intersection on non triangle (%d)' % (l,)
s0, s1, s2 = map(self.side, points)
if abs(s0 + s1 + s2) == 3:
return [] # all points on same side of plane
p0, p1, p2 = map(Point, points)
if s0 == 0 or s1 == 0 or s2 == 0: # at least one point on plane
# handle if all points in plane
if s0 == 0 and s1 == 0 and s2 == 0:
return [(p0, p1), (p1, p2), (p2, p0)]
# handle if two points in plane
if s0 == 0 and s1 == 0:
return [(p0, p1)]
if s1 == 0 and s2 == 0:
return [(p1, p2)]
if s2 == 0 and s0 == 0:
return [(p2, p0)]
# one point on plane, two on same side
if s0 == 0 and s1 == s2:
return [(p0, p0)]
if s1 == 0 and s2 == s0:
return [(p1, p1)]
if s2 == 0 and s0 == s1:
return [(p2, p2)]
# two points on one side, one point on the other
p01 = intersect_line_plane(p0, p1, self.o, self.n)
p12 = intersect_line_plane(p1, p2, self.o, self.n)
p20 = intersect_line_plane(p2, p0, self.o, self.n)
if s0 == 0:
return [(p0, p12)]
if s1 == 0:
return [(p1, p20)]
if s2 == 0:
return [(p2, p01)]
if s0 != s1 and s0 != s2 and p01 and p20:
return [(p01, p20)]
if s1 != s0 and s1 != s2 and p01 and p12:
return [(p01, p12)]
if s2 != s0 and s2 != s1 and p12 and p20:
return [(p12, p20)]
print('%s %s %s' % (str(p0), str(p1), str(p2)))
print('%s %s %s' % (str(s0), str(s1), str(s2)))
print('%s %s %s' % (str(p01), str(p12), str(p20)))
assert False
开发者ID:CGCookie,项目名称:retopoflow,代码行数:45,代码来源:maths.py
示例8: follow_mouse_intersection
def follow_mouse_intersection(sensor):
ray_p0 = sensor.raySource
ray_p1 = sensor.rayTarget
# print ("rays ", ray_p0, ray_p1)
intersection = geometry.intersect_line_plane(ray_p0, ray_p1, G.plane.p, G.plane.n)
if intersection:
# print (intersection)
G.stimLocation = [intersection.x, intersection.y, G.stim.worldPosition[2]]
G.holeLocation = [intersection.x, intersection.y, G.hole.worldPosition[2]]
开发者ID:jaybo,项目名称:BlenderStim,代码行数:10,代码来源:CircleStim.py
示例9: grab_mouse_move
def grab_mouse_move(self,context,x,y):
region = context.region
rv3d = context.region_data
coord = x, y
view_vector = view3d_utils.region_2d_to_vector_3d(region, rv3d, coord)
ray_origin = view3d_utils.region_2d_to_origin_3d(region, rv3d, coord)
ray_target = ray_origin + (view_vector * 1000)
crv_mx = self.crv_obj.matrix_world
i_crv_mx = crv_mx.inverted()
hit = False
if self.snap_type == 'SCENE':
mx = Matrix.Identity(4) #scene ray cast returns world coords
if bversion() < '002.077.000':
res, obj, omx, loc, no = context.scene.ray_cast(ray_origin, ray_target)
else:
res, loc, no, ind, obj, omx = context.scene.ray_cast(ray_origin, view_vector)
if res:
hit = True
else:
#cast the ray into a plane a
#perpendicular to the view dir, at the last bez point of the curve
hit = True
view_direction = rv3d.view_rotation * Vector((0,0,-1))
plane_pt = self.grab_undo_loc
loc = intersect_line_plane(ray_origin, ray_target,plane_pt, view_direction)
elif self.snap_type == 'OBJECT':
mx = self.snap_ob.matrix_world
imx = mx.inverted()
if bversion() < '002.077.000':
loc, no, face_ind = self.snap_ob.ray_cast(imx * ray_origin, imx * ray_target)
if face_ind != -1:
hit = True
else:
ok, loc, no, face_ind = self.snap_ob.ray_cast(imx * ray_origin, imx * ray_target - imx*ray_origin)
if ok:
hit = True
if not hit:
self.grab_cancel()
else:
local_loc = i_crv_mx * mx * loc
self.crv_data.splines[0].bezier_points[self.selected].co = local_loc
self.b_pts[self.selected] = mx * loc
开发者ID:patmo141,项目名称:odc_public,代码行数:52,代码来源:curve.py
示例10: execute
def execute(self, context):
bpy.ops.object.editmode_toggle()
bm = bmesh.new()
bm.from_mesh(context.active_object.data)
# For easy access to verts, edges, and faces:
bVerts = bm.verts
bEdges = bm.edges
bFaces = bm.faces
fVerts = []
normal = None
# Find the selected face. This will provide the plane to project onto:
for f in bFaces:
if f.select:
for v in f.verts:
fVerts.append(v)
f.normal_update()
normal = f.normal
f.select = False
break
for e in bEdges:
if e.select:
v1 = e.verts[0]
v2 = e.verts[1]
if v1 in fVerts and v2 in fVerts:
e.select = False
continue
intersection = intersect_line_plane(v1.co, v2.co, fVerts[0].co, normal)
if intersection != None:
d1 = distance_point_to_plane(v1.co, fVerts[0].co, normal)
d2 = distance_point_to_plane(v2.co, fVerts[0].co, normal)
# If they have different signs, then the edge crosses the plane:
if abs(d1 + d2) < abs(d1 - d2):
# Make the first vertice the positive vertice:
if d1 < d2:
v2, v1 = v1, v2
new = list(bmesh.utils.edge_split(e, v1, 0.5))
new[1].co = intersection
e.select = False
new[0].select = False
if self.pos:
bEdges.remove(new[0])
if self.neg:
bEdges.remove(e)
bm.to_mesh(context.active_object.data)
bpy.ops.object.editmode_toggle()
## bpy.ops.mesh.remove_doubles()
return {'FINISHED'}
开发者ID:Badcreature,项目名称:sagcg,代码行数:52,代码来源:mesh_edgetools.py
示例11: edge_intersection
def edge_intersection(self, points: List[Point]):
s0, s1 = map(self.side, points)
if abs(s0 + s1) == 2:
return [] # points on same side
p0, p1 = map(Point, points)
if s0 == 0 and s1 == 0:
return [(p0, p1)]
if s0 == 0:
return [(p0, p0)]
if s1 == 0:
return [(p1, p1)]
p01 = Point(intersect_line_plane(p0, p1, self.o, self.n))
return [(p01, p01)]
开发者ID:CGCookie,项目名称:retopoflow,代码行数:13,代码来源:maths.py
示例12: get_world_coords
def get_world_coords(coords):
cont = logic.getCurrentController()
ray = cont.sensors["MouseRay"]
ray_start = ray.raySource
ray_end = ray.rayTarget
plane_origin = Vector((0, 0, 0))
plane_normal = Vector((0, 0, 1))
intersection = geometry.intersect_line_plane(ray_start, ray_end, plane_origin, plane_normal)
if intersection:
return intersection
开发者ID:gandalf3,项目名称:The-Queen-s-Workers,代码行数:13,代码来源:selecter.py
示例13: region_2d_to_location_3d
def region_2d_to_location_3d(region, rv3d, coord, depth_location):
"""
Return a 3d location from the region relative 2d coords, aligned with
*depth_location*.
:arg region: region of the 3D viewport, typically bpy.context.region.
:type region: :class:`bpy.types.Region`
:arg rv3d: 3D region data, typically bpy.context.space_data.region_3d.
:type rv3d: :class:`bpy.types.RegionView3D`
:arg coord: 2d coordinates relative to the region;
(event.mouse_region_x, event.mouse_region_y) for example.
:type coord: 2d vector
:arg depth_location: the returned vectors depth is aligned with this since
there is no defined depth with a 2d region input.
:type depth_location: 3d vector
:return: normalized 3d vector.
:rtype: :class:`mathutils.Vector`
"""
from mathutils import Vector
from mathutils.geometry import intersect_point_line
persmat = rv3d.perspective_matrix.copy()
viewinv = rv3d.view_matrix.inverted()
coord_vec = region_2d_to_vector_3d(region, rv3d, coord)
depth_location = Vector(depth_location)
if rv3d.is_perspective:
from mathutils.geometry import intersect_line_plane
origin_start = viewinv.translation.copy()
origin_end = origin_start + coord_vec
view_vec = viewinv.col[2].copy()
return intersect_line_plane(origin_start,
origin_end,
depth_location,
view_vec, 1,
)
else:
dx = (2.0 * coord[0] / region.width) - 1.0
dy = (2.0 * coord[1] / region.height) - 1.0
persinv = persmat.inverted()
viewinv = rv3d.view_matrix.inverted()
origin_start = ((persinv.col[0].xyz * dx) +
(persinv.col[1].xyz * dy) +
viewinv.translation)
origin_end = origin_start + coord_vec
return intersect_point_line(depth_location,
origin_start,
origin_end,
)[0]
开发者ID:Badcreature,项目名称:sagcg,代码行数:50,代码来源:view3d_utils.py
示例14: mousemove_drawing
def mousemove_drawing(self, context, event):
screen_v = Vector((event.mouse_region_x, event.mouse_region_y))
self.mouse_path.append((event.mouse_region_x, event.mouse_region_y))
#this will just add in apoint every 10 recorded mouse positions
#later you will want to do something smarter :-)
if len(self.mouse_path) > self.draw_points_max or (screen_v - Vector(self.mouse_path[0])).length >= self.extrusion_radius:
region = context.region
rv3d = context.region_data
#this is the view_vector @ the mous coord
#which is not the same as the view_direction!!!
view_vector = view3d_utils.region_2d_to_vector_3d(region, rv3d, self.mouse_path[-1])
ray_origin = view3d_utils.region_2d_to_origin_3d(region, rv3d, self.mouse_path[-1])
ray_target = ray_origin + (view_vector * 10000)
#cast the ray into a plane a
#perpendicular to the view dir, at the last bez point of the curve
view_direction = rv3d.view_rotation * Vector((0,0,-1))
if self.active_spline.type == 'BEZIER':
plane_pt = self.curve_object.matrix_world * self.active_spline.bezier_points[-1].co
elif self.active_spline.type == 'NURBS':
plane_pt = self.curve_object.matrix_world * self.active_spline.points[-1].co
new_coord = intersect_line_plane(ray_origin, ray_target,plane_pt, view_direction)
if new_coord:
if self.active_spline.type == 'BEZIER':
self.active_spline.bezier_points.add(1)
self.active_spline.bezier_points[-1].co = self.curve_object.matrix_world.inverted() * new_coord
self.active_spline.bezier_points[-1].handle_right.xyz = self.active_spline.bezier_points[-1].co
self.active_spline.bezier_points[-1].handle_left.xyz = self.active_spline.bezier_points[-1].co
self.active_spline.bezier_points[-1].handle_left_type = 'AUTO'
self.active_spline.bezier_points[-1].handle_right_type = 'AUTO'
elif self.active_spline.type == 'NURBS':
self.active_spline.points.add(1)
loc = self.curve_object.matrix_world.inverted() * new_coord
#NURBS pahts have 4 dim points
self.active_spline.points[-1].co = Vector((loc[0], loc[1], loc[2], 1))
#udpate everything
#udpate modifiers and objects etc.
self.curve_object.update_tag()
context.scene.update()
self.mouse_path = []
开发者ID:patmo141,项目名称:curve_extrude_playground,代码行数:48,代码来源:__init__.py
示例15: _intersect_edge_plane
def _intersect_edge_plane(self, edge, orientation, position, ix_points):
""" Find the intersection between this edge and plane.
Append the IntersectionPoint (if any) to ix_points.
"""
if (edge, None) in self._saved_results:
return self._saved_results[(edge, None)]
if (edge.t_vert.pos[orientation] > position and
edge.b_vert.pos[orientation] > position):
point = None
elif (edge.t_vert.pos[orientation] < position and
edge.b_vert.pos[orientation] < position):
point = None
else:
vec_t_vert = Vector((edge.t_vert.pos))
vec_b_vert = Vector((edge.b_vert.pos))
plane_co = Vector(([0,0,0]))
plane_co[orientation] = position
plane_norm = Vector(([0,0,0]))
plane_norm[orientation] = 1.
point = intersect_line_plane(vec_t_vert,
vec_b_vert,
plane_co,
plane_norm,
False) # only intersect segment
if not point:
ix_point = None
# print("Not found!")
# print(" t_vert: " + str(edge.t_vert.pos))
# print(" b_vert: " + str(edge.b_vert.pos))
# print(" pl_pos: " + str(position))
else:
# print("Found ixpoint! " + str(point))
# print(" t_vert: " + str(vec_t_vert))
# print(" b_vert: " + str(vec_b_vert))
# print(" pl_pos: " + str(position))
ix_point = IntersectionPoint(edge, None, point)
ix_points.append(ix_point)
self._saved_results[(edge, None)] = ix_point
return ix_point
开发者ID:andrewkho,项目名称:blendseg,代码行数:46,代码来源:intersector.py
示例16: f_3
def f_3(me, list_f, list_0):
dict_1 = {vi: [] for vi in list_0}
for fi in list_f:
f = me.faces[fi]
pp = (me.vertices[f.vertices[0]].co).copy()
pn = (f.normal).copy()
for vi in list_0:
v = (me.vertices[vi].co).copy()
p = v + ((f.normal).copy() * 0.1)
p1 = intersect_line_plane(v, p, pp, pn)
me.vertices.add(1)
me.vertices[-1].co = p1
me.vertices[-1].select = False
dict_1[vi].append(me.vertices[-1].index)
n = len(list_f)
edge_copy_1(me, dict_1, n)
faces_copy_1(me, dict_1, n)
开发者ID:TomACPace,项目名称:blenderpython,代码行数:22,代码来源:project_arbitrary.py
示例17: f_1
def f_1(me, list_0, list_1):
dict_1 = {vi: [] for vi in list_1}
for fi in list_0:
f = me.faces[fi]
for vi in list_1:
v = (me.vertices[vi].co).copy()
p = v + ((f.normal).copy() * 0.1)
pp = (me.vertices[f.vertices[0]].co).copy()
pn = (f.normal).copy()
p1 = intersect_line_plane(v, p, pp, pn)
d = (p1 - v).length
p2 = p1 + ((f.normal).copy() * d)
me.vertices.add(1)
me.vertices[-1].co = p2
me.vertices[-1].select = False
dict_1[vi].append(me.vertices[-1].index)
n = len(list_0)
edge_copy_1(me, dict_1, n)
faces_copy_1(me, dict_1, n)
开发者ID:Badcreature,项目名称:sagcg,代码行数:22,代码来源:mirror_arbitrary.py
示例18: com_line_cross_test
def com_line_cross_test(com1, com2, pt, no, factor = 2):
'''
test used to make sure a cut is reasoably between
2 other cuts
higher factor requires better aligned cuts
'''
v = intersect_line_plane(com1,com2,pt,no)
if v:
#if the distance between the intersection is less than
#than 1/factor the distance between the current pair
#than this pair is invalide because there is a loop
#in between
check = intersect_point_line(v,com1,com2)
invalid_length = (com2 - com1).length/factor #length beyond which an intersection is invalid
test_length = (v - pt).length
#this makes sure the plane is between A and B
#meaning the test plane is between the two COM's
in_between = check[1] >= 0 and check[1] <= 1
if in_between and test_length < invalid_length:
return True
开发者ID:tito21,项目名称:script-bakery,代码行数:24,代码来源:contour_utilities.py
示例19: intersect
def intersect(self, v1, v2):
"""平面とv1-v2からなる直線の交点を求める"""
return geom.intersect_line_plane(v1, v2, self.location, self.normal)
开发者ID:Italic-,项目名称:blenderpython,代码行数:3,代码来源:vamath.py
示例20: cross_section
def cross_section(bme, mx, point, normal, debug = True):
'''
Takes a mesh and associated world matrix of the object and returns a cross secion in local
space.
Args:
mesh: Blender BMesh
mx: World matrix (type Mathutils.Matrix)
point: any point on the cut plane in world coords (type Mathutils.Vector)
normal: plane normal direction (type Mathutisl.Vector)
'''
times = []
times.append(time.time())
#bme = bmesh.new()
#bme.from_mesh(me)
#bme.normal_update()
#if debug:
#n = len(times)
#times.append(time.time())
#print('succesfully created bmesh in %f sec' % (times[n]-times[n-1]))
verts =[]
eds = []
#convert point and normal into local coords
#in the mesh into world space.This saves 2*(Nverts -1) matrix multiplications
imx = mx.inverted()
pt = imx * point
no = imx.to_3x3() * normal #local normal
edge_mapping = {} #perhaps we should use bmesh becaus it stores the great cycles..answer yup
for ed in bme.edges:
A = ed.verts[0].co
B = ed.verts[1].co
V = B - A
proj = V.project(no).length
#perp to normal = parallel to plane
#only calc 2nd projection if necessary
if proj == 0:
#make sure not coplanar
p_to_A = A - pt
a_proj = p_to_A.project(no).length
if a_proj == 0:
edge_mapping[len(verts)] = ed.link_faces
verts.append(1/2 * (A +B)) #put a midpoing since both are coplanar
else:
#this handles the one point on plane case
v = intersect_line_plane(A,B,pt,no)
if v:
check = intersect_point_line(v,A,B)
if check[1] >= 0 and check[1] <= 1:
#the vert coord index = the face indices it came from
edge_mapping[len(verts)] = [f.index for f in ed.link_faces]
verts.append(v)
if debug:
n = len(times)
times.append(time.time())
print('calced intersections %f sec' % (times[n]-times[n-1]))
#iterate through smartly to create edge keys
for i in range(0,len(verts)):
a_faces = set(edge_mapping[i])
for m in range(i,len(verts)):
if m != i:
b_faces = set(edge_mapping[m])
if a_faces & b_faces:
eds.append((i,m))
if debug:
n = len(times)
times.append(time.time())
print('calced connectivity %f sec' % (times[n]-times[n-1]))
if len(verts):
#new_me = bpy.data.meshes.new('Cross Section')
#new_me.from_pydata(verts,eds,[])
#if debug:
#n = len(times)
#times.append(time.time())
#print('Total Time: %f sec' % (times[-1]-times[0]))
return (verts, eds)
else:
#.........这里部分代码省略.........
开发者ID:ElectricShadow,项目名称:script-bakery,代码行数:101,代码来源:contour_utilities.py
注:本文中的mathutils.geometry.intersect_line_plane函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论