17#ifndef GAZEBO_RENDERING_VISUAL_HH_
18#define GAZEBO_RENDERING_VISUAL_HH_
20#include <boost/enable_shared_from_this.hpp>
21#include <boost/function.hpp>
27#include <ignition/math/Box.hh>
28#include <ignition/math/Color.hh>
29#include <ignition/math/Pose3.hh>
30#include <ignition/math/Quaternion.hh>
31#include <ignition/math/Vector3.hh>
32#include <ignition/msgs/MessageTypes.hh>
37#include "gazebo/msgs/MessageTypes.hh"
60 public std::enable_shared_from_this<Visual>
90 bool _useRTShader =
true);
98 bool _useRTShader =
true);
121 public:
void Load(sdf::ElementPtr _sdf);
139 public:
void SetName(
const std::string &_name);
143 public: std::string
Name()
const;
189 public: Ogre::MovableObject *
AttachMesh(
const std::string &_meshName,
190 const std::string &_subMesh=
"",
191 bool _centerSubmesh =
false,
192 const std::string &_objName=
"");
196 public:
void SetScale(
const ignition::math::Vector3d &_scale);
200 public: ignition::math::Vector3d
Scale()
const;
221 bool _unique =
true,
const bool _cascade =
true);
233 const std::string &_shaderType,
const std::string &_value);
239 const bool _cascade =
true);
245 const bool _cascade =
true);
251 const bool _cascade =
true);
256 public:
virtual void SetEmissive(
const ignition::math::Color &_color,
257 const bool _cascade =
true);
261 public: ignition::math::Color
Ambient()
const;
265 public: ignition::math::Color
Diffuse()
const;
286 private:
void SetTransparencyInnerLoop(Ogre::SceneNode *_sceneNode);
331 public:
virtual void SetVisible(
bool _visible,
bool _cascade =
true);
346 public:
void SetRotation(
const ignition::math::Quaterniond &_rot);
350 public:
void SetPose(
const ignition::math::Pose3d &_pose);
358 public: ignition::math::Quaterniond
Rotation()
const;
362 public: ignition::math::Pose3d
Pose()
const;
415 const ignition::math::Color &_initialColor,
416 const ignition::math::Color &_changeColor);
436 unsigned int _index);
447 const std::string &_subMesh =
"",
448 bool _centerSubmesh =
false);
455 const std::string &_subMesh =
"",
456 bool _centerSubmesh =
false);
519 const std::vector<ignition::math::Pose3d> &_pts,
const double _time,
520 std::function<
void()> _onComplete =
nullptr);
581 const std::string &_name,
582 sdf::ElementPtr _sdf);
638 public:
void SetTypeMsg(
const google::protobuf::Message *_msg);
645 const google::protobuf::Message *> _pair);
651 const msgs::Visual::Type &_type);
671 protected:
Visual(VisualPrivate &_dataPtr,
672 const std::string &_name,
VisualPtr _parent,
673 bool _useRTShader =
true);
682 protected:
Visual(VisualPrivate &_dataPtr,
683 const std::string &_name,
ScenePtr _scene,
684 bool _useRTShader =
true);
696 private:
void Init(
const std::string &_name,
ScenePtr _scene,
705 private:
void Init(
const std::string &_name,
VisualPtr _parent,
710 private:
void LoadPlugins();
712 private:
void LoadPlugin(sdf::ElementPtr _sdf);
717 private:
void BoundsHelper(Ogre::SceneNode *_node,
718 ignition::math::Box &_box)
const;
723 private:
bool GetCenterSubMesh()
const;
727 private:
void DestroyAllAttachedMovableObjects(
728 Ogre::SceneNode *_sceneNode);
733 private:
void UpdateGeomSize(
const ignition::math::Vector3d &_scale);
737 private:
void UpdateTransparency(
const bool _cascade =
true);
rendering
Definition RenderEngine.hh:31
A 3D mesh.
Definition Mesh.hh:43
Class for drawing lines that can change.
Definition DynamicLines.hh:43
A renderable object.
Definition Visual.hh:61
void SetRibbonTrail(bool _value, const ignition::math::Color &_initialColor, const ignition::math::Color &_changeColor)
True on or off a ribbon trail.
bool GetVisible() const
Get whether the visual is visible.
ignition::math::Color Diffuse() const
Get the diffuse color of the visual.
std::string GetMaterialName() const
Get the name of the material.
virtual void SetEmissive(const ignition::math::Color &_color, const bool _cascade=true)
Set the emissive value.
void UpdateFromMsg(ConstVisualPtr &_msg)
Update a visual based on a message.
void SetId(uint32_t _id)
Set the id associated with this visual.
void SetWorldPose(const ignition::math::Pose3d &_pose)
Set the world pose of the visual.
void SetName(const std::string &_name)
Set the name of the visual.
std::string GetShaderType() const
Get the shader type.
Visual(VisualPrivate &_dataPtr, const std::string &_name, VisualPtr _parent, bool _useRTShader=true)
void SetMaterial(const std::string &_materialName, bool _unique=true, const bool _cascade=true)
Set the material.
void DetachObjects()
Detach all objects.
unsigned int GetDepth() const
Get the depth of this visual, where 0 is the depth of the world visual.
void DetachVisual(const std::string &_name)
Detach a visual.
void Init()
Helper for the contructor.
void MakeStatic()
Make the visual objects static renderables.
VisualPtr GetParent() const
Get the parent visual, if one exists.
VisualPtr Clone(const std::string &_name, VisualPtr _newParent)
Clone the visual with a new name.
void ToggleLayer(const int32_t _layer)
Toggle layer visibility.
void AttachVisual(VisualPtr _vis)
Attach a visual to this visual.
bool HasAttachedObject(const std::string &_name)
Returns true if an object with _name is attached.
uint32_t GetVisibilityFlags()
Get visibility flags for this visual and all children.
virtual void Fini()
Helper for the destructor.
DynamicLines * CreateDynamicLine(RenderOpType _type=RENDERING_LINE_STRIP)
Add a line to the visual.
ignition::math::Pose3d InitialRelativePose() const
Get the initial relative pose of the visual.
VisualPtr GetRootVisual()
Get the root visual.
bool IsAncestorOf(const rendering::VisualPtr _visual) const
Check if this visual is an ancestor of another visual.
static Visual::VisualType ConvertVisualType(const msgs::Visual::Type &_type)
Convert from msgs::Visual::Type to VisualType.
void RemovePlugin(const std::string &_name)
Remove a running plugin.
virtual ~Visual()
Destructor.
ignition::math::Color Emissive() const
Get the emissive color of the visual.
ignition::math::Vector3d DerivedScale() const
Get the scale of the visual as inherited from all parents.
std::string Name() const
Get the name of the visual.
void ShowInertia(bool _show)
Display inertia visuals.
sdf::ElementPtr GetSDF() const
Get the visual SDF.
void ShowLinkFrame(bool _show)
Display link frame visuals.
ignition::math::Vector3d GetGeometrySize() const
Get the geometry size.
void SetDiffuse(const ignition::math::Color &_color, const bool _cascade=true)
Set the diffuse color of the visual.
void SetCastShadows(bool _shadows)
Set whether the visual should cast shadows.
ignition::math::Vector3d Position() const
Get the position of the visual.
void SetLighting(bool _lighting)
Set whether or not to enable or disable lighting.
void SetScene(ScenePtr _scene)
Set current scene.
void DetachVisual(VisualPtr _vis)
Detach a visual.
std::string GetNormalMap() const
Get the normal map.
Visual(const std::string &_name, ScenePtr _scene, bool _useRTShader=true)
Constructor.
void SetRotation(const ignition::math::Quaterniond &_rot)
Set the rotation of the visual.
virtual void Load()
Load the visual with default parameters.
void DeleteDynamicLine(DynamicLines *_line)
Delete a dynamic line.
void SetAmbient(const ignition::math::Color &_color, const bool _cascade=true)
Set the ambient color of the visual.
void SetWorldPosition(const ignition::math::Vector3d &_pos)
Set the world linear position of the visual.
ScenePtr GetScene() const
Get current.
bool UseRTShader() const
Get whether this visual uses RT shader system.
void SetSpecular(const ignition::math::Color &_color, const bool _cascade=true)
Set the specular color of the visual.
void AttachObject(Ogre::MovableObject *_obj)
Attach a renerable object to the visual.
void AddPendingChild(std::pair< VisualType, const google::protobuf::Message * > _pair)
Push a message for a child of this visual which hasn't been loaded yet.
void ShowSkeleton(bool _show)
Display the skeleton visuals.
ignition::math::Color Specular() const
Get the specular color of the visual.
void SetTypeMsg(const google::protobuf::Message *_msg)
Set a message specific for this visual type.
void LoadFromMsg(ConstVisualPtr &_msg)
Load from a message.
bool IsPlane() const
Return true if the visual is a plane.
bool IsStatic() const
Return true if the visual is a static geometry.
std::string GetGeometryType() const
Get the geometry type.
bool GetHighlighted() const
Get whether or not the visual is visually highlighted.
Ogre::SceneNode * GetSceneNode() const
Return the scene Node of this visual entity.
void ToggleVisible()
Toggle whether this visual is visible.
VisualPtr GetChild(unsigned int _index)
Get an attached visual based on an index.
static msgs::Visual::Type ConvertVisualType(const Visual::VisualType &_type)
Convert from msgs::Visual::Type to VisualType.
void SetWireframe(bool _show)
Enable or disable wireframe for this visual.
static void InsertMesh(const common::Mesh *_mesh, const std::string &_subMesh="", bool _centerSubmesh=false)
Insert a mesh into Ogre.
void EnableTrackVisual(VisualPtr _vis)
Set one visual to track/follow another.
void SetMaterialShaderParam(const std::string &_paramName, const std::string &_shaderType, const std::string &_value)
Set a shader program parameter associated to this visual's material.
void ShowCOM(bool _show)
Display Center of Mass visuals.
void AttachLineVertex(DynamicLines *_line, unsigned int _index)
Attach a vertex of a line to the position of the visual.
void SetShaderType(const std::string &_type)
Set the shader type for the visual's material.
virtual void SetHighlighted(bool _highlighted)
Set the visual to be visually highlighted.
void SetNormalMap(const std::string &_nmap)
Set the normal map.
Ogre::MovableObject * AttachMesh(const std::string &_meshName, const std::string &_subMesh="", bool _centerSubmesh=false, const std::string &_objName="")
Attach a mesh to this visual by name.
VisualPrivate * dataPtr
Definition Visual.hh:741
unsigned int GetAttachedObjectCount() const
Return the number of attached movable objects.
ignition::math::Box BoundingBox() const
Get the bounding box for the visual.
void DisableTrackVisual()
Disable tracking of a visual.
ignition::math::Quaterniond Rotation() const
Get the rotation of the visual.
Visual(const std::string &_name, VisualPtr _parent, bool _useRTShader=true)
Constructor.
ignition::math::Pose3d WorldPose() const
Get the global pose of the visual.
VisualType
Type of visual.
Definition Visual.hh:65
@ VT_COLLISION
Collision visual.
Definition Visual.hh:75
@ VT_MODEL
Model visual.
Definition Visual.hh:69
@ VT_SENSOR
Sensor visual.
Definition Visual.hh:77
@ VT_GUI
GUI visual.
Definition Visual.hh:79
@ VT_VISUAL
Visual visual.
Definition Visual.hh:73
@ VT_LINK
Link visual.
Definition Visual.hh:71
@ VT_ENTITY
Entity visual.
Definition Visual.hh:67
@ VT_PHYSICS
Physics data visual.
Definition Visual.hh:81
bool InheritTransparency() const
Get whether this visual inherits transparency from parent.
ignition::math::Pose3d Pose() const
Get the pose of the visual.
unsigned int GetChildCount()
Get the number of attached visuals.
void SetVisibilityFlags(uint32_t _flags)
Set visibility flags for this visual and all children.
void SetTransparency(float _trans)
Set the transparency.
void LoadPlugin(const std::string &_filename, const std::string &_name, sdf::ElementPtr _sdf)
Load a plugin.
void MoveToPositions(const std::vector< ignition::math::Pose3d > &_pts, const double _time, std::function< void()> _onComplete=nullptr)
Move to a series of pose and over a given time.
void SetWorldRotation(const ignition::math::Quaterniond &_rot)
Set the world orientation of the visual.
void SetInheritTransparency(const bool _inherit)
Set whether to inherit transparency from parent.
uint32_t GetId() const
Get the id associated with this visual.
bool GetCastShadows() const
Get whether the visual casts shadows.
void SetType(const Visual::VisualType _type)
Set type of visual.
bool IsDescendantOf(const rendering::VisualPtr _visual) const
Check if this visual is a descendant of another visual.
void MoveToPosition(const ignition::math::Pose3d &_pose, const double _time)
Move to a pose and over a given time.
void Load(sdf::ElementPtr _sdf)
Load the visual with a set of parameters.
void ShowBoundingBox()
Display the bounding box visual.
bool GetLighting() const
Get whether or not lighting is enabled.
void ShowCollision(bool _show)
Display the collision visuals.
void FillMaterialMsg(ignition::msgs::Material &_msg) const
Fill an ignition::msgs::Material message based on this visual's material properties.
void InsertMesh(const std::string &_meshName, const std::string &_subMesh="", bool _centerSubmesh=false)
Insert a mesh into Ogre.
ignition::math::Vector3d Scale() const
Get the scale.
float DerivedTransparency() const
Get the transparency of the visual as inherited from all parents.
void SetPose(const ignition::math::Pose3d &_pose)
Set the pose of the visual.
std::string GetMeshName() const
The name of the mesh set in the visual's SDF.
void Update()
Update the visual.
VisualPtr GetNthAncestor(unsigned int _n)
Get the nth ancestor counting from the world visual.
Visual(VisualPrivate &_dataPtr, const std::string &_name, ScenePtr _scene, bool _useRTShader=true)
Visual::VisualType GetType() const
Get type of visual.
bool Wireframe() const
Get whether wireframe is enabled for this visual.
void SetSkeletonPose(const msgs::PoseAnimation &_pose)
Set animation skeleton pose.
void SetPosition(const ignition::math::Vector3d &_pos)
Set the position of the visual.
void SetLayer(const int32_t _layer)
Set the layer this visual belongs to.
void ProcessMaterialMsg(const ignition::msgs::Material &_msg)
Process a material message.
float GetTransparency()
Get the transparency.
void ClearParent()
Clear parents.
ignition::math::Color Ambient() const
Get the ambient color of the visual.
void SetScale(const ignition::math::Vector3d &_scale)
Set the scale.
std::string GetSubMeshName() const
Get the name of the sub mesh set in the visual's SDF.
virtual void SetVisible(bool _visible, bool _cascade=true)
Set whether the visual is visible.
void ShowJoints(bool _show)
Display joint visuals.
Definition JointMaker.hh:40
std::shared_ptr< Visual > VisualPtr
Definition RenderTypes.hh:114
RenderOpType
Type of render operation for a drawable.
Definition RenderTypes.hh:217
@ RENDERING_LINE_STRIP
A strip of connected lines, 1 vertex per line plus 1 start vertex.
Definition RenderTypes.hh:226
boost::shared_ptr< Scene > ScenePtr
Definition RenderTypes.hh:82
Forward declarations for the common classes.
Definition Animation.hh:27