def poly_to_doom(me, p, radius):
"""
Convert a face into Doom3 representation (infinite plane defined by its normal
and distance from origin along that normal).
"""
# Compute the distance to the mesh from the origin to the plane.
# Line from origin in the direction of the face normal.
origin = Vector((0, 0, 0))
target = Vector(p.normal) * radius
# Find the target point.
intersect = mathutils.geometry.intersect_line_plane(origin, target, Vector(p.center), Vector(p.normal))
# We have to handle cases where intersection with face happens on the "negative" part of the vector!
length = intersect.length
nor = p.normal.copy()
if (nor.dot(intersect.normalized()) > 0):
length *= -1
nor.resize_4d()
nor.w = length
return nor
评论列表
文章目录