Go to the documentation of this file.
17 #ifndef GZ_RENDERING_BASE_BASEARROWVISUAL_HH_
18 #define GZ_RENDERING_BASE_BASEARROWVISUAL_HH_
22 #include <gz/common/MeshManager.hh>
31 inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
45 protected:
virtual void Destroy()
override;
48 public:
virtual VisualPtr Head()
const override;
51 public:
virtual VisualPtr Shaft()
const override;
54 public:
virtual VisualPtr Rotation()
const override;
57 public:
virtual void ShowArrowHead(
bool _b)
override;
60 public:
virtual void ShowArrowShaft(
bool _b)
override;
63 public:
virtual void ShowArrowRotation(
bool _b)
override;
66 public:
virtual void SetVisible(
bool _visible)
override;
69 protected:
virtual void Init()
override;
72 protected:
bool rotationVisible =
false;
91 while (this->ChildCount() > 0u)
93 auto visual = std::dynamic_pointer_cast<Visual>(this->ChildByIndex(0));
106 return std::dynamic_pointer_cast<Visual>(this->ChildByIndex(2));
113 return std::dynamic_pointer_cast<Visual>(this->ChildByIndex(1));
120 return std::dynamic_pointer_cast<Visual>(this->ChildByIndex(0));
127 NodePtr child = this->ChildByIndex(2);
128 VisualPtr visual = std::dynamic_pointer_cast<Visual>(child);
131 visual->SetVisible(_b);
139 NodePtr child = this->ChildByIndex(1);
140 VisualPtr visual = std::dynamic_pointer_cast<Visual>(child);
143 visual->SetVisible(_b);
151 NodePtr child = this->ChildByIndex(0);
152 VisualPtr visual = std::dynamic_pointer_cast<Visual>(child);
155 visual->SetVisible(_b);
156 this->rotationVisible = _b;
164 T::SetVisible(_visible);
166 NodePtr child = this->ChildByIndex(0);
167 VisualPtr visual = std::dynamic_pointer_cast<Visual>(child);
174 visual->SetVisible(this->rotationVisible && _visible);
185 cone->AddGeometry(this->
Scene()->CreateCone());
186 cone->SetOrigin(0, 0, -0.5);
187 cone->SetLocalPosition(0, 0, 0);
188 cone->SetLocalScale(0.1, 0.1, 0.25);
189 this->AddChild(cone);
192 cylinder->AddGeometry(this->
Scene()->CreateCylinder());
193 cylinder->SetOrigin(0, 0, 0.5);
194 cylinder->SetLocalPosition(0, 0, 0);
195 cylinder->SetLocalScale(0.05, 0.05, 0.5);
196 this->AddChild(cylinder);
200 if (!meshMgr->
HasMesh(rotMeshName))
201 meshMgr->
CreateTube(rotMeshName, 0.070f, 0.075f, 0.01f, 1, 32);
204 rotationVis->AddGeometry(this->
Scene()->CreateMesh(rotMeshName));
205 rotationVis->SetOrigin(0, 0, -0.125);
206 rotationVis->SetLocalPosition(0, 0, 0);
207 rotationVis->SetVisible(this->rotationVisible);
208 this->AddChild(rotationVis);
210 this->SetOrigin(0, 0, -0.5);
bool rotationVisible
Flag to indicate whether arrow rotation is visible.
Definition: gz/rendering/base/BaseArrowVisual.hh:72
BaseArrowVisual()
Constructor.
Definition: gz/rendering/base/BaseArrowVisual.hh:77
bool HasMesh(const std::string &_name) const
virtual void ShowArrowHead(bool _b) override
set true to show the arrow head, false otherwise
Definition: gz/rendering/base/BaseArrowVisual.hh:125
virtual VisualPtr Head() const override
Get arrow-head visual.
Definition: gz/rendering/base/BaseArrowVisual.hh:104
static MeshManager * Instance()
virtual void ShowArrowRotation(bool _b) override
Set true to show the rotation of the arrow, false otherwise.
Definition: gz/rendering/base/BaseArrowVisual.hh:149
virtual void Destroy() override
Destroy any resources associated with this object. Invoking any other functions after destroying an o...
Definition: gz/rendering/base/BaseArrowVisual.hh:89
virtual VisualPtr CreateVisual()=0
Create new visual. A unique ID and name will automatically be assigned to the visual.
Manages a single scene-graph. This class updates scene-wide properties and holds the root scene node....
Definition: gz/rendering/Scene.hh:49
void CreateTube(const std::string &_name, const float _innerRadius, const float _outterRadius, const float _height, const int _rings, const int _segments, const double _arc=2.0 *IGN_PI)
virtual void SetVisible(bool _visible) override
Specify if this visual is visible.
Definition: gz/rendering/base/BaseArrowVisual.hh:162
virtual void ShowArrowShaft(bool _b) override
set true to show the arrow shaft, false otherwise
Definition: gz/rendering/base/BaseArrowVisual.hh:137
virtual void Init() override
Definition: gz/rendering/base/BaseArrowVisual.hh:180
virtual VisualPtr Rotation() const override
Get arrow-rotation visual.
Definition: gz/rendering/base/BaseArrowVisual.hh:118
Definition: gz/rendering/base/BaseArrowVisual.hh:34
virtual VisualPtr Shaft() const override
Get arrow-shaft visual.
Definition: gz/rendering/base/BaseArrowVisual.hh:111
Represents a arrow composite visual.
Definition: gz/rendering/ArrowVisual.hh:31
virtual ~BaseArrowVisual()
Destructor.
Definition: gz/rendering/base/BaseArrowVisual.hh:83