7b8c8d255b5e57eced41a18dae5756b199914d89
[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& ray, Vec3f& intensity)
23 {
24 float dist = ((ray.origin() + ray.direction() * ray.t()) - m_pos).norm();
25
26 float c1 = 1, c2 = 0.5, c3 = 0;
27 float in = 1 / (c1 + c2*dist + c3*dist*dist);
28
29 intensity = Vec3f(in, in, in);
30 return false;
31 }
32
33 const Vec3f&
34 PointLight::position() const
35 {
36 return m_pos;
37 }
38
39 const Vec3f&
40 PointLight::intensity() const
41 {
42 return m_intensity;
43 }
44
45
This page took 0.042776 seconds and 3 git commands to generate.