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/Color.hh>
24 #include <ignition/math/Quaternion.hh>
25 #include <ignition/math/Vector3.hh>
26 
27 #include "gazebo/msgs/msgs.hh"
29 #include "gazebo/common/Color.hh"
30 #include "gazebo/util/system.hh"
31 
32 namespace Ogre
33 {
34  class Light;
35 }
36 
37 namespace gazebo
38 {
39  namespace rendering
40  {
41  // Forward declare private data.
42  class LightPrivate;
43 
46 
54  class GZ_RENDERING_VISIBLE Light :
55  public boost::enable_shared_from_this<Light>
56  {
59  public: explicit Light(ScenePtr _scene);
60 
62  public: virtual ~Light();
63 
67  public: void Load(sdf::ElementPtr _sdf);
68 
70  public: void Load();
71 
74  public: void LoadFromMsg(ConstLightPtr &_msg);
75 
78  public: void LoadFromMsg(const msgs::Light &_msg);
79 
82  public: void SetName(const std::string &_name);
83 
86  public: std::string Name() const;
87 
90  public: std::string Type() const;
91 
94  public: void SetPosition(const ignition::math::Vector3d &_p);
95 
98  public: ignition::math::Vector3d Position() const;
99 
102  public: void SetRotation(const ignition::math::Quaterniond &_q);
103 
106  public: ignition::math::Quaterniond Rotation() const;
107 
111  public: virtual bool SetSelected(const bool _s);
112 
113  // \brief Toggle light visual visibility
114  public: void ToggleShowVisual();
115 
118  public: void ShowVisual(const bool _s);
119 
123  public: void SetVisible(const bool _s);
124 
127  public: bool Visible() const;
128 
131  public: void SetLightType(const std::string &_type);
132 
135  public: std::string LightType() const;
136 
140  public: void SetDiffuseColor(const common::Color &_color)
141  GAZEBO_DEPRECATED(9.0);
142 
145  public: void SetDiffuseColor(const ignition::math::Color &_color);
146 
149  public: ignition::math::Color DiffuseColor() const;
150 
154  public: void SetSpecularColor(const common::Color &_color)
155  GAZEBO_DEPRECATED(9.0);
156 
159  public: void SetSpecularColor(const ignition::math::Color &_color);
160 
163  public: ignition::math::Color SpecularColor() const;
164 
168  public: void SetDirection(const ignition::math::Vector3d &_dir);
169 
172  public: ignition::math::Vector3d Direction() const;
173 
178  public: void SetAttenuation(double _constant, double _linear,
179  double _quadratic);
180 
183  public: void SetSpotInnerAngle(const double _angle);
184 
187  public: void SetSpotOuterAngle(const double _angle);
188 
191  public: void SetSpotFalloff(const double _value);
192 
195  public: void SetRange(const double _range);
196 
199  public: void SetCastShadows(const bool _cast);
200 
203  public: bool CastShadows() const;
204 
207  public: void FillMsg(msgs::Light &_msg) const;
208 
211  public: void UpdateFromMsg(ConstLightPtr &_msg);
212 
217  public: LightPtr Clone(const std::string &_name, ScenePtr _scene);
218 
221  public: uint32_t Id() const;
222 
224  protected: virtual void OnPoseChange() {}
225 
227  private: void CreateVisual();
228 
230  private: void Update();
231 
234  private: void UpdateSDFFromMsg(const msgs::Light &_msg);
235 
238  private: std::unique_ptr<LightPrivate> dataPtr;
239  };
241  }
242 }
243 #endif
void FillMsg(msgs::Light &_msg) const
Fill the contents of a light message.
std::string Name() const
Get the name of the visual.
void LoadFromMsg(ConstLightPtr &_msg)
Load from a light message.
void SetDirection(const ignition::math::Vector3d &_dir)
Set the direction.
void SetCastShadows(const bool _cast)
Set cast shadows.
virtual ~Light()
Destructor.
Definition: JointMaker.hh:39
uint32_t Id() const
Get the id associated with this light.
bool CastShadows() const
Get cast shadows.
Forward declarations for the common classes.
Definition: Animation.hh:26
bool Visible() const
Get whether the light is visible.
std::string Type() const
Get the type of the light.
ignition::math::Vector3d Position() const
Get the position of the light.
std::string LightType() const
Get the light type.
virtual void OnPoseChange()
On pose change callback.
Definition: rendering/Light.hh:224
void SetPosition(const ignition::math::Vector3d &_p)
Set the position of the light.
void SetRange(const double _range)
Set the range.
void SetVisible(const bool _s)
Set whether the light will be visible.
void SetSpotInnerAngle(const double _angle)
Set the spot light inner angle.
void SetRotation(const ignition::math::Quaterniond &_q)
Set the rotation of the light.
void SetName(const std::string &_name)
Set the name of the visual.
ignition::math::Quaterniond Rotation() const
Get the rotation of the light.
void SetAttenuation(double _constant, double _linear, double _quadratic)
Set the attenuation.
virtual bool SetSelected(const bool _s)
Set whether this entity has been selected by the user through the gui.
LightPtr Clone(const std::string &_name, ScenePtr _scene)
Clone the light with a new name.
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:82
void UpdateFromMsg(ConstLightPtr &_msg)
Update a light source from a message.
void SetLightType(const std::string &_type)
Set the light type.
void SetSpecularColor(const common::Color &_color) GAZEBO_DEPRECATED(9.0)
Set the specular color.
void SetSpotFalloff(const double _value)
Set the spot light falloff.
void ShowVisual(const bool _s)
Set whether to show the visual.
Defines a color.
Definition: Color.hh:36
Light(ScenePtr _scene)
Constructor.
void Load()
Load the light using default parameters.
ignition::math::Color SpecularColor() const
Get the specular color.
ignition::math::Vector3d Direction() const
Get the direction.
void ToggleShowVisual()
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:328
boost::shared_ptr< Light > LightPtr
Definition: RenderTypes.hh:86
void SetDiffuseColor(const common::Color &_color) GAZEBO_DEPRECATED(9.0)
Set the diffuse color.
ignition::math::Color DiffuseColor() const
Get the diffuse color.
A light source.
Definition: rendering/Light.hh:54
void SetSpotOuterAngle(const double _angle)
Set the spot light outer angle.