Light.h
Go to the documentation of this file.
1 #ifndef B_LIGHT_H
2 #define B_LIGHT_H
3 
4 #include <memory>
5 #include "vmmlib/vector.hpp"
6 #include "Renderer_GL.h"
7 #include "Configuration.h"
8 
9 
13 class Light
14 {
15 public:
16 
17  /* Functions */
18 
23  {}
24 
29  Light(const vmml::Vector3f &position, const vmml::Vector3f &color)
31  {}
32 
40  Light(const vmml::Vector3f &position, const vmml::Vector3f &color, GLfloat intensity, GLfloat attenuation, GLfloat radius)
41  : Light(position, color, color, intensity, attenuation, radius)
42  {}
43 
52  Light(const vmml::Vector3f &position, const vmml::Vector3f &diffuseColor, const vmml::Vector3f &specularColor, GLfloat intensity, GLfloat attenuation, GLfloat radius)
53  : _position(vmml::Vector4f(position, 1.0)), _diffuseColor(diffuseColor), _specularColor(specularColor), _intensity(intensity), _attenuation(attenuation), _radius(radius)
54  {}
55 
58  virtual ~Light(){}
59 
63  void setPosition(const vmml::Vector3f &position) { _position = vmml::Vector4f(position, 1.0); }
64 
68  void setDiffuseColor(const vmml::Vector3f &color) { _diffuseColor = color; }
69 
73  void setSpecularColor(const vmml::Vector3f &color) { _specularColor = color; }
74 
78  void setIntensity(GLfloat intensity) { _intensity = intensity; }
79 
83  void setAttenuation(GLfloat attenuation) { _attenuation = attenuation; }
84 
88  void setRadius(GLfloat radius) { _radius = radius; }
89 
92  const vmml::Vector4f &getPosition() { return _position; }
93 
96  const vmml::Vector3f &getDiffuseColor() { return _diffuseColor; }
97 
100  const vmml::Vector3f &getSpecularColor() { return _specularColor; }
101 
104  GLfloat getIntensity() { return _intensity; }
105 
108  GLfloat getAttenuation() { return _attenuation; }
109 
112  GLfloat getRadius() { return _radius; }
113 
114 private:
115 
116  /* Variables */
117 
118  vmml::Vector4f _position;
119  vmml::Vector3f _diffuseColor;
120  vmml::Vector3f _specularColor;
121  GLfloat _intensity;
122  GLfloat _attenuation;
123  GLfloat _radius;
124 
125 };
126 
127 typedef std::shared_ptr<Light> LightPtr;
128 
129 #endif /* defined(B_LIGHT_H) */
void setPosition(const vmml::Vector3f &position)
Sets the position of the light.
Definition: Light.h:63
GLfloat DEFAULT_LIGHT_RADIUS()
Definition: Configuration.cpp:137
Light(const vmml::Vector3f &position, const vmml::Vector3f &diffuseColor, const vmml::Vector3f &specularColor, GLfloat intensity, GLfloat attenuation, GLfloat radius)
Constructor.
Definition: Light.h:52
Definition: Configuration.h:8
const vmml::Vector3f & getDiffuseColor()
Returns the color of the light for diffuse lighting.
Definition: Light.h:96
A simple point light source.
Definition: Light.h:13
virtual ~Light()
Virtual destructor.
Definition: Light.h:58
const vmml::Vector3f & getSpecularColor()
Returns the color of the light for specular lighting.
Definition: Light.h:100
Light(const vmml::Vector3f &position, const vmml::Vector3f &color)
Constructor loading standard values for intensity and attenuation.
Definition: Light.h:29
Light(const vmml::Vector3f &position, const vmml::Vector3f &color, GLfloat intensity, GLfloat attenuation, GLfloat radius)
Constructor.
Definition: Light.h:40
void setRadius(GLfloat radius)
Sets the radius of the light.
Definition: Light.h:88
GLfloat getRadius()
Returns the radius of the light.
Definition: Light.h:112
GLfloat getIntensity()
Returns the intensity of the light.
Definition: Light.h:104
vmml::Vector4f DEFAULT_LIGHT_POSITION()
Definition: Configuration.cpp:124
void setAttenuation(GLfloat attenuation)
Sets the attenuation of the light.
Definition: Light.h:83
void setDiffuseColor(const vmml::Vector3f &color)
Sets the color of the light for diffuse lighting.
Definition: Light.h:68
void setIntensity(GLfloat intensity)
Sets the intensity of the light.
Definition: Light.h:78
GLfloat DEFAULT_LIGHT_ATTENUATION()
Definition: Configuration.cpp:136
Light()
Constructor loading standard values for position, color, intensity and attenuation.
Definition: Light.h:21
GLfloat getAttenuation()
Returns the attenuation of the light.
Definition: Light.h:108
const vmml::Vector4f & getPosition()
Returns the position of the light.
Definition: Light.h:92
vmml::Vector3f DEFAULT_LIGHT_COLOR()
Definition: Configuration.cpp:128
std::shared_ptr< Light > LightPtr
Definition: Light.h:127
void setSpecularColor(const vmml::Vector3f &color)
Sets the color of the light for specular lighting.
Definition: Light.h:73
GLfloat DEFAULT_LIGHT_INTENSITY()
Definition: Configuration.cpp:135