Example #1
0
    def test_isect1(self):
        direction = Vector3(-1.0, -1.0, -1.0)
        direction.normalize()
        ray = Ray(Vector3(5.0, 5.0, 5.0), direction)
        sphere = Sphere(Vector3(0.0, 0.0, 0.0), 2)

        runtime = Runtime()
        assembler = create_assembler()
        sphere.isect_asm([runtime], "ray_sphere_intersection")
        mc = assembler.assemble(self.asm_code())
        ds = runtime.load("test", mc)

        self.intersect(ray, sphere, runtime, ds)
        for i in range(100):
            r = self.random_ray()
            s = self.random_sphere()
            self.intersect(r, s, runtime, ds)
Example #2
0
    def test_isect1(self):
        direction = Vector3(-1.0, -1.0, -1.0)
        direction.normalize()
        ray = Ray(Vector3(5.0, 5.0, 5.0), direction)
        sphere = Sphere(Vector3(0.0, 0.0, 0.0), 2)

        runtime = Runtime()
        assembler = create_assembler()
        sphere.isect_asm([runtime], "ray_sphere_intersection")
        mc = assembler.assemble(self.asm_code())
        ds = runtime.load("test", mc)

        self.intersect(ray, sphere, runtime, ds)
        for i in range(100):
            r = self.random_ray()
            s = self.random_sphere()
            self.intersect(r, s, runtime, ds)
Example #3
0
 def asm_code2(self):
     code = """
         #DATA
     """
     code += Ray.asm_struct() + Sphere.asm_struct() + """
         Ray ray1
         Sphere sph1
         float min_dist = 99999.000
         uint32 ret
         float t
         #CODE
         macro mov eax, ray1
         macro mov ebx, sph1
         macro mov ecx, min_dist
         call ray_sphere_intersection 
         mov dword [ret], eax
         macro eq32 t = xmm0 {xmm0}
         #END
     """
     return code
Example #4
0
 def asm_code(self):
     code = """
         #DATA
     """
     code += Ray.asm_struct() + Sphere.asm_struct() + HitPoint.asm_struct() + """
         Ray ray1
         Sphere sph1
         Hitpoint hp1
         float min_dist = 99999.000
         uint32 ret
         #CODE
         macro mov eax, ray1
         macro mov ebx, sph1
         macro mov ecx, min_dist
         macro mov edx, hp1
         call ray_sphere_intersection 
         mov dword [ret], eax
         #END
     """
     return code
Example #5
0
 def asm_code2(self):
     code = """
         #DATA
     """
     code += Ray.asm_struct() + Sphere.asm_struct() + """
         Ray ray1
         Sphere sph1
         float min_dist = 99999.000
         uint32 ret
         float t
         #CODE
         macro mov eax, ray1
         macro mov ebx, sph1
         macro mov ecx, min_dist
         call ray_sphere_intersection 
         mov dword [ret], eax
         macro eq32 t = xmm0 {xmm0}
         #END
     """
     return code
Example #6
0
 def asm_code(self):
     code = """
         #DATA
     """
     code += Ray.asm_struct() + Sphere.asm_struct() + HitPoint.asm_struct(
     ) + """
         Ray ray1
         Sphere sph1
         Hitpoint hp1
         float min_dist = 99999.000
         uint32 ret
         #CODE
         macro mov eax, ray1
         macro mov ebx, sph1
         macro mov ecx, min_dist
         macro mov edx, hp1
         call ray_sphere_intersection 
         mov dword [ret], eax
         #END
     """
     return code
Example #7
0
 def random_sphere(self):
     origin = Vector3(random(), random(), random())
     radius = random()
     return Sphere(origin, radius)