Gazebo Rendering

API Reference

9.0.0
Visual Class Referenceabstract

Represents a visual node in a scene graph. A Visual is the only node that can have Geometry and other Visual children. More...

#include <gz/rendering/Visual.hh>

Public Member Functions

virtual ~Visual ()
 Destructor.
 
virtual void AddGeometry (GeometryPtr _geometry)=0
 Add the given geometry to this visual. If the given node is already attached, no work will be done.
 
virtual void AddVisibilityFlags (uint32_t _flags)=0
 Add visibility flags.
 
virtual gz::math::AxisAlignedBox BoundingBox () const =0
 Get the bounding box in world frame coordinates.
 
virtual VisualPtr Clone (const std::string &_name, NodePtr _newParent) const =0
 Clone the visual (and its children) with a new name.
 
virtual GeometryPtr GeometryByIndex (unsigned int _index) const =0
 Get geometry at given index. If no geometry exists at given index, NULL will be returned.
 
virtual unsigned int GeometryCount () const =0
 Get the number of geometries attached to this visual.
 
virtual bool HasGeometry (ConstGeometryPtr _geometry) const =0
 Determine if given geometry is attached to this visual.
 
virtual gz::math::AxisAlignedBox LocalBoundingBox () const =0
 Get the local bounding box of the visual.
 
virtual MaterialPtr Material () const =0
 Get the material assigned to attached visuals and geometries.
 
virtual void RemoveGeometries ()=0
 Remove all attached geometries from this visual.
 
virtual GeometryPtr RemoveGeometry (GeometryPtr _geometry)=0
 Remove the given geometry from this visual. If the given node is not a child of this visual, no work will be done.
 
virtual GeometryPtr RemoveGeometryByIndex (unsigned int _index)=0
 Remove the geometry at the given index from this visual. If the specified node is not attached this visual, no work will be done.
 
virtual void RemoveVisibilityFlags (uint32_t _flags)=0
 Remove visibility flags.
 
virtual void SetChildMaterial (MaterialPtr _material, bool _unique=true)=0
 Set the material for all attached visuals only.
 
virtual void SetGeometryMaterial (MaterialPtr _material, bool _unique=true)=0
 Set the material for all attached geometries only.
 
virtual void SetMaterial (const std::string &_name, bool _unique=true)=0
 Set the material for all attached visuals and geometries. The specified material will be retrieved from Scene::Material using the given material name. If no material is registered with the given name, no work will be done.
 
virtual void SetMaterial (MaterialPtr _material, bool _unique=true)=0
 Set the material for all attached visuals and geometries.
 
