rendering/Light.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 GAZEBO_RENDERING_LIGHT_HH_
18 #define GAZEBO_RENDERING_LIGHT_HH_
19 
20 #include <string>
21 #include <iostream>
22 #include <sdf/sdf.hh>
23 #include <ignition/math/Quaternion.hh>
24 #include <ignition/math/Vector3.hh>
25 
26 #include "gazebo/msgs/msgs.hh"
28 #include "gazebo/common/Color.hh"
29 #include "gazebo/util/system.hh"
30 
31 namespace Ogre
32 {
33  class Light;
34 }
35 
36 namespace gazebo
37 {
38  namespace rendering
39  {
40  // Forward declare private data.
41  class LightPrivate;
42 
45 
53  class GZ_RENDERING_VISIBLE Light :
54  public boost::enable_shared_from_this<Light>
55  {
58  public: explicit Light(ScenePtr _scene);
59 
61  public: virtual ~Light();
62 
66  public: void Load(sdf::ElementPtr _sdf);
67 
69  public: void Load();
70 
73  public: void LoadFromMsg(ConstLightPtr &_msg);
74 
77  public: void LoadFromMsg(const msgs::Light &_msg);
78 
81  public: void SetName(const std::string &_name);
82 
85  public: std::string Name() const;
86 
89  public: std::string Type() const;
90 
93  public: void SetPosition(const ignition::math::Vector3d &_p);
94 
97  public: ignition::math::Vector3d Position() const;
98 
101  public: void SetRotation(const ignition::math::Quaterniond &_q);
102 
105  public: ignition::math::Quaterniond Rotation() const;
106 
110  public: virtual bool SetSelected(const bool _s);
111 
112  // \brief Toggle light visual visibility
113  public: void ToggleShowVisual();
114 
117  public: void ShowVisual(const bool _s);
118 
121  public: bool Visible() const;
122 
125  public: void SetLightType(const std::string &_type);
126 
129  public: std::string LightType() const;
130 
133  public: void SetDiffuseColor(const common::Color &_color);
134 
137  public: common::Color DiffuseColor() const;
138 
141  public: void SetSpecularColor(const common::Color &_color);
142 
145  public: common::Color SpecularColor() const;
146 
150  public: void SetDirection(const ignition::math::Vector3d &_dir);
151 
154  public: ignition::math::Vector3d Direction() const;
155 
160  public: void SetAttenuation(double _constant, double _linear,
161  double _quadratic);
162 
165  public: void SetSpotInnerAngle(const double _angle);
166 
169  public: void SetSpotOuterAngle(const double _angle);
170 
173  public: void SetSpotFalloff(const double _value);
174 
177  public: void SetRange(const double _range);
178 
181  public: void SetCastShadows(const bool _cast);
182 
185  public: bool CastShadows() const;
186 
189  public: void FillMsg(msgs::Light &_msg) const;
190 
193  public: void UpdateFromMsg(ConstLightPtr &_msg);
194 
199  public: LightPtr Clone(const std::string &_name, ScenePtr _scene);
200 
202  protected: virtual void OnPoseChange() {}
203 
205  private: void CreateVisual();
206 
208  private: void Update();
209 
212  private: void UpdateSDFFromMsg(const msgs::Light &_msg);
213 
216  private: std::unique_ptr<LightPrivate> dataPtr;
217  };
219  }
220 }
221 #endif
virtual void OnPoseChange()
On pose change callback.
Definition: rendering/Light.hh:202
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:81
Defines a color.
Definition: Color.hh:36
A light source.
Definition: rendering/Light.hh:53
boost::shared_ptr< Light > LightPtr
Definition: RenderTypes.hh:85