Ignition Rendering

API Reference

4.1.0
BaseLight.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef IGNITION_RENDERING_BASE_BASELIGHT_HH_
18 #define IGNITION_RENDERING_BASE_BASELIGHT_HH_
19 
21 
22 namespace ignition
23 {
24  namespace rendering
25  {
26  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
27  //
28  template <class T>
29  class BaseLight :
30  public virtual Light,
31  public virtual T
32  {
33  protected: BaseLight();
34 
35  public: virtual ~BaseLight();
36 
37  public: virtual void SetDiffuseColor(double _r, double _g, double _b,
38  double _a = 1.0);
39 
40  public: virtual void SetDiffuseColor(const math::Color &_color) = 0;
41 
42  public: virtual void SetSpecularColor(double _r, double _g, double _b,
43  double _a = 1.0);
44 
45  public: virtual void SetSpecularColor(const math::Color &_color) = 0;
46 
47  public: virtual void SetAttenuationConstant(double _value) = 0;
48 
49  public: virtual void SetAttenuationLinear(double _value) = 0;
50 
51  public: virtual void SetAttenuationQuadratic(double _value) = 0;
52 
53  public: virtual void SetAttenuationRange(double _range) = 0;
54 
55  public: virtual void SetCastShadows(bool _castShadows) = 0;
56 
57  protected: virtual void Reset();
58  };
59 
60  template <class T>
62  public virtual DirectionalLight,
63  public virtual T
64  {
65  protected: BaseDirectionalLight();
66 
67  public: virtual ~BaseDirectionalLight();
68 
69  public: virtual void SetDirection(double _x, double _y, double _z);
70 
71  public: virtual void SetDirection(const math::Vector3d &_dir) = 0;
72 
73  protected: virtual void Reset();
74  };
75 
76  template <class T>
78  public virtual PointLight,
79  public virtual T
80  {
81  protected: BasePointLight();
82 
83  public: virtual ~BasePointLight();
84  };
85 
86  template <class T>
87  class BaseSpotLight :
88  public virtual SpotLight,
89  public virtual T
90  {
91  protected: BaseSpotLight();
92 
93  public: virtual ~BaseSpotLight();
94 
95  public: virtual void SetDirection(double _x, double _y, double _z);
96 
97  public: virtual void SetDirection(const math::Vector3d &_dir) = 0;
98 
99  public: virtual void SetInnerAngle(double _radians);
100 
101  public: virtual void SetInnerAngle(const math::Angle &_angle) = 0;
102 
103  public: virtual void SetOuterAngle(double _radians);
104 
105  public: virtual void SetOuterAngle(const math::Angle &_angle) = 0;
106 
107  public: virtual void SetFalloff(double _falloff) = 0;
108 
109  protected: virtual void Reset();
110  };
111 
113  template <class T>
115  {
116  }
117 
119  template <class T>
121  {
122  }
123 
125  template <class T>
126  void BaseLight<T>::SetDiffuseColor(double _r, double _g, double _b,
127  double _a)
128  {
129  this->SetDiffuseColor(math::Color(_r, _g, _b, _a));
130  }
131 
133  template <class T>
134  void BaseLight<T>::SetSpecularColor(double _r, double _g, double _b,
135  double _a)
136  {
137  this->SetSpecularColor(math::Color(_r, _g, _b, _a));
138  }
139 
141  template <class T>
143  {
144  this->SetDiffuseColor(math::Color::White);
145  this->SetSpecularColor(math::Color::White);
146  this->SetAttenuationConstant(1);
147  this->SetAttenuationLinear(0);
148  this->SetAttenuationQuadratic(0);
149  this->SetAttenuationRange(100);
150  this->SetCastShadows(true);
151  }
152 
154  template <class T>
156  {
157  }
158 
160  template <class T>
162  {
163  }
164 
166  template <class T>
167  void BaseDirectionalLight<T>::SetDirection(double _x, double _y, double _z)
168  {
169  this->SetDirection(math::Vector3d(_x, _y, _z));
170  }
171 
173  template <class T>
175  {
176  T::Reset();
177  this->SetDirection(0, 0, -1);
178  }
179 
181  template <class T>
183  {
184  }
185 
187  template <class T>
189  {
190  }
191 
193  template <class T>
195  {
196  }
197 
199  template <class T>
201  {
202  }
203 
205  template <class T>
206  void BaseSpotLight<T>::SetDirection(double _x, double _y, double _z)
207  {
208  this->SetDirection(math::Vector3d(_x, _y, _z));
209  }
210 
212  template <class T>
213  void BaseSpotLight<T>::SetInnerAngle(double _radians)
214  {
215  this->SetInnerAngle(math::Angle(_radians));
216  }
217 
219  template <class T>
220  void BaseSpotLight<T>::SetOuterAngle(double _radians)
221  {
222  this->SetOuterAngle(math::Angle(_radians));
223  }
224 
226  template <class T>
228  {
229  T::Reset();
230  this->SetDirection(0, 0, -1);
231  this->SetInnerAngle(IGN_PI / 4.5);
232  this->SetOuterAngle(IGN_PI / 4.0);
233  this->SetFalloff(1.0);
234  }
235  }
236  }
237 }
238 #endif
Definition: BaseLight.hh:29
virtual ~BasePointLight()
Definition: BaseLight.hh:188
virtual void Reset()
Definition: BaseLight.hh:227
virtual void SetOuterAngle(double _radians)
Set the outer angle of the spotlight.
Definition: BaseLight.hh:220
Definition: BaseLight.hh:77
BaseSpotLight()
Definition: BaseLight.hh:194
virtual ~BaseLight()
Definition: BaseLight.hh:120
Represents a point light.
Definition: Light.hh:136
virtual void SetDirection(double _x, double _y, double _z)
Set the direction of the light.
Definition: BaseLight.hh:167
BaseLight()
Definition: BaseLight.hh:114
virtual ~BaseDirectionalLight()
Definition: BaseLight.hh:161
Definition: BaseLight.hh:87
static const Color White
virtual void SetDirection(double _x, double _y, double _z)
Set the direction of the light.
Definition: BaseLight.hh:206
virtual ~BaseSpotLight()
Definition: BaseLight.hh:200
Represents a light source in the scene graph.
Definition: Light.hh:32
Represents a spotlight.
Definition: Light.hh:145
Represents a infinite directional light.
Definition: Light.hh:113
BasePointLight()
Definition: BaseLight.hh:182
virtual void SetSpecularColor(double _r, double _g, double _b, double _a=1.0)
Set the specular color.
Definition: BaseLight.hh:134
virtual void SetInnerAngle(double _radians)
Set the inner angle of the spotlight.
Definition: BaseLight.hh:213
BaseDirectionalLight()
Definition: BaseLight.hh:155
virtual void Reset()
Definition: BaseLight.hh:174
virtual void SetDiffuseColor(double _r, double _g, double _b, double _a=1.0)
Set the diffuse color.
Definition: BaseLight.hh:126
virtual void Reset()
Definition: BaseLight.hh:142
#define IGN_PI