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/util/system.hh"
30
31namespace Ogre
32{
33 class Light;
34}
35
36namespace 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
109 public: ignition::math::Pose3d WorldPose() const;
110
114 public: virtual bool SetSelected(const bool _s);
115
116 // \brief Toggle light visual visibility
117 public: void ToggleShowVisual();
118
121 public: void ShowVisual(const bool _s);
122
126 public: void SetVisible(const bool _s);
127
130 public: bool Visible() const;
131
134 public: void SetLightType(const std::string &_type);
135
138 public: std::string LightType() const;
139
142 public: void SetDiffuseColor(const ignition::math::Color &_color);
143
146 public: ignition::math::Color DiffuseColor() const;
147
150 public: void SetSpecularColor(const ignition::math::Color &_color);
151
154 public: ignition::math::Color SpecularColor() const;
155
159 public: void SetDirection(const ignition::math::Vector3d &_dir);
160
163 public: ignition::math::Vector3d Direction() const;
164
169 public: void SetAttenuation(double _constant, double _linear,
170 double _quadratic);
171
174 public: void SetSpotInnerAngle(const double _angle);
175
178 public: void SetSpotOuterAngle(const double _angle);
179
182 public: void SetSpotFalloff(const double _value);
183
186 public: void SetRange(const double _range);
187
190 public: void SetCastShadows(const bool _cast);
191
194 public: bool CastShadows() const;
195
198 public: void FillMsg(msgs::Light &_msg) const;
199
202 public: void UpdateFromMsg(ConstLightPtr &_msg);
203
208 public: LightPtr Clone(const std::string &_name, ScenePtr _scene);
209
212 public: uint32_t Id() const;
213
215 protected: virtual void OnPoseChange() {}
216
218 private: void CreateVisual();
219
221 private: void Update();
222
225 private: void UpdateSDFFromMsg(const msgs::Light &_msg);
226
229 private: std::unique_ptr<LightPrivate> dataPtr;
230 };
232 }
233}
234#endif
rendering
Definition RenderEngine.hh:31
A light source.
Definition rendering/Light.hh:55
void SetDirection(const ignition::math::Vector3d &_dir)
Set the direction.
void SetSpecularColor(const ignition::math::Color &_color)
Set the specular color.
ignition::math::Color DiffuseColor() const
Get the diffuse color.
void UpdateFromMsg(ConstLightPtr &_msg)
Update a light source from a message.
void SetName(const std::string &_name)
Set the name of the visual.
void SetSpotOuterAngle(const double _angle)
Set the spot light outer angle.
void ShowVisual(const bool _s)
Set whether to show the visual.
Light(ScenePtr _scene)
Constructor.
std::string Name() const
Get the name of the visual.
std::string LightType() const
Get the light type.
virtual ~Light()
Destructor.
ignition::math::Vector3d Position() const
Get the position of the light.
void SetRotation(const ignition::math::Quaterniond &_q)
Set the rotation of the light.
LightPtr Clone(const std::string &_name, ScenePtr _scene)
Clone the light with a new name.
virtual bool SetSelected(const bool _s)
Set whether this entity has been selected by the user through the gui.
void SetRange(const double _range)
Set the range.
void SetPosition(const ignition::math::Vector3d &_p)
Set the position of the light.
void SetLightType(const std::string &_type)
Set the light type.
void SetCastShadows(const bool _cast)
Set cast shadows.
void SetDiffuseColor(const ignition::math::Color &_color)
Set the diffuse color.
std::string Type() const
Get the type of the light.
bool CastShadows() const
Get cast shadows.
void LoadFromMsg(const msgs::Light &_msg)
Load from a light message.
void LoadFromMsg(ConstLightPtr &_msg)
Load from a light message.
void SetAttenuation(double _constant, double _linear, double _quadratic)
Set the attenuation.
void SetSpotInnerAngle(const double _angle)
Set the spot light inner angle.
ignition::math::Quaterniond Rotation() const
Get the rotation of the light.
ignition::math::Pose3d WorldPose() const
Get the world pose of the light.
ignition::math::Color SpecularColor() const
Get the specular color.
void SetVisible(const bool _s)
Set whether the light will be visible.
bool Visible() const
Get whether the light is visible.
void FillMsg(msgs::Light &_msg) const
Fill the contents of a light message.
void Load(sdf::ElementPtr _sdf)
Load the light using a set of SDF parameters.
uint32_t Id() const
Get the id associated with this light.
ignition::math::Vector3d Direction() const
Get the direction.
virtual void OnPoseChange()
On pose change callback.
Definition rendering/Light.hh:215
void Load()
Load the light using default parameters.
void SetSpotFalloff(const double _value)
Set the spot light falloff.
Definition JointMaker.hh:40
boost::shared_ptr< Light > LightPtr
Definition RenderTypes.hh:86
boost::shared_ptr< Scene > ScenePtr
Definition RenderTypes.hh:82
Forward declarations for the common classes.
Definition Animation.hh:27