Gazebo Rendering

API Reference

3.7.2
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  }
162 
164  template <class T>
166  {
167  }
168 
170  template <class T>
172  {
173  }
174 
176  template <class T>
177  void BaseDirectionalLight<T>::SetDirection(double _x, double _y, double _z)
178  {
179  this->SetDirection(math::Vector3d(_x, _y, _z));
180  }
181 
183  template <class T>
185  {
186  T::Reset();
187  this->SetDirection(0, 0, -1);
188  }
189 
191  template <class T>
193  {
194  }
195 
197  template <class T>
199  {
200  }
201 
203  template <class T>
205  {
206  }
207 
209  template <class T>
211  {
212  }
213 
215  template <class T>
216  void BaseSpotLight<T>::SetDirection(double _x, double _y, double _z)
217  {
218  this->SetDirection(math::Vector3d(_x, _y, _z));
219  }
220 
222  template <class T>
223  void BaseSpotLight<T>::SetInnerAngle(double _radians)
224  {
225  this->SetInnerAngle(math::Angle(_radians));
226  }
227 
229  template <class T>
230  void BaseSpotLight<T>::SetOuterAngle(double _radians)
231  {
232  this->SetOuterAngle(math::Angle(_radians));
233  }
234 
236  template <class T>
238  {
239  T::Reset();
240  this->SetDirection(0, 0, -1);
241  this->SetInnerAngle(IGN_PI / 4.5);
242  this->SetOuterAngle(IGN_PI / 4.0);
243  this->SetFalloff(1.0);
244  }
245  }
246  }
247 }
248 #endif
virtual void Reset()
Definition: gz/rendering/base/BaseLight.hh:184
Definition: gz/rendering/base/BaseLight.hh:97
BaseDirectionalLight()
Definition: gz/rendering/base/BaseLight.hh:165
#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:145
Definition: gz/rendering/base/BaseLight.hh:87
virtual ~BaseSpotLight()
Definition: gz/rendering/base/BaseLight.hh:210
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:204
virtual void SetDirection(double _x, double _y, double _z)
Set the direction of the light.
Definition: gz/rendering/base/BaseLight.hh:216
Definition: gz/rendering/base/BaseLight.hh:29
BasePointLight()
Definition: gz/rendering/base/BaseLight.hh:192
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:171
virtual void Reset()
Definition: gz/rendering/base/BaseLight.hh:237
virtual ~BasePointLight()
Definition: gz/rendering/base/BaseLight.hh:198
Represents a infinite directional light.
Definition: gz/rendering/Light.hh:113
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:136
virtual void SetOuterAngle(double _radians)
Set the outer angle of the spotlight.
Definition: gz/rendering/base/BaseLight.hh:230
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:223
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:177