All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Light.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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 
18 /* Desc: A Light
19  * Author: Nate Koenig
20  * Date: 15 July 2003
21  */
22 
23 #ifndef _LIGHT_HH_
24 #define _LIGHT_HH_
25 
26 #include <string>
27 #include <iostream>
28 #include <sdf/sdf.hh>
29 
30 #include "gazebo/msgs/msgs.hh"
32 #include "gazebo/common/Event.hh"
33 #include "gazebo/common/Color.hh"
34 
35 namespace Ogre
36 {
37  class Light;
38 }
39 
40 namespace gazebo
41 {
42  namespace rendering
43  {
44  class Scene;
45  class DynamicLines;
46 
49 
57  class Light
58  {
61  public: Light(ScenePtr _scene);
62 
64  public: virtual ~Light();
65 
69  public: void Load(sdf::ElementPtr _sdf);
70 
72  public: void Load();
73 
76  public: void LoadFromMsg(ConstLightPtr &_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 
101  public: virtual bool SetSelected(bool _s);
102 
103  // \brief Toggle light visual visibility
104  public: void ToggleShowVisual();
105 
108  public: void ShowVisual(bool _s);
109 
112  public: void SetLightType(const std::string &_type);
113 
116  public: void SetDiffuseColor(const common::Color &_color);
117 
120  public: common::Color GetDiffuseColor() const;
121 
124  public: void SetSpecularColor(const common::Color &_color);
125 
128  public: common::Color GetSpecularColor() const;
129 
133  public: void SetDirection(const math::Vector3 &_dir);
134 
137  public: math::Vector3 GetDirection() const;
138 
143  public: void SetAttenuation(double _constant, double _linear,
144  double _quadratic);
145 
148  public: void SetSpotInnerAngle(const double &_angle);
149 
152  public: void SetSpotOuterAngle(const double &_angle);
153 
156  public: void SetSpotFalloff(const double &_value);
157 
160  public: void SetRange(const double &_range);
161 
164  public: void SetCastShadows(const bool &_cast);
165 
168  public: void FillMsg(msgs::Light &_msg) const;
169 
172  public: void UpdateFromMsg(ConstLightPtr &_msg);
173 
175  protected: virtual void OnPoseChange() {}
176 
178  private: void CreateVisual();
179 
181  private: void Update();
182 
185  private: void UpdateSDFFromMsg(ConstLightPtr &_msg);
186 
188  private: Ogre::Light *light;
189 
191  private: VisualPtr visual;
192 
194  private: DynamicLines *line;
195 
197  private: sdf::ElementPtr sdf;
198 
200  private: event::ConnectionPtr showLightsConnection;
201 
203  private: static unsigned int lightCounter;
204 
206  private: ScenePtr scene;
207 
210  public: bool GetVisible() const;
211  };
213  }
214 }
215 #endif