solution for 3.1a)
authorRoland Hieber <rohieb@bmhvehicle.ibr.cs.tu-bs.de>
Tue, 26 Jan 2010 14:45:26 +0000 (15:45 +0100)
committerRoland Hieber <rohieb@bmhvehicle.ibr.cs.tu-bs.de>
Tue, 26 Jan 2010 14:45:26 +0000 (15:45 +0100)
PointLight.cxx
Scene.cxx

index 1ce5f0b..7b8c8d2 100644 (file)
@@ -21,7 +21,12 @@ PointLight::PointLight()
 bool
 PointLight::Illuminate(Ray& ray, Vec3f& intensity)
 {
+  float dist = ((ray.origin() + ray.direction() * ray.t()) - m_pos).norm();
 
+  float c1 = 1, c2 = 0.5, c3 = 0;
+  float in = 1 / (c1 + c2*dist + c3*dist*dist);
+
+  intensity = Vec3f(in, in, in);
   return false;
 }
 
index bbd6785..a1d3acd 100644 (file)
--- a/Scene.cxx
+++ b/Scene.cxx
@@ -2,11 +2,11 @@
 #include "PerspectiveCamera.hxx"
 
 Scene::Scene()
-  : m_camera(new PerspectiveCamera(Vec3f(0,0,8), 
-                                  Vec3f(0,0,-1), 
-                                  Vec3f(0,1,0), 
-                                  50, 
-                                  640, 
+  : m_camera(new PerspectiveCamera(Vec3f(0,0,8),
+                                  Vec3f(0,0,-1),
+                                  Vec3f(0,1,0),
+                                  50,
+                                  640,
                                   480)
             ),
     m_bgColor(Vec3f(0,0,0))
@@ -29,7 +29,7 @@ Scene::operator=(const Scene& s)
   return *this;
 }
 
-void 
+void
 Scene::Add(Primitive* p)
 {
   m_primitives.push_back(p);
@@ -38,6 +38,7 @@ Scene::Add(Primitive* p)
 void
 Scene::Add(Light* l)
 {
+  m_lights.push_back(l);
 }
 
 bool
@@ -49,7 +50,7 @@ Scene::Intersect(Ray& ray)
     {
       intersect |= m_primitives[i]->Intersect(ray);
     }
-  
+
   return intersect;
 }
 
@@ -66,7 +67,7 @@ Scene::RayTrace(Ray& ray)
   return (intersect) ? ray.hit()->shader()->Shade(ray) : m_bgColor;
 }
 
-const Camera* 
+const Camera*
 Scene::camera() const
 {
   return m_camera;
This page took 0.031054 seconds and 4 git commands to generate.