-
Notifications
You must be signed in to change notification settings - Fork 0
/
scene.hh
executable file
·128 lines (94 loc) · 3.71 KB
/
scene.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/***************************************************************************
* Copyright (C) 2007 by Eugeniu Plamadeala *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/**
* @file scene.hh The Scene class and implementation of several methods
*/
#ifndef SCENE_HH
#define SCENE_HH
#include <iostream>
#include <vector>
/**
* @include Needed in order for the shared_ptr container
*/
#include <boost/shared_ptr.hpp>
#include "scene_objects/sceneobject.hh"
#include "color.hh"
#include "ray.hh"
#include "camera.hh"
#include "light.hh"
using namespace std;
//Returned by Intersection(const Ray &) if there's no intersection.
/** The result of the Intersection function if no intersection is detected
* @see SceneClass::Intersection()
*/
const int NO_INTERSECTION = -1;
/** The background color of the scene.
* @see Color
*/
const Color BACKGROUND_CLR = Color(0.1,0.1,0.5);
/** A shorter definition for a shared_pt<SceneObject> object */
typedef boost::shared_ptr<SceneObject> SPSceneObject;
/** A shorter definition for a shared_pt<Light> object*/
typedef boost::shared_ptr<Light> SPLight;
/** Describes the scene.
* Has information about the surroundings:
* light source, objects.
* Needs a camera object in order to render a scene.
* @see Camera
*/
class Scene
{
public:
/** An STL vector holding the Scene Objects */
vector<SPSceneObject> SObjects;
/** An STL vector holding Light objects */
vector<SPLight> Lights;
/** Default constructor. Does nothing. */
Scene() {};
/** Destructor. Does nothing. */
~Scene() {};
/** Adds a new SceneObject to the scene */
void AddSceneObject(SPSceneObject SObject);
/** Adds a new Light object to the scene */
void AddLight(SPLight LObject);
/** Renders the scene. */
void Render(const Camera & cam, int imgSize, ostream & out) const;
/** Returns the color of the object that the ray falls on. */
Color traceRay(const Ray & R, unsigned int depth = 0) const;
/** Prints information about the scene.
* Mostly used for debugging.
**/
void Describe();
};
inline void Scene::AddSceneObject(SPSceneObject SObject)
{
//Check valid pointer
assert(SObject != 0);
//Should check for enough memory if the vector is resized?
SObjects.push_back(SObject);
}
inline void Scene::AddLight(SPLight LObject)
{
//Check valid pointer
assert(LObject != 0);
//Should check for enough memory in case of resizing?
Lights.push_back(LObject);
}
#endif //SCENE_HH