Gazebo Rendering

API Reference

6.6.3
gz/rendering/base/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 GZ_RENDERING_BASE_BASELIGHT_HH_
18 #define GZ_RENDERING_BASE_BASELIGHT_HH_
19 
20 #include "gz/rendering/Light.hh"
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  // Documentation inherited
38  public: virtual void SetDiffuseColor(double _r, double _g, double _b,
39  double _a = 1.0);
40 
41  // Documentation inherited.
42  public: virtual void SetDiffuseColor(const math::Color &_color) = 0;
43 
44  // Documentation inherited.
45  public: virtual void SetSpecularColor(double _r, double _g, double _b,
46  double _a = 1.0);
47 
48  // Documentation inherited.
49  public: virtual void SetSpecularColor(const math::Color &_color) = 0;
50 
51  // Documentation inherited.
52  public: virtual void SetAttenuationConstant(double _value) = 0;
53 
54  // Documentation inherited.
55  public: virtual void SetAttenuationLinear(double _value) = 0;
56 
57  // Documentation inherited.
58  public: virtual void SetAttenuationQuadratic(double _value) = 0;
59 
60  // Documentation inherited.
61  public: virtual void SetAttenuationRange(double _range) = 0;
62 
63  // Documentation inherited.
64  public: virtual void SetCastShadows(bool _castShadows) = 0;
65 
66  // Documentation inherited.
67  protected: virtual void Reset();
68  };
69 
70  template <class T>
72  public virtual DirectionalLight,
73  public virtual T
74  {
75  protected: BaseDirectionalLight();
76 
77  public: virtual ~BaseDirectionalLight();
78 
79  public: virtual void SetDirection(double _x, double _y, double _z);
80 
81  public: virtual void SetDirection(const math::Vector3d &_dir) = 0;
82 
83  protected: virtual void Reset();
84  };
85 
86  template <class T>
88  public virtual PointLight,
89  public virtual T
90  {
91  protected: BasePointLight();
92 
93  public: virtual ~BasePointLight();
94  };
95 
96  template <class T>
97  class BaseSpotLight :
98  public virtual SpotLight,
99  public virtual T
100  {
101  protected: BaseSpotLight();
102 
103  public: virtual ~BaseSpotLight();
104 
105  public: virtual void SetDirection(double _x, double _y, double _z);
106 
107  public: virtual void SetDirection(const math::Vector3d &_dir) = 0;
108 
109  public: virtual void SetInnerAngle(double _radians);
110 
111  public: virtual void SetInnerAngle(const math::Angle &_angle) = 0;
112 
113  public: virtual void SetOuterAngle(double _radians);
114 
115  public: virtual void SetOuterAngle(const math::Angle &_angle) = 0;
116 
117  public: virtual void SetFalloff(double _falloff) = 0;
118 
119  protected: virtual void Reset();
120  };
121 
123  template <class T>
125  {
126  }
127 
129  template <class T>
131  {
132  }
133 
135  template <class T>
136  void BaseLight<T>::SetDiffuseColor(double _r, double _g, double _b,
137  double _a)
138  {
139  this->SetDiffuseColor(math::Color(_r, _g, _b, _a));
140  }
141 
143  template <class T>
144  void BaseLight<T>::SetSpecularColor(double _r, double _g, double _b,
145  double _a)
146  {
147  this->SetSpecularColor(math::Color(_r, _g, _b, _a));
148  }
149 
151  template <class T>
153  {
154  this->SetDiffuseColor(math::Color::White);
155  this->SetSpecularColor(math::Color::White);
156  this->SetAttenuationConstant(1);
157  this->SetAttenuationLinear(0);
158  this->SetAttenuationQuadratic(0);
159  this->SetAttenuationRange(100);
160  this->SetCastShadows(true);
161  this->SetIntensity(1.0);
162  }
163 
165  template <class T>
167  {
168  }
169 
171  template <class T>
173  {
174  }
175 
177  template <class T>
178  void BaseDirectionalLight<T>::SetDirection(double _x, double _y, double _z)
179  {
180  this->SetDirection(math::Vector3d(_x, _y, _z));
181  }
182 
184  template <class T>
186  {
187  T::Reset();
188  this->SetDirection(0, 0, -1);
189  }
190 
192  template <class T>
194  {
195  }
196 
198  template <class T>
200  {
201  }
202 
204  template <class T>
206  {
207  }
208 
210  template <class T>
212  {
213  }
214 
216  template <class T>
217  void BaseSpotLight<T>::SetDirection(double _x, double _y, double _z)
218  {
219  this->SetDirection(math::Vector3d(_x, _y, _z));
220  }
221 
223  template <class T>
224  void BaseSpotLight<T>::SetInnerAngle(double _radians)
225  {
226  this->SetInnerAngle(math::Angle(_radians));
227  }
228 
230  template <class T>
231  void BaseSpotLight<T>::SetOuterAngle(double _radians)
232  {
233  this->SetOuterAngle(math::Angle(_radians));
234  }
235 
237  template <class T>
239  {
240  T::Reset();
241  this->SetDirection(0, 0, -1);
242  this->SetInnerAngle(IGN_PI / 4.5);
243  this->SetOuterAngle(IGN_PI / 4.0);
244  this->SetFalloff(1.0);
245  }
246  }
247  }
248 }
249 #endif
virtual void Reset()
Definition: gz/rendering/base/BaseLight.hh:185
Definition: gz/rendering/base/BaseLight.hh:97
BaseDirectionalLight()
Definition: gz/rendering/base/BaseLight.hh:166
#define IGN_PI
virtual void SetDiffuseColor(double _r, double _g, double _b, double _a=1.0)
Set the diffuse color.
Definition: gz/rendering/base/BaseLight.hh:136
virtual void Reset()
Definition: gz/rendering/base/BaseLight.hh:152
Definition: gz/rendering/base/BaseLight.hh:71
virtual void SetFalloff(double _falloff)=0
Set the falloff of the spotlight.
Represents a spotlight.
Definition: gz/rendering/Light.hh:153
Definition: gz/rendering/base/BaseLight.hh:87
virtual ~BaseSpotLight()
Definition: gz/rendering/base/BaseLight.hh:211
BaseLight()
Definition: gz/rendering/base/BaseLight.hh:124
virtual void SetAttenuationRange(double _range)=0
Set the attenuation range.
BaseSpotLight()
Definition: gz/rendering/base/BaseLight.hh:205
virtual void SetDirection(double _x, double _y, double _z)
Set the direction of the light.
Definition: gz/rendering/base/BaseLight.hh:217
Definition: gz/rendering/base/BaseLight.hh:29
BasePointLight()
Definition: gz/rendering/base/BaseLight.hh:193
virtual void SetAttenuationQuadratic(double _value)=0
Set the attenuation quadratic value.
virtual ~BaseLight()
Definition: gz/rendering/base/BaseLight.hh:130
virtual ~BaseDirectionalLight()
Definition: gz/rendering/base/BaseLight.hh:172
virtual void Reset()
Definition: gz/rendering/base/BaseLight.hh:238
virtual ~BasePointLight()
Definition: gz/rendering/base/BaseLight.hh:199
Represents a infinite directional light.
Definition: gz/rendering/Light.hh:121
virtual void SetSpecularColor(double _r, double _g, double _b, double _a=1.0)
Set the specular color.
Definition: gz/rendering/base/BaseLight.hh:144
virtual void SetAttenuationLinear(double _value)=0
Set the attenuation linear value.
virtual void SetCastShadows(bool _castShadows)=0
Specify if this light should cast shadows.
Represents a point light.
Definition: gz/rendering/Light.hh:144
virtual void SetOuterAngle(double _radians)
Set the outer angle of the spotlight.
Definition: gz/rendering/base/BaseLight.hh:231
Represents a light source in the scene graph.
Definition: gz/rendering/Light.hh:32
virtual void SetInnerAngle(double _radians)
Set the inner angle of the spotlight.
Definition: gz/rendering/base/BaseLight.hh:224
virtual void SetAttenuationConstant(double _value)=0
Set the attenuation constant value.
static const Color White
virtual void SetDirection(double _x, double _y, double _z)
Set the direction of the light.
Definition: gz/rendering/base/BaseLight.hh:178