Gazebo Rendering

API Reference

9.0.0~pre2
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
22namespace gz
23{
24 namespace rendering
25 {
26 inline namespace GZ_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 {
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>
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>
127
129 template <class T>
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>
169
171 template <class T>
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>
196
198 template <class T>
202
204 template <class T>
208
210 template <class T>
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>
225 {
226 this->SetInnerAngle(math::Angle(_radians));
227 }
228
230 template <class T>
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(GZ_PI / 4.5);
243 this->SetOuterAngle(GZ_PI / 4.0);
244 this->SetFalloff(1.0);
245 }
246 }
247 }
248}
249#endif