Exemplo n.º 1
0
    def test_isect_b(self):
        point = Vector3(0.0, 0.0, 55.92)
        e1 = Vector3(55.28, 0.0, 0.0)
        e2 = Vector3(0.0, 54.88, 0.0)
        normal = Vector3(0.0, 0.0, -1.0)
        rectangle = Rectangle(point, e1, e2, normal)

        origin = Vector3(3.0, 2.5, 0.0)
        direction = Vector3(0.0, 0.1, 0.88)
        direction.normalize()
        ray = Ray(origin, direction)

        runtime = Runtime()
        rectangle.isect_asm_b([runtime], "ray_rectangle_intersection")

        assembler = create_assembler()
        mc = assembler.assemble(self.asm_code_bool())
        ds = runtime.load("test", mc)

        Ray.populate_ds(ds, ray, 'ray1')
        Rectangle.populate_ds(ds, rectangle, 'rec1')

        runtime.run("test")
        hp = rectangle.isect(ray)

        if hp is False: self.assertFalse(ds["ret"] != 0)
        if ds["ret"] == 0: self.assertFalse(hp)
Exemplo n.º 2
0
    def test_isect_b(self):
        point = Vector3(0.0, 0.0, 55.92)
        e1 = Vector3(55.28, 0.0, 0.0)
        e2 = Vector3(0.0, 54.88, 0.0)
        normal = Vector3(0.0, 0.0, -1.0)
        rectangle = Rectangle(point, e1, e2, normal)

        origin = Vector3(3.0, 2.5, 0.0)
        direction = Vector3(0.0, 0.1, 0.88)
        direction.normalize()
        ray = Ray(origin, direction)

        runtime = Runtime()
        rectangle.isect_asm_b([runtime], "ray_rectangle_intersection")

        assembler = create_assembler()
        mc = assembler.assemble(self.asm_code_bool())
        ds = runtime.load("test", mc)

        Ray.populate_ds(ds, ray, 'ray1')
        Rectangle.populate_ds(ds, rectangle, 'rec1')

        runtime.run("test")
        hp = rectangle.isect(ray)

        if hp is False: self.assertFalse(ds["ret"]!=0)
        if ds["ret"] == 0: self.assertFalse(hp)
Exemplo n.º 3
0
    def intersect(self, ray, rectangle, runtime, ds):
        Ray.populate_ds(ds, ray, 'ray1')
        Rectangle.populate_ds(ds, rectangle, 'rec1')

        runtime.run("test")
        hp = rectangle.isect(ray)

        if hp is False: self.assertFalse(ds["ret"] != 0)
        if ds["ret"] == 0: self.assertFalse(hp)
        if hp is not False:
            self.compare(hp, ds, "hp1", ray, rectangle)
Exemplo n.º 4
0
    def intersect(self, ray, rectangle, runtime, ds):
        Ray.populate_ds(ds, ray, 'ray1')
        Rectangle.populate_ds(ds, rectangle, 'rec1')

        runtime.run("test")
        hp = rectangle.isect(ray)

        if hp is False: self.assertFalse(ds["ret"]!=0)
        if ds["ret"] == 0: self.assertFalse(hp)
        if hp is not False:
            self.compare(hp, ds, "hp1", ray, rectangle)
Exemplo n.º 5
0
    float _xmm0

    #CODE
    macro mov eax, ray1
    macro mov ebx, tri1
    macro mov ecx, min_dist
    macro mov edx, hp1
    call ray_triangle_intersection 
    mov dword [ret], eax
    macro eq32 _xmm0 = xmm0 {xmm0}
    #END
"""
mc = asm.assemble(code)
ds = runtime1.load("test", mc)

Ray.populate_ds(ds, ray, 'ray1')
Triangle.populate_ds(ds, t, 'tri1')
ds['min_dist'] = min_dist

runtime1.run("test")

if hit:
    print('hit=true ', 'ds["ret"]=', ds['ret'])
    print(hit.t, ds['hp1.t'], ds['_xmm0'])
    print(hit.hit)
    print(ds['hp1.hit'])
    print('----------------------------')
    print(hit.normal)
    print(ds['hp1.normal'])
    print('----------------------------')
    print(hit.material_idx, ds['hp1.material_idx'])
Exemplo n.º 6
0
    float _xmm0

    #CODE
    macro mov eax, ray1
    macro mov ebx, tri1
    macro mov ecx, min_dist
    macro mov edx, hp1
    call ray_triangle_intersection 
    mov dword [ret], eax
    macro eq32 _xmm0 = xmm0 {xmm0}
    #END
"""
mc = asm.assemble(code)
ds = runtime1.load("test", mc)

Ray.populate_ds(ds, ray, 'ray1')
Triangle.populate_ds(ds, t, 'tri1')
ds['min_dist'] = min_dist

runtime1.run("test")

if hit:
    print('hit=true ', 'ds["ret"]=', ds['ret'])
    print(hit.t, ds['hp1.t'], ds['_xmm0'])
    print(hit.hit)
    print(ds['hp1.hit'])
    print('----------------------------')
    print(hit.normal)
    print(ds['hp1.normal'])
    print('----------------------------')
    print(hit.material_idx, ds['hp1.material_idx'])