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 <ignition/math/Pose3.hh>
23 #include <ignition/math/Angle.hh>
24 #include <ignition/utils/ImplPtr.hh>
25 
26 #include "sdf/Element.hh"
27 #include "sdf/SemanticPose.hh"
28 #include "sdf/Types.hh"
29 #include "sdf/sdf_config.h"
30 #include "sdf/system_util.hh"
31 
32 namespace 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 ignition::math::Pose3d &RawPose() const;
98 
102  public: void SetRawPose(const ignition::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: double Intensity() const;
132 
135  public: void SetIntensity(const double _intensity);
136 
141  public: ignition::math::Color Diffuse() const;
142 
147  public: void SetDiffuse(const ignition::math::Color &_color);
148 
153  public: ignition::math::Color Specular() const;
154 
159  public: void SetSpecular(const ignition::math::Color &_color);
160 
163  public: double AttenuationRange() const;
164 
167  public: void SetAttenuationRange(const double _range);
168 
173  public: double LinearAttenuationFactor() const;
174 
179  public: void SetLinearAttenuationFactor(const double _factor);
180 
185  public: double ConstantAttenuationFactor() const;
186 
191  public: void SetConstantAttenuationFactor(const double _factor);
192 
196  public: double QuadraticAttenuationFactor() const;
197 
201  public: void SetQuadraticAttenuationFactor(const double _factor);
202 
207  public: ignition::math::Vector3d Direction() const;
208 
212  public: void SetDirection(const ignition::math::Vector3d &_dir);
213 
217  public: ignition::math::Angle SpotInnerAngle() const;
218 
222  public: void SetSpotInnerAngle(const ignition::math::Angle &_angle);
223 
227  public: ignition::math::Angle SpotOuterAngle() const;
228 
232  public: void SetSpotOuterAngle(const ignition::math::Angle &_angle);
233 
239  public: double SpotFalloff() const;
240 
246  public: void SetSpotFalloff(const double _falloff);
247 
252  public: sdf::ElementPtr Element() const;
253 
256  private: void CopyFrom(const Light &_light);
257 
262  private: void SetXmlParentName(const std::string &_xmlParentName);
263 
268  private: void SetPoseRelativeToGraph(
270 
274  public: sdf::ElementPtr ToElement() const;
275 
280  friend class Link;
281  friend class World;
282 
284  IGN_UTILS_IMPL_PTR(dataPtr)
285  };
286  }
287 }
288 #endif
Provides a description of a light source.
Definition: Light.hh:64
void SetName(const std::string &_name)
Set the name of the light.
void SetSpotOuterAngle(const ignition::math::Angle &_angle)
Set the angle covered by the outer cone.
void SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this object's pose is expressed.
void SetSpecular(const ignition::math::Color &_color)
Set the specular color.
double LinearAttenuationFactor() const
Get the linear attenuation factor.
ignition::math::Angle SpotInnerAngle() const
Get the angle covered by the bright inner cone.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this light object.
LightType Type() const
Get the light type.
ignition::math::Color Diffuse() const
Get the diffuse color.
void SetSpotFalloff(const double _falloff)
Set the rate of falloff between the inner and outer cones.
void SetDirection(const ignition::math::Vector3d &_dir)
Set the direction of the light source.
sdf::SemanticPose SemanticPose() const
Get SemanticPose object of this object to aid in resolving poses.
void SetIntensity(const double _intensity)
Set the light intensity.
void SetLinearAttenuationFactor(const double _factor)
Set the linear attenuation factor.
ignition::math::Angle SpotOuterAngle() const
Get the angle covered by the outer cone.
double SpotFalloff() const
Get the rate of falloff between the inner and outer cones.
void SetAttenuationRange(const double _range)
Set the range of the light source in meters.
void SetCastShadows(const bool _cast)
Set whether the light casts shadows.
ignition::math::Vector3d Direction() const
Get the direction of the light source.
void SetConstantAttenuationFactor(const double _factor)
Set the constant attenuation factor.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this object's pose is expressed.
void SetType(const LightType _type)
Set the light type.
void SetDiffuse(const ignition::math::Color &_color)
Set the diffuse color.
void SetRawPose(const ignition::math::Pose3d &_pose)
Set the pose of the light.
std::string Name() const
Get the name of the light.
Light()
Default constructor.
Errors Load(ElementPtr _sdf)
Load the light based on a element pointer.
double Intensity() const
Get the light intensity.
bool CastShadows() const
Get whether the light casts shadows.
void SetSpotInnerAngle(const ignition::math::Angle &_angle)
Set the angle covered by the bright inner cone.
double ConstantAttenuationFactor() const
Get the constant attenuation factor.
double QuadraticAttenuationFactor() const
Get the quadratic attenuation factor which adds a curvature to the attenuation.
const ignition::math::Pose3d & RawPose() const
Get the pose of the light.
double AttenuationRange() const
Get the range of the light source in meters.
void SetQuadraticAttenuationFactor(const double _factor)
Set the quadratic attenuation factor which adds a curvature to the attenuation.
ignition::math::Color Specular() const
Get the specular color.
Definition: Collision.hh:39
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:55
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
LightType
The set of light types.
Definition: Light.hh:46
namespace for Simulation Description Format parser
Definition: Actor.hh:34
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:41