demos/dragon.py
branchpyrit
changeset 19 4e0955fca797
parent 18 25b7c445cf61
child 24 d0d76e8a5203
equal deleted inserted replaced
18:25b7c445cf61 19:4e0955fca797
    24 
    24 
    25 	# read vertices
    25 	# read vertices
    26 	while (vertex_num):
    26 	while (vertex_num):
    27 		tokens = fp.readline().split()
    27 		tokens = fp.readline().split()
    28 		v = [scale*float(x) for x in tokens[0:3]]
    28 		v = [scale*float(x) for x in tokens[0:3]]
    29 		#v[0] = -v[0]
    29 		v[0] = -v[0]
    30 		v[1] = v[1]-3.5
    30 		v[1] = v[1]-3.6
    31 		#v[2] = -v[2]
    31 		v[2] = -v[2]
    32 		vertices.append(tuple(v))
    32 		vertices.append(tuple(v))
    33 		vertex_num -= 1
    33 		vertex_num -= 1
    34 
    34 
    35 	# read faces
    35 	# read faces
    36 	while (face_num):
    36 	while (face_num):
    42 		rt.addshape(face)
    42 		rt.addshape(face)
    43 		face_num -= 1
    43 		face_num -= 1
    44 
    44 
    45 rt = Raytracer()
    45 rt = Raytracer()
    46 mat = Material(colour=(0.9, 0.9, 0.9))
    46 mat = Material(colour=(0.9, 0.9, 0.9))
    47 LoadStanfordPlyFile(rt, mat, "dragon_vrip.ply", 30.0)
    47 LoadStanfordPlyFile(rt, mat, "dragon_vrip.ply", 29.0)
    48 
    48 
    49 light = Light(position=(-5.0, 2.0, -8.0), colour=(0.9, 0.3, 0.6))
    49 light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6))
    50 rt.addlight(light)
    50 rt.addlight(light)
    51 
    51 
    52 imagesize = (800, 600)
    52 imagesize = (800, 600)
    53 data = rt.render(imagesize)
    53 data = rt.render(imagesize)
    54 img = Image.fromstring("RGB", imagesize, data)
    54 img = Image.fromstring("RGB", imagesize, data)