69ea9edf36b83ed173e3c890f4ea5d8a27201c4d
[MicroTrace.git] / Scene.cxx
1 #include "Scene.hxx"
2 #include "PerspectiveCamera.hxx"
3
4 Scene::Scene()
5 : m_camera(new PerspectiveCamera(Vec3f(0,0,8),
6 Vec3f(0,0,-1),
7 Vec3f(0,1,0),
8 50,
9 640,
10 480)
11 ),
12 m_bgColor(Vec3f(0,0,0))
13 {
14 }
15
16 Scene::~Scene()
17 {
18 delete m_camera;
19 }
20
21 Scene::Scene(const Scene& s)
22 {
23 operator=(s);
24 }
25
26 Scene&
27 Scene::operator=(const Scene& s)
28 {
29 return *this;
30 }
31
32 void
33 Scene::Add(Primitive* p)
34 {
35 m_primitives.push_back(p);
36 }
37
38
39 bool
40 Scene::Intersect(Ray& ray)
41 {
42 bool hit = false;
43 for( std::vector<Primitive*>::iterator i = m_primitives.begin();
44 i != m_primitives.end(); i++ ) {
45 hit |= (*i)->Intersect(ray);
46 }
47 return hit;
48 }
49
50 bool
51 Scene::Occluded(Ray& ray)
52 {
53 return false;
54 }
55
56 Vec3f
57 Scene::RayTrace(Ray& ray)
58 {
59 return (Intersect(ray)) ? Vec3f(255,255,255) : Vec3f(0,0,0);
60 }
61
62 const Camera*
63 Scene::camera() const
64 {
65 return m_camera;
66 }
This page took 0.047464 seconds and 3 git commands to generate.