--- a/demos/lworeader.py Fri Apr 04 01:55:25 2008 +0200
+++ b/demos/lworeader.py Fri Apr 04 13:54:47 2008 +0200
@@ -1,7 +1,7 @@
# LightWave .lwo file loader
from struct import *
-from raytracer import Triangle, NormalVertex
+from raytracer import Triangle, NormalVertex, Material
def read_int4(f):
return unpack('>i', f.read(4))[0]
@@ -109,6 +109,11 @@
vertices = []
normals = []
vertex_face_num = []
+ materials = []
+
+ for surf in surfaces:
+ mat = Material(colour=tuple(float(x)/255. for x in surf['color']))
+ materials.append(mat)
for point in points:
v0 = scale[0]*point[0] + trans[0]
@@ -118,12 +123,10 @@
normals.append([0.,0.,0.])
vertex_face_num.append(0)
-
for f in faces:
v = [vertices[x] for x in f[0:3]]
- surf = f[3]
- mat = defmat
- face = Triangle(v[0], v[1], v[2], mat)
+ matidx = f[3]-1
+ face = Triangle(v[0], v[1], v[2], materials[matidx])
n = face.getNormal()
for x in f[0:3]:
for i in range(3):