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/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 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 
119  public: sdf::SemanticPose SemanticPose() const;
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
sdf::SDF_VERSION_NAMESPACE::LightType::DIRECTIONAL
@ DIRECTIONAL
A directional light source.
sdf::SDF_VERSION_NAMESPACE::LightType::POINT
@ POINT
A point light source.
sdf::SDF_VERSION_NAMESPACE::LightType::SPOT
@ SPOT
A spot light source.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::SDF_VERSION_NAMESPACE::LightType
LightType
Definition: Light.hh:45
sdf::SDF_VERSION_NAMESPACE::LightType::INVALID
@ INVALID
An invalid light.
Types.hh
SemanticPose.hh
sdf_config.h
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::SDF_VERSION_NAMESPACE::Light
Provides a description of a light source.
Definition: Light.hh:63
sdf::SDF_VERSION_NAMESPACE::Element
class GZ_SDFORMAT_VISIBLE Element
Definition: Element.hh:51
sdf::SDF_VERSION_NAMESPACE::SemanticPose
SemanticPose is a data structure that can be used by different DOM objects to resolve poses on a Pose...
Definition: SemanticPose.hh:54
sdf::SDF_VERSION_NAMESPACE::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:80
sdf::SDF_VERSION_NAMESPACE::ScopedGraph
Definition: Collision.hh:40
system_util.hh
sdf::SDF_VERSION_NAMESPACE::World
Definition: World.hh:58
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55
Element.hh