equal
deleted
inserted
replaced
2 |
2 |
3 # read nff data from standart input and render image to render_nff.png |
3 # read nff data from standart input and render image to render_nff.png |
4 # see http://tog.acm.org/resources/SPD/ |
4 # see http://tog.acm.org/resources/SPD/ |
5 # cylinders are not implemented |
5 # cylinders are not implemented |
6 |
6 |
7 from raytracer import Raytracer, Camera, Light, Material, Sphere, NormalVertex, Triangle |
7 from pyrit import * |
8 from math import pi |
8 from math import pi |
9 import sys, Image |
9 import sys |
10 |
10 |
11 rt = Raytracer() |
11 rt = Raytracer() |
|
12 top = KdTree() |
|
13 rt.setTop(top) |
|
14 rt.setCamera(Camera()) |
|
15 |
12 imagesize = (800, 600) |
16 imagesize = (800, 600) |
13 |
17 |
14 mat = Material(colour=(1.0, 1.0, 1.0)) |
18 mat = Material(colour=(1.0, 1.0, 1.0)) |
15 |
19 |
16 f = sys.stdin |
20 f = sys.stdin |
|
21 fbase = "render_nff" |
|
22 if len(sys.argv) > 1: |
|
23 f = open(sys.argv[1]) |
|
24 fbase = sys.argv[1].rsplit('.',1)[0] |
|
25 |
17 while True: |
26 while True: |
18 line = f.readline() |
27 line = f.readline() |
19 if line == "": |
28 if line == "": |
20 break; |
29 break; |
21 ln = line.split() |
30 ln = line.split() |
88 pass |
97 pass |
89 else: |
98 else: |
90 print "Not implemented:", line |
99 print "Not implemented:", line |
91 f.close() |
100 f.close() |
92 |
101 |
93 data = rt.render(imagesize) |
102 top.optimize() |
94 img = Image.fromstring("RGB", imagesize, data) |
103 |
95 img.save('render_nff.png') |
104 sampler = DefaultSampler(imagesize) |
|
105 rt.setSampler(sampler) |
|
106 rt.render() |
|
107 sampler.getPixmap().writePNG(fbase+'.png') |