Exemplo n.º 1
0
def shade(scol, mesh, lights):
	clr = 0
	for light in lights:
		lray = poly.ray(light[0], scol[1])
		lcol = mesh.test_collision(lray)
		if (lcol[0] > 0 and lcol[0] < 0.9999):
			clr = clr + 0.000000001
		else:
			refl = lray.direction.skalar(scol[2].plane.h)/(lray.direction.abs()*scol[2].plane.h.abs())
			clr = clr + light[1] * abs(refl)
	return int(clr)
Exemplo n.º 2
0
def render(mesh, x_pix, y_pix):
	x = x_pix
	y = y_pix
	lines = []
	for line_nr in range(y):
		line = []
		for pix in range(x):
			sray = poly.ray(camerap, calc_pixelpoint(pix, line_nr))
			col = mesh.test_collision(sray)
			if (col[0] > 0):
				line.append(shade(col, mesh, lights))
			else:
				line.append(0)
			
		lines.append(line)
	return lines
Exemplo n.º 3
0
import poly
m = poly.mesh()
m.load_raw("ball4.raw")
r1 = poly.ray(p1 = poly.point([1, 20, 1]), p2 = poly.point([1, 19, 1]))
print(m.test_collision(r1))
r1.debug_print()