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 2011 Nate Koenig
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 
29 #include "msgs/msgs.hh"
30 #include "rendering/RenderTypes.hh"
31 #include "common/Event.hh"
32 #include "common/Color.hh"
33 
34 #include "sdf/sdf.hh"
35 
36 namespace Ogre
37 {
38  class Light;
39 }
40 
41 namespace gazebo
42 {
43  namespace rendering
44  {
45  class Scene;
46  class DynamicLines;
47 
50 
58  class Light
59  {
62  public: Light(Scene *_scene);
63 
65  public: virtual ~Light();
66 
70  public: void Load(sdf::ElementPtr _sdf);
71 
73  public: void Load();
74 
77  public: void LoadFromMsg(ConstLightPtr &_msg);
78 
81  public: void SetName(const std::string &_name);
82 
85  public: std::string GetName() const;
86 
89  public: std::string GetType() const;
90 
93  public: void SetPosition(const math::Vector3 &_p);
94 
97  public: math::Vector3 GetPosition() const;
98 
102  public: virtual bool SetSelected(bool _s);
103 
104  // \brief Toggle light visual visibility
105  public: void ToggleShowVisual();
106 
109  public: void ShowVisual(bool _s);
110 
113  public: void SetLightType(const std::string &_type);
114 
117  public: void SetDiffuseColor(const common::Color &_color);
118 
121  public: common::Color GetDiffuseColor() const;
122 
125  public: void SetSpecularColor(const common::Color &_color);
126 
129  public: common::Color GetSpecularColor() const;
130 
134  public: void SetDirection(const math::Vector3 &_dir);
135 
138  public: math::Vector3 GetDirection() const;
139 
144  public: void SetAttenuation(double _constant, double _linear,
145  double _quadratic);
146 
149  public: void SetSpotInnerAngle(const double &_angle);
150 
153  public: void SetSpotOuterAngle(const double &_angle);
154 
157  public: void SetSpotFalloff(const double &_value);
158 
161  public: void SetRange(const double &_range);
162 
165  public: void SetCastShadows(const bool &_cast);
166 
169  public: void FillMsg(msgs::Light &_msg) const;
170 
173  public: void UpdateFromMsg(ConstLightPtr &_msg);
174 
176  protected: virtual void OnPoseChange() {}
177 
179  private: void CreateVisual();
180 
182  private: void Update();
183 
186  private: void UpdateSDFFromMsg(ConstLightPtr &_msg);
187 
189  private: Ogre::Light *light;
190 
192  private: VisualPtr visual;
193 
195  private: DynamicLines *line;
196 
198  private: sdf::ElementPtr sdf;
199 
201  private: event::ConnectionPtr showLightsConnection;
202 
204  private: static unsigned int lightCounter;
205 
207  private: Scene *scene;
208  };
210  }
211 }
212 #endif