From: Roland Hieber Date: Mon, 18 Jan 2010 03:43:52 +0000 (+0100) Subject: solution for assignment 2.1 X-Git-Url: https://git.rohieb.name/MicroTrace.git/commitdiff_plain/464aa50da8460f3e20b8601750cde04386e23374 solution for assignment 2.1 --- diff --git a/Scene.cxx b/Scene.cxx index 184b7e1..69ea9ed 100644 --- a/Scene.cxx +++ b/Scene.cxx @@ -32,13 +32,19 @@ Scene::operator=(const Scene& s) void Scene::Add(Primitive* p) { + m_primitives.push_back(p); } bool Scene::Intersect(Ray& ray) { - return false; + bool hit = false; + for( std::vector::iterator i = m_primitives.begin(); + i != m_primitives.end(); i++ ) { + hit |= (*i)->Intersect(ray); + } + return hit; } bool @@ -50,7 +56,7 @@ Scene::Occluded(Ray& ray) Vec3f Scene::RayTrace(Ray& ray) { - return Vec3f(); + return (Intersect(ray)) ? Vec3f(255,255,255) : Vec3f(0,0,0); } const Camera*