-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlight.h
94 lines (85 loc) · 2.07 KB
/
light.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
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
#ifndef LIGHT_H
#define LIGHT_H
#include "geometry.h"
#include <string>
#include <vector>
#include "matrix.h"
class Color;
class Light;
class PointLight;
class DirecLight;
class Object;
/*
* Class Color
* three float for each color channel
*/
class Color {
public:
float r;
float g;
float b;
Color();
Color(float,float,float);
Color(Vector);
void cutOff();
void scale(float k);
void add(Color color);
void sub(Color color);
void mul(Color color);
float mag();
};
/*
* Class Light - superclass for point and directional lights
* vector for direction the light is pointing at
*/
class Light {
public:
Vector vector;
Color color;
std::string type;
Light();
Light(float,float,float,float,float,float);
virtual void generateLightRay(LocalGeo*, Ray&, Color&) = 0;
};
class PointLight: public Light {
public:
PointLight();
PointLight(float,float,float,float,float,float);
void generateLightRay(LocalGeo*, Ray&, Color&);
};
class DirecLight: public Light {
public:
DirecLight();
DirecLight(float,float,float,float,float,float);
void generateLightRay(LocalGeo*, Ray&, Color&);
};
class AmbieLight: public Light {
public:
AmbieLight();
AmbieLight(float,float,float);
void generateLightRay(LocalGeo*, Ray&, Color&);
};
/*
* Class Object - contains a shape and BRDF
*/
class Object {
public:
std::vector< Shape* > shape;
Matrix transform;
Color ambient;
Color diffuse;
Color specular;
Color reflective;
float specularPow;
Object();
Object(std::vector< Shape* >);
Object(std::vector< Shape* >, Color, Color, Color, float, Color);
Object(std::vector< Shape* >, float, float, float, float, float, float, float, float, float, float, float, float, float);
Object(Shape*);
Object(Shape*, Color, Color, Color, float, Color);
Object(Shape*, float, float, float, float, float, float, float, float, float, float, float, float, float);
float intersect(Ray&);
float intersect(Ray&, LocalGeo*);
void setTransform(Matrix&);
};
#endif