LightMaker.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 _LIGHTMAKER_HH_
18 #define _LIGHTMAKER_HH_
19 
20 #include <string>
21 
22 #include "gazebo/msgs/msgs.hh"
24 #include "gazebo/util/system.hh"
25 
26 namespace gazebo
27 {
28  namespace rendering
29  {
30  class Light;
31  }
32 
33  namespace gui
34  {
36  {
37  public: LightMaker();
38 
39  public: void Start(const rendering::UserCameraPtr _camera);
40  public: void Stop();
41  public: virtual bool IsActive() const;
42 
43  public: void OnMousePush(const common::MouseEvent &_event);
44 
45  public: virtual void OnMouseMove(const common::MouseEvent &_event);
46  public: virtual void OnMouseRelease(const common::MouseEvent &_event);
47  public: virtual void OnMouseDrag(const common::MouseEvent &) {}
48 
52  public: bool InitFromLight(const std::string & _lightName);
53 
56  protected: virtual bool Init();
57 
58  protected: virtual void CreateTheEntity();
59 
60  protected: int state;
61  protected: msgs::Light msg;
63  private: static unsigned int counter;
64  protected: std::string lightTypename;
65 
67  private: rendering::LightPtr light;
68  };
69 
71  {
73  {
74  this->msg.set_type(msgs::Light::POINT);
75  this->msg.set_cast_shadows(false);
76  this->lightTypename = "point";
77  }
78  };
79 
81  {
82  public: SpotLightMaker() : LightMaker()
83  {
84  this->msg.set_type(msgs::Light::SPOT);
85  msgs::Set(this->msg.mutable_direction(),
86  math::Vector3(0, 0, -1));
87  this->msg.set_cast_shadows(false);
88 
89  this->msg.set_spot_inner_angle(0.6);
90  this->msg.set_spot_outer_angle(1.0);
91  this->msg.set_spot_falloff(1.0);
92  this->lightTypename = "spot";
93  }
94  };
95 
97  {
99  {
100  this->msg.set_type(msgs::Light::DIRECTIONAL);
101  msgs::Set(this->msg.mutable_direction(),
102  math::Vector3(.1, .1, -0.9));
103  this->msg.set_cast_shadows(true);
104 
105  this->lightTypename = "directional";
106  }
107  };
108  }
109 }
110 #endif
Generic description of a mouse event.
Definition: MouseEvent.hh:32
Definition: LightMaker.hh:35
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
virtual void OnMouseDrag(const common::MouseEvent &)
Callback for dragging with mouse.
Definition: LightMaker.hh:47
boost::shared_ptr< Light > LightPtr
Definition: RenderTypes.hh:78
Definition: LightMaker.hh:80
msgs::Light msg
Definition: LightMaker.hh:61
PointLightMaker()
Definition: LightMaker.hh:72
DirectionalLightMaker()
Definition: LightMaker.hh:98
Definition: LightMaker.hh:70
std::string lightTypename
Definition: LightMaker.hh:64
to make an entity base class
Definition: EntityMaker.hh:41
Definition: LightMaker.hh:96
int state
Definition: LightMaker.hh:60
GAZEBO_VISIBLE void Set(common::Image &_img, const msgs::Image &_msg)
Convert a msgs::Image to a common::Image.
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
A light source.
Definition: Light.hh:52
boost::shared_ptr< UserCamera > UserCameraPtr
Definition: RenderTypes.hh:86
SpotLightMaker()
Definition: LightMaker.hh:82
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
transport::PublisherPtr lightPub
Definition: LightMaker.hh:62
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48