equal
deleted
inserted
replaced
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[1] = v[1]-3 |
30 v[1] = v[1]-5 |
|
31 v[2] = -v[2] |
|
32 vertices.append(tuple(v)) |
30 vertices.append(tuple(v)) |
33 vertex_num -= 1 |
31 vertex_num -= 1 |
34 |
32 |
35 # read faces |
33 # read faces |
36 while (face_num): |
34 while (face_num): |
42 rt.addshape(face) |
40 rt.addshape(face) |
43 face_num -= 1 |
41 face_num -= 1 |
44 |
42 |
45 rt = Raytracer() |
43 rt = Raytracer() |
46 mat = Material(colour=(0.9, 0.9, 0.9)) |
44 mat = Material(colour=(0.9, 0.9, 0.9)) |
47 LoadStanfordPlyFile(rt, mat, "happy_vrip_res2.ply", 30.0) |
45 LoadStanfordPlyFile(rt, mat ,"happy_vrip_res2.ply", 20.0) |
48 |
46 |
49 light = Light(position=(-5.0, 2.0, -8.0), colour=(0.9, 0.3, 0.6)) |
47 light = Light(position=(-5.0, 2.0, 8.0), colour=(0.9, 0.3, 0.6)) |
50 rt.addlight(light) |
48 rt.addlight(light) |
51 |
49 |
52 imagesize = (800, 600) |
50 imagesize = (800, 600) |
53 data = rt.render(imagesize) |
51 data = rt.render(imagesize) |
54 img = Image.fromstring("RGB", imagesize, data) |
52 img = Image.fromstring("RGB", imagesize, data) |