예제 #1
0
def by_outside(vertices, edges, faces, percent, center):
    face_normals = pols_normals(vertices, faces, output_numpy=True)
    center = Vector(center[0])

    def get_center(face):
        verts = [Vector(vertices[i]) for i in face]
        result = Vector((0, 0, 0))
        for v in verts:
            result += v
        return (1.0 / float(len(verts))) * result

    values = []
    for face, normal in zip(faces, face_normals):
        face_center = get_center(face)
        direction = face_center - center
        dirlength = direction.length
        if dirlength > 0:
            value = math.pi - direction.angle(normal)
        else:
            value = math.pi
        values.append(value)
    threshold = map_percent(values, percent[0])

    out_face_mask = [(value >= threshold) for value in values]

    return out_face_mask
예제 #2
0
def by_normal(vertices, edges, faces, percent, direction):
    face_normals = pols_normals(vertices, faces, output_numpy=True)
    np_dir, np_percent = numpy_match_long_repeat(
        [np.array(direction), np.array(percent)])
    values = np_dot(face_normals[:, np.newaxis], np_dir[np.newaxis, :], axis=2)
    threshold = map_percent(values, np_percent)
    out_face_mask = np.any(values >= threshold, axis=1)

    return out_face_mask
예제 #3
0
def face_light_factor(vecs, polygons, light):
    return (np_dot(pols_normals(vecs, polygons, output_numpy=True), light)*0.5+0.5).tolist()