-
Notifications
You must be signed in to change notification settings - Fork 0
/
Light.h
172 lines (135 loc) · 3.52 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#ifndef LIGHT_H
#define LIGHT_H
#include <GL/gl.h>
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/ptree.hpp>
#include <string>
#include <iostream>
using namespace std;
using namespace boost;
using namespace boost::property_tree;
class Light {
public:
/** Indicator of movable light. */
bool dynamic;
/**
* Create new light.
*/
Light(int _number, ptree& _config);
/**
* Destroy the light.
*/
virtual ~Light(void);
/**
* Switch on the light.
*/
void switchOn(void);
/**
* Switch of the light.
*/
void switchOff(void);
/**
* Set up ambient color.
* @param _r Red color.
* @param _g Green color.
* @param _b Blue color.
* @param _a Alpha canal.
*/
void setAmbient(GLfloat _r, GLfloat _g, GLfloat _b, GLfloat _a = 1.0);
/**
* Set up diffuse color.
* @param _r Red color.
* @param _g Green color.
* @param _b Blue color.
* @param _a Alpha canal.
*/
void setDiffuse(GLfloat _r, GLfloat _g, GLfloat _b, GLfloat _a = 1.0);
/**
* Set up specular color.
* @param _r Red color.
* @param _g Green color.
* @param _b Blue color.
* @param _a Alpha canal.
*/
void setSpecular(GLfloat _r, GLfloat _g, GLfloat _b, GLfloat _a = 1.0);
/**
* Set up position of light.
* @param _x X coordinate.
* @param _y Y coordinate.
* @param _z Z coordinate.
* @param _w W coordinate.
*/
void setPosition(GLfloat _x, GLfloat _y, GLfloat _z, GLfloat _w = 0.0);
/**
* Replace light in the same position. Due to tranformation.
*/
void rePosition(void);
/**
* Set up direction of spot light.
* @param _x X coordinate.
* @param _y Y coordinate.
* @param _z Z coordinate.
*/
void setSpotDirection(GLfloat _x, GLfloat _y, GLfloat _z);
/**
* Set up direction of spot light again.
*/
void reSpotDirection(void);
/**
* Set up exponent of spot light.
* @param _exponent Exponent.
*/
void setSpotExponent(GLfloat _exponent);
/**
* Set up cutoff angle of spot light.
* @param _cutOff Angle in degrees.
*/
void setSpotCutOff(GLfloat _cutOff);
/**
* Set up attenuation.
* @param _constant Constant element.
* @param _linear Linear element.
* @param _quadratic Quadratic element.
*/
void setAttenuation(GLfloat _constant, GLfloat _linear, GLfloat _quadratic);
/**
* Get state of light.
* @return false = off, true = on.
*/
bool getState(void);
friend ostream & operator<<(ostream& os, Light& light);
private:
/** Light name. */
GLenum name;
// Light identifier.
int id;
/** Ambient color. */
GLfloat ambient[4];
/** Diffuse color. */
GLfloat diffuse[4];
/** Specular color. */
GLfloat specular[4];
/** Position of light. */
GLfloat position[4];
/** Direction of spot light. */
GLfloat spotDirection[3];
/** Exponent of spot light. */
GLfloat spotExponent;
/** Cutoff angle of spot light. */
GLfloat spotCutOff;
/** Factor of attenuation.
* [0] Constant element.
* [1] Linear element.
* [2] Quadratic element.
*/
GLfloat attenuation[3];
/** Indicator of on/off. */
bool enabled;
/**
* Set up light from configuration.
* @param _name Light name.
* @param _config Configuration.
*/
void loadConfig(const string& _name, ptree& _config);
};
#endif /* LIGHT_H */