Beispiel #1
0
def asm_code(label_ray_mesh_isect, mesh):
    struct_name = mesh.asm_struct_name()
    code = """
        #DATA
    """
    code += Ray.asm_struct() + mesh.asm_struct() + HitPoint.asm_struct() + """
        Ray ray1
    """
    code += struct_name + " mesh1" + """
        Hitpoint hp1
        float min_dist = 99999.000
        float max_dist = 99999.000
        uint32 ret
        float t
        #CODE
        macro eq32 min_dist = max_dist {xmm7}
        macro mov eax, ray1
        macro mov ebx, mesh1
        macro mov ecx, min_dist
        macro mov edx, hp1
    """
    code += "call " + label_ray_mesh_isect + """ 
        mov dword [ret], eax
        macro eq32 t = xmm0 {xmm7}
        #END
    """
    return code
Beispiel #2
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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #6
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
Beispiel #7
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
Beispiel #8
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
Beispiel #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
Beispiel #10
0
mgr.add('t2', t2)

origin = Vector3(0.2, 0.4, 0.6)
direction = Vector3(1.2, 1.1, 1.12)
direction.normalize()
ray = Ray(origin, direction)

linear = LinearIsect(mgr)

hit = linear.isect(ray)

runtime = Runtime()
linear.isect_asm([runtime], 'ray_scene_intersection')

code = "#DATA \n"
code += Ray.asm_struct() + HitPoint.asm_struct() + """
    Ray ray1
    Hitpoint hp1
    uint32 ret

    #CODE
    macro mov eax, ray1
    macro mov ebx, hp1
    call ray_scene_intersection 
    mov dword [ret], eax
    #END
"""
asm = create_assembler()
mc = asm.assemble(code)

ds = runtime.load('test', mc)
Beispiel #11
0
t = Triangle(v0, v1, v2, n0=n0, n1=n1, n2=n2, tu0=0.1, tv0=0.6, tu1=0.2,
        tv1=0.5, tu2=0.45, tv2=0.2)

min_dist = 1.93
hit = t.isect(ray, min_dist)

runtime1 = Runtime()
runtimes = [runtime1]

asm = create_assembler()
Triangle.isect_asm(runtimes, "ray_triangle_intersection")

code = """
    #DATA
"""
code += Ray.asm_struct() + Triangle.asm_struct() + HitPoint.asm_struct() + """
    Ray ray1
    Triangle tri1
    Hitpoint hp1
    uint32 ret
    float min_dist = 1.92
    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}
Beispiel #12
0
mgr.add('t2', t2)

origin = Vector3(0.2, 0.4, 0.6)
direction = Vector3(1.2, 1.1, 1.12)
direction.normalize()
ray = Ray(origin, direction)

linear = LinearIsect(mgr)

hit = linear.isect(ray)

runtime = Runtime()
linear.isect_asm([runtime], 'ray_scene_intersection')

code = "#DATA \n"
code += Ray.asm_struct() + HitPoint.asm_struct() + """
    Ray ray1
    Hitpoint hp1
    uint32 ret

    #CODE
    macro mov eax, ray1
    macro mov ebx, hp1
    call ray_scene_intersection 
    mov dword [ret], eax
    #END
"""
asm = create_assembler()
mc = asm.assemble(code)

ds = runtime.load('test', mc)
Beispiel #13
0
             tu2=0.45,
             tv2=0.2)

min_dist = 1.93
hit = t.isect(ray, min_dist)

runtime1 = Runtime()
runtimes = [runtime1]

asm = create_assembler()
Triangle.isect_asm(runtimes, "ray_triangle_intersection")

code = """
    #DATA
"""
code += Ray.asm_struct() + Triangle.asm_struct() + HitPoint.asm_struct() + """
    Ray ray1
    Triangle tri1
    Hitpoint hp1
    uint32 ret
    float min_dist = 1.92
    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}