virtual void SetStatic (bool _static)=0
 Tells Render Engine this Visual will be static (i.e. won't move, rotate or scale) You can still move, rotate or scale the Visual; however doing so has a performance impact. How much of an impact will depend on the rendering backend being used.
 
virtual void SetVisibilityFlags (uint32_t _flags)=0
 Set visibility flags.
 
virtual void SetVisible (bool _visible)=0
 Specify if this visual is visible.
 
virtual void SetWireframe (bool _show)=0
 Enable or disable wireframe.
 
virtual bool Static () const =0
 Get whether the visual is static.
 
virtual uint32_t VisibilityFlags () const =0
 Get visibility flags.
 
virtual bool Wireframe () const =0
 Get whether wireframe is enabled for this visual.
 
- Public Member Functions inherited from Node
virtual ~Node ()
 Destructor.
 
virtual void AddChild (NodePtr _child)=0
 Add the given node to this node. If the given node is already a child, no work will be done.
 
virtual NodePtr ChildById (unsigned int _id) const =0
 Get node with given ID. If no child exists with given ID, NULL will be returned.
 
virtual NodePtr ChildByIndex (unsigned int _index) const =0
 Get node at given index. If no child exists at given index, NULL will be returned.
 
virtual NodePtr ChildByName (const std::string &_name) const =0
 Get node with given name. If no child exists with given name, NULL will be returned.
 
virtual unsigned int ChildCount () const =0
 Get number of child nodes.
 
virtual bool HasChild (ConstNodePtr _child) const =0
 Determine if given node is an attached child.
 
virtual bool HasChildId (unsigned int _id) const =0
 Determine if node with given ID is an attached child.
 
virtual bool HasChildName (const std::string &_name) const =0
 Determine if node with given name is an attached child.
 
virtual bool HasParent () const =0
 Determine if this Node is attached to another Node.
 
virtual bool HasUserData (const std::string &_key) const =0
 Check if node has custom data.
 
virtual bool InheritScale () const =0
 Determine if this node inherits scale from this parent.
 
virtual math::Pose3d InitialLocalPose () const =0
 Get the initial local pose.
 
virtual math::Pose3d LocalPose () const =0
 Get the local pose.
 
virtual math::Vector3d LocalPosition () const =0
 Get the local position.
 
virtual math::Quaterniond LocalRotation () const =0
 Get the local rotation.
 
virtual math::Vector3d LocalScale () const =0
 Get the local scale.
 
virtual math::Vector3d Origin () const =0
 Get position of origin.
 
virtual NodePtr Parent () const =0
 Get the parent Node.
 
virtual NodePtr RemoveChild (NodePtr _child)=0
 Remove (detach) the given node from this node. If the given node is not a child of this node, no work will be done.
 
virtual NodePtr RemoveChildById (unsigned int _id)=0
 Remove (detach) the node with the given ID from this node. If the specified node is not a child of this node, no work will be done.
 
virtual NodePtr RemoveChildByIndex (unsigned int _index)=0
 Remove (detach) the node at the given index from this node. If the specified node is not a child of this node, no work will be done.
 
virtual NodePtr RemoveChildByName (const std::string &_name)=0
 Remove (detach) the node with the given name from this node. If the specified node is not a child of this node, no work will be done.
 
virtual void RemoveChildren ()=0
 Remove all child nodes from this node This detaches all the child nodes but does not destroy them.
 
virtual void RemoveParent ()=0
 Detach this Node from its parent. If this Node does not have a parent, no work will be done.
 
virtual void Scale (const math::Vector3d &_scale)=0
 Scale the current scale by the given scalars.
 
virtual void Scale (double _scale)=0
 Scale the current scale by the given scalar. The given scalar will be assigned to the x, y, and z coordinates.
 
virtual void Scale (double _x, double _y, double _z)=0
 Scale the current scale by the given scalars.
 
virtual void SetInheritScale (bool _inherit)=0
 Specify if this node inherits scale from its parent.
 
virtual void SetLocalPose (const math::Pose3d &_pose)=0
 Set the local pose.
 
virtual void SetLocalPosition (const math::Vector3d &_position)=0
 Set the local position.
 
virtual void SetLocalPosition (double _x, double _y, double _z)=0
 Set the local position.
 
virtual void SetLocalRotation (const math::Quaterniond &_rotation)=0
 Set the local rotation.
 
virtual void SetLocalRotation (double _r, double _p, double _y)=0
 Set the local rotation.
 
virtual void SetLocalRotation (double _w, double _x, double _y, double _z)=0
 Set the local rotation.
 
virtual void SetLocalScale (const math::Vector3d &_scale)=0
 Set the local scale.
 
virtual void SetLocalScale (double _scale)=0
 Set the local scale. The given scale will be assigned to the x, y, and z coordinates.
 
virtual void SetLocalScale (double _x, double _y, double _z)=0
 Set the local scale.
 
virtual void SetOrigin (const math::Vector3d &_origin)=0
 Set position of origin. The position should be relative to the original origin of the geometry.
 
virtual void SetOrigin (double _x, double _y, double _z)=0
 Set position of origin. The position should be relative to the original origin of the geometry.
 
virtual void SetUserData (const std::string &_key, Variant _value)=0
 Store any custom data associated with this node.
 
virtual void SetWorldPose (const math::Pose3d &_pose)=0
 Set the world pose.
 
virtual void SetWorldPosition (const math::Vector3d &_position)=0
 Set the world position.
 
virtual void SetWorldPosition (double _x, double _y, double _z)=0
 Set the world position.
 
virtual void SetWorldRotation (const math::Quaterniond &_rotation)=0
 Set the world rotation.
 
virtual void SetWorldRotation (double _r, double _p, double _y)=0
 Set the world rotation.
 
virtual void SetWorldRotation (double _w, double _x, double _y, double _z)=0
 Set the world rotation.
 
virtual void SetWorldScale (const math::Vector3d &_scale)=0
 Set the world scale.
 
virtual void SetWorldScale (double _scale)=0
 Set the world scale. The given scale will be assigned to the x, y, and z coordinates.
 
virtual void SetWorldScale (double _x, double _y, double _z)=0
 Set the world scale.
 
virtual Variant UserData (const std::string &_key) const =0
 Get custom data stored in this node.
 
virtual math::Pose3d WorldPose () const =0
 Get the world pose.
 
virtual math::Vector3d WorldPosition () const =0
 Get the world position.
 
virtual math::Quaterniond WorldRotation () const =0
 Get the world rotation.
 
virtual math::Vector3d WorldScale () const =0
 Get the world scale.
 
virtual math::Pose3d WorldToLocal (const math::Pose3d &_pose) const =0
 Convert given world pose to local pose.
 
- Public Member Functions inherited from Object
virtual ~Object ()
 Destructor.
 
virtual void Destroy ()=0
 Destroy any resources associated with this object. Invoking any other functions after destroying an object will result in undefined behavior.
 
virtual unsigned int Id () const =0
 Get the object ID. This ID will be unique across all objects inside a given scene, but necessarily true for objects across different scenes.
 
virtual std::string Name () const =0
 Get the object name. This name will be unique across all objects inside a given scene, but necessarily true for objects across different scenes.
 
virtual void PostRender ()=0
 Post process this object and any of its children after rendering.
 
virtual void PreRender ()=0
 Prepare this object and any of its children for rendering. This should be called for each object in a scene just before rendering, which can be achieved by a single call to Scene::PreRender.
 
virtual ScenePtr Scene () const =0
 Get the Scene that created this object.
 

Detailed Description

Represents a visual node in a scene graph. A Visual is the only node that can have Geometry and other Visual children.

Constructor & Destructor Documentation

◆ ~Visual()

virtual ~Visual ( )
virtual

Destructor.

Member Function Documentation

◆ AddGeometry()

virtual void AddGeometry ( GeometryPtr  _geometry)
pure virtual

Add the given geometry to this visual. If the given node is already attached, no work will be done.

Parameters
[in]_geometryGeometry to be added

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ AddVisibilityFlags()

virtual void AddVisibilityFlags ( uint32_t  _flags)
pure virtual

Add visibility flags.

Parameters
[in]_flagsVisibility flags

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ BoundingBox()

virtual gz::math::AxisAlignedBox BoundingBox ( ) const
pure virtual

Get the bounding box in world frame coordinates.

Returns
The axis aligned bounding box

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, BaseVisual< OgreNode >, OgreVisual, and Ogre2Visual.

◆ Clone()

virtual VisualPtr Clone ( const std::string _name,
NodePtr  _newParent 
) const
pure virtual

Clone the visual (and its children) with a new name.

Parameters
[in]_nameName of the cloned Visual. Set this to an empty string to auto-generate a unique name for the cloned visual.
[in]_newParentParent of the cloned Visual. Set to nullptr if the cloned visual should have no parent.
Returns
The visual. nullptr is returned if cloning failed.

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ GeometryByIndex()

virtual GeometryPtr GeometryByIndex ( unsigned int  _index) const
pure virtual

Get geometry at given index. If no geometry exists at given index, NULL will be returned.

Parameters
[in]_indexIndex of the desired geometry
Returns
The specified geometry

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ GeometryCount()

virtual unsigned int GeometryCount ( ) const
pure virtual

Get the number of geometries attached to this visual.

Returns
The number of geometries attached to this visual

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ HasGeometry()

virtual bool HasGeometry ( ConstGeometryPtr  _geometry) const
pure virtual

Determine if given geometry is attached to this visual.

Parameters
[in]_geometryGeometry in question
Returns
True if given node is attached to this visual

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ LocalBoundingBox()

virtual gz::math::AxisAlignedBox LocalBoundingBox ( ) const
pure virtual

Get the local bounding box of the visual.

Returns
The local bounding box

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, BaseVisual< OgreNode >, OgreVisual, and Ogre2Visual.

◆ Material()

virtual MaterialPtr Material ( ) const
pure virtual

Get the material assigned to attached visuals and geometries.

Returns
the Pointer to the material assigned to this visual. If the material is cloned at the time it is set to this visual, the cloned material will be returned.

Implemented in BaseParticleEmitter< T >, BaseParticleEmitter< Ogre2Visual >, BaseParticleEmitter< OgreVisual >, BaseVisual< T >, BaseVisual< Ogre2Node >, BaseVisual< OgreNode >, OgreCOMVisual, OgreInertiaVisual, OgreLightVisual, Ogre2COMVisual, Ogre2InertiaVisual, and Ogre2LightVisual.

◆ RemoveGeometries()

virtual void RemoveGeometries ( )
pure virtual

Remove all attached geometries from this visual.

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ RemoveGeometry()

virtual GeometryPtr RemoveGeometry ( GeometryPtr  _geometry)
pure virtual

Remove the given geometry from this visual. If the given node is not a child of this visual, no work will be done.

Parameters
[in]_geometryGeometry to be removed
Returns
The removed geometry

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ RemoveGeometryByIndex()

virtual GeometryPtr RemoveGeometryByIndex ( unsigned int  _index)
pure virtual

Remove the geometry at the given index from this visual. If the specified node is not attached this visual, no work will be done.

Parameters
[in]_indexIndex of the geometry to be removed
Returns
The removed geometry

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ RemoveVisibilityFlags()

virtual void RemoveVisibilityFlags ( uint32_t  _flags)
pure virtual

Remove visibility flags.

Parameters
[in]_flagsVisibility flags

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ SetChildMaterial()

virtual void SetChildMaterial ( MaterialPtr  _material,
bool  _unique = true 
)
pure virtual

Set the material for all attached visuals only.

Parameters
[in]_materialName of the material to be assigned
[in]_uniqueTrue if the specified material should be cloned

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ SetGeometryMaterial()

virtual void SetGeometryMaterial ( MaterialPtr  _material,
bool  _unique = true 
)
pure virtual

Set the material for all attached geometries only.

Parameters
[in]_materialName of the material to be assigned
[in]_uniqueTrue if the specified material should be cloned

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ SetMaterial() [1/2]

virtual void SetMaterial ( const std::string _name,
bool  _unique = true 
)
pure virtual

Set the material for all attached visuals and geometries. The specified material will be retrieved from Scene::Material using the given material name. If no material is registered with the given name, no work will be done.

Parameters
[in]_nameName of the material to be assigned
[in]_uniqueTrue if the specified material should be cloned

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ SetMaterial() [2/2]

virtual void SetMaterial ( MaterialPtr  _material,
bool  _unique = true 
)
pure virtual

Set the material for all attached visuals and geometries.

Parameters
[in]_materialName of the material to be assigned
[in]_uniqueTrue if the specified material should be cloned

Implemented in OgreCOMVisual, OgreInertiaVisual, OgreLightVisual, Ogre2COMVisual, Ogre2InertiaVisual, Ogre2LightVisual, BaseParticleEmitter< T >, BaseParticleEmitter< Ogre2Visual >, BaseParticleEmitter< OgreVisual >, BaseVisual< T >, BaseVisual< Ogre2Node >, BaseVisual< OgreNode >, and Ogre2ParticleEmitter.

◆ SetStatic()

virtual void SetStatic ( bool  _static)
pure virtual

Tells Render Engine this Visual will be static (i.e. won't move, rotate or scale) You can still move, rotate or scale the Visual; however doing so has a performance impact. How much of an impact will depend on the rendering backend being used.

Remarks
Performance impact of switching staticness depends on on engine. In ogre2 it isn't expensive but it isn't free either. Try to minimize transitions. Raytracing engines may rely on this information for their BVH structures TODO(anyone): Staticness should be ideally be supplied during construction for maximum performance
ogre2 specific: OgreNext keeps 2 lists of objects. Dynamic and Static. Every frame OgreNext iterates through all nodes & items in the dynamic lists and forcefully updates them (regardless of whether they have actually changed). This may sound slow but Ogre 1.x worked by only updating those objects that have changed, and it was slower. CPUs care a lot more about processing in bulk and having all the data hot in cache.

For the static list, it only iterates through the entire list in that frame when the whole list is tagged as dirty. If one element changes, then the whole list is dirty (OgreNext might be able to optimize it and only update a part of the list by narrowing).

Changing a static node transform implies calling OgreNext's notifyStaticDirty. This is very cheap so it can be called whenever a static object changes. The only thing that needs to be taken into account is that notifyStaticDirty should be called as little as possible. And by "as little as possible" that means ideally it should not be called ever except when loading a scene or when something relevant changed. If it gets called e.g. once per frame or more then it's the same as having all objects dynamic.

Thus if an object is static, make sure you don't keep moving around because it negates the performance of all static objects.

Remarks
(INTERNAL) For implementations: Dynamic Scene Node + Dynamic MovableObject = Valid Static Scene Node + Static MovableObject = Valid Static Scene Node + Dynamic MovableObject = Valid, but rarely makes sense Dynamic Scene Node + Static MovableObject = Invalid
Parameters
[in]_staticTrue if this visual should be made static

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, BaseVisual< OgreNode >, and Ogre2Visual.

◆ SetVisibilityFlags()

virtual void SetVisibilityFlags ( uint32_t  _flags)
pure virtual

Set visibility flags.

Parameters
[in]_flagsVisibility flags

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, BaseVisual< OgreNode >, OgreVisual, and Ogre2Visual.

◆ SetVisible()

◆ SetWireframe()

virtual void SetWireframe ( bool  _show)
pure virtual

Enable or disable wireframe.

Parameters
[in]_showTrue to enable wireframe

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, BaseVisual< OgreNode >, OgreVisual, and Ogre2Visual.

◆ Static()

virtual bool Static ( ) const
pure virtual

Get whether the visual is static.

Returns
True if the visual is static, false otherwise
See also
SetStatic

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, BaseVisual< OgreNode >, and Ogre2Visual.

◆ VisibilityFlags()

virtual uint32_t VisibilityFlags ( ) const
pure virtual

Get visibility flags.

Returns
visibility flags

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, and BaseVisual< OgreNode >.

◆ Wireframe()

virtual bool Wireframe ( ) const
pure virtual

Get whether wireframe is enabled for this visual.

Returns
True if wireframe is enabled for this visual.

Implemented in BaseVisual< T >, BaseVisual< Ogre2Node >, BaseVisual< OgreNode >, OgreVisual, and Ogre2Visual.


The documentation for this class was generated from the following file: