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>
38 #include "gazebo/msgs/MessageTypes.hh"
61 public std::enable_shared_from_this<Visual>
65 public:
enum VisualType
91 bool _useRTShader =
true);
99 bool _useRTShader =
true);
102 public:
virtual ~
Visual();
108 public:
virtual void Fini();
118 public:
void LoadFromMsg(ConstVisualPtr &_msg);
122 public:
void Load(sdf::ElementPtr _sdf);
125 public:
virtual void Load();
128 public:
void Update();
136 public: sdf::ElementPtr GetSDF()
const;
140 public:
void SetName(
const std::string &_name);
144 public: std::string Name()
const;
148 public:
void AttachVisual(
VisualPtr _vis);
152 public:
void DetachVisual(
VisualPtr _vis);
156 public:
void DetachVisual(
const std::string &_name);
160 public:
void AttachObject(Ogre::MovableObject *_obj);
164 public:
bool HasAttachedObject(
const std::string &_name);
168 public:
unsigned int GetAttachedObjectCount()
const;
171 public:
void DetachObjects();
175 public:
unsigned int GetChildCount();
181 public:
VisualPtr GetChild(
unsigned int _index);
190 public: Ogre::MovableObject *AttachMesh(
const std::string &_meshName,
191 const std::string &_subMesh=
"",
192 bool _centerSubmesh =
false,
193 const std::string &_objName=
"");
197 public:
void SetScale(
const ignition::math::Vector3d &_scale);
201 public: ignition::math::Vector3d Scale()
const;
205 public: ignition::math::Vector3d DerivedScale()
const;
209 public:
bool GetLighting()
const;
213 public:
void SetLighting(
bool _lighting);
221 public:
void SetMaterial(
const std::string &_materialName,
222 bool _unique =
true,
const bool _cascade =
true);
229 const bool _cascade =
true) GAZEBO_DEPRECATED(9.0);
234 public:
void SetAmbient(const ignition::math::Color &_color,
235 const
bool _cascade = true);
241 public:
void SetDiffuse(const common::Color &_color,
242 const
bool _cascade = true) GAZEBO_DEPRECATED(9.0);
247 public:
void SetDiffuse(const ignition::math::Color &_color,
248 const
bool _cascade = true);
254 public:
void SetSpecular(const common::Color &_color,
255 const
bool _cascade = true) GAZEBO_DEPRECATED(9.0);
260 public:
void SetSpecular(const ignition::math::Color &_color,
261 const
bool _cascade = true);
267 public: virtual
void SetEmissive(const common::Color &_color,
268 const
bool _cascade = true) GAZEBO_DEPRECATED(9.0);
273 public: virtual
void SetEmissive(const ignition::math::Color &_color,
274 const
bool _cascade = true);
279 public: common::Color GetAmbient() const GAZEBO_DEPRECATED(9.0);
283 public: ignition::math::Color Ambient() const;
288 public: common::Color GetDiffuse() const GAZEBO_DEPRECATED(9.0);
292 public: ignition::math::Color Diffuse() const;
297 public: common::Color GetSpecular() const GAZEBO_DEPRECATED(9.0);
301 public: ignition::math::Color Specular() const;
306 public: common::Color GetEmissive() const GAZEBO_DEPRECATED(9.0);
310 public: ignition::math::Color Emissive() const;
314 public:
void SetWireframe(
bool _show);
318 public:
bool Wireframe() const;
323 private:
void SetTransparencyInnerLoop(Ogre::SceneNode *_sceneNode);
328 public:
void SetTransparency(
float _trans);
332 public:
float GetTransparency();
337 public:
float DerivedTransparency() const;
341 public:
void SetInheritTransparency(const
bool _inherit);
345 public:
bool InheritTransparency() const;
350 public: virtual
void SetHighlighted(
bool _highlighted);
355 public:
bool GetHighlighted() const;
359 public:
bool GetCastShadows() const;
363 public:
void SetCastShadows(
bool _shadows);
368 public: virtual
void SetVisible(
bool _visible,
bool _cascade = true);
371 public:
void ToggleVisible();
375 public:
bool GetVisible() const;
379 public:
void SetPosition(const ignition::math::Vector3d &_pos);
383 public:
void SetRotation(const ignition::math::Quaterniond &_rot);
387 public:
void SetPose(const ignition::math::Pose3d &_pose);
391 public: ignition::math::Vector3d Position() const;
395 public: ignition::math::Quaterniond Rotation() const;
399 public: ignition::math::Pose3d Pose() const;
403 public: ignition::math::Pose3d InitialRelativePose() const;
407 public: ignition::math::Pose3d WorldPose() const;
411 public:
void SetWorldPose(const ignition::math::Pose3d &_pose);
415 public:
void SetWorldPosition(const ignition::math::Vector3d &_pos);
419 public:
void SetWorldRotation(const ignition::math::Quaterniond &_rot);
423 public: Ogre::SceneNode *GetSceneNode() const;
426 public:
void MakeStatic();
430 public:
bool IsStatic() const;
434 public:
void EnableTrackVisual(
VisualPtr _vis);
437 public:
void DisableTrackVisual();
441 public: std::
string GetNormalMap() const;
445 public:
void SetNormalMap(const std::
string &_nmap);
452 public:
void SetRibbonTrail(
bool _value,
453 const common::Color &_initialColor,
454 const common::Color &_changeColor) GAZEBO_DEPRECATED(9.0);
460 public:
void SetRibbonTrail(
bool _value,
461 const ignition::math::Color &_initialColor,
462 const ignition::math::Color &_changeColor);
466 public: ignition::math::Box BoundingBox() const;
482 unsigned int _index);
486 public: std::
string GetMaterialName() const;
492 public:
void InsertMesh(const std::
string &_meshName,
493 const std::
string &_subMesh = "",
494 bool _centerSubmesh = false);
500 public: static
void InsertMesh(const common::Mesh *_mesh,
501 const std::
string &_subMesh = "",
502 bool _centerSubmesh = false);
506 public:
void UpdateFromMsg(ConstVisualPtr &_msg);
510 public:
bool IsPlane() const;
527 public:
VisualPtr GetNthAncestor(
unsigned int _n);
532 public:
bool IsAncestorOf(const rendering::
VisualPtr _visual) const;
537 public:
bool IsDescendantOf(const rendering::
VisualPtr _visual) const;
542 public:
unsigned int GetDepth() const;
547 public: std::
string GetShaderType() const;
552 public:
void SetShaderType(const std::
string &_type);
557 public:
void MoveToPosition(const ignition::math::Pose3d &_pose,
564 public:
void MoveToPositions(
565 const std::vector<ignition::math::Pose3d> &_pts, const
double _time,
566 std::function<
void()> _onComplete =
nullptr);
573 public:
void SetVisibilityFlags(uint32_t _flags);
580 public: uint32_t GetVisibilityFlags();
583 public:
void ShowBoundingBox();
588 public:
void ShowCollision(
bool _show);
592 public:
void ShowSkeleton(
bool _show);
596 public:
void SetScene(
ScenePtr _scene);
604 public:
void ShowJoints(
bool _show);
608 public:
void ShowCOM(
bool _show);
612 public:
void ShowInertia(
bool _show);
616 public:
void ShowLinkFrame(
bool _show);
620 public:
void SetSkeletonPose(const msgs::PoseAnimation &_pose);
626 public:
void LoadPlugin(const std::
string &_filename,
627 const std::
string &_name,
628 sdf::ElementPtr _sdf);
632 public:
void RemovePlugin(const std::
string &_name);
635 public: uint32_t GetId() const;
638 public:
void SetId(uint32_t _id);
642 public: std::
string GetGeometryType() const;
646 public: ignition::math::Vector3d GetGeometrySize() const;
650 public: std::
string GetMeshName() const;
655 public: std::
string GetSubMeshName() const;
658 public:
void ClearParent();
663 public:
void ToggleLayer(const int32_t _layer);
667 public:
void SetLayer(const int32_t _layer);
671 public:
Visual::VisualType GetType() const;
675 public:
void SetType(const
Visual::VisualType _type);
679 public:
bool UseRTShader() const;
684 public:
void SetTypeMsg(const google::protobuf::Message *_msg);
690 public:
void AddPendingChild(std::pair<VisualType,
691 const google::protobuf::Message *> _pair);
696 public: static
Visual::VisualType ConvertVisualType(
697 const msgs::
Visual::Type &_type);
702 public: static msgs::
Visual::Type ConvertVisualType(
703 const
Visual::VisualType &_type);
708 public:
void FillMaterialMsg(ignition::msgs::Material &_msg) const;
717 protected:
Visual(VisualPrivate &_dataPtr,
718 const std::
string &_name,
VisualPtr _parent,
719 bool _useRTShader = true);
728 protected:
Visual(VisualPrivate &_dataPtr,
729 const std::
string &_name,
ScenePtr _scene,
730 bool _useRTShader = true);
734 protected:
void ProcessMaterialMsg(const ignition::msgs::Material &_msg);
742 private:
void Init(const std::
string &_name,
ScenePtr _scene,
751 private:
void Init(const std::
string &_name,
VisualPtr _parent,
756 private:
void LoadPlugins();
758 private:
void LoadPlugin(sdf::ElementPtr _sdf);
763 private:
void BoundsHelper(Ogre::SceneNode *_node,
764 ignition::math::Box &_box) const;
769 private:
bool GetCenterSubMesh() const;
773 private:
void DestroyAllAttachedMovableObjects(
774 Ogre::SceneNode *_sceneNode);
779 private:
void UpdateGeomSize(const ignition::math::Vector3d &_scale);
783 private:
void UpdateTransparency(const
bool _cascade = true);
787 protected: VisualPrivate *dataPtr;
Class for drawing lines that can change.
Definition: DynamicLines.hh:42
Link visual.
Definition: Visual.hh:72
Entity visual.
Definition: Visual.hh:68
GUI visual.
Definition: Visual.hh:80
A renderable object.
Definition: Visual.hh:60
RenderOpType
Type of render operation for a drawable.
Definition: RenderTypes.hh:216
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:82
Model visual.
Definition: Visual.hh:70
Defines a color.
Definition: Color.hh:36
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Visual visual.
Definition: Visual.hh:74
Collision visual.
Definition: Visual.hh:76
Sensor visual.
Definition: Visual.hh:78