equal
deleted
inserted
replaced
|
1 from raytracer import Triangle, NormalVertex |
|
2 |
|
3 def LoadWavefrontObjFile(rt, filename, mat, scale): |
|
4 vertices = [] |
|
5 fp = file(filename) |
|
6 while True: |
|
7 ln = fp.readline() |
|
8 if ln == "": |
|
9 break; |
|
10 ln = ln.split() |
|
11 if ln[0] == "v": |
|
12 v = [scale*float(x) for x in ln[1:4]] |
|
13 vertices.append(tuple(v)) |
|
14 if ln[0] == "f": |
|
15 f = [vertices[int(x)-1] for x in ln[1:4]] |
|
16 face = Triangle(NormalVertex(f[0]), NormalVertex(f[1]), NormalVertex(f[2]), mat) |
|
17 rt.addshape(face) |