diff --git a/src/scene.cc b/src/scene.cc index 29c528c..d3d26d3 100644 --- a/src/scene.cc +++ b/src/scene.cc @@ -115,6 +115,11 @@ Scene::render() } +/* + * Scene::add_shape -- + * + * Add a shape to the scene. + */ void Scene::add_shape(Shape *shape) { @@ -122,6 +127,23 @@ Scene::add_shape(Shape *shape) } +/* + * Scene::add_light -- + * + * Add a light to the scene. + */ +void +Scene::add_light(Light *light) +{ + lights.push_back(light); +} + + +/* + * Scene::trace_ray -- + * + * Trace the given ray through the scene, recursing until depth has been reached. + */ Color Scene::trace_ray(const Ray &ray, const int depth) { @@ -144,7 +166,7 @@ Scene::trace_ray(const Ray &ray, const int depth) } // If there was no intersection, return black. - if (intersected_shape == NULL) { + if (intersected_shape != NULL) { return Color::Black; } diff --git a/src/scene.h b/src/scene.h index 326f117..c38ff5e 100644 --- a/src/scene.h +++ b/src/scene.h @@ -16,6 +16,7 @@ #include "basics.h" +class Light; class Shape; class Writer; @@ -36,12 +37,14 @@ public: void render(); void add_shape(Shape *obj); + void add_light(Light *light); private: Color trace_ray(const Ray &ray, const int depth); int width, height; std::list shapes; + std::list lights; bool _is_rendered; Color *pixels;