diff -r 7c3f38dff082 -r a5127346fbcd demos/render_nff.py --- a/demos/render_nff.py Sun Apr 20 16:48:24 2008 +0200 +++ b/demos/render_nff.py Sun Apr 20 19:27:59 2008 +0200 @@ -2,7 +2,7 @@ # read nff data from standart input and render image to render_nff.png # see http://tog.acm.org/resources/SPD/ -# only spheres and triangles are implemented +# cylinders are not implemented from raytracer import Raytracer, Camera, Light, Material, Sphere, NormalVertex, Triangle from math import pi @@ -72,6 +72,18 @@ rt.addshape(Triangle(vertices[0], vertices[1], vertices[2], mat)) for i in range(vertex_count)[3:]: rt.addshape(Triangle(vertices[0], vertices[i-1], vertices[i], mat)) + elif ln[0] == 'pp': # Polygonal patch + mat.setSmooth(True) + vertex_count = int(ln[1]) + vertices = [] + for i in range(vertex_count): + ln = f.readline().split() + vertex = (float(ln[0]), float(ln[1]), float(ln[2])) + normal = (float(ln[3]), float(ln[4]), float(ln[5])) + vertices.append(NormalVertex(vertex, normal)) + rt.addshape(Triangle(vertices[0], vertices[1], vertices[2], mat)) + for i in range(vertex_count)[3:]: + rt.addshape(Triangle(vertices[0], vertices[i-1], vertices[i], mat)) else: print "Not implemented:", line f.close()