# HG changeset patch # User Radek Brich # Date 1208712479 -7200 # Node ID a5127346fbcdb7eb61b4fa5fe0d17686531456dd # Parent 7c3f38dff0821a9f7aa56263a99ed82b1656ed79 correct camera angle of view render_nff.py - polygonal patches 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() diff -r 7c3f38dff082 -r a5127346fbcd include/scene.h --- a/include/scene.h Sun Apr 20 16:48:24 2008 +0200 +++ b/include/scene.h Sun Apr 20 19:27:59 2008 +0200 @@ -66,18 +66,18 @@ Vector3 eye, p, u, v; Float F; - Camera(): eye(0,0,10), p(0,0,-1), u(-1,0,0), v(0,1,0), F(0.7071) {}; + Camera(): eye(0,0,10), p(0,0,-1), u(-1,0,0), v(0,1,0), F(2.*tan(M_PI/8.)) {}; Camera(const Vector3 &C, const Vector3 &ap, const Vector3 &au, const Vector3 &av): - eye(C), p(ap), u(au), v(av), F(0.7071) {}; + eye(C), p(ap), u(au), v(av), F(2.*tan(M_PI/8.)) {}; Camera(const Vector3 &from, const Vector3 &lookat, const Vector3 &up): - eye(from), F(0.7071) + eye(from), F(2.*tan(M_PI/8.)) { p = lookat - from; u = cross(up, p); p.normalize(); u.normalize(); v = cross(p, u); }; void setEye(const Vector3 &aeye) { eye = aeye; }; - void setAngle(const Float angle) { F = sin(angle); }; + void setAngle(const Float angle) { F = 2.*tan(angle/2.); }; void rotate(const Quaternion &q); void move(const Float fw, const Float left, const Float up);