Go to the documentation of this file.
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/Color.hh>
31 #include <ignition/math/Vector2.hh>
32 #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);
127 public:
void Load(sdf::ElementPtr _scene);
144 public: std::string
Name()
const;
167 const float _cellLength,
const ignition::math::Color &_color);
184 const bool _autoRender =
true);
192 const bool _autoRender =
true);
195 public: OculusCameraPtr CreateOculusCamera(
const std::string &_name);
202 public: uint32_t OculusCameraCount()
const;
211 const bool _autoRender =
true);
219 const bool _autoRender =
true);
244 const bool _stereoEnabled =
false);
310 const std::string &_mode);
319 const ignition::math::Vector2i &_mousePos,
332 const ignition::math::Vector2i &_mousePos);
340 const ignition::math::Vector2i &_mousePos);
352 std::vector<VisualPtr> &_visuals);
366 const ignition::math::Vector2i &_mousePos,
367 ignition::math::Vector3d &_position);
376 public:
void SetVisible(
const std::string &_name,
const bool _visible);
382 public:
void DrawLine(
const ignition::math::Vector3d &_start,
383 const ignition::math::Vector3d &_end,
384 const std::string &_name);
393 public:
void SetFog(
const std::string &_type,
394 const ignition::math::Color &_color,
395 const double _density,
const double _start,
400 public: uint32_t
Id()
const;
607 private:
void SetSky();
610 private:
void InitDeferredShading();
618 private: Ogre::Entity *OgreEntityAt(
CameraPtr _camera,
619 const ignition::math::Vector2i &_mousePos,
620 const bool _ignoreSelectionObj);
632 private:
void MeshInformation(
const Ogre::Mesh *_mesh,
633 size_t &_vertexCount,
634 Ogre::Vector3* &_vertices,
637 const ignition::math::Vector3d &_position,
638 const ignition::math::Quaterniond &_orient,
639 const ignition::math::Vector3d &_scale);
644 private:
void PrintSceneGraphHelper(
const std::string &_prefix,
650 private:
void OnScene(ConstScenePtr &_msg);
654 private:
void OnResponse(ConstResponsePtr &_msg);
658 private:
void OnRequest(ConstRequestPtr &_msg);
662 private:
void OnJointMsg(ConstJointPtr &_msg);
666 private:
bool ProcessSensorMsg(ConstSensorPtr &_msg);
670 private:
bool ProcessJointMsg(ConstJointPtr &_msg);
674 private:
bool ProcessLinkMsg(ConstLinkPtr &_msg);
678 private:
bool ProcessSceneMsg(ConstScenePtr &_msg);
682 private:
bool ProcessModelMsg(
const msgs::Model &_msg);
686 private:
void OnSensorMsg(ConstSensorPtr &_msg);
690 private:
void OnVisualMsg(ConstVisualPtr &_msg);
696 private:
bool ProcessVisualMsg(ConstVisualPtr &_msg,
701 private:
void OnLightFactoryMsg(ConstLightPtr &_msg);
705 private:
void OnLightModifyMsg(ConstLightPtr &_msg);
709 private:
bool ProcessLightFactoryMsg(ConstLightPtr &_msg);
713 private:
bool ProcessLightModifyMsg(ConstLightPtr &_msg);
717 private:
void ProcessRequestMsg(ConstRequestPtr &_msg);
721 private:
void OnSkyMsg(ConstSkyPtr &_msg);
725 private:
void OnModelMsg(ConstModelPtr &_msg);
729 private:
void OnPoseMsg(ConstPosesStampedPtr &_msg);
733 private:
void OnSkeletonPoseMsg(ConstPoseAnimationPtr &_msg);
737 private:
void OnRoadMsg(ConstRoadPtr &_msg);
742 private:
void CreateCOMVisual(ConstLinkPtr &_msg,
VisualPtr _linkVisual);
747 private:
void CreateCOMVisual(sdf::ElementPtr _elem,
753 private:
void CreateInertiaVisual(ConstLinkPtr &_msg,
759 private:
void CreateInertiaVisual(sdf::ElementPtr _elem,
765 private:
void CreateLinkFrameVisual(ConstLinkPtr &_msg,
771 private:
void RemoveVisualizations(
VisualPtr _vis);
775 private: std::unique_ptr<ScenePrivate> dataPtr;
bool FirstContact(CameraPtr _camera, const ignition::math::Vector2i &_mousePos, ignition::math::Vector3d &_position)
Get the world pos of a the first contact at a pixel location.
void ShowClouds(const bool _show)
Display clouds in the sky.
void ShowOrigin(const bool _show)
Show/hide the world origin indicator.
LightPtr GetLight(const uint32_t _index) const GAZEBO_DEPRECATED(9.1)
Get a light based on an index.
void SetBackgroundColor(const ignition::math::Color &_color)
Set the background color.
void SetTransparent(const bool _show)
Enable or disable transparency for all visuals.
void SetHeightmapLOD(const unsigned int _value)
Set the Level Of Detail (LOD) value for the heightmap.
Scene(const std::string &_name, const bool _enableVisualizations=false, const bool _isServer=false)
Constructor.
boost::shared_ptr< UserCamera > UserCameraPtr
Definition: RenderTypes.hh:94
bool ShowClouds() const
Get whether or not clouds are displayed.
ignition::math::Color BackgroundColor() const
Get the background color.
std::string IdString() const
Get the scene Id as a string.
Definition: JointMaker.hh:40
void Load()
Load the scene with default parameters.
void SetAmbientColor(const ignition::math::Color &_color)
Set the ambient color.
LightPtr LightById(const uint32_t _id) const
Get a light by id.
double HeightBelowPoint(const ignition::math::Vector3d &_pt)
Get the Z-value of the first object below the given point.
CameraPtr GetCamera(const std::string &_name) const
Get a camera by name.
Representation of an entire scene graph.
Definition: Scene.hh:102
Forward declarations for the common classes.
Definition: Animation.hh:27
Heightmap * GetHeightmap() const
Get a pointer to the heightmap.
Rendering a terrain using heightmap information.
Definition: Heightmap.hh:63
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:48
bool Wireframe() const
Get whether wireframe is enabled for all visuals.
boost::shared_ptr< GpuLaser > GpuLaserPtr
Definition: RenderTypes.hh:106
@ VT_ENTITY
Entity visual.
Definition: Visual.hh:67
UserCameraPtr CreateUserCamera(const std::string &_name, const bool _stereoEnabled=false)
Create a user camera.
bool EnableVisualizations() const
Check whether visualizations are enabled or not.
common::Time SimTime() const
Get the scene simulation time.
VisualPtr VisualAt(CameraPtr _camera, const ignition::math::Vector2i &_mousePos, std::string &_mod)
Get an entity at a pixel location using a camera.
Forward declarations for transport.
void VisualsBelowPoint(const ignition::math::Vector3d &_pt, std::vector< VisualPtr > &_visuals)
Get a visual directly below a point.
void SetVisible(const std::string &_name, const bool _visible)
Hide or show a visual.
Grid * GetGrid(uint32_t _index) const
Get a grid based on an index.
uint32_t Id() const
Get the scene ID.
void CreateGrid(const uint32_t _cellCount, const float _cellLength, const ignition::math::Color &_color)
Create a square grid of cells.
uint32_t VisualCount() const
Get the number of visuals.
void ShowJoints(const bool _show)
Enable or disable joint visualization.
void SetSkyXMode(const unsigned int _mode)
Set SkyX mode to enable/disable skyx components such as clouds and moon.
unsigned int HeightmapLOD() const
Get the Level Of Detail (LOD) value for the heightmap.
DepthCameraPtr CreateDepthCamera(const std::string &_name, const bool _autoRender=true)
Create depth camera.
void PrintSceneGraph()
Print the scene graph to std_out.
void Clear()
Clear rendering::Scene.
VisualPtr VisualAt(CameraPtr _camera, const ignition::math::Vector2i &_mousePos)
Get a visual at a mouse position.
virtual ~Scene()
Destructor.
void ShowSkeleton(const bool _show)
Enable or disable skeleton visualization.
void ShowInertias(const bool _show)
Enable or disable inertia visualization.
void SetHeightmapSkirtLength(const double _value)
Set the skirt length value for the heightmap LOD tiles.
void SetGrid(const bool _enabled)
Set the grid on or off.
double HeightmapSkirtLength() const
Get the skirt length value for the heightmap LOD tiles.
void Load(sdf::ElementPtr _scene)
Load the scene from a set of parameters.
void EnableVisualizations(const bool _enable)
Enable visualizations, currently only applies to sensor visuals.
uint32_t CameraCount() const
Get the number of cameras in this scene.
@ GZ_SKYX_NONE
Definition: Scene.hh:107
@ GZ_SKYX_ALL
Definition: Scene.hh:104
void RemoveProjectors()
Remove all projectors.
Displays a grid of cells, drawn with lines.
Definition: Grid.hh:54
void SetFog(const std::string &_type, const ignition::math::Color &_color, const double _density, const double _start, const double _end)
Set the fog parameters.
rendering
Definition: RenderEngine.hh:31
void RemoveCamera(const std::string &_name)
Remove a camera from the scene.
VisualType
Type of visual.
Definition: Visual.hh:65
uint32_t LightCount() const
Get the count of the lights.
LightPtr LightByName(const std::string &_name) const
Get a light by name.
void RemoveVisual(const uint32_t _id)
Remove a visual from the scene.
void ShowContacts(const bool _show)
Enable or disable contact visualization.
void SetVisualId(VisualPtr _vis, const uint32_t _id)
boost::shared_ptr< DepthCamera > DepthCameraPtr
Definition: RenderTypes.hh:98
CameraPtr GetCamera(const uint32_t _index) const
Get a camera based on an index.
void ShowCollisions(const bool _show)
Enable or disable collision visualization.
SkyX::SkyX * GetSkyX() const
Get the sky in the scene.
VisualPtr WorldVisual() const
Get the top level world visual.
@ GZ_SKYX_MOON
Definition: Scene.hh:106
void SetShadowsEnabled(const bool _value)
Set whether shadows are on or off.
bool Initialized() const
Return true if the Scene has been initialized.
GpuLaserPtr CreateGpuLaser(const std::string &_name, const bool _autoRender=true)
Create laser that generates data from rendering.
void RemoveVisual(VisualPtr _vis)
Remove a visual from the scene.
void SetWireframe(const bool _show)
Enable or disable wireframe for all visuals.
LightPtr GetLight(const std::string &_name) const GAZEBO_DEPRECATED(9.1)
Get a light by name.
UserCameraPtr GetUserCamera(const uint32_t _index) const
Get a user camera by index.
VisualPtr SelectedVisual() const
Get the currently selected visual.
bool ShadowsEnabled() const
Get whether shadows are on or off.
uint32_t UserCameraCount() const
Get the number of user cameras in this scene.
void AddLight(LightPtr _light)
Add a light to the scene.
SkyXMode
Definition: Scene.hh:103
bool SetShadowTextureSize(const unsigned int _size)
Set the shadow texture size.
void ToggleLayer(const int32_t _layer)
Toggle layer visilibility.
uint32_t GridCount() const
Get the number of grids.
@ GZ_SKYX_CLOUDS
Definition: Scene.hh:105
VisualPtr ModelVisualAt(CameraPtr _camera, const ignition::math::Vector2i &_mousePos)
Get a model's visual at a mouse position.
void Init()
Init rendering::Scene.
LightPtr LightByIndex(const uint32_t _index) const
Get a light based on an index.
void AddVisual(VisualPtr _vis)
Add a visual to the scene.
void RemoveLight(LightPtr _light)
Remove a light to the scene.
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:328
bool HasLayer(const int32_t _layer) const
Return true if the layer exits.
void ShowLinkFrames(const bool _show)
Enable or disable link frame visualization.
void SelectVisual(const std::string &_name, const std::string &_mode)
Select a visual by name.
VisualPtr GetVisual(const std::string &_name) const
Get a visual by name.
boost::shared_ptr< Light > LightPtr
Definition: RenderTypes.hh:86
Ogre::SceneManager * OgreSceneManager() const
Get the OGRE scene manager.
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
std::string Name() const
Get the name of the scene.
unsigned int ShadowTextureSize() const
Get the shadow texture size.
VisualPtr GetVisual(const uint32_t _id) const
Get a visual by id.
bool LayerState(const int32_t _layer) const
Return whether a layer is on or off.
VisualPtr VisualBelow(const std::string &_visualName)
Get the closest visual below a given visual.
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:90
boost::shared_ptr< WideAngleCamera > WideAngleCameraPtr
Definition: RenderTypes.hh:102
void PreRender()
Process all received messages.
void DrawLine(const ignition::math::Vector3d &_start, const ignition::math::Vector3d &_end, const std::string &_name)
Draw a named line.
WideAngleCameraPtr CreateWideAngleCamera(const std::string &_name, const bool _autoRender=true)
Create a wide-angle camera.
void SnapVisualToNearestBelow(const std::string &_visualName)
Move the visual to be ontop of the nearest visual below it.
ignition::math::Color AmbientColor() const
Get the ambient color.
std::string StripSceneName(const std::string &_name) const
Remove the name of scene from a string.
void ShowCOMs(const bool _show)
Enable or disable center of mass visualization.
CameraPtr CreateCamera(const std::string &_name, const bool _autoRender=true)
Create a camera.