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 
25 #include "sdf/Element.hh"
26 #include "sdf/SemanticPose.hh"
27 #include "sdf/Types.hh"
28 #include "sdf/sdf_config.h"
29 #include "sdf/system_util.hh"
30 
31 namespace sdf
32 {
33  // Inline bracket to help doxygen filtering.
34  inline namespace SDF_VERSION_NAMESPACE {
35  //
36 
37  // Forward declare private data class.
38  class LightPrivate;
39  struct PoseRelativeToGraph;
40 
44  enum class LightType
45  {
48  INVALID = 0,
49 
51  POINT = 1,
52 
54  SPOT = 2,
55 
57  DIRECTIONAL = 3,
58  };
59 
63  {
65  public: Light();
66 
69  public: Light(const Light &_light);
70 
73  public: Light(Light &&_light) noexcept;
74 
76  public: ~Light();
77 
81  public: Light &operator=(Light &&_light);
82 
86  public: Light &operator=(const Light &_light);
87 
94  public: Errors Load(ElementPtr _sdf);
95 
98  public: LightType Type() const;
99 
102  public: void SetType(const LightType _type);
103 
106  public: std::string Name() const;
107 
110  public: void SetName(const std::string &_name) const;
111 
117  public: const ignition::math::Pose3d &RawPose() const;
118 
122  public: void SetRawPose(const ignition::math::Pose3d &_pose);
123 
128  public: const std::string &PoseRelativeTo() const;
129 
134  public: void SetPoseRelativeTo(const std::string &_frame);
135 
139  public: sdf::SemanticPose SemanticPose() const;
140 
143  public: bool CastShadows() const;
144 
147  public: void SetCastShadows(const bool _cast);
148 
153  public: ignition::math::Color Diffuse() const;
154 
159  public: void SetDiffuse(const ignition::math::Color &_color) const;
160 
165  public: ignition::math::Color Specular() const;
166 
171  public: void SetSpecular(const ignition::math::Color &_color) const;
172 
175  public: double AttenuationRange() const;
176 
179  public: void SetAttenuationRange(const double _range);
180 
185  public: double LinearAttenuationFactor() const;
186 
191  public: void SetLinearAttenuationFactor(const double _factor);
192 
197  public: double ConstantAttenuationFactor() const;
198 
203  public: void SetConstantAttenuationFactor(const double _factor);
204 
208  public: double QuadraticAttenuationFactor() const;
209 
213  public: void SetQuadraticAttenuationFactor(const double _factor);
214 
219  public: ignition::math::Vector3d Direction() const;
220 
224  public: void SetDirection(const ignition::math::Vector3d &_dir);
225 
229  public: ignition::math::Angle SpotInnerAngle() const;
230 
234  public: void SetSpotInnerAngle(const ignition::math::Angle &_angle);
235 
239  public: ignition::math::Angle SpotOuterAngle() const;
240 
244  public: void SetSpotOuterAngle(const ignition::math::Angle &_angle);
245 
251  public: double SpotFalloff() const;
252 
258  public: void SetSpotFalloff(const double _falloff);
259 
264  public: sdf::ElementPtr Element() const;
265 
268  private: void CopyFrom(const Light &_light);
269 
274  private: void SetXmlParentName(const std::string &_xmlParentName);
275 
280  private: void SetPoseRelativeToGraph(
281  std::weak_ptr<const PoseRelativeToGraph> _graph);
282 
287  friend class Link;
288  friend class World;
289 
291  private: LightPrivate *dataPtr = nullptr;
292  };
293  }
294 }
295 #endif
sdf::v10::SemanticPose
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:53
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:32
sdf::v10::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95
sdf::v10::JointType::INVALID
@ INVALID
An invalid joint.
Types.hh
SemanticPose.hh
sdf::v10::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:48
sdf::v10::LightType::POINT
@ POINT
A point light source.
sdf::v10::Light
Provides a description of a light source.
Definition: Light.hh:62
sdf::v10::LightType::SPOT
@ SPOT
A spot light source.
sdf::v10::World
Definition: World.hh:45
sdf::v10::LightType::DIRECTIONAL
@ DIRECTIONAL
A directional light source.
system_util.hh
sdf::v10::LightType
LightType
Definition: Light.hh:44
sdf::v10::Element
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
Element.hh