00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef CLightH
00023 #define CLightH
00024
00025 #include "math/CMaths.h"
00026 #include "graphics/CColor.h"
00027 #include "graphics/CMacrosGL.h"
00028 #include "scenegraph/CGenericObject.h"
00029
00030 class cWorld;
00031
00032
00033
00041
00042
00043
00053
00054 class cLight : public cGenericObject
00055 {
00056
00057
00058
00059
00060
00062 friend class cWorld;
00063
00065 friend class cCamera;
00066
00067
00068 public:
00069
00070
00071
00072
00073
00075 cLight(cWorld* a_world = NULL);
00076
00078 ~cLight();
00079
00080
00081
00082
00083
00084
00086 cColorf m_ambient;
00087
00089 cColorf m_diffuse;
00090
00092 cColorf m_specular;
00093
00094
00095
00096
00097
00098
00100 void setDir(const cVector3d& a_direction);
00101
00103 void setDir(const double a_x, const double a_y, const double a_z);
00104
00106 cVector3d getDir() const { return (m_localRot.getCol0()); }
00107
00109 void setDirectionalLight(bool a_directionalLight) { m_directionalLight = a_directionalLight; }
00110
00112 bool getDirectionalLight() { return m_directionalLight; }
00113
00115 void setAttConstant(const GLfloat& a_value) { m_attConstant = cClamp(a_value, 0.0f, 1.0f); }
00116
00118 GLfloat getAttConstant() const { return (m_attConstant); }
00119
00121 void setAttLinear(const GLfloat& a_value) { m_attLinear = cClamp(a_value, 0.0f, 1.0f); }
00122
00124 GLfloat getAttLinear() const { return (m_attLinear); }
00125
00127 void setAttQuadratic(const GLfloat& a_value) { m_attQuadratic = cClamp(a_value, 0.0f, 1.0f); }
00128
00130 GLfloat getAttQuadratic() const { return (m_attQuadratic); }
00131
00133 void setSpotExponent(const GLfloat& a_value) { m_spotExponent = cClamp(a_value, 0.0f, 100.0f); }
00134
00136 GLfloat getSpotExponent() const { return (m_spotExponent); }
00137
00139 void setCutOffAngle(const GLfloat& a_value);
00140
00142 GLfloat getCutOffAngle() const { return (m_cutOffAngle); }
00143
00145 void setEnabled(const bool& a_enabled) { m_enabled = a_enabled; }
00146
00148 bool getEnabled() const { return (m_enabled); }
00149
00150
00151 protected:
00152
00153
00154
00155
00156
00158 cWorld* m_parentWorld;
00159
00161 GLfloat m_attConstant;
00162
00164 GLfloat m_attLinear;
00165
00167 GLfloat m_attQuadratic;
00168
00170 GLfloat m_spotExponent;
00171
00173 GLfloat m_cutOffAngle;
00174
00176 bool m_enabled;
00177
00179 bool m_directionalLight;
00180
00182 GLint m_glLightNumber;
00183
00184
00185
00186
00187
00188
00190 void renderLightSource();
00191 };
00192
00193
00194 #endif
00195
00196