Light.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-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 _LIGHT_HH_
18 #define _LIGHT_HH_
19 
20 #include <string>
21 #include <iostream>
22 #include <sdf/sdf.hh>
23 
24 #include "gazebo/msgs/msgs.hh"
26 #include "gazebo/common/Event.hh"
27 #include "gazebo/common/Color.hh"
28 #include "gazebo/util/system.hh"
29 
30 namespace Ogre
31 {
32  class Light;
33 }
34 
35 namespace gazebo
36 {
37  namespace rendering
38  {
39  class Scene;
40  class DynamicLines;
41 
44 
52  class GAZEBO_VISIBLE Light : public boost::enable_shared_from_this<Light>
53  {
56  public: Light(ScenePtr _scene);
57 
59  public: virtual ~Light();
60 
64  public: void Load(sdf::ElementPtr _sdf);
65 
67  public: void Load();
68 
71  public: void LoadFromMsg(ConstLightPtr &_msg);
72 
75  public: void LoadFromMsg(const msgs::Light &_msg);
76 
79  public: void SetName(const std::string &_name);
80 
83  public: std::string GetName() const;
84 
87  public: std::string GetType() const;
88 
91  public: void SetPosition(const math::Vector3 &_p);
92 
95  public: math::Vector3 GetPosition() const;
96 
99  public: void SetRotation(const math::Quaternion &_q);
100 
103  public: math::Quaternion GetRotation() const;
104 
108  public: virtual bool SetSelected(bool _s);
109 
110  // \brief Toggle light visual visibility
111  public: void ToggleShowVisual();
112 
115  public: void ShowVisual(bool _s);
116 
119  public: bool GetVisible() const;
120 
123  public: void SetLightType(const std::string &_type);
124 
127  public: void SetDiffuseColor(const common::Color &_color);
128 
131  public: common::Color GetDiffuseColor() const;
132 
135  public: void SetSpecularColor(const common::Color &_color);
136 
139  public: common::Color GetSpecularColor() const;
140 
144  public: void SetDirection(const math::Vector3 &_dir);
145 
148  public: math::Vector3 GetDirection() const;
149 
154  public: void SetAttenuation(double _constant, double _linear,
155  double _quadratic);
156 
159  public: void SetSpotInnerAngle(const double &_angle);
160 
163  public: void SetSpotOuterAngle(const double &_angle);
164 
167  public: void SetSpotFalloff(const double &_value);
168 
171  public: void SetRange(const double &_range);
172 
175  public: void SetCastShadows(const bool &_cast);
176 
179  public: void FillMsg(msgs::Light &_msg) const;
180 
183  public: void UpdateFromMsg(ConstLightPtr &_msg);
184 
189  public: LightPtr Clone(const std::string &_name, ScenePtr _scene);
190 
192  protected: virtual void OnPoseChange() {}
193 
195  private: void CreateVisual();
196 
198  private: void Update();
199 
202  private: void UpdateSDFFromMsg(const msgs::Light &_msg);
203 
205  private: Ogre::Light *light;
206 
208  private: VisualPtr visual;
209 
211  private: DynamicLines *line;
212 
214  private: sdf::ElementPtr sdf;
215 
217  private: event::ConnectionPtr showLightsConnection;
218 
220  private: static unsigned int lightCounter;
221 
223  private: ScenePtr scene;
224  };
226  }
227 }
228 #endif
Class for drawing lines that can change.
Definition: DynamicLines.hh:43
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:144
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
boost::shared_ptr< Light > LightPtr
Definition: RenderTypes.hh:78
A quaternion class.
Definition: Quaternion.hh:41
Defines a color.
Definition: Color.hh:39
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:74
A light source.
Definition: Light.hh:52
boost::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:102
virtual void OnPoseChange()
On pose change callback.
Definition: Light.hh:192
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48