author | Radek Brich <radek.brich@devl.cz> |
Sun, 27 Apr 2008 09:44:49 +0200 | |
branch | pyrit |
changeset 84 | 6f7fe14782c2 |
parent 75 | 20dee9819b17 |
child 90 | f6a72eb99631 |
permissions | -rwxr-xr-x |
58 | 1 |
#!/usr/bin/python |
2 |
||
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
3 |
from raytracer import Raytracer, Light, Sphere, Triangle, Material, Camera |
58 | 4 |
from lworeader import LoadLightwaveLwoFile |
5 |
import Image |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
6 |
from math import * |
58 | 7 |
|
8 |
rt = Raytracer() |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
9 |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
10 |
cam = Camera(eye=(0.,2.,8.)) |
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
11 |
rotx=0.15 |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
12 |
cam.rotate((cos(rotx),-sin(rotx),0.,0.)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
13 |
rt.setCamera(cam) |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
14 |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
15 |
LoadLightwaveLwoFile(rt, "../models/lwo/Nissan300ZX.lwo", scale=0.4, trans=(-0.2,0,0.3)) |
58 | 16 |
|
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
17 |
light1 = Light(position=(-5.0, 20.0, 8.0), colour=(0.9, 0.9, 0.9)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
18 |
rt.addLight(light1) |
69
303583d2fb97
move "smooth" attribute from Triangle to Material
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
19 |
light2 = Light(position=(5.0, 10.0, 10.0), colour=(0.9, 0.7, 0.7)) |
75
20dee9819b17
unify capitalization of method names in C++ and Python
Radek Brich <radek.brich@devl.cz>
parents:
69
diff
changeset
|
20 |
rt.addLight(light2) |
58 | 21 |
|
22 |
imagesize = (800, 600) |
|
23 |
data = rt.render(imagesize) |
|
24 |
img = Image.fromstring("RGB", imagesize, data) |
|
25 |
img.save('car.png') |