Phongo Clap RT  1.0
Simple Raytracing Renderer
Light.h
Go to the documentation of this file.
1 #ifndef _LIGHT_H_
2 #define _LIGHT_H_
3 
4 #include <ngl/Vec3.h>
5 #include <ngl/Colour.h>
6 
10 
11 // LIGHT - Base Class
12 //----------------------------------------------------------------------------------------------------------------------
17 //----------------------------------------------------------------------------------------------------------------------
18 class Light
19 {
20 public:
21  //------------------------------------------------------------------------------------------------------------------
29  //------------------------------------------------------------------------------------------------------------------
30  Light(ngl::Vec3 _pos,
31  ngl::Colour _diff_col,
32  ngl::Colour _spec_col,
33  float _diff_int,
34  float _spec_int,
35  float _falloff) : m_pos(_pos), m_diff_col(_diff_col), m_spec_col(_spec_col),
36  m_diff_int(_diff_int), m_spec_int(_spec_int), m_falloff(_falloff) {}
37  //------------------------------------------------------------------------------------------------------------------
39  //------------------------------------------------------------------------------------------------------------------
40  ~Light() {}
41 
42  // Allow Renderer to access the protected interface
43  friend class Renderer;
44 
45 protected:
46  //--------------------------------------------------------------------------------------------------------------------
48  //--------------------------------------------------------------------------------------------------------------------
49  ngl::Vec3 m_pos;
50  //--------------------------------------------------------------------------------------------------------------------
52  //--------------------------------------------------------------------------------------------------------------------
53  ngl::Colour m_diff_col;
54  //--------------------------------------------------------------------------------------------------------------------
56  //--------------------------------------------------------------------------------------------------------------------
57  ngl::Colour m_spec_col;
58  //--------------------------------------------------------------------------------------------------------------------
60  //--------------------------------------------------------------------------------------------------------------------
61  float m_diff_int;
62  //--------------------------------------------------------------------------------------------------------------------
64  //--------------------------------------------------------------------------------------------------------------------
65  float m_spec_int;
66  //--------------------------------------------------------------------------------------------------------------------
68  //--------------------------------------------------------------------------------------------------------------------
69  float m_falloff;
70 };
71 
72 /* POINT LIGHT */
73 //------------------------------------------------------------------------------------------------------------------
81 //------------------------------------------------------------------------------------------------------------------
82 class PointLight : public Light
83 {
84 public:
85  PointLight(ngl::Vec3 _pos,
86  ngl::Colour _diff_col,
87  ngl::Colour _spec_col,
88  float _diff_int,
89  float _spec_int,
90  float _falloff) : Light(_pos, _diff_col, _spec_col, _diff_int, _spec_int, _falloff) {}
92 };
93 
94 /* POINT LIGHT */
95 //------------------------------------------------------------------------------------------------------------------
105 //------------------------------------------------------------------------------------------------------------------
106 class SpotLight : public Light
107 {
108 public:
109 SpotLight(ngl::Vec3 _pos,
110  ngl::Colour _diff_col,
111  ngl::Colour _spec_col,
112  float _diff_int,
113  float _spec_int,
114  float _falloff,
115  float _angle,
116  ngl::Vec3 _dir) : Light(_pos, _diff_col,
117  _spec_col,
118  _diff_int,
119  _spec_int,
120  _falloff),
121  m_angle(_angle), m_dir(_dir) {}
123 private:
124  //--------------------------------------------------------------------------------------------------------------------
126  //--------------------------------------------------------------------------------------------------------------------
127  float m_angle;
128  //--------------------------------------------------------------------------------------------------------------------
130  //--------------------------------------------------------------------------------------------------------------------
131  ngl::Vec3 m_dir;
132 };
133 
134 #endif // Light.h
This is a base class that will be used as template when creating concretes types of light...
Definition: Light.h:18
PointLight(ngl::Vec3 _pos, ngl::Colour _diff_col, ngl::Colour _spec_col, float _diff_int, float _spec_int, float _falloff)
Definition: Light.h:85
SpotLight(ngl::Vec3 _pos, ngl::Colour _diff_col, ngl::Colour _spec_col, float _diff_int, float _spec_int, float _falloff, float _angle, ngl::Vec3 _dir)
Definition: Light.h:109
Core of my program, central unit that manages all the other classes almost.
Definition: Renderer.h:23
float m_diff_int
Diffuse contribution intensity. It will multiply the diffuse colour when doing the Phong calculations...
Definition: Light.h:61
Light(ngl::Vec3 _pos, ngl::Colour _diff_col, ngl::Colour _spec_col, float _diff_int, float _spec_int, float _falloff)
Light constructor.
Definition: Light.h:30
ngl::Colour m_diff_col
Diffuse colour emmited by the light.
Definition: Light.h:53
ngl::Vec3 m_pos
Light's position vector.
Definition: Light.h:49
~Light()
Destructor for the Light objects.
Definition: Light.h:40
ngl::Vec3 m_dir
Direction or aiming vector of the spotlight.
Definition: Light.h:131
float m_falloff
Controlls the falloff of the light. Higher values will accentuate the decay.
Definition: Light.h:69
ngl::Colour m_spec_col
Specular colour emmited by the light.
Definition: Light.h:57
Spotlight constructor.
Definition: Light.h:106
float m_angle
The cone angle in which light is emitted.
Definition: Light.h:127
~PointLight()
Definition: Light.h:91
~SpotLight()
Definition: Light.h:122
Point light constructor.
Definition: Light.h:82
float m_spec_int
Specular contribution intensity. Will multiply the specular colour when doing the Phong calculations ...
Definition: Light.h:65