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 
53  public boost::enable_shared_from_this<Light>
54  {
57  public: Light(ScenePtr _scene);
58 
60  public: virtual ~Light();
61 
65  public: void Load(sdf::ElementPtr _sdf);
66 
68  public: void Load();
69 
72  public: void LoadFromMsg(ConstLightPtr &_msg);
73 
76  public: void LoadFromMsg(const msgs::Light &_msg);
77 
80  public: void SetName(const std::string &_name);
81 
84  public: std::string GetName() const;
85 
88  public: std::string GetType() const;
89 
92  public: void SetPosition(const math::Vector3 &_p);
93 
96  public: math::Vector3 GetPosition() const;
97 
100  public: void SetRotation(const math::Quaternion &_q);
101 
104  public: math::Quaternion GetRotation() const;
105 
109  public: virtual bool SetSelected(bool _s);
110 
111  // \brief Toggle light visual visibility
112  public: void ToggleShowVisual();
113 
116  public: void ShowVisual(bool _s);
117 
120  public: bool GetVisible() const;
121 
124  public: void SetLightType(const std::string &_type);
125 
128  public: void SetDiffuseColor(const common::Color &_color);
129 
132  public: common::Color GetDiffuseColor() const;
133 
136  public: void SetSpecularColor(const common::Color &_color);
137 
140  public: common::Color GetSpecularColor() const;
141 
145  public: void SetDirection(const math::Vector3 &_dir);
146 
149  public: math::Vector3 GetDirection() const;
150 
155  public: void SetAttenuation(double _constant, double _linear,
156  double _quadratic);
157 
160  public: void SetSpotInnerAngle(const double &_angle);
161 
164  public: void SetSpotOuterAngle(const double &_angle);
165 
168  public: void SetSpotFalloff(const double &_value);
169 
172  public: void SetRange(const double &_range);
173 
176  public: void SetCastShadows(const bool &_cast);
177 
180  public: void FillMsg(msgs::Light &_msg) const;
181 
184  public: void UpdateFromMsg(ConstLightPtr &_msg);
185 
190  public: LightPtr Clone(const std::string &_name, ScenePtr _scene);
191 
193  protected: virtual void OnPoseChange() {}
194 
196  private: void CreateVisual();
197 
199  private: void Update();
200 
203  private: void UpdateSDFFromMsg(const msgs::Light &_msg);
204 
206  private: Ogre::Light *light;
207 
209  private: VisualPtr visual;
210 
212  private: DynamicLines *line;
213 
215  private: sdf::ElementPtr sdf;
216 
218  private: event::ConnectionPtr showLightsConnection;
219 
221  private: static unsigned int lightCounter;
222 
224  private: ScenePtr scene;
225  };
227  }
228 }
229 #endif
Class for drawing lines that can change.
Definition: DynamicLines.hh:43
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:147
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
boost::shared_ptr< Light > LightPtr
Definition: RenderTypes.hh:83
#define GZ_RENDERING_VISIBLE
Definition: system.hh:241
A quaternion class.
Definition: Quaternion.hh:42
Defines a color.
Definition: Color.hh:36
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:79
A light source.
Definition: Light.hh:52
boost::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:107
virtual void OnPoseChange()
On pose change callback.
Definition: Light.hh:193