-
Notifications
You must be signed in to change notification settings - Fork 5
/
scene.h
63 lines (49 loc) · 1.5 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <vector>
#include <stack>
#include <sstream>
#include "object.h"
using namespace std;
#ifndef _SCENE_H
#define _SCENE_H
void rightmultiply(const mat4 & M, stack<mat4> &transform_stack);
struct Camera {
vec3 eye;
vec3 center;
vec3 up;
float fovy ; // For field of view
Camera(const vec3 &_eye, const vec3 &_center, const vec3 &_up, const float& _fovy) :
eye(_eye), center(_center), up(_up), fovy(_fovy) {}
// Default camera configuration
Camera() : eye(0.0,0.0,5.0), center(0.0,0.0,0.0), up(0.0,1.0,0.0) {}
};
struct Light {
vec3 positionOrDirection; // Light Positions for point light
vec3 transform; // Lights transformed by modelview
Color color; // Light Colors
enum Type {directional, point};
Type type;
const vec3& position() const;
const vec3& direction() const;
};
class Scene
{
private:
bool readvals (stringstream &s, const int numvals, float *values) ;
public:
Scene();
~Scene();
void readfile (const string &filename);
string outputFile;
Camera camera;
int maxDepth; // max depth of ray tracing
int width, height;
// Lighting parameter array, similar to that in the fragment shader
vector<Light> lights;
Materials materials; // This is global material
float attenuation[3]; // Global attenuation
// For multiple objects, read from a file.
vector<Object*> objects;
vector<vec3> vertexBuffer, vertexBufferWithNormal; // vertex buffer
vector<vec3> vertexNormalBuffer; // vertex normal, correspond to vertex with normal
};
#endif // _SCENE_H