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);
101 public:
virtual ~
Visual();
107 public:
virtual void Fini();
117 public:
void LoadFromMsg(ConstVisualPtr &_msg);
121 public:
void Load(sdf::ElementPtr _sdf);
124 public:
virtual void Load();
127 public:
void Update();
135 public: sdf::ElementPtr GetSDF()
const;
139 public:
void SetName(
const std::string &_name);
143 public: std::string Name()
const;
147 public:
void AttachVisual(
VisualPtr _vis);
151 public:
void DetachVisual(
VisualPtr _vis);
155 public:
void DetachVisual(
const std::string &_name);
159 public:
void AttachObject(Ogre::MovableObject *_obj);
163 public:
bool HasAttachedObject(
const std::string &_name);
167 public:
unsigned int GetAttachedObjectCount()
const;
170 public:
void DetachObjects();
174 public:
unsigned int GetChildCount();
180 public:
VisualPtr GetChild(
unsigned int _index);
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;
204 public: ignition::math::Vector3d DerivedScale()
const;
208 public:
bool GetLighting()
const;
212 public:
void SetLighting(
bool _lighting);
220 public:
void SetMaterial(
const std::string &_materialName,
221 bool _unique =
true,
const bool _cascade =
true);
232 public:
void SetMaterialShaderParam(
const std::string &_paramName,
233 const std::string &_shaderType,
const std::string &_value);
238 public:
void SetAmbient(
const ignition::math::Color &_color,
239 const bool _cascade =
true);
244 public:
void SetDiffuse(
const ignition::math::Color &_color,
245 const bool _cascade =
true);
250 public:
void SetSpecular(
const ignition::math::Color &_color,
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;
269 public: ignition::math::Color Specular()
const;
273 public: ignition::math::Color Emissive()
const;
277 public:
void SetWireframe(
bool _show);
281 public:
bool Wireframe()
const;
286 private:
void SetTransparencyInnerLoop(Ogre::SceneNode *_sceneNode);
291 public:
void SetTransparency(
float _trans);
295 public:
float GetTransparency();
300 public:
float DerivedTransparency()
const;
304 public:
void SetInheritTransparency(
const bool _inherit);
308 public:
bool InheritTransparency()
const;
313 public:
virtual void SetHighlighted(
bool _highlighted);
318 public:
bool GetHighlighted()
const;
322 public:
bool GetCastShadows()
const;
326 public:
void SetCastShadows(
bool _shadows);
331 public:
virtual void SetVisible(
bool _visible,
bool _cascade =
true);
334 public:
void ToggleVisible();
338 public:
bool GetVisible()
const;
342 public:
void SetPosition(
const ignition::math::Vector3d &_pos);
346 public:
void SetRotation(
const ignition::math::Quaterniond &_rot);
350 public:
void SetPose(
const ignition::math::Pose3d &_pose);
354 public: ignition::math::Vector3d Position()
const;
358 public: ignition::math::Quaterniond Rotation()
const;
362 public: ignition::math::Pose3d Pose()
const;
366 public: ignition::math::Pose3d InitialRelativePose()
const;
370 public: ignition::math::Pose3d WorldPose()
const;
374 public:
void SetWorldPose(
const ignition::math::Pose3d &_pose);
378 public:
void SetWorldPosition(
const ignition::math::Vector3d &_pos);
382 public:
void SetWorldRotation(
const ignition::math::Quaterniond &_rot);
386 public: Ogre::SceneNode *GetSceneNode()
const;
389 public:
void MakeStatic();
393 public:
bool IsStatic()
const;
397 public:
void EnableTrackVisual(
VisualPtr _vis);
400 public:
void DisableTrackVisual();
404 public: std::string GetNormalMap()
const;
408 public:
void SetNormalMap(
const std::string &_nmap);
414 public:
void SetRibbonTrail(
bool _value,
415 const ignition::math::Color &_initialColor,
416 const ignition::math::Color &_changeColor);
420 public: ignition::math::Box BoundingBox()
const;
436 unsigned int _index);
440 public: std::string GetMaterialName()
const;
446 public:
void InsertMesh(
const std::string &_meshName,
447 const std::string &_subMesh =
"",
448 bool _centerSubmesh =
false);
454 public:
static void InsertMesh(
const common::Mesh *_mesh,
455 const std::string &_subMesh =
"",
456 bool _centerSubmesh =
false);
460 public:
void UpdateFromMsg(ConstVisualPtr &_msg);
464 public:
bool IsPlane()
const;
481 public:
VisualPtr GetNthAncestor(
unsigned int _n);
496 public:
unsigned int GetDepth()
const;
501 public: std::string GetShaderType()
const;
506 public:
void SetShaderType(
const std::string &_type);
511 public:
void MoveToPosition(
const ignition::math::Pose3d &_pose,
518 public:
void MoveToPositions(
519 const std::vector<ignition::math::Pose3d> &_pts,
const double _time,
520 std::function<
void()> _onComplete =
nullptr);
527 public:
void SetVisibilityFlags(uint32_t _flags);
534 public: uint32_t GetVisibilityFlags();
537 public:
void ShowBoundingBox();
542 public:
void ShowCollision(
bool _show);
546 public:
void ShowSkeleton(
bool _show);
550 public:
void SetScene(
ScenePtr _scene);
558 public:
void ShowJoints(
bool _show);
562 public:
void ShowCOM(
bool _show);
566 public:
void ShowInertia(
bool _show);
570 public:
void ShowLinkFrame(
bool _show);
574 public:
void SetSkeletonPose(
const msgs::PoseAnimation &_pose);
580 public:
void LoadPlugin(
const std::string &_filename,
581 const std::string &_name,
582 sdf::ElementPtr _sdf);
586 public:
void RemovePlugin(
const std::string &_name);
589 public: uint32_t GetId()
const;
592 public:
void SetId(uint32_t _id);
596 public: std::string GetGeometryType()
const;
600 public: ignition::math::Vector3d GetGeometrySize()
const;
604 public: std::string GetMeshName()
const;
609 public: std::string GetSubMeshName()
const;
612 public:
void ClearParent();
617 public:
void ToggleLayer(
const int32_t _layer);
621 public:
void SetLayer(
const int32_t _layer);
633 public:
bool UseRTShader()
const;
638 public:
void SetTypeMsg(
const google::protobuf::Message *_msg);
644 public:
void AddPendingChild(std::pair<
VisualType,
645 const google::protobuf::Message *> _pair);
651 const msgs::Visual::Type &_type);
656 public:
static msgs::Visual::Type ConvertVisualType(
662 public:
void FillMaterialMsg(ignition::msgs::Material &_msg)
const;
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);
688 protected:
void ProcessMaterialMsg(
const ignition::msgs::Material &_msg);
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);
A 3D mesh.
Definition: Mesh.hh:42
Class for drawing lines that can change.
Definition: DynamicLines.hh:42
Link visual.
Definition: Visual.hh:71
Forward declarations for the common classes.
Definition: Animation.hh:26
VisualPrivate * dataPtr
Definition: Visual.hh:741
Entity visual.
Definition: Visual.hh:67
GUI visual.
Definition: Visual.hh:79
A renderable object.
Definition: Visual.hh:59
RenderOpType
Type of render operation for a drawable.
Definition: RenderTypes.hh:216
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
Model visual.
Definition: Visual.hh:69
VisualType
Type of visual.
Definition: Visual.hh:64
Definition: JointMaker.hh:39
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:73
Collision visual.
Definition: Visual.hh:75
Sensor visual.
Definition: Visual.hh:77