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;
}
#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))
return *this;
}
-void
+void
Scene::Add(Primitive* p)
{
m_primitives.push_back(p);
void
Scene::Add(Light* l)
{
+ m_lights.push_back(l);
}
bool
{
intersect |= m_primitives[i]->Intersect(ray);
}
-
+
return intersect;
}
return (intersect) ? ray.hit()->shader()->Shade(ray) : m_bgColor;
}
-const Camera*
+const Camera*
Scene::camera() const
{
return m_camera;