a1d3acdea9d120670d1338eb1551ed3345244a62
[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 void
39 Scene::Add(Light* l)
40 {
41 m_lights.push_back(l);
42 }
43
44 bool
45 Scene::Intersect(Ray& ray)
46 {
47 bool intersect = false;
48
49 for(unsigned int i = 0; i < m_primitives.size(); ++i)
50 {
51 intersect |= m_primitives[i]->Intersect(ray);
52 }
53
54 return intersect;
55 }
56
57 bool
58 Scene::Occluded(Ray& ray)
59 {
60 return false;
61 }
62
63 Vec3f
64 Scene::RayTrace(Ray& ray)
65 {
66 bool intersect = this->Intersect(ray);
67 return (intersect) ? ray.hit()->shader()->Shade(ray) : m_bgColor;
68 }
69
70 const Camera*
71 Scene::camera() const
72 {
73 return m_camera;
74 }
This page took 0.044814 seconds and 3 git commands to generate.