Ignition Rendering

API Reference

5.0.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  this->SetIntensity(1.0);
152  }
153 
155  template <class T>
157  {
158  }
159 
161  template <class T>
163  {
164  }
165 
167  template <class T>
168  void BaseDirectionalLight<T>::SetDirection(double _x, double _y, double _z)
169  {
170  this->SetDirection(math::Vector3d(_x, _y, _z));
171  }
172 
174  template <class T>
176  {
177  T::Reset();
178  this->SetDirection(0, 0, -1);
179  }
180 
182  template <class T>
184  {
185  }
186 
188  template <class T>
190  {
191  }
192 
194  template <class T>
196  {
197  }
198 
200  template <class T>
202  {
203  }
204 
206  template <class T>
207  void BaseSpotLight<T>::SetDirection(double _x, double _y, double _z)
208  {
209  this->SetDirection(math::Vector3d(_x, _y, _z));
210  }
211 
213  template <class T>
214  void BaseSpotLight<T>::SetInnerAngle(double _radians)
215  {
216  this->SetInnerAngle(math::Angle(_radians));
217  }
218 
220  template <class T>
221  void BaseSpotLight<T>::SetOuterAngle(double _radians)
222  {
223  this->SetOuterAngle(math::Angle(_radians));
224  }
225 
227  template <class T>
229  {
230  T::Reset();
231  this->SetDirection(0, 0, -1);
232  this->SetInnerAngle(IGN_PI / 4.5);
233  this->SetOuterAngle(IGN_PI / 4.0);
234  this->SetFalloff(1.0);
235  }
236  }
237  }
238 }
239 #endif
Definition: BaseLight.hh:29
virtual ~BasePointLight()
Definition: BaseLight.hh:189
virtual void Reset()
Definition: BaseLight.hh:228
virtual void SetOuterAngle(double _radians)
Set the outer angle of the spotlight.
Definition: BaseLight.hh:221
Definition: BaseLight.hh:77
BaseSpotLight()
Definition: BaseLight.hh:195
virtual ~BaseLight()
Definition: BaseLight.hh:120
Represents a point light.
Definition: Light.hh:144
virtual void SetDirection(double _x, double _y, double _z)
Set the direction of the light.
Definition: BaseLight.hh:168
BaseLight()
Definition: BaseLight.hh:114
virtual ~BaseDirectionalLight()
Definition: BaseLight.hh:162
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:207
virtual ~BaseSpotLight()
Definition: BaseLight.hh:201
Represents a light source in the scene graph.
Definition: Light.hh:32
Represents a spotlight.
Definition: Light.hh:153
Represents a infinite directional light.
Definition: Light.hh:121
BasePointLight()
Definition: BaseLight.hh:183
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:214
BaseDirectionalLight()
Definition: BaseLight.hh:156
virtual void Reset()
Definition: BaseLight.hh:175
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