-
Notifications
You must be signed in to change notification settings - Fork 0
/
light_source.h
42 lines (35 loc) · 1.28 KB
/
light_source.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
/***********************************************************
Starter code for Assignment 3
This code was originally written by Jack Wang for
CSC418, SPRING 2005
light source classes
***********************************************************/
#include "util.h"
// Base class for a light source. You could define different types
// of lights here, but point light is sufficient for most scenes you
// might want to render. Different light sources shade the ray
// differently.
class LightSource {
public:
using Ptr = std::shared_ptr<LightSource>;
virtual void shade( Ray3D& ) = 0;
virtual Point3D get_position() const = 0;
virtual ~LightSource() {}
};
// A point light is defined by its position in world space and its
// colour.
class PointLight : public LightSource {
public:
PointLight( Point3D pos, Colour col ) : _pos(pos), _col_ambient(col),
_col_diffuse(col), _col_specular(col) {}
PointLight( Point3D pos, Colour ambient, Colour diffuse, Colour specular )
: _pos(pos), _col_ambient(ambient), _col_diffuse(diffuse),
_col_specular(specular) {}
void shade( Ray3D& ray );
Point3D get_position() const { return _pos; }
private:
Point3D _pos;
Colour _col_ambient;
Colour _col_diffuse;
Colour _col_specular;
};