18 #ifndef GAZEBO_RENDERING_SCENE_HH_ 19 #define GAZEBO_RENDERING_SCENE_HH_ 25 #include <boost/enable_shared_from_this.hpp> 26 #include <boost/shared_ptr.hpp> 30 #include <ignition/math/Vector2.hh> 31 #include <ignition/math/Vector3.hh> 35 #include "gazebo/gazebo_config.h" 101 public boost::enable_shared_from_this<Scene>
104 GZ_SKYX_ALL = 0x0FFFFFFF,
105 GZ_SKYX_CLOUDS = 0x0000001,
106 GZ_SKYX_MOON = 0x0000002,
118 public:
Scene(
const std::string &_name,
119 const bool _enableVisualizations =
false,
120 const bool _isServer =
false);
123 public:
virtual ~
Scene();
127 public:
void Load(sdf::ElementPtr _scene);
136 public:
void PreRender();
140 public: Ogre::SceneManager *OgreSceneManager()
const;
144 public: std::string Name()
const;
156 public:
void SetBackgroundColor(
const common::Color &_color);
167 public:
void CreateGrid(
const uint32_t _cellCount,
168 const float _cellLength,
const float _lineWidth,
174 public:
Grid *GetGrid(uint32_t _index)
const;
178 public: uint32_t GridCount()
const;
185 public:
CameraPtr CreateCamera(
const std::string &_name,
186 const bool _autoRender =
true);
194 const bool _autoRender =
true);
197 public: OculusCameraPtr CreateOculusCamera(
const std::string &_name);
204 public: uint32_t OculusCameraCount()
const;
212 public:
DepthCameraPtr CreateDepthCamera(
const std::string &_name,
213 const bool _autoRender =
true);
220 public:
GpuLaserPtr CreateGpuLaser(
const std::string &_name,
221 const bool _autoRender =
true);
225 public: uint32_t CameraCount()
const;
231 public:
CameraPtr GetCamera(
const uint32_t _index)
const;
236 public:
CameraPtr GetCamera(
const std::string &_name)
const;
245 public:
UserCameraPtr CreateUserCamera(
const std::string &_name,
246 const bool _stereoEnabled =
false);
250 public: uint32_t UserCameraCount()
const;
257 public:
UserCameraPtr GetUserCamera(
const uint32_t _index)
const;
261 public:
void RemoveCamera(
const std::string &_name);
266 public:
LightPtr GetLight(
const std::string &_name)
const;
270 public: uint32_t LightCount()
const;
276 public:
LightPtr GetLight(
const uint32_t _index)
const;
281 public:
VisualPtr GetVisual(
const std::string &_name)
const;
286 public:
VisualPtr GetVisual(
const uint32_t _id)
const;
291 public:
void SelectVisual(
const std::string &_name,
292 const std::string &_mode);
301 const ignition::math::Vector2i &_mousePos,
306 public:
void SnapVisualToNearestBelow(
const std::string &_visualName);
314 const ignition::math::Vector2i &_mousePos);
322 const ignition::math::Vector2i &_mousePos);
327 public:
VisualPtr VisualBelow(
const std::string &_visualName);
333 public:
void VisualsBelowPoint(
const ignition::math::Vector3d &_pt,
334 std::vector<VisualPtr> &_visuals);
340 public:
double HeightBelowPoint(
const ignition::math::Vector3d &_pt);
347 public:
bool FirstContact(
CameraPtr _camera,
348 const ignition::math::Vector2i &_mousePos,
349 ignition::math::Vector3d &_position);
352 public:
void PrintSceneGraph();
358 public:
void SetVisible(
const std::string &_name,
const bool _visible);
364 public:
void DrawLine(
const ignition::math::Vector3d &_start,
365 const ignition::math::Vector3d &_end,
366 const std::string &_name);
375 public:
void SetFog(
const std::string &_type,
377 const double _density,
const double _start,
382 public: uint32_t Id()
const;
386 public: std::string IdString()
const;
390 public:
void SetShadowsEnabled(
const bool _value);
394 public:
bool ShadowsEnabled()
const;
402 public:
void RemoveVisual(
VisualPtr _vis);
406 public:
void RemoveVisual(
const uint32_t _id);
413 public:
void SetVisualId(
VisualPtr _vis,
const uint32_t _id);
417 public:
void AddLight(
LightPtr _light);
421 public:
void RemoveLight(
LightPtr _light);
425 public:
void SetGrid(
const bool _enabled);
429 public:
void ShowOrigin(
const bool _show);
438 public: std::string StripSceneName(
const std::string &_name)
const;
445 public:
void Clear();
450 public:
VisualPtr SelectedVisual()
const;
454 public:
void SetWireframe(
const bool _show);
458 public:
bool Wireframe()
const;
462 public:
void SetTransparent(
const bool _show);
466 public:
void ShowCOMs(
const bool _show);
470 public:
void ShowInertias(
const bool _show);
474 public:
void ShowLinkFrames(
const bool _show);
478 public:
void ShowSkeleton(
const bool _show);
482 public:
void ShowJoints(
const bool _show);
486 public:
void ShowCollisions(
const bool _show);
490 public:
void ShowContacts(
const bool _show);
494 public:
void ShowClouds(
const bool _show);
498 public:
bool ShowClouds()
const;
504 public:
void SetSkyXMode(
const unsigned int _mode);
508 public: SkyX::SkyX *GetSkyX()
const;
512 public:
bool Initialized()
const;
523 public: uint32_t VisualCount()
const;
526 public:
void RemoveProjectors();
532 public:
void ToggleLayer(
const int32_t _layer);
539 public:
bool LayerState(
const int32_t _layer)
const;
545 public:
bool HasLayer(
const int32_t _layer)
const;
548 private:
void SetSky();
551 private:
void InitDeferredShading();
559 private: Ogre::Entity *OgreEntityAt(
CameraPtr _camera,
560 const ignition::math::Vector2i &_mousePos,
561 const bool _ignoreSelectionObj);
573 private:
void MeshInformation(
const Ogre::Mesh *_mesh,
574 size_t &_vertexCount,
575 Ogre::Vector3* &_vertices,
578 const ignition::math::Vector3d &_position,
579 const ignition::math::Quaterniond &_orient,
580 const ignition::math::Vector3d &_scale);
585 private:
void PrintSceneGraphHelper(
const std::string &_prefix,
591 private:
void OnScene(ConstScenePtr &_msg);
595 private:
void OnResponse(ConstResponsePtr &_msg);
599 private:
void OnRequest(ConstRequestPtr &_msg);
603 private:
void OnJointMsg(ConstJointPtr &_msg);
607 private:
bool ProcessSensorMsg(ConstSensorPtr &_msg);
611 private:
bool ProcessJointMsg(ConstJointPtr &_msg);
615 private:
bool ProcessLinkMsg(ConstLinkPtr &_msg);
619 private:
bool ProcessSceneMsg(ConstScenePtr &_msg);
623 private:
bool ProcessModelMsg(
const msgs::Model &_msg);
627 private:
void OnSensorMsg(ConstSensorPtr &_msg);
631 private:
void OnVisualMsg(ConstVisualPtr &_msg);
637 private:
bool ProcessVisualMsg(ConstVisualPtr &_msg,
642 private:
void OnLightFactoryMsg(ConstLightPtr &_msg);
646 private:
void OnLightModifyMsg(ConstLightPtr &_msg);
650 private:
bool ProcessLightFactoryMsg(ConstLightPtr &_msg);
654 private:
bool ProcessLightModifyMsg(ConstLightPtr &_msg);
658 private:
void ProcessRequestMsg(ConstRequestPtr &_msg);
662 private:
void OnSkyMsg(ConstSkyPtr &_msg);
666 private:
void OnModelMsg(ConstModelPtr &_msg);
670 private:
void OnPoseMsg(ConstPosesStampedPtr &_msg);
674 private:
void OnSkeletonPoseMsg(ConstPoseAnimationPtr &_msg);
678 private:
void OnRoadMsg(ConstRoadPtr &_msg);
683 private:
void CreateCOMVisual(ConstLinkPtr &_msg,
VisualPtr _linkVisual);
688 private:
void CreateCOMVisual(sdf::ElementPtr _elem,
694 private:
void CreateInertiaVisual(ConstLinkPtr &_msg,
700 private:
void CreateInertiaVisual(sdf::ElementPtr _elem,
706 private:
void CreateLinkFrameVisual(ConstLinkPtr &_msg,
712 private:
void RemoveVisualizations(
VisualPtr _vis);
716 private: std::unique_ptr<ScenePrivate> dataPtr;
boost::shared_ptr< UserCamera > UserCameraPtr
Definition: RenderTypes.hh:93
Forward declarations for the common classes.
Definition: Animation.hh:33
boost::shared_ptr< GpuLaser > GpuLaserPtr
Definition: RenderTypes.hh:105
SkyXMode
Definition: Scene.hh:103
Forward declarations for transport.
Displays a grid of cells, drawn with lines.
Definition: Grid.hh:56
boost::shared_ptr< DepthCamera > DepthCameraPtr
Definition: RenderTypes.hh:97
VisualType
Type of visual.
Definition: Visual.hh:68
Rendering a terrain using heightmap information.
Definition: Heightmap.hh:62
Representation of an entire scene graph.
Definition: Scene.hh:100
Definition: JointMaker.hh:39
Defines a color.
Definition: Color.hh:36
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:113
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
boost::shared_ptr< WideAngleCamera > WideAngleCameraPtr
Definition: RenderTypes.hh:101
boost::shared_ptr< Light > LightPtr
Definition: RenderTypes.hh:85
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:89
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44