1 #include <GLviewer/Scenes/ScenePointLight.hh>
2 #include <GLviewer/GLProjectionParametersBase.hh>
4 #include <Gui/biasgl.h>
5 #include <Base/Math/Vector3.hh>
17 lightAsHeadALight_ =
false;
19 diffuse_[0] = diffuse_[1] = diffuse_[2] = diffuse_[3] = 1.0;
20 specular_[0] = specular_[1] = specular_[2] = specular_[3] = 1.0;
21 ambient_[0] = ambient_[1] = ambient_[2] = 0.4; ambient_[3] = 1.0;
23 useAttenuation_ =
false;
24 attenuationFactors_[0] = 1.0f;
25 attenuationFactors_[1] = 0.2f;
26 attenuationFactors_[2] = 0.08f;
33 glEnable(GL_LIGHTING);
36 if( lightAsHeadALight_ && camera_ != NULL) {
37 lightPos_ = camera_->GetMyselfAsProjectionParameterBase()->GetC();
40 float c[4] = { (float)lightPos_[0], (
float)lightPos_[1], (float)lightPos_[2], 1.0 };
41 glLightfv(GL_LIGHT0, GL_POSITION, c);
42 glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_);
43 glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_);
44 glLightfv(GL_LIGHT0, GL_SPECULAR, specular_);
46 if (useAttenuation_) {
47 glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, attenuationFactors_[0]);
48 glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, attenuationFactors_[1]);
49 glLightf(GL_LIGHT0, GL_QUADRATIC_ATTENUATION, attenuationFactors_[2]);
52 if (drawLight_) DrawLightPosition_();
58 glDisable(GL_LIGHTING);
61 glGetIntegerv(GL_POINT_SIZE,ps);
64 glColor3f(1.0, 1.0, 0.0);
65 float c[4] = {(float)lightPos_[0], (
float)lightPos_[1], (float)lightPos_[2], 1.0};
72 glEnable(GL_LIGHTING);
virtual void Draw()
To do anything usefull, overload this method, assume context is ready and draw.
void DrawLightPosition_()