示例#1
0
def isect(bbox, shader, linear):
    #origin = Vector3(0.0, 0.0, 0.0)
    origin = random_in_bbox(bbox)
    direction = random_in_bbox(bbox)
    direction.normalize()
    ray = Ray(origin, direction)
    hit = HitPoint()
    props = {'hit': hit, 'ret': 5, 'ray': ray}
    shader.props = props
    shader.update()

    shader.execute()
    h = linear.isect(ray)
    compare(h, shader, ray)
    if h is False:
        return 0
    return 1
示例#2
0
def visible(bbox, shader, linear):
    p1 = random_in_bbox(bbox)
    p2 = random_in_bbox(bbox)
    props = {'p1': p1, 'ret': 5, 'p2': p2}
    shader.props = props
    shader.update()

    shader.execute()
    h = linear.visibility(p1, p2)
    ret = shader.shader.get_value('ret')
    if h is True and ret != 1:
        print (p1)
        print (p2)
        raise ValueError("Something is wrong")
    if h is False and ret != 0:
        print (p1)
        print (p2)
        raise ValueError("Something is wrong")
示例#3
0
def generate_ray(bbox):
    dir = random_in_bbox(bbox) 
    dir.normalize()
    origin = Vector3(0.0, 0.0, 0.0)
    return Ray(origin, dir)