コード例 #1
0
ファイル: sphere.py プロジェクト: mario007/renmas
def intersect_ray_spheres_bool(n):
    asm = util.get_asm()
    mc = asm.assemble(ASM1)
    runtime = Runtime()

    #Sphere.intersectbool_asm(runtime, "ray_sphere_intersect")
    Sphere.intersect_asm(runtime, "ray_sphere_intersect")
    ds = runtime.load("test", mc)

    for x in range(n):
        sphere = generate_sphere()
        ray = generate_ray()
        ds["sph.origin"] = v4(sphere.origin)
        ds["sph.radius"] = sphere.radius
        ds["sph.mat_index"] = sphere.material

        ds["r1.origin"] = v4(ray.origin)
        ds["r1.dir"] = v4(ray.dir)

        hp = sphere.intersect(ray, 999999.0)

        runtime.run("test")

        if hp is not False and ds["hit"] == 0:
            print(hp.t, ds["t"], ds["hit"])
        if hp is False and ds["hit"] == 1:
            print(ds["t"], ds["hit"])

        if hp is not False:
            print_hitpoint(ds, hp)
コード例 #2
0
ファイル: sphere.py プロジェクト: mario007/renmas
def intersect_ray_spheres_bool(n):
    asm = util.get_asm()
    mc = asm.assemble(ASM1)
    runtime = Runtime()
    
    #Sphere.intersectbool_asm(runtime, "ray_sphere_intersect")
    Sphere.intersect_asm(runtime, "ray_sphere_intersect")
    ds = runtime.load("test", mc)

    for x in range(n):
        sphere = generate_sphere()
        ray = generate_ray()
        ds["sph.origin"] = v4(sphere.origin)
        ds["sph.radius"] = sphere.radius
        ds["sph.mat_index"] = sphere.material

        ds["r1.origin"] = v4(ray.origin)
        ds["r1.dir"] = v4(ray.dir)

        hp = sphere.intersect(ray, 999999.0)
        
        runtime.run("test")
        
        if hp is not False and ds["hit"] == 0:
            print(hp.t, ds["t"], ds["hit"])
        if hp is False and ds["hit"] == 1:
            print(ds["t"], ds["hit"])

        if hp is not False:
            print_hitpoint(ds, hp)
コード例 #3
0
ファイル: sphere.py プロジェクト: mario007/renmas

if __name__ == "__main__":

    asm = util.get_asm()
    mc = asm.assemble(ASM)
    #mc.print_machine_code()

    runtime = Runtime()
    #ds = runtime.load("test", mc)

    #intersect_sphere(runtime, ds)
    #intersect_ray_spheres(100000, runtime, ds)
    #intersect_ray_spheres_bool(10)

    Sphere.intersect_asm(runtime, "_sphere_intersect")
    intersect_ray_shape_array("sphere", runtime, "sphere_array",
                              "_sphere_intersect")
    mc = asm.assemble(ASM2)
    ds = runtime.load("test2", mc)
    spheres, dyn_spheres = generate_spheres(1000)

    ray = generate_ray()
    hp = ray_objects(ray, spheres)

    adr = dyn_spheres.get_addr()
    ds["ptr_spheres"] = adr
    ds["nspheres"] = dyn_spheres.size

    ds["r1.origin"] = v4(ray.origin)
    ds["r1.dir"] = v4(ray.dir)
コード例 #4
0
ファイル: multiple_shapes.py プロジェクト: mario007/renmas
    t = timeit.Timer(lambda : isect(ray, shape_db.shapes()))
    print ("time", t.timeit(1))
    hp = isect(ray, shape_db.shapes())
    hp2 = isect_ray_scene(ray)

    asm = util.get_asm()

    dy_spheres = shape_db.asm_shapes[Sphere]
    dy_planes = shape_db.asm_shapes[Plane]

    #ds["r1.origin"] = v4(ray.origin)
    #ds["r1.dir"] = v4(ray.dir)
    
    runtime = Runtime()

    Sphere.intersect_asm(runtime, "_sphere_intersect")
    intersect_ray_shape_array("sphere", runtime, "sphere_array", "_sphere_intersect")
    Plane.intersect_asm(runtime, "_plane_intersect")
    intersect_ray_shape_array("plane", runtime, "plane_array", "_plane_intersect")

    mc = asm.assemble(ASM)

    ds = runtime.load("test", mc)

    ds["r1.origin"] = v4(ray.origin)
    ds["r1.dir"] = v4(ray.dir)
    ds["ptr_spheres"] = dy_spheres.get_addr()
    ds["nspheres"] = dy_spheres.size
    ds["ptr_planes"] = dy_planes.get_addr()
    ds["nplanes"] = dy_planes.size