1 #ifndef POINTLIGHT_HXX
2 #define POINTLIGHT_HXX
3
4 #include "Light.hxx"
5
6 class PointLight : public Light
7 {
8 public:
9 Vec3f position; // origin
10
11 PointLight(Scene *scene, Vec3f position, Vec3f intensity)
12 : Light(scene, intensity),position(position)
13 {};
14
15 virtual void Illuminate(Ray &ray, Vec3f &intensity)
16 {
17 ray.dir = position - ray.org;
18 ray.t = Length(ray.dir) - Epsilon;
19 ray.hit = NULL;
20
21 Normalize(ray.dir);
22
23 intensity = this->intensity / (0.5f * ray.t + 1.0f);
24 };
25
26 virtual void Initialize(TravellingPhoton &photon, Vec3f &intensity)
27 {
28 photon.org = position;
29 intensity = this->intensity;
30 };
31 };
32
33 #endif
syntax highlighted by Code2HTML, v. 0.9.1