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 
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 
118  public: const gz::math::Pose3d &Pose() const
119  SDF_DEPRECATED(9.0);
120 
125  public: void SetPose(const gz::math::Pose3d &_pose)
126  SDF_DEPRECATED(9.0);
127 
133  public: const gz::math::Pose3d &RawPose() const;
134 
138  public: void SetRawPose(const gz::math::Pose3d &_pose);
139 
144  public: const std::string &PoseRelativeTo() const;
145 
150  public: void SetPoseRelativeTo(const std::string &_frame);
151 
157  public: const std::string &PoseFrame() const
158  SDF_DEPRECATED(9.0);
159 
165  public: void SetPoseFrame(const std::string &_frame)
166  SDF_DEPRECATED(9.0);
167 
171  public: sdf::SemanticPose SemanticPose() const;
172 
175  public: bool CastShadows() const;
176 
179  public: void SetCastShadows(const bool _cast);
180 
185  public: gz::math::Color Diffuse() const;
186 
191  public: void SetDiffuse(const gz::math::Color &_color) const;
192 
197  public: gz::math::Color Specular() const;
198 
203  public: void SetSpecular(const gz::math::Color &_color) const;
204 
207  public: double AttenuationRange() const;
208 
211  public: void SetAttenuationRange(const double _range);
212 
217  public: double LinearAttenuationFactor() const;
218 
223  public: void SetLinearAttenuationFactor(const double _factor);
224 
229  public: double ConstantAttenuationFactor() const;
230 
235  public: void SetConstantAttenuationFactor(const double _factor);
236 
240  public: double QuadraticAttenuationFactor() const;
241 
245  public: void SetQuadraticAttenuationFactor(const double _factor);
246 
251  public: gz::math::Vector3d Direction() const;
252 
256  public: void SetDirection(const gz::math::Vector3d &_dir);
257 
261  public: gz::math::Angle SpotInnerAngle() const;
262 
266  public: void SetSpotInnerAngle(const gz::math::Angle &_angle);
267 
271  public: gz::math::Angle SpotOuterAngle() const;
272 
276  public: void SetSpotOuterAngle(const gz::math::Angle &_angle);
277 
283  public: double SpotFalloff() const;
284 
290  public: void SetSpotFalloff(const double _falloff);
291 
296  public: sdf::ElementPtr Element() const;
297 
300  private: void CopyFrom(const Light &_light);
301 
306  private: void SetXmlParentName(const std::string &_xmlParentName);
307 
312  private: void SetPoseRelativeToGraph(
313  std::weak_ptr<const PoseRelativeToGraph> _graph);
314 
319  friend class Link;
320  friend class World;
321 
323  private: LightPrivate *dataPtr = nullptr;
324  };
325  }
326 }
327 #endif
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:32
sdf::v9::LightType::DIRECTIONAL
@ DIRECTIONAL
A directional light source.
sdf::v9::LightType
LightType
Definition: Light.hh:44
Types.hh
SemanticPose.hh
sdf::v9::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:89
sdf::v9::LightType::SPOT
@ SPOT
A spot light source.
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:48
sdf::v9::World
Definition: World.hh:45
sdf::v9::SDF_DEPRECATED
class SDFORMAT_VISIBLE SDF_DEPRECATED(9.2) URDF2SDF
URDF to SDF converter.
Definition: parser_urdf.hh:40
sdf::v9::Light
Provides a description of a light source.
Definition: Light.hh:62
sdf::v9::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::v9::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::v9::LightType::POINT
@ POINT
A point light source.
system_util.hh
sdf::v9::Element
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
sdf::v9::ForceTorqueFrame::INVALID
@ INVALID
Invalid frame.
Element.hh