17 #ifndef IGNITION_RENDERING_BASE_BASEVISUAL_HH_ 18 #define IGNITION_RENDERING_BASE_BASEVISUAL_HH_ 39 public:
virtual unsigned int ChildCount()
const;
41 public:
virtual math::Pose3d LocalPose()
const;
43 public:
virtual void SetLocalPose(
const math::Pose3d &_pose);
45 public:
virtual bool HasChild(
ConstNodePtr _child)
const;
47 public:
virtual bool HasChildId(
unsigned int _id)
const;
49 public:
virtual bool HasChildName(
const std::string &_name)
const;
51 public:
virtual NodePtr ChildById(
unsigned int _id)
const;
55 public:
virtual NodePtr ChildByIndex(
unsigned int _index)
const;
57 public:
virtual void AddChild(
NodePtr _child);
61 public:
virtual NodePtr RemoveChildById(
unsigned int _id);
65 public:
virtual NodePtr RemoveChildByIndex(
unsigned int _index);
67 public:
virtual void RemoveChildren();
69 public:
virtual unsigned int GeometryCount()
const;
73 public:
virtual GeometryPtr GeometryByIndex(
unsigned int _index)
const;
75 public:
virtual void AddGeometry(
GeometryPtr _geometry);
79 public:
virtual GeometryPtr RemoveGeometryByIndex(
unsigned int _index);
81 public:
virtual void RemoveGeometries();
83 public:
virtual void SetMaterial(
const std::string &_name,
86 public:
virtual void SetMaterial(
MaterialPtr _material,
89 public:
virtual void SetChildMaterial(
MaterialPtr _material,
92 public:
virtual void SetGeometryMaterial(
MaterialPtr _material,
98 public:
virtual math::Vector3d LocalScale()
const = 0;
100 public:
virtual void SetLocalScale(
double _scale);
102 public:
virtual void SetLocalScale(
double _x,
double _y,
double _z);
104 public:
virtual void SetLocalScale(
const math::Vector3d &_scale);
106 public:
virtual math::Vector3d WorldScale()
const;
108 public:
virtual void SetWorldScale(
double _scale);
110 public:
virtual void SetWorldScale(
double _x,
double _y,
double _z);
112 public:
virtual void SetWorldScale(
const math::Vector3d &_scale);
114 public:
virtual void Scale(
double _scale);
116 public:
virtual void Scale(
double _x,
double _y,
double _z);
118 public:
virtual void Scale(
const math::Vector3d &_scale);
120 public:
virtual bool InheritScale()
const = 0;
122 public:
virtual void PreRender();
124 public:
virtual void Destroy();
126 protected:
virtual void PreRenderChildren();
128 protected:
virtual void PreRenderGeometries();
134 protected:
virtual bool AttachChild(
NodePtr _child) = 0;
136 protected:
virtual bool DetachChild(
NodePtr _child) = 0;
138 protected:
virtual bool AttachGeometry(
GeometryPtr _geometry) = 0;
140 protected:
virtual bool DetachGeometry(
GeometryPtr _geometry) = 0;
142 protected:
virtual void SetLocalScaleImpl(
143 const math::Vector3d &_scale) = 0;
165 math::Pose3d rawPose = this->RawLocalPose();
166 math::Vector3d scale = this->LocalScale();
167 rawPose.Pos() += rawPose.Rot() * (scale * this->origin);
175 math::Pose3d rawPose = _pose;
176 math::Vector3d scale = this->LocalScale();
177 rawPose.Pos() -= rawPose.Rot() * (scale * this->origin);
178 this->SetRawLocalPose(rawPose);
185 return this->Children()->Size();
192 return this->Children()->Contains(_child);
199 return this->Children()->ContainsId(_id);
206 return this->Children()->ContainsName(_name);
213 return this->Children()->GetById(_id);
220 return this->Children()->GetByName(_name);
227 return this->Children()->GetByIndex(_index);
234 if (this->AttachChild(_child))
236 this->Children()->Add(_child);
244 NodePtr child = this->Children()->Remove(_child);
245 if (child) this->DetachChild(child);
253 NodePtr child = this->Children()->RemoveById(_id);
254 if (child) this->DetachChild(child);
262 NodePtr child = this->Children()->RemoveByName(_name);
263 if (child) this->DetachChild(child);
271 NodePtr child = this->Children()->RemoveByIndex(_index);
272 if (child) this->DetachChild(child);
280 unsigned int count = this->Children()->Size();
282 for (
unsigned int i = 0; i < count; ++i)
284 this->RemoveChildByIndex(i);
292 return this->Geometries()->Size();
299 return this->Geometries()->Contains(_geometry);
306 return this->Geometries()->GetByIndex(_index);
313 if (this->AttachGeometry(_geometry))
315 this->Geometries()->Add(_geometry);
323 return this->Geometries()->Remove(_geometry);
330 return this->Geometries()->RemoveByIndex(_index);
337 this->Geometries()->RemoveAll();
345 if (mat) this->SetMaterial(mat, _unique);
352 _material = (_unique) ? _material->Clone() : _material;
353 this->SetChildMaterial(_material,
false);
354 this->SetGeometryMaterial(_material,
false);
355 this->material = _material;
362 unsigned int count = this->ChildCount();
363 _material = (_unique && count > 0) ? _material->Clone() : _material;
365 for (
unsigned int i = 0; i < count; ++i)
367 NodePtr child = this->ChildByIndex(i);
369 if (visual) visual->SetMaterial(_material,
false);
377 unsigned int count = this->GeometryCount();
378 _material = (_unique && count > 0) ? _material->Clone() : _material;
380 for (
unsigned int i = 0; i < count; ++i)
383 geometry->SetMaterial(_material,
false);
391 return this->material;
398 this->SetLocalScale(math::Vector3d(_scale, _scale, _scale));
405 this->SetLocalScale(math::Vector3d(_x, _y, _z));
412 math::Pose3d rawPose = this->LocalPose();
413 this->SetLocalScaleImpl(_scale);
414 this->SetLocalPose(rawPose);
421 math::Vector3d scale = this->LocalScale();
423 if (!this->InheritScale() || !this->HasParent())
428 return scale * this->Parent()->WorldScale();
435 this->SetWorldScale(math::Vector3d(_scale, _scale, _scale));
442 this->SetWorldScale(math::Vector3d(_x, _y, _z));
449 math::Vector3d currentScale = this->WorldScale();
450 this->SetLocalScale(_scale / currentScale);
457 this->Scale(math::Vector3d(_scale, _scale, _scale));
464 this->Scale(math::Vector3d(_x, _y, _z));
471 this->SetLocalScale(_scale * this->LocalScale());
479 this->PreRenderChildren();
480 this->PreRenderGeometries();
488 this->Geometries()->DestroyAll();
489 this->Children()->RemoveAll();
496 unsigned int count = this->ChildCount();
498 for (
unsigned int i = 0; i < count; ++i)
500 NodePtr child = this->ChildByIndex(i);
509 unsigned int count = this->GeometryCount();
511 for (
unsigned int i = 0; i < count; ++i)
514 geometry->PreRender();
virtual math::Pose3d LocalPose() const
Get the local pose.
Definition: BaseVisual.hh:163
virtual unsigned int GeometryCount() const
Get the number of geometries attached to this visual.
Definition: BaseVisual.hh:290
virtual ~BaseVisual()
Definition: BaseVisual.hh:157
virtual math::Vector3d WorldScale() const
Get the world scale.
Definition: BaseVisual.hh:419
virtual void SetLocalScale(double _scale)
Set the local scale. The given scale will be assigned to the x, y, and z coordinates.
Definition: BaseVisual.hh:396
virtual void PreRender()
Prepare this object and any of its children for rendering. This should be called for each object in a...
Definition: BaseVisual.hh:476
virtual void PreRenderChildren()
Definition: BaseVisual.hh:494
virtual NodePtr ChildByName(const std::string &_name) const
Get node with given name. If no child exists with given name, NULL will be returned.
Definition: BaseVisual.hh:218
virtual MaterialPtr Material()
Get the material assigned to attached visuals and geometries.
Definition: BaseVisual.hh:389
virtual void AddGeometry(GeometryPtr _geometry)
Add the given geometry to this visual. If the given node is already attached, no work will be done...
Definition: BaseVisual.hh:311
virtual NodePtr ChildByIndex(unsigned int _index) const
Get node at given index. If no child exists at given index, NULL will be returned.
Definition: BaseVisual.hh:225
BaseVisual()
Definition: BaseVisual.hh:151
virtual void SetGeometryMaterial(MaterialPtr _material, bool _unique=true)
Set the material for all attached geometries only.
Definition: BaseVisual.hh:375
virtual GeometryPtr RemoveGeometry(GeometryPtr _geometry)
Remove the given geometry from this visual. If the given node is not a child of this visual...
Definition: BaseVisual.hh:321
virtual void SetMaterial(const std::string &_name, bool _unique=true)
Set the material for all attached visuals and geometries. The specified material will be retrieved fr...
Definition: BaseVisual.hh:342
virtual void SetLocalPose(const math::Pose3d &_pose)
Set the local pose.
Definition: BaseVisual.hh:173
virtual GeometryPtr RemoveGeometryByIndex(unsigned int _index)
Remove the geometry at the given index from this visual. If the specified node is not attached this v...
Definition: BaseVisual.hh:328
virtual void SetChildMaterial(MaterialPtr _material, bool _unique=true)
Set the material for all attached visuals only.
Definition: BaseVisual.hh:360
virtual void PreRenderGeometries()
Definition: BaseVisual.hh:507
virtual void Scale(double _scale)
Scale the current scale by the given scalar. The given scalar will be assigned to the x...
Definition: BaseVisual.hh:455
virtual NodePtr RemoveChildByIndex(unsigned int _index)
Remove the node at the given index from this visual. If the specified node is not a child of this vis...
Definition: BaseVisual.hh:269
virtual NodePtr RemoveChild(NodePtr _child)
Remove the given node from this visual. If the given node is not a child of this visual, no work will be done.
Definition: BaseVisual.hh:242
virtual void AddChild(NodePtr _child)
Add the given node to this visual. If the given node is already a child, no work will be done...
Definition: BaseVisual.hh:232
Manages a single scene-graph. This class updates scene-wide properties and holds the root scene node...
Definition: Scene.hh:44
virtual unsigned int ChildCount() const
Get number of child nodes.
Definition: BaseVisual.hh:183
T dynamic_pointer_cast(T... args)
virtual NodePtr RemoveChildByName(const std::string &_name)
Remove the node with the given name from this visual. If the specified node is not a child of this vi...
Definition: BaseVisual.hh:260
virtual bool HasChildId(unsigned int _id) const
Determine if node with given ID is an attached child.
Definition: BaseVisual.hh:197
Definition: BaseVisual.hh:31
virtual void RemoveChildren()
Remove all child nodes from this visual.
Definition: BaseVisual.hh:278
virtual NodePtr RemoveChildById(unsigned int _id)
Remove the node with the given ID from this visual. If the specified node is not a child of this visu...
Definition: BaseVisual.hh:251
Represents a visual node in a scene graph. A Visual is the only node that can have Geometry and other...
Definition: Visual.hh:30
virtual bool HasGeometry(ConstGeometryPtr _geometry) const
Determine if given geometry is attached to this visual.
Definition: BaseVisual.hh:297
virtual void SetWorldScale(double _scale)
Set the world scale. The given scale will be assigned to the x, y, and z coordinates.
Definition: BaseVisual.hh:433
MaterialPtr material
Pointer to material assigned to this visual.
Definition: BaseVisual.hh:146
virtual void RemoveGeometries()
Remove all attached geometries from this visual.
Definition: BaseVisual.hh:335
virtual NodePtr ChildById(unsigned int _id) const
Get node with given ID. If no child exists with given ID, NULL will be returned.
Definition: BaseVisual.hh:211
Definition: ArrowVisual.hh:22
virtual void Destroy()
Destroy any resources associated with this object. Invoking any other functions after destroying an o...
Definition: BaseVisual.hh:485
Represents a surface material of a Geometry.
Definition: Material.hh:34
virtual GeometryPtr GeometryByIndex(unsigned int _index) const
Get geometry at given index. If no geometry exists at given index, NULL will be returned.
Definition: BaseVisual.hh:304
virtual bool HasChildName(const std::string &_name) const
Determine if node with given name is an attached child.
Definition: BaseVisual.hh:204
virtual bool HasChild(ConstNodePtr _child) const
Determine if given node is an attached child.
Definition: BaseVisual.hh:190
virtual MaterialPtr Material(const std::string &_name) const =0
Get material registered under the given name. If no material is registered under the given name...