branch | pyrit |
changeset 93 | 96d65f841791 |
parent 92 | 9af5c039b678 |
child 94 | 4c8abb8977dc |
92:9af5c039b678 | 93:96d65f841791 |
---|---|
77 class Camera |
77 class Camera |
78 { |
78 { |
79 Vector eye, p, u, v; |
79 Vector eye, p, u, v; |
80 Float F; |
80 Float F; |
81 public: |
81 public: |
82 Camera(): eye(0,0,10), p(0,0,-1), u(-1,0,0), v(0,1,0), F(2.*tan(M_PI/8.)) {}; |
82 Camera(): eye(0,0,10), p(0,0,-1), u(-1,0,0), v(0,1,0), F(2*tan(PI/8)) {}; |
83 Camera(const Vector &C, const Vector &ap, const Vector &au, const Vector &av): |
83 Camera(const Vector &C, const Vector &ap, const Vector &au, const Vector &av): |
84 eye(C), p(ap), u(au), v(av), F(2.*tan(M_PI/8.)) {}; |
84 eye(C), p(ap), u(au), v(av), F(2*tan(PI/8)) {}; |
85 Camera(const Vector &from, const Vector &lookat, const Vector &up): |
85 Camera(const Vector &from, const Vector &lookat, const Vector &up): |
86 eye(from), F(2.*tan(M_PI/8.)) |
86 eye(from), F(2*tan(PI/8)) |
87 { |
87 { |
88 p = lookat - from; u = cross(up, p); |
88 p = lookat - from; u = cross(up, p); |
89 p.normalize(); u.normalize(); |
89 p.normalize(); u.normalize(); |
90 v = cross(p, u); |
90 v = cross(p, u); |
91 }; |
91 }; |
98 void setEye(const Vector &aeye) { eye = aeye; }; |
98 void setEye(const Vector &aeye) { eye = aeye; }; |
99 void setp(const Vector &ap) { p = ap; }; |
99 void setp(const Vector &ap) { p = ap; }; |
100 void setu(const Vector &au) { u = au; }; |
100 void setu(const Vector &au) { u = au; }; |
101 void setv(const Vector &av) { v = av; }; |
101 void setv(const Vector &av) { v = av; }; |
102 void setF(const Float &aF) { F = aF; }; |
102 void setF(const Float &aF) { F = aF; }; |
103 void setAngle(const Float angle) { F = 2.0f*tan(angle/2.0f); }; |
103 void setAngle(const Float angle) { F = 2*tan(angle/2); }; |
104 void rotate(const Quaternion &q); |
104 void rotate(const Quaternion &q); |
105 void move(const Float fw, const Float left, const Float up); |
105 void move(const Float fw, const Float left, const Float up); |
106 |
106 |
107 const Ray makeRay(const Sample &samp) const |
107 const Ray makeRay(const Sample &samp) const |
108 { |
108 { |
171 class Light |
171 class Light |
172 { |
172 { |
173 public: |
173 public: |
174 Vector pos; |
174 Vector pos; |
175 Colour colour; |
175 Colour colour; |
176 bool cast_shadows; |
176 int cast_shadows; |
177 |
177 |
178 Light(): |
178 Light(): |
179 pos(Vector(0,0,0)), colour(Colour(1,1,1)), cast_shadows(true) {}; |
179 pos(Vector(0,0,0)), colour(Colour(1,1,1)), cast_shadows(true) {}; |
180 Light(const Vector &position, const Colour &acolour): |
180 Light(const Vector &position, const Colour &acolour): |
181 pos(position), colour(acolour), cast_shadows(true) {}; |
181 pos(position), colour(acolour), cast_shadows(true) {}; |
182 void castShadows(bool cast) { cast_shadows = cast; }; |
182 void castShadows(int cast) { cast_shadows = cast; }; |
183 }; |
183 }; |
184 |
184 |
185 /** |
185 /** |
186 * axis-aligned bounding box |
186 * axis-aligned bounding box |
187 */ |
187 */ |