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/Pose3.hh>
29 #include <ignition/math/Quaternion.hh>
30 #include <ignition/math/Vector3.hh>
31 #include <ignition/msgs/MessageTypes.hh>
37 #include "gazebo/msgs/MessageTypes.hh"
64 public std::enable_shared_from_this<Visual>
68 public:
enum VisualType
94 bool _useRTShader =
true);
102 bool _useRTShader =
true);
105 public:
virtual ~
Visual();
111 public:
virtual void Fini();
121 public:
void LoadFromMsg(ConstVisualPtr &_msg);
125 public:
void Load(sdf::ElementPtr _sdf);
128 public:
virtual void Load();
131 public:
void Update();
139 public: sdf::ElementPtr GetSDF()
const;
143 public:
void SetName(
const std::string &_name);
148 public: std::string GetName() const GAZEBO_DEPRECATED(8.0);
152 public: std::
string Name() const;
156 public:
void AttachVisual(
VisualPtr _vis);
160 public:
void DetachVisual(
VisualPtr _vis);
164 public:
void DetachVisual(const std::
string &_name);
168 public:
void AttachObject(Ogre::MovableObject *_obj);
172 public:
bool HasAttachedObject(const std::
string &_name);
176 public:
unsigned int GetAttachedObjectCount() const;
179 public:
void DetachObjects();
183 public:
unsigned int GetChildCount();
189 public:
VisualPtr GetChild(
unsigned int _index);
198 public: Ogre::MovableObject *AttachMesh(const std::
string &_meshName,
199 const std::
string &_subMesh="",
200 bool _centerSubmesh = false,
201 const std::
string &_objName="");
206 public:
void SetScale(const math::Vector3 &_scale) GAZEBO_DEPRECATED(8.0);
210 public:
void SetScale(const ignition::math::Vector3d &_scale);
215 public: math::Vector3 GetScale() GAZEBO_DEPRECATED(8.0);
219 public: ignition::math::Vector3d Scale() const;
223 public: ignition::math::Vector3d DerivedScale() const;
227 public:
bool GetLighting() const;
231 public:
void SetLighting(
bool _lighting);
239 public:
void SetMaterial(const std::
string &_materialName,
240 bool _unique = true, const
bool _cascade = true);
245 public:
void SetAmbient(const common::Color &_color,
246 const
bool _cascade = true);
251 public:
void SetDiffuse(const common::Color &_color,
252 const
bool _cascade = true);
257 public:
void SetSpecular(const common::Color &_color,
258 const
bool _cascade = true);
263 public: virtual
void SetEmissive(const common::Color &_color,
264 const
bool _cascade = true);
268 public: common::Color GetAmbient() const;
272 public: common::Color GetDiffuse() const;
276 public: common::Color GetSpecular() const;
280 public: common::Color GetEmissive() const;
284 public:
void SetWireframe(
bool _show);
288 public:
bool Wireframe() const;
293 private:
void SetTransparencyInnerLoop(Ogre::SceneNode *_sceneNode);
298 public:
void SetTransparency(
float _trans);
302 public:
float GetTransparency();
307 public:
float DerivedTransparency() const;
311 public:
void SetInheritTransparency(const
bool _inherit);
315 public:
bool InheritTransparency() const;
320 public: virtual
void SetHighlighted(
bool _highlighted);
325 public:
bool GetHighlighted() const;
329 public:
bool GetCastShadows() const;
333 public:
void SetCastShadows(
bool _shadows);
338 public: virtual
void SetVisible(
bool _visible,
bool _cascade = true);
341 public:
void ToggleVisible();
345 public:
bool GetVisible() const;
350 public:
void SetPosition(const math::Vector3 &_pos)
351 GAZEBO_DEPRECATED(8.0);
355 public:
void SetPosition(const ignition::math::Vector3d &_pos);
360 public:
void SetRotation(const math::Quaternion &_rot)
361 GAZEBO_DEPRECATED(8.0);
365 public:
void SetRotation(const ignition::math::Quaterniond &_rot);
370 public:
void SetPose(const math::Pose &_pose) GAZEBO_DEPRECATED(8.0);
374 public:
void SetPose(const ignition::math::Pose3d &_pose);
379 public: math::Vector3 GetPosition() const GAZEBO_DEPRECATED(8.0);
383 public: ignition::math::Vector3d Position() const;
388 public: math::Quaternion GetRotation() const GAZEBO_DEPRECATED(8.0);
392 public: ignition::math::Quaterniond Rotation() const;
397 public: math::Pose GetPose() const GAZEBO_DEPRECATED(8.0);
402 public: ignition::math::Pose3d Pose() const;
406 public: ignition::math::Pose3d InitialRelativePose() const;
411 public: math::Pose GetWorldPose() const GAZEBO_DEPRECATED(8.0);
415 public: ignition::math::Pose3d WorldPose() const;
420 public:
void SetWorldPose(const math::Pose &_pose) GAZEBO_DEPRECATED(8.0);
424 public:
void SetWorldPose(const ignition::math::Pose3d &_pose);
429 public:
void SetWorldPosition(const math::Vector3 &_pos)
430 GAZEBO_DEPRECATED(8.0);
434 public:
void SetWorldPosition(const ignition::math::Vector3d &_pos);
439 public:
void SetWorldRotation(const math::Quaternion &_rot)
440 GAZEBO_DEPRECATED(8.0);
444 public:
void SetWorldRotation(const ignition::math::Quaterniond &_rot);
448 public: Ogre::SceneNode *GetSceneNode() const;
451 public:
void MakeStatic();
455 public:
bool IsStatic() const;
459 public:
void EnableTrackVisual(
VisualPtr _vis);
462 public:
void DisableTrackVisual();
466 public: std::
string GetNormalMap() const;
470 public:
void SetNormalMap(const std::
string &_nmap);
476 public:
void SetRibbonTrail(
bool _value,
477 const common::Color &_initialColor,
478 const common::Color &_changeColor);
483 public: math::Box GetBoundingBox() const GAZEBO_DEPRECATED(8.0);
487 public: ignition::math::Box BoundingBox() const;
503 unsigned int _index);
507 public: std::
string GetMaterialName() const;
513 public:
void InsertMesh(const std::
string &_meshName,
514 const std::
string &_subMesh = "",
515 bool _centerSubmesh = false);
521 public: static
void InsertMesh(const common::Mesh *_mesh,
522 const std::
string &_subMesh = "",
523 bool _centerSubmesh = false);
527 public:
void UpdateFromMsg(ConstVisualPtr &_msg);
531 public:
bool IsPlane() const;
548 public:
VisualPtr GetNthAncestor(
unsigned int _n);
553 public:
bool IsAncestorOf(const rendering::
VisualPtr _visual) const;
558 public:
bool IsDescendantOf(const rendering::
VisualPtr _visual) const;
563 public:
unsigned int GetDepth() const;
568 public: std::
string GetShaderType() const;
573 public:
void SetShaderType(const std::
string &_type);
579 public:
void MoveToPosition(const math::Pose &_pose,
double _time)
580 GAZEBO_DEPRECATED(8.0);
585 public:
void MoveToPosition(const ignition::math::Pose3d &_pose,
593 public:
void MoveToPositions(const std::vector<math::Pose> &_pts,
595 std::function<
void()> _onComplete =
nullptr)
596 GAZEBO_DEPRECATED(8.0);
602 public:
void MoveToPositions(
603 const std::vector<ignition::math::Pose3d> &_pts, const
double _time,
604 std::function<
void()> _onComplete =
nullptr);
611 public:
void SetVisibilityFlags(uint32_t _flags);
618 public: uint32_t GetVisibilityFlags();
621 public:
void ShowBoundingBox();
626 public:
void ShowCollision(
bool _show);
630 public:
void ShowSkeleton(
bool _show);
634 public:
void SetScene(
ScenePtr _scene);
642 public:
void ShowJoints(
bool _show);
646 public:
void ShowCOM(
bool _show);
650 public:
void ShowInertia(
bool _show);
654 public:
void ShowLinkFrame(
bool _show);
658 public:
void SetSkeletonPose(const msgs::PoseAnimation &_pose);
664 public:
void LoadPlugin(const std::
string &_filename,
665 const std::
string &_name,
666 sdf::ElementPtr _sdf);
670 public:
void RemovePlugin(const std::
string &_name);
673 public: uint32_t GetId() const;
676 public:
void SetId(uint32_t _id);
680 public: std::
string GetGeometryType() const;
684 public: ignition::math::Vector3d GetGeometrySize() const;
688 public: std::
string GetMeshName() const;
693 public: std::
string GetSubMeshName() const;
696 public:
void ClearParent();
701 public:
void ToggleLayer(const int32_t _layer);
705 public:
void SetLayer(const int32_t _layer);
709 public:
Visual::VisualType GetType() const;
713 public:
void SetType(const
Visual::VisualType _type);
717 public:
bool UseRTShader() const;
722 public:
void SetTypeMsg(const google::protobuf::Message *_msg);
728 public:
void AddPendingChild(std::pair<VisualType,
729 const google::protobuf::Message *> _pair);
734 public: static
Visual::VisualType ConvertVisualType(
735 const msgs::
Visual::Type &_type);
740 public: static msgs::
Visual::Type ConvertVisualType(
741 const
Visual::VisualType &_type);
746 public:
void FillMaterialMsg(ignition::msgs::Material &_msg) const;
755 protected:
Visual(VisualPrivate &_dataPtr,
756 const std::
string &_name,
VisualPtr _parent,
757 bool _useRTShader = true);
766 protected:
Visual(VisualPrivate &_dataPtr,
767 const std::
string &_name,
ScenePtr _scene,
768 bool _useRTShader = true);
772 protected:
void ProcessMaterialMsg(const ignition::msgs::Material &_msg);
780 private:
void Init(const std::
string &_name,
ScenePtr _scene,
789 private:
void Init(const std::
string &_name,
VisualPtr _parent,
794 private:
void LoadPlugins();
796 private:
void LoadPlugin(sdf::ElementPtr _sdf);
801 private:
void BoundsHelper(Ogre::SceneNode *_node,
802 ignition::math::Box &_box) const;
807 private:
bool GetCenterSubMesh() const;
811 private:
void DestroyAllAttachedMovableObjects(
812 Ogre::SceneNode *_sceneNode);
817 private:
void UpdateGeomSize(const ignition::math::Vector3d &_scale);
821 private:
void UpdateTransparency(const
bool _cascade = true);
825 protected: VisualPrivate *dataPtr;
Class for drawing lines that can change.
Definition: DynamicLines.hh:37
Link visual.
Definition: Visual.hh:75
Entity visual.
Definition: Visual.hh:71
GUI visual.
Definition: Visual.hh:83
A renderable object.
Definition: Visual.hh:63
RenderOpType
Type of render operation for a drawable.
Definition: RenderTypes.hh:211
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:81
Model visual.
Definition: Visual.hh:73
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:113
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Visual visual.
Definition: Visual.hh:77
Collision visual.
Definition: Visual.hh:79
Sensor visual.
Definition: Visual.hh:81