Exemplo n.º 1
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.º 2
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.º 3
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.º 4
0
    def test_isect1(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([runtime], "ray_rectangle_intersection")

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

        self.intersect(ray, rectangle, runtime, ds)
Exemplo n.º 5
0
    def test_isect1(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([runtime], "ray_rectangle_intersection")

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

        self.intersect(ray, rectangle, runtime, ds)
Exemplo n.º 6
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.º 7
0
    def asm_code_bool(self):
        code = """
            #DATA
        """
        code += Ray.asm_struct() + Rectangle.asm_struct() + """
            Ray ray1
            Rectangle rec1
            float min_dist = 99999.000
            uint32 ret

            #CODE
            macro mov eax, ray1
            macro mov ebx, rec1 
            macro mov ecx, min_dist
            call ray_rectangle_intersection 
            mov dword [ret], eax

            #END
        """
        return code
Exemplo n.º 8
0
    def asm_code_bool(self):
        code = """
            #DATA
        """
        code += Ray.asm_struct() + Rectangle.asm_struct() + """
            Ray ray1
            Rectangle rec1
            float min_dist = 99999.000
            uint32 ret

            #CODE
            macro mov eax, ray1
            macro mov ebx, rec1 
            macro mov ecx, min_dist
            call ray_rectangle_intersection 
            mov dword [ret], eax

            #END
        """
        return code
Exemplo n.º 9
0
    def asm_code(self):
        code = """
            #DATA
        """
        code += Ray.asm_struct() + Rectangle.asm_struct() + HitPoint.asm_struct() + """
            Ray ray1
            Rectangle rec1
            Hitpoint hp1
            float min_dist = 99999.000
            uint32 ret

            #CODE
            mov eax, ray1
            mov ebx, rec1 
            mov ecx, min_dist
            mov edx, hp1
            call ray_rectangle_intersection 
            mov dword [ret], eax

            #END
        """
        return code
Exemplo n.º 10
0
    def asm_code(self):
        code = """
            #DATA
        """
        code += Ray.asm_struct() + Rectangle.asm_struct(
        ) + HitPoint.asm_struct() + """
            Ray ray1
            Rectangle rec1
            Hitpoint hp1
            float min_dist = 99999.000
            uint32 ret

            #CODE
            mov eax, ray1
            mov ebx, rec1 
            mov ecx, min_dist
            mov edx, hp1
            call ray_rectangle_intersection 
            mov dword [ret], eax

            #END
        """
        return code