コード例 #1
0
ファイル: test_sphere.py プロジェクト: mario007/renmas
def isect_sphere(runtime, ds, n):
    nhits = 0
    for x in range(n):
        sph = random_sphere()
        ray = ren.random_ray()
        
        ray_ds(ds, ray, "r1")
        sphere_ds(ds, sph, "sph")

        runtime.run("isect")
        hit =  ds["hit"]
        hp = sph.isect(ray, 999999.0)

        if hp is not False:
            if round(hp.t, 1) != round(ds["hp.t"], 1):
                print(hp.t, ds["hp.t"])
                raise ValueError("Intersection of ray - sphere rounding")

            nhits += 1
            if ds["hit"] == 0:
                raise ValueError("Intersection of ray - sphere problem")
        if ds["hit"] == 1:
            if hp is False:
                raise ValueError("Intersection of ray - sphere problem")
    print("Number of hits", nhits)        
コード例 #2
0
ファイル: test_sphere.py プロジェクト: mario007/renmas
def isect_sphere(runtime, ds, n):
    nhits = 0
    for x in range(n):
        sph = random_sphere()
        ray = ren.random_ray()

        ray_ds(ds, ray, "r1")
        sphere_ds(ds, sph, "sph")

        runtime.run("isect")
        hit = ds["hit"]
        hp = sph.isect(ray, 999999.0)

        if hp is not False:
            if round(hp.t, 1) != round(ds["hp.t"], 1):
                print(hp.t, ds["hp.t"])
                raise ValueError("Intersection of ray - sphere rounding")

            nhits += 1
            if ds["hit"] == 0:
                raise ValueError("Intersection of ray - sphere problem")
        if ds["hit"] == 1:
            if hp is False:
                raise ValueError("Intersection of ray - sphere problem")
    print("Number of hits", nhits)
コード例 #3
0
ファイル: test_sphere.py プロジェクト: mario007/renmas
def test_linear():
    runtime, ds = isect_ray_sphere_array()
    random_spheres(1000)
    shapes = ren.lst_shapes()
    ray = ren.random_ray()
    ray_ds(ds, ray, "r1")

    dyn_arrays = ren.dyn_arrays()
    ds["nspheres"] = dyn_arrays[renmas.shapes.Sphere].size
    ds["ptr_spheres"] = dyn_arrays[renmas.shapes.Sphere].get_addr()

    runtime.run("isect")
    hp = renmas.shapes.isect(ray, shapes, 999999.0)
    if hp is not None:
        print(hp.t, ds["hp.t"])
コード例 #4
0
ファイル: test_sphere.py プロジェクト: mario007/renmas
def test_linear():
    runtime, ds = isect_ray_sphere_array()
    random_spheres(1000)
    shapes = ren.lst_shapes()
    ray = ren.random_ray()
    ray_ds(ds, ray, "r1")

    dyn_arrays = ren.dyn_arrays()
    ds["nspheres"] = dyn_arrays[renmas.shapes.Sphere].size
    ds["ptr_spheres"] = dyn_arrays[renmas.shapes.Sphere].get_addr()

    runtime.run("isect")
    hp = renmas.shapes.isect(ray, shapes, 999999.0)
    if hp is not None:
        print(hp.t, ds["hp.t"])
コード例 #5
0
ファイル: test_plane.py プロジェクト: mario007/renmas
def isect_bool(runtime, ds, n):
    nhits = 0
    for x in range(n):
        pl = random_plane()
        ray = ren.random_ray()

        ray_ds(ds, ray, "r1")
        plane_ds(ds, pl, "pl")

        runtime.run("isect")
        hit = ds["hit"]
        hp = pl.isect(ray, 999999.0)

        if hp is not False:
            nhits += 1
            if ds["hit"] == 0:
                raise ValueError("Intersection of ray - sphere problem")
        if ds["hit"] == 1:
            if hp is False:
                raise ValueError("Intersection of ray - sphere problem")
    print("Number of hits", nhits, ds["hp.t"])
コード例 #6
0
def isect_bool(runtime, ds, n):
    nhits = 0
    for x in range(n):
        tri = random_triangle()
        ray = ren.random_ray()
        
        ray_ds(ds, ray, "r1")
        triangle_ds(ds, tri, "tri")

        runtime.run("isect")
        hit =  ds["hit"]
        hp = tri.isect(ray, 999999.0)

        if hp is not False:
            nhits += 1
            if ds["hit"] == 0:
                raise ValueError("Intersection of ray - sphere problem")
        if ds["hit"] == 1:
            if hp is False:
                raise ValueError("Intersection of ray - sphere problem")
    print("Number of hits", nhits, ds["hp.t"])
コード例 #7
0
ファイル: multiple.py プロジェクト: mario007/renmas
    add esp, 20 
    ret


"""

asm = Tdasm()
renmas.shapes.multiple_isect_asm(runtime, "multiple_isect")
mc = asm.assemble(ASM)

def v4(v3):
    return (v3.x, v3.y, v3.z, 0.0)

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

ray = ren.random_ray()
ds["ray1.origin"] = v4(ray.origin)
ds["ray1.dir"] = v4(ray.dir)
ds["num"] = len(lst_shapes)
ds["addrs"] = adrese

runtime.run("test")

print(ds["hp.t"], ds["clocks"])

hp = isect(ray, lst_shapes)
print(hp.t)


runtime2 = Runtime()
renmas.shapes.linear_isect_asm(runtime2, "ray_scene", ren.dyn_arrays())
コード例 #8
0
ファイル: test_multiple.py プロジェクト: mario007/renmas
    ; eax = pointer_to_ray, ebx = pointer_to_hitpoint
    mov eax, r1
    mov ebx, hp
    call scene_isect 
    mov dword [hit], eax

    #END

"""
gen_random_shapes(10)
shapes = ren.lst_shapes()
dyn_arrays = ren.dyn_arrays()

runtime = Runtime()
renmas.shapes.linear_isect_asm(runtime, "scene_isect", dyn_arrays)

asm = renmas.utils.get_asm()
mc = asm.assemble(ASM)
ds = runtime.load("isect", mc)
ray = ren.random_ray()
ray_ds(ds, ray, "r1")

runtime.run("isect")

hp = renmas.shapes.isect(ray, shapes, 999999.0)

if hp is not None:
    print(hp.t, ds["hp.t"], ds["hit"])
else:
    print(ds["hit"])