-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scene.h
executable file
·45 lines (33 loc) · 1.27 KB
/
Scene.h
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
////////////////////////////////////////
// Scene.h
////////////////////////////////////////
#pragma once
#include "Object.h"
#include "Light.h"
#include <vector>
////////////////////////////////////////////////////////////////////////////////
class Scene {
public:
Scene() {SkyColor.Set(0.2f,0.2f,0.5f);}
void AddObject(Object &obj) {Objects.push_back(&obj);}
void AddLight(Light &lgt) {Lights.push_back(&lgt);}
void SetSkyColor(const Color sky) {SkyColor=sky;}
void SetGradientColor(const Color grad) {GradientColor = grad;}
int GetNumLights() {return (int)Lights.size();}
Light &GetLight(int i) {return *Lights[i];}
Color GetSkyColor() {return SkyColor;}
Color GetGradientColor() {return GradientColor;}
//Checks the intersection for all the objects in the scene.
bool Intersect(const Ray &ray,Intersection &hit) {
bool success=false;
for(unsigned int i=0;i<Objects.size();i++)
if(Objects[i]->Intersect(ray,hit)) success=true;
return success;
}
private:
std::vector<Object*> Objects;
std::vector<Light*> Lights;
Color SkyColor;
Color GradientColor;
};
////////////////////////////////////////////////////////////////////////////////