Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ScenePointLight.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003, 2004 (see file CONTACTS for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef __ScenePointLight_HH__
26 #define __ScenePointLight_HH__
27 
28 #include <bias_config.h>
29 
30 #ifndef BIAS_HAVE_OPENGL
31 # error You need BIAS with USE_OpenGL Please recompile BIAS.
32 #endif // BUILD_GLviewer
33 
34 
35 #include <GLviewer/Scenes/SceneBase.hh>
36 #include <GLviewer/Controller/ControlInterface.hh>
37 #include <Base/Math/Vector3.hh>
38 
39 namespace BIAS {
40 
41  /** @class SceneBase
42  @brief Simple point light in GL.
43  @ingroup g_glviewer
44  @author bartczak
45  */
46  class BIASGLviewer_EXPORT ScenePointLight : public SceneBase
47  {
48  public:
49 
51 
53  lightPos_ = pos;
54  }
55 
57  ambient_[0] = am[0]; ambient_[1] = am[1];
58  ambient_[2] = am[2]; ambient_[3] = am[3];
59  }
60 
62  diffuse_[0] = di[0]; diffuse_[1] = di[1];
63  diffuse_[2] = di[2]; diffuse_[3] = di[3];
64  }
65 
67  specular_[0] = sp[0]; specular_[1] = sp[1];
68  specular_[2] = sp[2]; specular_[3] = sp[3];
69  }
70 
71  void SetDrawLightPosition(bool drawLight) {
72  drawLight_ = drawLight;
73  }
74 
75  void SetLightAsHeadLight(bool asHeadLight) {
76  lightAsHeadALight_ = asHeadLight;
77  }
78 
79  /** @brief Enable/disable attenuation for point light. */
80  void UseAttenuation(bool useAttenuation) {
81  useAttenuation_ = useAttenuation;
82  }
83 
84  /** @brief Set polynomial factors for light attenuation function,
85  i.e. att(d) = 1 / (a0 + a1*d + a2*d*d) with distance d. */
86  void SetAttenuationFactors(double a0, double a1, double a2) {
87  attenuationFactors_[0] = a0; attenuationFactors_[1] = a1;
88  attenuationFactors_[2] = a2;
89  }
90 
91  protected:
92 
93  virtual void Draw();
94 
95  void DrawLightPosition_();
96 
98  bool drawLight_;
100  float diffuse_[4];
101  float ambient_[4];
102  float specular_[4];
103 
105  float attenuationFactors_[3];
106 
107  };
108 
109 }
110 
111 #endif
void SetLightAsHeadLight(bool asHeadLight)
void SetAttenuationFactors(double a0, double a1, double a2)
Set polynomial factors for light attenuation function, i.e.
void SetSpecular(BIAS::Vector4< double > sp)
class Vector4 contains a Vector of dim.
Definition: Vector4.hh:65
void SetDiffuse(BIAS::Vector4< double > di)
BIAS::Vector3< double > lightPos_
Base class for all scenes.
Definition: SceneBase.hh:68
void SetLightPosition(BIAS::Vector3< double > pos)
void UseAttenuation(bool useAttenuation)
Enable/disable attenuation for point light.
void SetAmbient(BIAS::Vector4< double > am)
void SetDrawLightPosition(bool drawLight)