Loading...
Searching...
No Matches
Light.hh
Go to the documentation of this file.
1/*
2 * Copyright 2018 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 SDF_LIGHT_HH_
18#define SDF_LIGHT_HH_
19
20#include <memory>
21#include <string>
22#include <gz/math/Pose3.hh>
23#include <gz/math/Angle.hh>
24#include <gz/utils/ImplPtr.hh>
25
26#include "sdf/Element.hh"
27#include "sdf/SemanticPose.hh"
28#include "sdf/Types.hh"
29#include "sdf/config.hh"
30#include "sdf/system_util.hh"
31
32namespace sdf
33{
34 // Inline bracket to help doxygen filtering.
35 inline namespace SDF_VERSION_NAMESPACE {
36 //
37
38 // Forward declare private data class.
39 struct PoseRelativeToGraph;
40 template <typename T> class ScopedGraph;
41
45 enum class LightType
46 {
49 INVALID = 0,
50
52 POINT = 1,
53
55 SPOT = 2,
56
58 DIRECTIONAL = 3,
59 };
60
64 {
66 public: Light();
67
74 public: Errors Load(ElementPtr _sdf);
75
78 public: LightType Type() const;
79
82 public: void SetType(const LightType _type);
83
86 public: std::string Name() const;
87
90 public: void SetName(const std::string &_name);
91
97 public: const gz::math::Pose3d &RawPose() const;
98
102 public: void SetRawPose(const gz::math::Pose3d &_pose);
103
108 public: const std::string &PoseRelativeTo() const;
109
114 public: void SetPoseRelativeTo(const std::string &_frame);
115
120
123 public: bool CastShadows() const;
124
127 public: void SetCastShadows(const bool _cast);
128
131 public: bool LightOn() const;
132
135 public: void SetLightOn(const bool _isLightOn);
136
139 public: bool Visualize() const;
140
143 public: void SetVisualize(const bool _visualize);
144
147 public: double Intensity() const;
148
151 public: void SetIntensity(const double _intensity);
152
157 public: gz::math::Color Diffuse() const;
158
163 public: void SetDiffuse(const gz::math::Color &_color);
164
169 public: gz::math::Color Specular() const;
170
175 public: void SetSpecular(const gz::math::Color &_color);
176
179 public: double AttenuationRange() const;
180
183 public: void SetAttenuationRange(const double _range);
184
189 public: double LinearAttenuationFactor() const;
190
195 public: void SetLinearAttenuationFactor(const double _factor);
196
201 public: double ConstantAttenuationFactor() const;
202
207 public: void SetConstantAttenuationFactor(const double _factor);
208
212 public: double QuadraticAttenuationFactor() const;
213
217 public: void SetQuadraticAttenuationFactor(const double _factor);
218
223 public: gz::math::Vector3d Direction() const;
224
228 public: void SetDirection(const gz::math::Vector3d &_dir);
229
233 public: gz::math::Angle SpotInnerAngle() const;
234
238 public: void SetSpotInnerAngle(const gz::math::Angle &_angle);
239
243 public: gz::math::Angle SpotOuterAngle() const;
244
248 public: void SetSpotOuterAngle(const gz::math::Angle &_angle);
249
255 public: double SpotFalloff() const;
256
262 public: void SetSpotFalloff(const double _falloff);
263
268 public: sdf::ElementPtr Element() const;
269
272 private: void CopyFrom(const Light &_light);
273
278 private: void SetXmlParentName(const std::string &_xmlParentName);
279
284 private: void SetPoseRelativeToGraph(
286
292 public: sdf::ElementPtr ToElement() const;
293
300 public: sdf::ElementPtr ToElement(sdf::Errors &_errors) const;
301
306 friend class Link;
307 friend class World;
308
310 GZ_UTILS_IMPL_PTR(dataPtr)
311 };
312 }
313}
314#endif
Provides a description of a light source.
Definition Light.hh:64
void SetAttenuationRange(const double _range)
Set the range of the light source in meters.
Light()
Default constructor.
Errors Load(ElementPtr _sdf)
Load the light based on a element pointer.
void SetCastShadows(const bool _cast)
Set whether the light casts shadows.
bool LightOn() const
Get if the light is on.
bool CastShadows() const
Get whether the light casts shadows.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
void SetSpotOuterAngle(const gz::math::Angle &_angle)
Set the angle covered by the outer cone.
double Intensity() const
Get the light intensity.
void SetSpotFalloff(const double _falloff)
Set the rate of falloff between the inner and outer cones.
void SetIntensity(const double _intensity)
Set the light intensity.
void SetType(const LightType _type)
Set the light type.
std::string Name() const
Get the name of the light.
void SetName(const std::string &_name)
Set the name of the light.
LightType Type() const
Get the light type.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this light object.
void SetLightOn(const bool _isLightOn)
Set if the light is ON/OFF.
gz::math::Angle SpotOuterAngle() const
Get the angle covered by the outer cone.
gz::math::Vector3d Direction() const
Get the direction of the light source.
double ConstantAttenuationFactor() const
Get the constant attenuation factor.
sdf::SemanticPose SemanticPose() const
Get SemanticPose object of this object to aid in resolving poses.
double SpotFalloff() const
Get the rate of falloff between the inner and outer cones.
void SetConstantAttenuationFactor(const double _factor)
Set the constant attenuation factor.
double QuadraticAttenuationFactor() const
Get the quadratic attenuation factor which adds a curvature to the attenuation.
sdf::ElementPtr ToElement(sdf::Errors &_errors) const
Create and return an SDF element filled with data from this light object.
gz::math::Angle SpotInnerAngle() const
Get the angle covered by the bright inner cone.
double AttenuationRange() const
Get the range of the light source in meters.
void SetRawPose(const gz::math::Pose3d &_pose)
Set the pose of the light.
const gz::math::Pose3d & RawPose() const
Get the pose of the light.
void SetSpecular(const gz::math::Color &_color)
Set the specular color.
bool Visualize() const
Whether light visualization in the GUI is enabled.
void SetLinearAttenuationFactor(const double _factor)
Set the linear attenuation factor.
void SetDiffuse(const gz::math::Color &_color)
Set the diffuse color.
void SetQuadraticAttenuationFactor(const double _factor)
Set the quadratic attenuation factor which adds a curvature to the attenuation.
gz::math::Color Diffuse() const
Get the diffuse color.
gz::math::Color Specular() const
Get the specular color.
void SetSpotInnerAngle(const gz::math::Angle &_angle)
Set the angle covered by the bright inner cone.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this object's pose is expressed.
void SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this object's pose is expressed.
void SetVisualize(const bool _visualize)
Set whether light visualization in the GUI is enabled.
double LinearAttenuationFactor() const
Get the linear attenuation factor.
void SetDirection(const gz::math::Vector3d &_dir)
Set the direction of the light source.
Definition Collision.hh:44
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition SemanticPose.hh:55
Definition World.hh:59
LightType
The set of light types.
Definition Light.hh:46
@ DIRECTIONAL
A directional light source.
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:81
std::shared_ptr< Element > ElementPtr
Definition Element.hh:55
namespace for Simulation Description Format parser
Definition Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:25