author | Radek Brich <radek.brich@devl.cz> |
Fri, 04 Apr 2008 13:54:47 +0200 | |
branch | pyrit |
changeset 59 | 64e456ab823d |
parent 58 | cfe98f5c0ae9 |
child 60 | a23b5089b9c3 |
permissions | -rwxr-xr-x |
58 | 1 |
#!/usr/bin/python |
2 |
||
3 |
import sys |
|
4 |
sys.path.append(open('ModulePath').read().strip()) |
|
5 |
||
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
6 |
from raytracer import Raytracer, Light, Sphere, Triangle, Material, Camera |
58 | 7 |
from lworeader import LoadLightwaveLwoFile |
8 |
import Image |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
9 |
from math import * |
58 | 10 |
|
11 |
rt = Raytracer() |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
12 |
|
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
13 |
cam = Camera(eye=(0.,5.,8.)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
14 |
rotx=0.3 |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
15 |
cam.rotate((cos(rotx),-sin(rotx),0.,0.)) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
16 |
rt.setcamera(cam) |
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
17 |
|
58 | 18 |
mat = Material(colour=(0.9, 0.9, 0.9)) |
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
19 |
LoadLightwaveLwoFile(rt, "../models/car/Nissan300ZX.lwo", mat, smooth=False, scale=0.4) |
58 | 20 |
|
59
64e456ab823d
add color support to lwo reader
Radek Brich <radek.brich@devl.cz>
parents:
58
diff
changeset
|
21 |
light = Light(position=(-5.0, 2.0, 8.0), colour=(0.7, 0.7, 0.7)) |
58 | 22 |
rt.addlight(light) |
23 |
||
24 |
imagesize = (800, 600) |
|
25 |
data = rt.render(imagesize) |
|
26 |
img = Image.fromstring("RGB", imagesize, data) |
|
27 |
img.save('car.png') |