Page principale   Liste des namespaces   Hiérarchie des classes   Liste par ordre alphabétique   Liste des composants   Liste des fichiers   Composants   Déclarations  

ExCLight.cpp

Aller à la documentation de ce fichier.
00001 /*
00002  * ExNihilo 3D Engine
00003  * 
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Please read AUTHORS file !!!
00019  * 
00020  * $Id: ExCLight.cpp,v 1.7 2002/07/02 13:48:47 data Exp $
00021  *
00022  */
00023 
00024 #include "ExCLight.h"
00025 
00026 ExCLight::ExCLight()
00027 {
00028 Guard(ExCLight::ExCLight())
00029         Reset();
00030         m_LightNumber=0;
00031 UnGuard
00032 }
00033 
00034 ExCLight::ExCLight(GLenum Number)
00035 {
00036 Guard(ExCLight::ExCLight(GLenum Number))
00037         Reset();
00038         m_LightNumber=Number;
00039 UnGuard
00040 }
00041 
00042 ExCLight::~ExCLight(void)
00043 {
00044 Guard(ExCLight::~ExCLight(void))
00045 UnGuard
00046 }
00047 
00048 void ExCLight::Reset(void)
00049 {
00050 Guard(ExCLight::Reset(void))
00051         m_AngleX=0;
00052         m_AngleY=0;
00053         m_AngleZ=0;
00054         m_State=false;
00055         SetAmbiant(0.0f,0.0f,0.0f,1.0f);
00056         SetDiffuse(1.0f,1.0f,1.0f,1.0f);
00057         SetSpecular(1.0f,1.0f,1.0f,1.0f);
00058         m_Position.SetX(0.0f);
00059         m_Position.SetY(0.0f);
00060         m_Position.SetZ(0.0f);
00061         m_Target.SetX(0.0f);
00062         m_Target.SetY(0.0f);
00063         m_Target.SetZ(-1.0f);
00064         SetSpotExponent(0.0f);
00065         SetSpotCutOff(180.0f);
00066         SetConstantAttenuation(1.0f);
00067         SetLinearAttenuation(0.0f);
00068         SetQuadraticAttenuation(0.0f);
00069 UnGuard
00070 }
00071 
00072 void ExCLight::SetLightNumber(GLenum light)
00073 {
00074 Guard(void ExCLight::SetLightNumber(GLenum light))
00075         m_LightNumber=light;    
00076 UnGuard
00077 }
00078 
00079 void ExCLight::TurnOn(void)
00080 {
00081 Guard(void ExCLight::TurnOn(void))
00082         m_State=true;
00083         glEnable(m_LightNumber);
00084 UnGuard
00085 }
00086 
00087 void ExCLight::TurnOff(void)
00088 {
00089 Guard(void ExCLight::TurnOff(void))
00090         m_State=false;
00091         glDisable(m_LightNumber);
00092 UnGuard
00093 }
00094 
00095 void ExCLight::SetAmbiant(float R,float G,float B,float A)
00096 {
00097 Guard(void ExCLight::SetAmbiant(float R,float G,float B,float A))
00098         SetAmbiantR(R);
00099         SetAmbiantG(G);
00100         SetAmbiantB(B);
00101         SetAmbiantA(A);
00102 UnGuard
00103 }
00104 
00105 void ExCLight::SetAmbiantR(float R)
00106 {
00107 Guard(void ExCLight::SetAmbiantR(float R))
00108         if(R>1)R=1.0f;if(R<0.0f)R=0.0f;
00109         m_ambiant[0]=R;
00110         glLightfv(m_LightNumber,GL_AMBIENT,m_ambiant);
00111 UnGuard
00112 }
00113 
00114 void ExCLight::SetAmbiantG(float G)
00115 {
00116 Guard(void ExCLight::SetAmbiantG(float G))
00117         if(G>1)G=1.0f;if(G<0.0f)G=0.0f; 
00118         m_ambiant[1]=G;
00119         glLightfv(m_LightNumber,GL_AMBIENT,m_ambiant);
00120 UnGuard
00121 }
00122 
00123 void ExCLight::SetAmbiantB(float B)
00124 {
00125 Guard(void ExCLight::SetAmbiantB(float B))
00126         if(B>1)B=1.0f;if(B<0.0f)B=0.0f;
00127         m_ambiant[2]=B;
00128         glLightfv(m_LightNumber,GL_AMBIENT,m_ambiant);
00129 UnGuard
00130 }
00131 
00132 void ExCLight::SetAmbiantA(float A)
00133 {
00134 Guard(void ExCLight::SetAmbiantA(float A))
00135         if(A>1)A=1.0f;if(A<0.0f)A=0.0f;
00136         m_ambiant[3]=A;
00137         glLightfv(m_LightNumber,GL_AMBIENT,m_ambiant);
00138 UnGuard
00139 }
00140 
00141 float ExCLight::GetAmbiantR(void)
00142 {
00143 Guard(float ExCLight::GetAmbiantR(void))
00144         return m_ambiant[0];
00145 UnGuard
00146 }
00147 
00148 float ExCLight::GetAmbiantG(void)
00149 {
00150 Guard(float ExCLight::GetAmbiantG(void))
00151         return m_ambiant[1];
00152 UnGuard
00153 }
00154 
00155 float ExCLight::GetAmbiantB(void)
00156 {
00157 Guard(float ExCLight::GetAmbiantB(void))
00158         return m_ambiant[2];
00159 UnGuard
00160 }
00161 
00162 float ExCLight::GetAmbiantA(void)
00163 {
00164 Guard(float ExCLight::GetAmbiantA(void))
00165         return m_ambiant[3];
00166 UnGuard
00167 }
00168 
00169 void ExCLight::IncAmbiantR(float inc)
00170 {
00171 Guard(void ExCLight::IncAmbiantR(float inc))
00172         SetAmbiantR(GetAmbiantR()+inc);
00173 UnGuard
00174 }
00175 
00176 void ExCLight::IncAmbiantG(float inc)
00177 {
00178 Guard(void ExCLight::IncAmbiantG(float inc))
00179         SetAmbiantG(GetAmbiantG()+inc);
00180 UnGuard
00181 }
00182 
00183 void ExCLight::IncAmbiantB(float inc)
00184 {
00185 Guard(void ExCLight::IncAmbiantB(float inc))
00186         SetAmbiantB(GetAmbiantB()+inc);
00187 UnGuard
00188 }
00189 
00190 void ExCLight::IncAmbiantA(float inc)
00191 {
00192 Guard(void ExCLight::IncAmbiantA(float inc))
00193         SetAmbiantA(GetAmbiantA()+inc);
00194 UnGuard
00195 }
00196 
00197 void ExCLight::SetDiffuse(float R,float G,float B,float A)
00198 {
00199 Guard(void ExCLight::SetDiffuse(float R,float G,float B,float A))
00200         SetDiffuseR(R);
00201         SetDiffuseG(G);
00202         SetDiffuseB(B);
00203         SetDiffuseA(A);
00204 UnGuard
00205 }
00206 
00207 void ExCLight::SetDiffuseR(float R)
00208 {
00209 Guard(void ExCLight::SetDiffuseR(float R))
00210         if(R>1)R=1.0f;if(R<0.0f)R=0.0f;
00211         m_diffuse[0]=R;
00212         glLightfv(m_LightNumber,GL_DIFFUSE,m_diffuse);
00213 UnGuard
00214 }
00215 
00216 void ExCLight::SetDiffuseG(float G)
00217 {
00218 Guard(void ExCLight::SetDiffuseG(float G))
00219         if(G>1)G=1.0f;if(G<0.0f)G=0.0f; 
00220         m_diffuse[1]=G;
00221         glLightfv(m_LightNumber,GL_DIFFUSE,m_diffuse);
00222 UnGuard
00223 }
00224 
00225 void ExCLight::SetDiffuseB(float B)
00226 {
00227 Guard(void ExCLight::SetDiffuseB(float B))
00228         if(B>1)B=1.0f;if(B<0.0f)B=0.0f;
00229         m_diffuse[2]=B;
00230         glLightfv(m_LightNumber,GL_DIFFUSE,m_diffuse);
00231 UnGuard
00232 }
00233 
00234 void ExCLight::SetDiffuseA(float A)
00235 {
00236 Guard(void ExCLight::SetDiffuseA(float A))
00237         if(A>1)A=1.0f;if(A<0.0f)A=0.0f;
00238         m_diffuse[3]=A;
00239         glLightfv(m_LightNumber,GL_DIFFUSE,m_diffuse);
00240 UnGuard
00241 }
00242 
00243 float ExCLight::GetDiffuseR(void)
00244 {
00245 Guard(float ExCLight::GetDiffuseR(void))
00246         return m_diffuse[0];
00247 UnGuard
00248 }
00249 
00250 float ExCLight::GetDiffuseG(void)
00251 {
00252 Guard(float ExCLight::GetDiffuseG(void))
00253         return m_diffuse[1];
00254 UnGuard
00255 }
00256 
00257 float ExCLight::GetDiffuseB(void)
00258 {
00259 Guard(float ExCLight::GetDiffuseB(void))
00260         return m_diffuse[2];
00261 UnGuard
00262 }
00263 
00264 float ExCLight::GetDiffuseA(void)
00265 {
00266 Guard(float ExCLight::GetDiffuseA(void))
00267         return m_diffuse[3];
00268 UnGuard
00269 }
00270 
00271 void ExCLight::IncDiffuseR(float inc)
00272 {
00273 Guard(void ExCLight::IncDiffuseR(float inc))
00274         SetDiffuseR(GetDiffuseR()+inc);
00275 UnGuard
00276 }
00277 
00278 void ExCLight::IncDiffuseG(float inc)
00279 {
00280 Guard(void ExCLight::IncDiffuseG(float inc))
00281         SetDiffuseG(GetDiffuseG()+inc);
00282 UnGuard
00283 }
00284 
00285 void ExCLight::IncDiffuseB(float inc)
00286 {
00287 Guard(void ExCLight::IncDiffuseB(float inc))
00288         SetDiffuseB(GetDiffuseB()+inc);
00289 UnGuard
00290 }
00291 
00292 void ExCLight::IncDiffuseA(float inc)
00293 {
00294 Guard(void ExCLight::IncDiffuseA(float inc))
00295         SetDiffuseA(GetDiffuseA()+inc);
00296 UnGuard
00297 }
00298 
00299 void ExCLight::SetSpecular(float R,float G,float B,float A)
00300 {
00301 Guard(void ExCLight::SetSpecular(float R,float G,float B,float A))
00302         SetSpecularR(R);
00303         SetSpecularG(G);
00304         SetSpecularB(B);
00305         SetSpecularA(A);
00306 UnGuard
00307 }
00308 
00309 void ExCLight::SetSpecularR(float R)
00310 {
00311 Guard(void ExCLight::SetSpecularR(float R))
00312         if(R>1)R=1.0f;if(R<0.0f)R=0.0f;
00313         m_specular[0]=R;
00314         glLightfv(m_LightNumber,GL_SPECULAR,m_specular);
00315 UnGuard
00316 }
00317 
00318 void ExCLight::SetSpecularG(float G)
00319 {
00320 Guard(void ExCLight::SetSpecularG(float G))
00321         if(G>1)G=1.0f;if(G<0.0f)G=0.0f; 
00322         m_specular[1]=G;
00323         glLightfv(m_LightNumber,GL_SPECULAR,m_specular);
00324 UnGuard
00325 }
00326 
00327 void ExCLight::SetSpecularB(float B)
00328 {
00329 Guard(void ExCLight::SetSpecularB(float B))
00330         if(B>1)B=1.0f;if(B<0.0f)B=0.0f;
00331         m_specular[2]=B;
00332         glLightfv(m_LightNumber,GL_SPECULAR,m_specular);
00333 UnGuard
00334 }
00335 
00336 void ExCLight::SetSpecularA(float A)
00337 {
00338 Guard(void ExCLight::SetSpecularA(float A))
00339         if(A>1)A=1.0f;if(A<0.0f)A=0.0f;
00340         m_specular[3]=A;
00341         glLightfv(m_LightNumber,GL_SPECULAR,m_specular);
00342 UnGuard
00343 }
00344 
00345 float ExCLight::GetSpecularR(void)
00346 {
00347 Guard(float ExCLight::GetSpecularR(void))
00348         return m_specular[0];
00349 UnGuard
00350 }
00351 
00352 float ExCLight::GetSpecularG(void)
00353 {
00354 Guard(float ExCLight::GetSpecularG(void))
00355         return m_specular[1];
00356 UnGuard
00357 }
00358 
00359 float ExCLight::GetSpecularB(void)
00360 {
00361 Guard(float ExCLight::GetSpecularB(void))
00362         return m_specular[2];
00363 UnGuard
00364 }
00365 
00366 float ExCLight::GetSpecularA(void)
00367 {
00368 Guard(float ExCLight::GetSpecularA(void))
00369         return m_specular[3];
00370 UnGuard
00371 }
00372 
00373 void ExCLight::IncSpecularR(float inc)
00374 {
00375 Guard(void ExCLight::IncSpecularR(float inc))
00376         SetSpecularR(GetSpecularR()+inc);
00377 UnGuard
00378 }
00379 
00380 void ExCLight::IncSpecularG(float inc)
00381 {
00382 Guard(void ExCLight::IncSpecularG(float inc))
00383         SetSpecularG(GetSpecularG()+inc);
00384 UnGuard
00385 }
00386 
00387 void ExCLight::IncSpecularB(float inc)
00388 {
00389 Guard(void ExCLight::IncSpecularB(float inc))
00390         SetSpecularB(GetSpecularB()+inc);
00391 UnGuard
00392 }
00393 
00394 void ExCLight::IncSpecularA(float inc)
00395 {
00396 Guard(void ExCLight::IncSpecularA(float inc))
00397         SetSpecularA(GetSpecularA()+inc);
00398 UnGuard
00399 }
00400 
00401 
00402 void ExCLight::SetPosition(double X,double Y,double Z)
00403 {
00404 Guard(void ExCLight::SetPosition(double X,double Y,double Z))
00405         SetPosition(X,Y,Z);
00406         GLfloat lightPos[] = { m_Position.GetX(), m_Position.GetY(),m_Position.GetZ()};
00407         glLightfv(m_LightNumber, GL_POSITION, lightPos );
00408 UnGuard
00409 }
00410 
00411 void ExCLight::SetPositionX(double X)
00412 {
00413 Guard(void ExCLight::SetPositionX(double X))
00414         m_Position.SetX(X);
00415         GLfloat lightPos[] = { m_Position.GetX(), m_Position.GetY(),m_Position.GetZ()};
00416         glLightfv(m_LightNumber, GL_POSITION, lightPos );
00417 UnGuard
00418 }
00419 
00420 void ExCLight::SetPositionY(double Y)
00421 {
00422 Guard(void ExCLight::SetPositionY(double Y))
00423         m_Position.SetY(Y);
00424         GLfloat lightPos[] = { m_Position.GetX(), m_Position.GetY(),m_Position.GetZ()};
00425         glLightfv(m_LightNumber, GL_POSITION, lightPos );
00426 UnGuard
00427 }
00428 
00429 void ExCLight::SetPositionZ(double Z)
00430 {
00431 Guard(void ExCLight::SetPositionZ(double Z))
00432         m_Position.SetZ(Z);
00433         GLfloat lightPos[] = { m_Position.GetX(), m_Position.GetY(),m_Position.GetZ()};
00434         glLightfv(m_LightNumber, GL_POSITION, lightPos );
00435 UnGuard
00436 }
00437 
00438 
00439 void ExCLight::SetTargetX(double X)
00440 {
00441 Guard(void ExCLight::SetTargetX(double X))
00442         m_Target.SetX(X);
00443         GLfloat lightPos[] = { m_Target.GetX(), m_Target.GetY(),m_Target.GetZ(), 1.0 };
00444         glLightfv(m_LightNumber, GL_POSITION, lightPos );
00445 UnGuard
00446 }
00447 
00448 void ExCLight::SetTargetY(double Y)
00449 {
00450 Guard(void ExCLight::SetTargetY(double Y))
00451         m_Target.SetY(Y);
00452         GLfloat lightPos[] = { m_Target.GetX(), m_Target.GetY(),m_Target.GetZ(), 1.0 };
00453         glLightfv(m_LightNumber, GL_POSITION, lightPos );
00454 UnGuard
00455 }
00456 
00457 void ExCLight::SetTargetZ(double Z)
00458 {
00459 Guard(void ExCLight::SetTargetZ(double Z))
00460         m_Target.SetZ(Z);
00461         GLfloat lightPos[] = { m_Target.GetX(), m_Target.GetY(),m_Target.GetZ(), 1.0 };
00462         glLightfv(m_LightNumber, GL_POSITION, lightPos );
00463 UnGuard
00464 }
00465 
00466 
00467 
00468 
00469 void ExCLight::SetTarget(double X,double Y,double Z)
00470 {
00471 Guard(void ExCLight::SetTarget(double X,double Y,double Z))
00472         //SetTarget(X,Y,Z);
00473         GLfloat lightPos[] = { m_Target.GetX(), m_Target.GetY(),m_Target.GetZ(), 1.0 };
00474         glLightfv(m_LightNumber,GL_SPOT_DIRECTION,lightPos);
00475 UnGuard
00476 }
00477 
00478 void ExCLight::SetSpotExponent(float Exponent)
00479 {
00480 Guard(void ExCLight::SetSpotExponent(float Exponent))
00481         if(Exponent<0)Exponent=0.0f;if(Exponent>128)Exponent=128.0f;
00482         m_spotExponent[0]=Exponent;
00483         glLightfv(m_LightNumber,GL_SPOT_EXPONENT,m_spotExponent);
00484 UnGuard
00485 }
00486 
00487 void ExCLight::IncSpotExponent(float inc)
00488 {
00489 Guard(void ExCLight::IncSpotExponent(float inc))
00490         SetSpotExponent(GetSpotExponent()+inc);
00491 UnGuard
00492 }
00493 
00494 float ExCLight::GetSpotExponent(void)
00495 {
00496 Guard(float ExCLight::GetSpotExponent(void))
00497         return m_spotExponent[0];
00498 UnGuard
00499 }
00500 
00501 void ExCLight::SetSpotCutOff(float cut)
00502 {
00503 Guard(void ExCLight::SetSpotCutOff(float cut))
00504         if(cut>m_spotCutOff[0])
00505         {
00506                 if(cut>90)cut=180;
00507         }else
00508         {
00509                 if(cut<0)cut=0;
00510                 if(cut>90)cut=90;
00511                 
00512         }
00513 
00514         m_spotCutOff[0]=cut;
00515         glLightfv(m_LightNumber,GL_SPOT_CUTOFF,m_spotCutOff);
00516 UnGuard
00517 }
00518 
00519 void ExCLight::IncSpotCutOff(float inc)
00520 {
00521 Guard(void ExCLight::IncSpotCutOff(float inc))
00522         SetSpotCutOff(GetSpotCutOff()+inc);
00523 UnGuard
00524 }
00525 
00526 float ExCLight::GetSpotCutOff(void)
00527 {
00528 Guard(float ExCLight::GetSpotCutOff(void))
00529         return m_spotCutOff[0];
00530 UnGuard
00531 }
00532 
00533 void ExCLight::SetConstantAttenuation(float att)
00534 {
00535 Guard(void ExCLight::SetConstantAttenuation(float att))
00536         if(att<0)att=0.0f;if(att>5)att=5.0f;
00537         m_spotConstentAtt[0]=att;
00538         glLightfv(m_LightNumber,GL_CONSTANT_ATTENUATION,m_spotConstentAtt);
00539 UnGuard
00540 }
00541 
00542 void ExCLight::IncConstantAttenuation(float inc)
00543 {
00544 Guard(void ExCLight::IncConstantAttenuation(float inc))
00545         SetConstantAttenuation(GetConstantAttenuation()+inc);
00546 UnGuard
00547 }
00548 
00549 float ExCLight::GetConstantAttenuation(void)
00550 {
00551 Guard(float ExCLight::GetConstantAttenuation(void))
00552         return m_spotConstentAtt[0];
00553 UnGuard
00554 }
00555 
00556 void ExCLight::SetLinearAttenuation(float att)
00557 {
00558 Guard(void ExCLight::SetLinearAttenuation(float att))
00559         if(att<0)att=0.0f;if(att>5)att=5.0f;
00560         m_spotLinearAtt[0]=att;
00561         glLightfv(m_LightNumber,GL_LINEAR_ATTENUATION,m_spotLinearAtt);
00562 UnGuard
00563 }
00564 
00565 void ExCLight::IncLinearAttenuation(float inc)
00566 {
00567 Guard(void ExCLight::IncLinearAttenuation(float inc))
00568         SetLinearAttenuation(GetLinearAttenuation()+inc);
00569 UnGuard
00570 }
00571 
00572 float ExCLight::GetLinearAttenuation(void)
00573 {
00574 Guard(float ExCLight::GetLinearAttenuation(void))
00575         return m_spotLinearAtt[0];
00576 UnGuard
00577 }
00578 
00579 void ExCLight::SetQuadraticAttenuation(float att)
00580 {
00581 Guard(void ExCLight::SetQuadraticAttenuation(float att))
00582         if(att<0)att=0.0f;if(att>5)att=5.0f;
00583         m_spotQuadraticAtt[1]=att;
00584         glLightfv(m_LightNumber,GL_QUADRATIC_ATTENUATION,m_spotQuadraticAtt);
00585 UnGuard
00586 }
00587 
00588 void ExCLight::IncQuadraticAttenuation(float inc)
00589 {
00590 Guard(void ExCLight::IncQuadraticAttenuation(float inc))
00591         SetQuadraticAttenuation(GetQuadraticAttenuation()+inc);
00592 UnGuard
00593 }
00594 
00595 float ExCLight::GetQuadraticAttenuation(void)
00596 {
00597 Guard(float ExCLight::GetQuadraticAttenuation(void))
00598         return m_spotQuadraticAtt[1];
00599 UnGuard
00600 }
00601 

Généré le Tue Aug 6 20:25:24 2002 pour ExNihilo par doxygen1.2.17