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 #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  {
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 
100  public: virtual bool SetSelected(bool _s);
101 
102  // \brief Toggle light visual visibility
103  public: void ToggleShowVisual();
104 
107  public: void ShowVisual(bool _s);
108 
111  public: bool GetVisible() const;
112 
115  public: void SetLightType(const std::string &_type);
116 
119  public: void SetDiffuseColor(const common::Color &_color);
120 
123  public: common::Color GetDiffuseColor() const;
124 
127  public: void SetSpecularColor(const common::Color &_color);
128 
131  public: common::Color GetSpecularColor() const;
132 
136  public: void SetDirection(const math::Vector3 &_dir);
137 
140  public: math::Vector3 GetDirection() const;
141 
146  public: void SetAttenuation(double _constant, double _linear,
147  double _quadratic);
148 
151  public: void SetSpotInnerAngle(const double &_angle);
152 
155  public: void SetSpotOuterAngle(const double &_angle);
156 
159  public: void SetSpotFalloff(const double &_value);
160 
163  public: void SetRange(const double &_range);
164 
167  public: void SetCastShadows(const bool &_cast);
168 
171  public: void FillMsg(msgs::Light &_msg) const;
172 
175  public: void UpdateFromMsg(ConstLightPtr &_msg);
176 
178  protected: virtual void OnPoseChange() {}
179 
181  private: void CreateVisual();
182 
184  private: void Update();
185 
188  private: void UpdateSDFFromMsg(const msgs::Light &_msg);
189 
191  private: Ogre::Light *light;
192 
194  private: VisualPtr visual;
195 
197  private: DynamicLines *line;
198 
200  private: sdf::ElementPtr sdf;
201 
203  private: event::ConnectionPtr showLightsConnection;
204 
206  private: static unsigned int lightCounter;
207 
209  private: ScenePtr scene;
210  };
212  }
213 }
214 #endif