solution for assignment 2.1
authorRoland Hieber <rohieb@rohieb.name>
Mon, 18 Jan 2010 03:43:52 +0000 (04:43 +0100)
committerRoland Hieber <rohieb@rohieb.name>
Mon, 18 Jan 2010 03:43:52 +0000 (04:43 +0100)
Scene.cxx

index 184b7e1..69ea9ed 100644 (file)
--- 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<Primitive*>::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* 
This page took 0.021328 seconds and 4 git commands to generate.