Ignition Rendering

API Reference

0.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  template <class T>
27  class IGNITION_RENDERING_VISIBLE BaseLight :
28  public virtual Light,
29  public virtual T
30  {
31  protected: BaseLight();
32 
33  public: virtual ~BaseLight();
34 
35  public: virtual void SetDiffuseColor(double _r, double _g, double _b,
36  double _a = 1.0);
37 
38  public: virtual void SetDiffuseColor(const math::Color &_color) = 0;
39 
40  public: virtual void SetSpecularColor(double _r, double _g, double _b,
41  double _a = 1.0);
42 
43  public: virtual void SetSpecularColor(const math::Color &_color) = 0;
44 
45  public: virtual void SetAttenuationConstant(double _value) = 0;
46 
47  public: virtual void SetAttenuationLinear(double _value) = 0;
48 
49  public: virtual void SetAttenuationQuadratic(double _value) = 0;
50 
51  public: virtual void SetAttenuationRange(double _range) = 0;
52 
53  public: virtual void SetCastShadows(bool _castShadows) = 0;
54 
55  protected: virtual void Reset();
56  };
57 
58  template <class T>
59  class IGNITION_RENDERING_VISIBLE BaseDirectionalLight :
60  public virtual DirectionalLight,
61  public virtual T
62  {
63  protected: BaseDirectionalLight();
64 
65  public: virtual ~BaseDirectionalLight();
66 
67  public: virtual void SetDirection(double _x, double _y, double _z);
68 
69  public: virtual void SetDirection(const math::Vector3d &_dir) = 0;
70 
71  protected: virtual void Reset();
72  };
73 
74  template <class T>
75  class IGNITION_RENDERING_VISIBLE BasePointLight :
76  public virtual PointLight,
77  public virtual T
78  {
79  protected: BasePointLight();
80 
81  public: virtual ~BasePointLight();
82  };
83 
84  template <class T>
85  class IGNITION_RENDERING_VISIBLE BaseSpotLight :
86  public virtual SpotLight,
87  public virtual T
88  {
89  protected: BaseSpotLight();
90 
91  public: virtual ~BaseSpotLight();
92 
93  public: virtual void SetDirection(double _x, double _y, double _z);
94 
95  public: virtual void SetDirection(const math::Vector3d &_dir) = 0;
96 
97  public: virtual void SetInnerAngle(double _radians);
98 
99  public: virtual void SetInnerAngle(const math::Angle &_angle) = 0;
100 
101  public: virtual void SetOuterAngle(double _radians);
102 
103  public: virtual void SetOuterAngle(const math::Angle &_angle) = 0;
104 
105  public: virtual void SetFalloff(double _falloff) = 0;
106 
107  protected: virtual void Reset();
108  };
109 
111  template <class T>
113  {
114  }
115 
117  template <class T>
119  {
120  }
121 
123  template <class T>
124  void BaseLight<T>::SetDiffuseColor(double _r, double _g, double _b,
125  double _a)
126  {
127  this->SetDiffuseColor(math::Color(_r, _g, _b, _a));
128  }
129 
131  template <class T>
132  void BaseLight<T>::SetSpecularColor(double _r, double _g, double _b,
133  double _a)
134  {
135  this->SetSpecularColor(math::Color(_r, _g, _b, _a));
136  }
137 
139  template <class T>
141  {
142  this->SetDiffuseColor(math::Color::White);
143  this->SetSpecularColor(math::Color::White);
144  this->SetAttenuationConstant(1);
145  this->SetAttenuationLinear(0);
146  this->SetAttenuationQuadratic(0);
147  this->SetAttenuationRange(100);
148  this->SetCastShadows(true);
149  }
150 
152  template <class T>
154  {
155  }
156 
158  template <class T>
160  {
161  }
162 
164  template <class T>
165  void BaseDirectionalLight<T>::SetDirection(double _x, double _y, double _z)
166  {
167  this->SetDirection(math::Vector3d(_x, _y, _z));
168  }
169 
171  template <class T>
173  {
174  T::Reset();
175  this->SetDirection(0, 0, -1);
176  }
177 
179  template <class T>
181  {
182  }
183 
185  template <class T>
187  {
188  }
189 
191  template <class T>
193  {
194  }
195 
197  template <class T>
199  {
200  }
201 
203  template <class T>
204  void BaseSpotLight<T>::SetDirection(double _x, double _y, double _z)
205  {
206  this->SetDirection(math::Vector3d(_x, _y, _z));
207  }
208 
210  template <class T>
211  void BaseSpotLight<T>::SetInnerAngle(double _radians)
212  {
213  this->SetInnerAngle(math::Angle(_radians));
214  }
215 
217  template <class T>
218  void BaseSpotLight<T>::SetOuterAngle(double _radians)
219  {
220  this->SetOuterAngle(math::Angle(_radians));
221  }
222 
224  template <class T>
226  {
227  T::Reset();
228  this->SetDirection(0, 0, -1);
229  this->SetInnerAngle(M_PI / 4.5);
230  this->SetOuterAngle(M_PI / 4.0);
231  this->SetFalloff(1.0);
232  }
233 
234  }
235 }
236 #endif
Definition: BaseLight.hh:27
virtual ~BasePointLight()
Definition: BaseLight.hh:186
virtual void Reset()
Definition: BaseLight.hh:225
virtual void SetOuterAngle(double _radians)
Set the outer angle of the spotlight.
Definition: BaseLight.hh:218
Definition: BaseLight.hh:75
BaseSpotLight()
Definition: BaseLight.hh:192
virtual ~BaseLight()
Definition: BaseLight.hh:118
Represents a point light.
Definition: Light.hh:133
virtual void SetDirection(double _x, double _y, double _z)
Set the direction of the light.
Definition: BaseLight.hh:165
BaseLight()
Definition: BaseLight.hh:112
virtual ~BaseDirectionalLight()
Definition: BaseLight.hh:159
Definition: BaseLight.hh:85
virtual void SetDirection(double _x, double _y, double _z)
Set the direction of the light.
Definition: BaseLight.hh:204
virtual ~BaseSpotLight()
Definition: BaseLight.hh:198
Represents a light source in the scene graph.
Definition: Light.hh:29
Represents a spotlight.
Definition: Light.hh:142
Represents a infinite directional light.
Definition: Light.hh:110
BasePointLight()
Definition: BaseLight.hh:180
virtual void SetSpecularColor(double _r, double _g, double _b, double _a=1.0)
Set the specular color.
Definition: BaseLight.hh:132
virtual void SetInnerAngle(double _radians)
Set the inner angle of the spotlight.
Definition: BaseLight.hh:211
BaseDirectionalLight()
Definition: BaseLight.hh:153
virtual void Reset()
Definition: BaseLight.hh:172
Definition: ArrowVisual.hh:22
virtual void SetDiffuseColor(double _r, double _g, double _b, double _a=1.0)
Set the diffuse color.
Definition: BaseLight.hh:124
virtual void Reset()
Definition: BaseLight.hh:140