(hopefully) finished Box::Clip()
[MicroTrace.git] / PointLight.cxx
1 #include "PointLight.hxx"
2
3 PointLight::PointLight(Scene* scene, const Vec3f& pos, const Vec3f& intensity)
4 : Light(scene),
5 m_pos(pos),
6 m_intensity(intensity)
7 {
8 }
9
10 PointLight::~PointLight()
11 {
12 }
13
14 PointLight::PointLight()
15 : Light(0),
16 m_pos(Vec3f()),
17 m_intensity(Vec3f())
18 {
19 }
20
21 bool
22 PointLight::Illuminate(Ray& shadow_ray, Vec3f& intensity)
23 {
24 // distance to light source
25 Vec3f dir = m_pos-shadow_ray.origin();
26 float r = dir.norm()-Epsilon;
27 float falloff = 1.0f/(r*r);
28
29
30 intensity = m_intensity * falloff;
31
32 // modify ray for shadow computation
33 shadow_ray.setHit(0);
34 // for shadow calculation
35 shadow_ray.setT(r);
36 // set direction to light source
37 dir.normalize();
38 shadow_ray.setDir(dir);
39
40 return true;
41 }
42
43 const Vec3f&
44 PointLight::position() const
45 {
46 return m_pos;
47 }
48
49 const Vec3f&
50 PointLight::intensity() const
51 {
52 return m_intensity;
53 }
54
55 bool
56 PointLight::IsArea()
57 {
58 return false;
59 }
This page took 0.050419 seconds and 5 git commands to generate.